KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > encoding > TestAutoTypes


1 package test.encoding;
2
3 import javax.xml.namespace.QName JavaDoc;
4
5 import junit.framework.TestCase;
6
7 import org.apache.axis.encoding.TypeMappingImpl;
8 import org.apache.axis.encoding.TypeMappingRegistry;
9 import org.apache.axis.server.AxisServer;
10 import org.apache.axis.wsdl.fromJava.Namespaces;
11 import org.apache.axis.wsdl.fromJava.Types;
12
13 /**
14  * Test auto-typing.
15  */

16 public class TestAutoTypes extends TestCase {
17
18     private AxisServer server = new AxisServer();
19
20     public TestAutoTypes(String JavaDoc name) {
21         super(name);
22     }
23     
24     public void testAutoTypes() throws Exception JavaDoc
25     {
26         TypeMappingRegistry tmr = server.getTypeMappingRegistry();
27         TypeMappingImpl tm = (TypeMappingImpl) tmr.getDefaultTypeMapping();
28         tm.setDoAutoTypes(true);
29         
30         QName JavaDoc qname = tm.getTypeQName( AttributeBean.class );
31         assertEquals( "http://encoding.test",
32                       qname.getNamespaceURI() );
33         assertEquals( "AttributeBean", qname.getLocalPart() );
34         
35         assertTrue( tm.getDeserializer(qname) != null );
36         assertTrue( tm.getSerializer(AttributeBean.class) != null );
37
38         assertEquals(
39             "http://encoding.test",
40             Namespaces.makeNamespace(AttributeBean[].class.getName()));
41         assertEquals(
42             "AttributeBean[]",
43             Types.getLocalNameFromFullName(AttributeBean[].class.getName()));
44
45 // qname = tm.getTypeQName( AttributeBean[].class );
46
// assertEquals( "http://encoding.test",
47
// qname.getNamespaceURI() );
48
// assertEquals( "AttributeBean[]", qname.getLocalPart() );
49

50     }
51 }
52
Popular Tags