You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2002/05/08 21:20:09 UTC

cvs commit: xml-axis/java/test/functional GlobalBean.java GlobalTypeTest.jws TestJWSGlobalTypes.java AltStockQuoteService.jws FunctionalTests.java

gdaniels    02/05/08 12:20:09

  Modified:    java/src/org/apache/axis/utils Options.java
               java/test build_functional_tests.xml
               java/test/functional AltStockQuoteService.jws
                        FunctionalTests.java
  Added:       java/test/functional GlobalBean.java GlobalTypeTest.jws
                        TestJWSGlobalTypes.java
  Log:
  Add functional test for a JWS service which utilizes a global type mapping.
  
  Revision  Changes    Path
  1.26      +3 -0      xml-axis/java/src/org/apache/axis/utils/Options.java
  
  Index: Options.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/Options.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- Options.java	22 Feb 2002 23:39:47 -0000	1.25
  +++ Options.java	8 May 2002 19:20:08 -0000	1.26
  @@ -88,6 +88,9 @@
        * Constructor - just pass in the <b>args</b> from the command line.
        */
       public Options(String _args[]) throws MalformedURLException {
  +        if (_args == null) {
  +            _args = new String [] {};
  +        }
           args = _args ;
           usedArgs = null ;
           defaultURL = new URL("http://localhost:8080/axis/servlet/AxisServlet");
  
  
  
  1.40      +1 -0      xml-axis/java/test/build_functional_tests.xml
  
  Index: build_functional_tests.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/build_functional_tests.xml,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- build_functional_tests.xml	15 Apr 2002 15:34:22 -0000	1.39
  +++ build_functional_tests.xml	8 May 2002 19:20:08 -0000	1.40
  @@ -75,6 +75,7 @@
       <mkdir dir="build/jws" />
       <copy file="samples/stock/StockQuoteService.jws" todir="build/jws" />
       <copy file="test/functional/AltStockQuoteService.jws" todir="build/jws" />
  +    <copy file="test/functional/GlobalTypeTest.jws" todir="build/jws"/>
   
       <!--...not to mention the sample user list -->
       <copy file="samples/stock/users.lst" todir="build"/>
  
  
  
  1.4       +8 -14     xml-axis/java/test/functional/AltStockQuoteService.jws
  
  Index: AltStockQuoteService.jws
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/functional/AltStockQuoteService.jws,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AltStockQuoteService.jws	13 Feb 2002 20:55:42 -0000	1.3
  +++ AltStockQuoteService.jws	8 May 2002 19:20:08 -0000	1.4
  @@ -2,7 +2,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights 
  + * Copyright (c) 2001 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -10,7 +10,7 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer. 
  + *    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
  @@ -18,7 +18,7 @@
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  - *    if any, must include the following acknowledgment:  
  + *    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,
  @@ -26,7 +26,7 @@
    *
    * 4. The names "AXIS" and "Apache Software Foundation" must
    *    not be used to endorse or promote products derived from this
  - *    software without prior written permission. For written 
  + *    software without prior written permission. For written
    *    permission, please contact apache@apache.org.
    *
    * 5. Products derived from this software may not be called "Apache",
  @@ -53,17 +53,11 @@
    * <http://www.apache.org/>.
    */
   
  -import java.io.*;
  -import java.util.* ;
  -import java.net.URL;
  -
   import org.w3c.dom.* ;
   import org.apache.axis.AxisServiceConfig;
   import org.apache.axis.AxisServiceConfigImpl;
   import org.apache.axis.utils.XMLUtils ;
   
  -
  -
   /**
    * See \samples\stock\readme for info.
    *
  @@ -86,17 +80,17 @@
     {
       return s;
     }
  -  
  +
     public float getQuote (String symbol) throws Exception {
  -    // get a real (delayed by 20min) stockquote from 
  -    // http://www.xmltoday.com/examples/stockquote/. The IP addr 
  +    // get a real (delayed by 20min) stockquote from
  +    // http://www.xmltoday.com/examples/stockquote/. The IP addr
       // below came from the host that the above form posts to ..
   
       // NOTE THAT THIS RETURNS 66.25 WHERE THE ORDINARY EXAMPLE RETURNS 55.25!
       if ( symbol.equals("XXX") ) return( (float) 66.25 );
   
       Document doc = null ;
  -    
  +
       doc = XMLUtils.newDocument( "http://www.xmltoday.com/examples/" +
                                   "stockquote/getxmlquote.vep?s="+symbol );
   
  
  
  
  1.20      +3 -0      xml-axis/java/test/functional/FunctionalTests.java
  
  Index: FunctionalTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/functional/FunctionalTests.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- FunctionalTests.java	2 May 2002 21:03:13 -0000	1.19
  +++ FunctionalTests.java	8 May 2002 19:20:08 -0000	1.20
  @@ -31,6 +31,9 @@
           // nothing else has been deployed
           suite.addTestSuite(TestStockSample.class);
   
  +        // JWS global types test (deploys a typeMapping)
  +        suite.addTestSuite(TestJWSGlobalTypes.class);
  +
           // TCP transport sample test
           suite.addTestSuite(TestTCPTransportSample.class);
           
  
  
  
  1.1                  xml-axis/java/test/functional/GlobalBean.java
  
  Index: GlobalBean.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 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 "Axis" 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 apache@apache.org.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * @author Glen Daniels (gdaniels@apache.org)
   */
  package test.functional;
  
  public class GlobalBean {
      private int intValue;
  
      public int getIntValue() {
          return intValue;
      }
  
      public void setIntValue(int intValue) {
          this.intValue = intValue;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/functional/GlobalTypeTest.jws
  
  Index: GlobalTypeTest.jws
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 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 "Axis" 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 apache@apache.org.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  import test.functional.GlobalBean;
  
  /**
   * This is a JWS which demonstrates that indeed, global type mappings work
   * in a JWS context.
   *
   * @author Glen Daniels (gdaniels@apache.org)
   */
  public class GlobalTypeTest {
      /**
       * Echo a bean.
       *
       * @param bean
       * @return the bean
       */
      public GlobalBean echo(GlobalBean bean) {
          return bean;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/functional/TestJWSGlobalTypes.java
  
  Index: TestJWSGlobalTypes.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 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 "Axis" 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 apache@apache.org.
   *
   * 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.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  /**
   * @author Glen Daniels (gdaniels@apache.org)
   */
  package test.functional;
  
  import junit.framework.TestCase;
  import org.apache.axis.deployment.wsdd.WSDDConstants;
  import org.apache.axis.client.AdminClient;
  import org.apache.axis.client.Call;
  import org.apache.axis.encoding.ser.BeanSerializerFactory;
  import org.apache.axis.encoding.ser.BeanDeserializerFactory;
  import org.apache.axis.utils.Options;
  
  import javax.xml.rpc.namespace.QName;
  import java.io.ByteArrayInputStream;
  
  public class TestJWSGlobalTypes extends TestCase {
      private static final String TYPEMAPPING_WSDD =
              "<deployment xmlns=\"" + WSDDConstants.WSDD_NS + "\" " +
                          "xmlns:java=\"" + WSDDConstants.WSDD_JAVA + "\" " +
                          "xmlns:ns=\"http://globalTypeTest\">\n" +
              "  <beanMapping type=\"java:test.functional.GlobalBean\" " +
                          "qname=\"ns:GlobalType\"/>\n" +
              "</deployment>";
  
      public TestJWSGlobalTypes(String s) {
          super(s);
      }
  
      protected void setUp() throws Exception {
          // Deploy the type mapping
          AdminClient client = new AdminClient();
          Options opts = new Options(null);
          ByteArrayInputStream bis =
                  new ByteArrayInputStream(TYPEMAPPING_WSDD.getBytes());
          client.process(opts, bis);
      }
  
      public void testGlobalTypes() throws Exception {
          Call call = new Call("http://localhost:8080/jws/GlobalTypeTest.jws");
          QName qname = new QName("http://globalTypeTest", "GlobalType");
          call.registerTypeMapping(GlobalBean.class, qname,
                      new BeanSerializerFactory(GlobalBean.class, qname),
                      new BeanDeserializerFactory(GlobalBean.class, qname));
          GlobalBean bean = new GlobalBean();
          bean.setIntValue(4);
          GlobalBean ret = (GlobalBean)call.invoke("echo", new Object [] { bean });
          assertEquals(4, ret.getIntValue());
      }
  }