snichol 2002/11/18 12:18:10 Modified: java/test/util/xml PackageTests.java Added: java/test/util/xml XMLJavaMappingRegistryTest.java Log: Add tests for XMLJavaMappingRegistry. Revision Changes Path 1.3 +1 -0 xml-soap/java/test/util/xml/PackageTests.java Index: PackageTests.java =================================================================== RCS file: /home/cvs/xml-soap/java/test/util/xml/PackageTests.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PackageTests.java 18 Nov 2002 17:29:39 -0000 1.2 +++ PackageTests.java 18 Nov 2002 20:18:10 -0000 1.3 @@ -76,6 +76,7 @@ suite.addTestSuite(NSStackTest.class); suite.addTestSuite(QNameTest.class); + suite.addTestSuite(XMLJavaMappingRegistryTest.class); return suite; } 1.1 xml-soap/java/test/util/xml/XMLJavaMappingRegistryTest.java Index: XMLJavaMappingRegistryTest.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2000 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, * if any, must include the following acknowledgment: * "This product includes software developed by the * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowledgment may appear in the software itself, * if and wherever such third-party acknowledgments normally appear. * * 4. The names "SOAP" and "Apache Software Foundation" must * not be used to endorse or promote products derived from this * software without prior written permission. For written * permission, please contact [EMAIL PROTECTED] * * 5. Products derived from this software may not be called "Apache", * nor may "Apache" appear in their name, without prior written * permission of the Apache Software Foundation. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * ==================================================================== * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation and was * originally based on software copyright (c) 2000, International * Business Machines, Inc., http://www.apache.org. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package test.util.xml; import org.apache.soap.Constants; import org.apache.soap.encoding.soapenc.IntDeserializer; import org.apache.soap.encoding.soapenc.SimpleSerializer; import org.apache.soap.util.xml.QName; import org.apache.soap.util.xml.XMLJavaMappingRegistry; import junit.framework.TestCase; /* * Tests XMLJavaMappingRegistry. * * @author Scott Nichol ([EMAIL PROTECTED]) */ public class XMLJavaMappingRegistryTest extends TestCase { private static final String BOGUS_ENC = "bogus"; private XMLJavaMappingRegistry xmjr; private QName qn1; private QName qn2; private SimpleSerializer ss; private SimpleSerializer ss2; private IntDeserializer id; private IntDeserializer id2; public XMLJavaMappingRegistryTest(String name) { super(name); } protected void setUp() { qn1 = new QName("urn:test", "anint"); qn2 = new QName("urn:test", "anint2"); ss = new SimpleSerializer(); ss2 = new SimpleSerializer(); id = new IntDeserializer(); id2 = new IntDeserializer(); xmjr = new XMLJavaMappingRegistry(); xmjr.setDefaultEncodingStyle(Constants.NS_URI_SOAP_ENC); xmjr.mapTypes(Constants.NS_URI_SOAP_ENC, qn1, Integer.class, ss, id); xmjr.mapTypes(BOGUS_ENC, qn1, Short.class, ss, id); xmjr.mapTypes(BOGUS_ENC, qn2, Integer.class, ss2, id2); } /* * Tests of simple behavior. */ public void test01() { assertSame("test01", xmjr.querySerializer(Integer.class, Constants.NS_URI_SOAP_ENC), ss); } public void test02() { assertSame("test02", xmjr.queryDeserializer(qn1, Constants.NS_URI_SOAP_ENC), id); } public void test03() { assertSame("test03", xmjr.queryElementType(Integer.class, Constants.NS_URI_SOAP_ENC), qn1); } public void test04() { assertSame("test04", xmjr.queryJavaType(qn1, Constants.NS_URI_SOAP_ENC), Integer.class); } /* * Tests of "full override". */ public void test05() { assertSame("test05", xmjr.querySerializer(Integer.class, BOGUS_ENC), ss2); } public void test06() { assertSame("test06", xmjr.queryDeserializer(qn2, BOGUS_ENC), id2); } public void test07() { assertSame("test07", xmjr.queryElementType(Integer.class, BOGUS_ENC), qn2); } public void test08() { assertSame("test08", xmjr.queryJavaType(qn2, BOGUS_ENC), Integer.class); } /* * Tests of "partial override". */ public void test09() { SimpleSerializer ss = new SimpleSerializer(); xmjr.mapTypes(BOGUS_ENC, qn1, Integer.class, ss, null); assertSame("test09a", xmjr.querySerializer(Integer.class, BOGUS_ENC), ss); assertSame("test09b", xmjr.queryElementType(Integer.class, BOGUS_ENC), qn1); assertSame("test09c", xmjr.queryJavaType(qn1, BOGUS_ENC), Short.class); } public void test10() { IntDeserializer id = new IntDeserializer(); xmjr.mapTypes(BOGUS_ENC, qn2, Short.class, null, id); assertSame("test10a", xmjr.queryDeserializer(qn2, BOGUS_ENC), id); assertSame("test10b", xmjr.queryElementType(Short.class, BOGUS_ENC), qn1); assertSame("test10c", xmjr.queryJavaType(qn2, BOGUS_ENC), Short.class); } public void test11() { SimpleSerializer ss = new SimpleSerializer(); xmjr.mapTypes(BOGUS_ENC, null, Integer.class, ss, null); assertSame("test11a", xmjr.querySerializer(Integer.class, BOGUS_ENC), ss); assertSame("test11b", xmjr.queryElementType(Integer.class, BOGUS_ENC), qn2); } public void test12() { IntDeserializer id = new IntDeserializer(); xmjr.mapTypes(BOGUS_ENC, qn2, null, null, id); assertSame("test12a", xmjr.queryDeserializer(qn2, BOGUS_ENC), id); assertSame("test12b", xmjr.queryJavaType(qn2, BOGUS_ENC), Integer.class); } /* * Tests of defaults. */ public void test13() { SimpleSerializer ss = new SimpleSerializer(); xmjr.mapTypes(BOGUS_ENC, qn2, null, ss, null); assertSame("test13a", xmjr.querySerializer(Long.class, BOGUS_ENC), ss); assertSame("test13b", xmjr.queryJavaType(qn2, BOGUS_ENC), Integer.class); } public void test14() { IntDeserializer id = new IntDeserializer(); xmjr.mapTypes(BOGUS_ENC, null, Integer.class, null, id); assertSame("test14a", xmjr.queryDeserializer(new QName("urn:what", "any"), BOGUS_ENC), id); assertSame("test14b", xmjr.queryElementType(Integer.class, BOGUS_ENC), qn2); } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>