Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 16 package net.sf.cglib.beans; 17 18 import java.beans.*; 19 import java.lang.reflect.Method ; 20 import junit.framework.*; 21 import net.sf.cglib.core.ReflectUtils; 22 23 26 public class TestBeanGenerator extends TestCase { 27 28 public void testSimple() throws Exception { 29 BeanGenerator bg = new BeanGenerator(); 30 bg.addProperty("sin", Double.TYPE); 31 Object bean = bg.create(); 32 33 PropertyDescriptor[] pds = ReflectUtils.getBeanProperties(bean.getClass()); 34 assertTrue(pds.length == 1); 35 assertTrue(pds[0].getName().equals("sin")); 36 assertTrue(pds[0].getPropertyType().equals(Double.TYPE)); 37 } 38 39 public void testSuperclass() throws Exception { 40 BeanGenerator bg = new BeanGenerator(); 41 bg.setSuperclass(MA.class); 42 bg.addProperty("sin", Double.TYPE); 43 Object bean = bg.create(); 44 45 assertTrue(bean instanceof MA); 46 assertTrue(BeanMap.create(bean).keySet().contains("sin")); 47 } 48 49 public TestBeanGenerator(String testName) { 50 super(testName); 51 } 52 53 public static void main(String [] args) { 54 junit.textui.TestRunner.run(suite()); 55 } 56 57 public static Test suite() { 58 return new TestSuite(TestBeanGenerator.class); 59 } 60 } 61
| Popular Tags
|