Package org.nutz.ioc

Source Code of org.nutz.ioc.SimpleIocTest

package org.nutz.ioc;

import static org.junit.Assert.*;

import org.junit.Test;
import org.nutz.ioc.impl.NutIoc;
import org.nutz.ioc.loader.annotation.AnnotationIocLoader;
import org.nutz.ioc.meta.issue348.DogMaster;
import org.nutz.ioc.meta.issue399.Issue399Service;

public class SimpleIocTest {

    @Test(expected=IocException.class)
    public void test_error_bean() {
        Ioc ioc = new NutIoc(new AnnotationIocLoader(DogMaster.class.getPackage().getName()));
        try {
            ioc.get(DogMaster.class);
            fail("Never Success");
        }
        catch (IocException e) {}
        ioc.get(DogMaster.class);
    }
   
    @Test
    public void test_no_singleton_depose() {
      Issue399Service.CreateCount = 0;
      Issue399Service.DeposeCount = 0;
      Ioc ioc = new NutIoc(new AnnotationIocLoader(Issue399Service.class.getPackage().getName()));
      for (int i = 0; i < 100; i++) {
      ioc.get(Issue399Service.class);
    }
      ioc.depose();
      System.gc();
      assertEquals(100, Issue399Service.CreateCount);
      assertEquals(0, Issue399Service.DeposeCount);
     
    }
}
TOP

Related Classes of org.nutz.ioc.SimpleIocTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.