Ejemplo n.º 1
0
 @Test
 public void testSetProperty_3args() throws Exception {
   C1 object = new C1();
   String propertyName = "string1";
   Object value = "myStringValue";
   Bean instance = new Bean(C1.class);
   instance.setProperty(object, propertyName, value);
   assertEquals(value, object.getString1());
 }
Ejemplo n.º 2
0
 @Test
 public void testGetProperty_field() throws Exception {
   C1 object = new C1();
   String propertyName = "string2";
   String value = "myStringValue";
   object.string2 = value;
   Bean instance = new Bean(C1.class);
   Object result = instance.getProperty(object, propertyName);
   assertEquals(value, result);
 }
Ejemplo n.º 3
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());
 }
Ejemplo n.º 4
0
 @Test
 public void testGetProperty_string1() throws Exception {
   System.out.println("getProperty");
   C1 object = new C1();
   String propertyName = "string1";
   Bean instance = new Bean(C1.class);
   String expResult = "myExpResult";
   object.setString1(expResult);
   Object result = instance.getProperty(object, propertyName);
   assertEquals(expResult, result);
 }
Ejemplo n.º 5
0
 @Test
 public void testGetProperty_3args_correct() throws Exception {
   C1 object = new C1();
   String propertyName = "string1";
   ClassFilter filter = new SimpleClassFilter();
   Bean instance = new Bean(C1.class);
   String expResult = "mystring";
   object.setString1(expResult);
   Object result = instance.getProperty(object, propertyName, filter);
   assertEquals(expResult, result);
 }
Ejemplo n.º 6
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");
 }