owenb 2003/03/07 03:43:45
Added: java/test/features FeaturesTest.java Log: New test for testing setting, getting and overriding features on WSIFServiceFactory Revision Changes Path 1.1 xml-axis-wsif/java/test/features/FeaturesTest.java Index: FeaturesTest.java =================================================================== /* * The Apache Software License, Version 1.1 * * * Copyright (c) 2003 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 "WSIF" 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) 2001, 2002, International * Business Machines, Inc., http://www.ibm.com. For more * information on the Apache Software Foundation, please see * <http://www.apache.org/>. */ package features; import java.util.HashMap; import java.util.Map; import junit.framework.Test; import junit.framework.TestCase; import junit.framework.TestSuite; import org.apache.wsif.WSIFConstants; import org.apache.wsif.WSIFServiceFactory; import util.TestUtilities; /** * Junit test to test out setting and getting features on WSIFServiceFactory * subclasses * @author Owen Burroughs <[EMAIL PROTECTED]> */ public class FeaturesTest extends TestCase { public FeaturesTest(String name) { super(name); } public static void main(String[] args) { junit.textui.TestRunner.run(suite()); } public static Test suite() { return new TestSuite(FeaturesTest.class); } public void setUp() { TestUtilities.setUpExtensionsAndProviders(); } public void testGetSetFeatures() { WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); factory.setFeature( WSIFConstants.WSIF_FEATURE_AUTO_MAP_TYPES, new Boolean(true)); factory.setFeature( WSIFConstants.WSIF_FEATURE_SERVICE_CACHING, new Boolean(true)); factory.setFeature(WSIFConstants.WSIF_FEATURE_MAPPER_CLASS, "test"); factory.setFeature( WSIFConstants.WSIF_FEATURE_MAPPINGCONVENTION_CLASS, "test2"); Object f1 = factory.getFeature(WSIFConstants.WSIF_FEATURE_AUTO_MAP_TYPES); assertNotNull("WSIF_FEATURE_AUTO_MAP_TYPES feature was null when retrieved from factory", f1); assertTrue( "WSIF_FEATURE_AUTO_MAP_TYPES feature was not a Boolean when retrieved from factory", f1 instanceof Boolean); assertTrue( "WSIF_FEATURE_AUTO_MAP_TYPES feature was not set to true when retrieved from factory", ((Boolean) f1).booleanValue()); Object f2 = factory.getFeature(WSIFConstants.WSIF_FEATURE_SERVICE_CACHING); assertNotNull("WSIF_FEATURE_SERVICE_CACHING feature was null when retrieved from factory", f2); assertTrue( "WSIF_FEATURE_SERVICE_CACHING feature was not a Boolean when retrieved from factory", f2 instanceof Boolean); assertTrue( "WSIF_FEATURE_SERVICE_CACHING feature was not set to true when retrieved from factory", ((Boolean) f2).booleanValue()); Object f3 = factory.getFeature(WSIFConstants.WSIF_FEATURE_MAPPER_CLASS); assertNotNull("WSIF_FEATURE_MAPPER_CLASS feature was null when retrieved from factory", f3); assertTrue( "WSIF_FEATURE_MAPPER_CLASS feature was not a String when retrieved from factory", f3 instanceof String); assertTrue( "WSIF_FEATURE_MAPPER_CLASS feature was not set to \"test\" when retrieved from factory", ((String) f3).equals("test")); Object f4 = factory.getFeature(WSIFConstants.WSIF_FEATURE_MAPPINGCONVENTION_CLASS); assertNotNull("WSIF_FEATURE_MAPPINGCONVENTION_CLASS feature was null when retrieved from factory", f4); assertTrue( "WSIF_FEATURE_MAPPINGCONVENTION_CLASS feature was not a String when retrieved from factory", f4 instanceof String); assertTrue( "WSIF_FEATURE_MAPPINGCONVENTION_CLASS feature was not set to \"test2\" when retrieved from factory", ((String) f4).equals("test2")); factory.setFeature(WSIFConstants.WSIF_FEATURE_MAPPER_CLASS, "test3"); Object f5 = factory.getFeature(WSIFConstants.WSIF_FEATURE_MAPPER_CLASS); assertNotNull("WSIF_FEATURE_MAPPER_CLASS feature was null when retrieved from factory", f3); assertTrue( "WSIF_FEATURE_MAPPER_CLASS feature was not a String when retrieved from factory a second time", f5 instanceof String); assertTrue( "WSIF_FEATURE_MAPPER_CLASS feature was not set to \"test3\" when retrieved from factory a second time", ((String) f5).equals("test3")); } public void testOverrideAllFeatures() { WSIFServiceFactory factory = WSIFServiceFactory.newInstance(); factory.setFeature( WSIFConstants.WSIF_FEATURE_AUTO_MAP_TYPES, new Boolean(true)); factory.setFeature( WSIFConstants.WSIF_FEATURE_SERVICE_CACHING, new Boolean(true)); factory.setFeature(WSIFConstants.WSIF_FEATURE_MAPPER_CLASS, "test"); factory.setFeature( WSIFConstants.WSIF_FEATURE_MAPPINGCONVENTION_CLASS, "test2"); Map m = new HashMap(); m.put(WSIFConstants.WSIF_FEATURE_AUTO_MAP_TYPES, new Boolean(false)); m.put(WSIFConstants.WSIF_FEATURE_MAPPER_CLASS, "testOverride"); factory.setFeatures(m); Object f1 = factory.getFeature(WSIFConstants.WSIF_FEATURE_AUTO_MAP_TYPES); assertNotNull("WSIF_FEATURE_AUTO_MAP_TYPES feature was null when retrieved from factory", f1); assertTrue( "WSIF_FEATURE_AUTO_MAP_TYPES feature was not a Boolean when retrieved from factory", f1 instanceof Boolean); assertTrue( "WSIF_FEATURE_AUTO_MAP_TYPES feature was not set to false when retrieved from factory", !((Boolean) f1).booleanValue()); // this feature was not in the map passed in to setFeatures and so the feature value should be null Object f2 = factory.getFeature(WSIFConstants.WSIF_FEATURE_SERVICE_CACHING); assertNull("WSIF_FEATURE_SERVICE_CACHING feature was not null when retrieved from factory", f2); Object f3 = factory.getFeature(WSIFConstants.WSIF_FEATURE_MAPPER_CLASS); assertNotNull("WSIF_FEATURE_MAPPER_CLASS feature was null when retrieved from factory", f3); assertTrue( "WSIF_FEATURE_MAPPER_CLASS feature was not a String when retrieved from factory", f3 instanceof String); assertTrue( "WSIF_FEATURE_MAPPER_CLASS feature was not set to \"testOverride\" when retrieved from factory", ((String) f3).equals("testOverride")); // this feature was not in the map passed in to setFeatures and so the feature value should be null Object f4 = factory.getFeature(WSIFConstants.WSIF_FEATURE_MAPPINGCONVENTION_CLASS); assertNull("WSIF_FEATURE_MAPPINGCONVENTION_CLASS feature was not null when retrieved from factory", f4); } }
