示例#1
0
 @Test
 public void testSetProperty_field() throws Exception {
   C1 object = new C1();
   String propertyName = "string2";
   Object value = "myStringValue";
   Bean instance = new Bean(C1.class);
   instance.setProperty(object, propertyName, value);
   assertEquals(value, object.string2);
 }
示例#2
0
 @Test
 public void testSetProperty_4args_correctSet() throws Exception {
   C1 object = new C1();
   String propertyName = "string1";
   Object value = "myStringValue";
   Bean instance = new Bean(C1.class);
   ClassFilter filter = new SimpleClassFilter();
   instance.setProperty(object, propertyName, value, filter);
   assertNotNull(object.getString1());
 }
示例#3
0
 @Test
 public void testSetProperty_4args_deniedByFilter() throws Exception {
   C1 object = new C1();
   object.setString1(null);
   String propertyName = "string1";
   Object value = "myStringValue";
   Bean instance = new Bean(C1.class);
   ClassFilter filter = new SimpleClassFilter(C3.class, TypeAnn.class);
   try {
     instance.setProperty(object, propertyName, value, filter);
   } catch (IllegalAccessException ex) {
     if (ex.getMessage().equals("Property no found")) {
       // IS OK - it is correct
       return;
     }
   }
   // Error
   throw new Exception("No correct - Inncorect result");
 }