KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > dozer > util > mapping > factory > JAXBBeanFactoryTest


1 package net.sf.dozer.util.mapping.factory;
2
3 import junit.framework.TestCase;
4 import net.sf.dozer.util.mapping.MappingException;
5
6 /**
7  * @author Vincent Jassogne
8  */

9 public class JAXBBeanFactoryTest extends TestCase {
10
11     private JAXBBeanFactory factory;
12     protected void setUp() throws Exception JavaDoc {
13         super.setUp();
14         factory = new JAXBBeanFactory();
15     }
16     /*
17      * Test method for 'net.sf.dozer.util.mapping.factory.JAXBFactory.createBean(Object, Class, String)'
18      */

19     public void testCreateBeanForSimpleJaxbClass() {
20         
21         Object JavaDoc obj = factory.createBean(null, null, "net.sf.dozer.util.mapping.vo.jaxb.employee.Employee");
22         assertNotNull("Object can not be null",obj);
23         assertEquals("Invalid class build",obj.getClass().getName(),"net.sf.dozer.util.mapping.vo.jaxb.employee.impl.EmployeeImpl" );
24     }
25     /*
26      *
27      */

28     public void testCreateBeanClassNotFoundException() {
29         try {
30             factory.createBean(null, null, "ve.ve.DE");
31         } catch (MappingException e) {
32             assertTrue(true);
33             // Success
34
} catch (Throwable JavaDoc e) {
35             fail("Not existing class should throw MappingException " + e.toString());
36         }
37         
38     }
39     /*
40      * Test method for 'net.sf.dozer.util.mapping.factory.JAXBFactory.createBean(Object, Class, String)'
41      */

42     public void testCreateBeanForInnerJaxbClass() {
43         
44         Object JavaDoc obj = factory.createBean(null, null, "net.sf.dozer.util.mapping.vo.jaxb.employee.EmployeeWithInnerClassType$AddressType");
45         assertNotNull("Object can not be null",obj);
46         assertEquals("Invalid class build",obj.getClass().getName(),"net.sf.dozer.util.mapping.vo.jaxb.employee.impl.EmployeeWithInnerClassTypeImpl$AddressTypeImpl" );
47     }
48
49 }
50
Popular Tags