@Test
 public void testStringToEnum() throws Exception {
   Bean1 bean1 = new Bean1();
   bean1.setSampleEnum(SampleEnum.TEST1.name());
   Bean2 bean2 = dozer.map(bean1, Bean2.class);
   assertEquals(bean2.getSampleEnum(), SampleEnum.TEST1);
 }
  @Test
  public void testEnumToString() throws Exception {
    Bean2 bean2 = new Bean2();
    bean2.setSampleEnum(SampleEnum.TEST2);

    Bean1 bean1 = dozer.map(bean2, Bean1.class);
    assertEquals(SampleEnum.TEST2.name(), bean1.getSampleEnum());
  }
 @Test
 public void FieldInjectByName() {
   Bean2 b2 = new Bean2();
   FieldInjectUtils.inject(b2, String.class, "name", "Spring");
   assertThat(b2.getName(), is("Spring"));
   FieldInjectUtils.inject(b2, String.class, "id", "id1");
   assertThat(b2.getId(), is("id1"));
 }
예제 #4
0
  public void testBean1() {
    // 取得bean工厂
    BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext-bean23.xml");
    // ApplicationContext factory = new ClassPathXmlApplicationContext("applicationContext.xml");

    /*在IoC容器中拿对象,当拿bean2时,bean2依赖的bean3将自动创建*/
    Bean2 bean2 = (Bean2) factory.getBean("bean2");
    System.out.println("------------bean23------------");
    System.out.println("bean2.bean3.name=" + bean2.getBean3().getName());
  }
예제 #5
0
파일: Bean1.java 프로젝트: wanglin90/jodd
 @Override
 @Logged
 public Object doInBean_1() {
   return aBean.doInBean_2();
 }