Search in sources :

Example 1 with BladeBeanDefineType

use of com.blade.types.BladeBeanDefineType in project blade by biezhi.

the class BeanDefineTest method testBeanDefine2.

@Test
public void testBeanDefine2() {
    BeanDefine beanDefine = new BeanDefine(new BladeBeanDefineType(), BladeBeanDefineType.class);
    assertEquals(BladeBeanDefineType.class, beanDefine.getType());
    beanDefine = new BeanDefine(new BladeBeanDefineType(), BladeBeanDefineType.class, true);
    assertEquals(BladeBeanDefineType.class, beanDefine.getType());
    assertEquals(true, beanDefine.isSingleton());
}
Also used : BladeBeanDefineType(com.blade.types.BladeBeanDefineType) BeanDefine(com.blade.ioc.bean.BeanDefine) Test(org.junit.Test)

Example 2 with BladeBeanDefineType

use of com.blade.types.BladeBeanDefineType in project blade by biezhi.

the class FieldInjectorTest method testFieldInjector.

@Test
public void testFieldInjector() {
    Ioc ioc = new SimpleIoc();
    ioc.addBean("jack");
    ioc.addBean(new BladeBeanDefineType());
    Field field = BladeBeanDefineType.class.getDeclaredFields()[0];
    FieldInjector fieldInjector = new FieldInjector(ioc, field);
    fieldInjector.injection(ioc.getBean(BladeBeanDefineType.class));
}
Also used : Field(java.lang.reflect.Field) BladeBeanDefineType(com.blade.types.BladeBeanDefineType) FieldInjector(com.blade.ioc.bean.FieldInjector) Test(org.junit.Test)

Example 3 with BladeBeanDefineType

use of com.blade.types.BladeBeanDefineType in project blade by biezhi.

the class BeanDefineTest method testBeanDefine.

@Test
public void testBeanDefine() {
    BeanDefine beanDefine = new BeanDefine(new BladeBeanDefineType());
    Class<?> type = beanDefine.getType();
    assertEquals(BladeBeanDefineType.class, type);
    Object bean = beanDefine.getBean();
    assertNotNull(bean);
    assertEquals(true, beanDefine.isSingleton());
    beanDefine.setSingleton(true);
    beanDefine.setType(BladeBeanDefineType.class);
    beanDefine.setBean(new BladeBeanDefineType());
    assertEquals(BladeBeanDefineType.class, type);
    assertNotNull(bean);
    assertEquals(true, beanDefine.isSingleton());
}
Also used : BladeBeanDefineType(com.blade.types.BladeBeanDefineType) BeanDefine(com.blade.ioc.bean.BeanDefine) Test(org.junit.Test)

Example 4 with BladeBeanDefineType

use of com.blade.types.BladeBeanDefineType in project blade by biezhi.

the class FieldInjectorTest method testFieldInjectorError.

@Test(expected = RuntimeException.class)
public void testFieldInjectorError() {
    Ioc ioc = new SimpleIoc();
    FieldInjector fieldInjector = new FieldInjector(ioc, null);
    fieldInjector.injection(new BladeBeanDefineType());
}
Also used : BladeBeanDefineType(com.blade.types.BladeBeanDefineType) FieldInjector(com.blade.ioc.bean.FieldInjector) Test(org.junit.Test)

Aggregations

BladeBeanDefineType (com.blade.types.BladeBeanDefineType)4 Test (org.junit.Test)4 BeanDefine (com.blade.ioc.bean.BeanDefine)2 FieldInjector (com.blade.ioc.bean.FieldInjector)2 Field (java.lang.reflect.Field)1