KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > mx > mxbean > test > CompositeTypeMetaDataFactoryUnitTestCase


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2006, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.test.mx.mxbean.test;
23
24 import javax.management.openmbean.CompositeType JavaDoc;
25
26 import junit.framework.Test;
27 import junit.framework.TestSuite;
28
29 import org.jboss.mx.mxbean.CompositeTypeMetaData;
30 import org.jboss.mx.mxbean.CompositeTypeMetaDataFactory;
31 import org.jboss.test.mx.mxbean.support.CollectionsInterface;
32 import org.jboss.test.mx.mxbean.support.CompositeInterface;
33 import org.jboss.test.mx.mxbean.support.SimpleInterface;
34 import org.jboss.test.mx.mxbean.support.SimpleObject;
35
36 /**
37  * CompositeTypeMetaDataFactoryUnitTestCase.
38  *
39  * @author <a HREF="adrian@jboss.com">Adrian Brock</a>
40  * @version $Revision: 1.1 $
41  */

42 public class CompositeTypeMetaDataFactoryUnitTestCase extends AbstractMXBeanTest
43 {
44    private static final CompositeType JavaDoc OBJECT_TYPE = CompositeTypeMetaData.generateObject();
45    private static final CompositeType JavaDoc CLASS_TYPE = CompositeTypeMetaData.generateClass();
46    private static final CompositeType JavaDoc CLASSLOADER_TYPE = CompositeTypeMetaData.generateClassLoader();
47    
48    public static Test suite()
49    {
50       return new TestSuite(CompositeTypeMetaDataFactoryUnitTestCase.class);
51    }
52    
53    public CompositeTypeMetaDataFactoryUnitTestCase(String JavaDoc name)
54    {
55       super(name);
56    }
57    
58    public void testGetCompositeDataObject() throws Exception JavaDoc
59    {
60       CompositeType JavaDoc type = CompositeTypeMetaDataFactory.getCompositeType(Object JavaDoc.class);
61       assertNotNull(type);
62       assertEquals(OBJECT_TYPE, type);
63    }
64    
65    public void testGetCompositeDataClass() throws Exception JavaDoc
66    {
67       CompositeType JavaDoc type = CompositeTypeMetaDataFactory.getCompositeType(Class JavaDoc.class);
68       assertNotNull(type);
69       assertEquals(CLASS_TYPE, type);
70    }
71    
72    public void testGetCompositeDataClassLoader() throws Exception JavaDoc
73    {
74       CompositeType JavaDoc type = CompositeTypeMetaDataFactory.getCompositeType(ClassLoader JavaDoc.class);
75       assertNotNull(type);
76       assertEquals(CLASSLOADER_TYPE, type);
77    }
78    
79    public void testSimpleInterfaceCompositeType() throws Exception JavaDoc
80    {
81       CompositeType JavaDoc type = CompositeTypeMetaDataFactory.getCompositeType(SimpleInterface.class);
82       assertNotNull(type);
83       assertEquals(createSimpleCompositeType(SimpleInterface.class), type);
84    }
85    
86    public void testSimpleObjectCompositeType() throws Exception JavaDoc
87    {
88       CompositeType JavaDoc type = CompositeTypeMetaDataFactory.getCompositeType(SimpleObject.class);
89       assertNotNull(type);
90       assertEquals(createSimpleCompositeType(SimpleObject.class), type);
91    }
92    
93    public void testCompositeInterfaceType() throws Exception JavaDoc
94    {
95       CompositeType JavaDoc type = CompositeTypeMetaDataFactory.getCompositeType(CompositeInterface.class);
96       assertNotNull(type);
97       CompositeType JavaDoc expected = createCompositeType(CompositeInterface.class.getName(), CompositeInterface.KEYS, CompositeInterface.TYPES);
98       assertEquals(expected, type);
99    }
100    
101    public void testCollectionsInterfaceType() throws Exception JavaDoc
102    {
103       CompositeType JavaDoc type = CompositeTypeMetaDataFactory.getCompositeType(CollectionsInterface.class);
104       assertNotNull(type);
105       CompositeType JavaDoc expected = createCompositeType(CollectionsInterface.class.getName(), CollectionsInterface.KEYS, CollectionsInterface.TYPES);
106       assertEquals(expected, type);
107    }
108    
109    protected CompositeType JavaDoc createSimpleCompositeType(Class JavaDoc clazz) throws Exception JavaDoc
110    {
111       return createCompositeType(clazz.getName(), SimpleInterface.KEYS, SimpleInterface.TYPES);
112    }
113 }
114
Popular Tags