axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bu...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/filegen AllOptionTestCase.java FileGen.wsdl FileGenTestCase.java
Date Wed, 06 Feb 2002 21:08:55 GMT
butek       02/02/06 13:08:55

  Modified:    java/src/org/apache/axis/utils resources.properties
               java/src/org/apache/axis/wsdl WSDL2Java.java
               java/src/org/apache/axis/wsdl/toJava Emitter.java
                        JavaWriterFactory.java PortTypeEntry.java
               java/test/wsdl Wsdl2javaAntTask.java Wsdl2javaTestSuite.xml
               java/test/wsdl/filegen FileGen.wsdl FileGenTestCase.java
  Added:       java/test/wsdl/filegen AllOptionTestCase.java
  Log:
  I added --all to WSDL2Java.  I thought it would be quick and easy.  Silly me.  This
  option exposed some bugs I had to fix.  I also added a quick test.
  
  Revision  Changes    Path
  1.50      +1 -0      xml-axis/java/src/org/apache/axis/utils/resources.properties
  
  Index: resources.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/resources.properties,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -r1.49 -r1.50
  --- resources.properties	6 Feb 2002 15:17:17 -0000	1.49
  +++ resources.properties	6 Feb 2002 21:08:54 -0000	1.50
  @@ -416,6 +416,7 @@
   # NOTE:  in the only1Header00, do not translate "Header"
   only1Header00=Only one Header element allowed!
   
  +optionAll00=generate code for all elements, even unreferenced ones
   optionHelp00=print this message and exit
   
   # NOTE:  in optionImport00, do not translate "WSDL"
  
  
  
  1.6       +20 -0     xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java
  
  Index: WSDL2Java.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/WSDL2Java.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- WSDL2Java.java	12 Jan 2002 16:31:37 -0000	1.5
  +++ WSDL2Java.java	6 Feb 2002 21:08:54 -0000	1.6
  @@ -93,6 +93,7 @@
       protected static final int NOIMPORTS_OPT = 'n';
       protected static final int PACKAGE_OPT = 'p';
       protected static final int DEBUG_OPT = 'D';
  +    protected static final int ALL_OPT = 'a';
   
       // Scope constants
       public static final byte NO_EXPLICIT_SCOPE = 0x00;
  @@ -153,6 +154,10 @@
                   CLOptionDescriptor.ARGUMENT_DISALLOWED,
                   NOIMPORTS_OPT,
                   JavaUtils.getMessage("optionImport00")),
  +        new CLOptionDescriptor("all",
  +                CLOptionDescriptor.ARGUMENT_DISALLOWED,
  +                ALL_OPT,
  +                JavaUtils.getMessage("optionAll00")),
           new CLOptionDescriptor("Debug",
                   CLOptionDescriptor.ARGUMENT_DISALLOWED,
                   DEBUG_OPT,
  @@ -228,6 +233,17 @@
       } // generateImports
   
       /**
  +     * By default, code is generated only for referenced elements.
  +     * Call generateAll(true) and WSDL2Java will generate code for all
  +     * elements in the scope regardless of whether they are
  +     * referenced.  Scope means:  by default, all WSDL files; if
  +     * generateImports(false), then only the immediate WSDL file.
  +     */
  +     public void generateAll(boolean all) {
  +         emitter.generateAll(all);
  +     } // generateAll
  +
  +    /**
        * Turn on/off debug messages.
        * @param boolean value
        */
  @@ -461,6 +477,10 @@
   
                       case NOIMPORTS_OPT:
                           wsdl2java.generateImports(false);
  +                        break;
  +
  +                    case ALL_OPT:
  +                        wsdl2java.generateAll(true);
                           break;
   
                       case DEBUG_OPT:
  
  
  
  1.15      +13 -2     xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/Emitter.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Emitter.java	1 Feb 2002 22:08:26 -0000	1.14
  +++ Emitter.java	6 Feb 2002 21:08:54 -0000	1.15
  @@ -109,6 +109,7 @@
       protected boolean bEmitTestCase = false;
       protected boolean bVerbose = false;
       protected boolean bGenerateImports = true;
  +    protected boolean bGenerateAll = false;
       protected String outputDir = null;
       protected String packageName = null;
       protected byte scope = NO_EXPLICIT_SCOPE;
  @@ -208,8 +209,7 @@
                       // that didn't contain a binding, merely a service that referred
                       // to a non-existent binding.  Don't bother writing it.
                       // If this isn't a SOAP binding, don't bother writing it, either.
  -                    if (binding.isUndefined() ||
  -                        bEntry.getBindingType() != BindingEntry.TYPE_SOAP) {
  +                    if (binding.isUndefined()) {
                           continue;
                       }
                       writer = writerFactory.getWriter(binding, symbolTable);
  @@ -304,6 +304,17 @@
       public void generateImports(boolean generateImports) {
           this.bGenerateImports = generateImports;
       } // generateImports
  +
  +    /**
  +     * By default, code is generated only for referenced elements.
  +     * Call generateAll(true) and WSDL2Java will generate code for all
  +     * elements in the scope regardless of whether they are
  +     * referenced.  Scope means:  by default, all WSDL files; if
  +     * generateImports(false), then only the immediate WSDL file.
  +     */
  +     public void generateAll(boolean all) {
  +         bGenerateAll = all;
  +     } // generateAll
   
       /**
        * Turn on/off debug messages.
  
  
  
  1.11      +27 -4     xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriterFactory.java
  
  Index: JavaWriterFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaWriterFactory.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- JavaWriterFactory.java	2 Feb 2002 15:43:51 -0000	1.10
  +++ JavaWriterFactory.java	6 Feb 2002 21:08:54 -0000	1.11
  @@ -95,7 +95,12 @@
           this.symbolTable = symbolTable;
           javifyNames(symbolTable);
           resolveNameClashes(symbolTable);
  -        ignoreNonSOAPBindingPortTypes(symbolTable);
  +        if (emitter.bGenerateAll) {
  +            setAllReferencesToTrue();
  +        }
  +        else {
  +            ignoreNonSOAPBindings(symbolTable);
  +        }
           constructSignatures(symbolTable);
           determineIfHoldersNeeded(symbolTable);
       } // writerPass
  @@ -319,9 +324,25 @@
       }
   
       /**
  -     * If a binding's type is not TYPE_SOAP, then we don't use that binding's portType.
  +     * The --all flag is set on the command line (or generateAll(true) is called on WSDL2Java).
  +     * Set all symbols as referenced.
        */
  -    private void ignoreNonSOAPBindingPortTypes(SymbolTable symbolTable) {
  +    private void setAllReferencesToTrue() {
  +        Iterator it = symbolTable.getHashMap().values().iterator();
  +        while (it.hasNext()) {
  +            Vector v = (Vector) it.next();
  +            for (int i = 0; i < v.size(); ++i) {
  +                SymTabEntry entry = (SymTabEntry) v.elementAt(i);
  +                entry.setIsReferenced(true);
  +            }
  +        }
  +    } // setAllReferencesToTrue
  +
  +    /**
  +     * If a binding's type is not TYPE_SOAP, then we don't use that binding
  +     * or that binding's portType.
  +     */
  +    private void ignoreNonSOAPBindings(SymbolTable symbolTable) {
   
           // Look at all uses of the portTypes.  If none of the portType's bindings are of
type
           // TYPE_SOAP, then turn off that portType's isReferenced flag.
  @@ -352,6 +373,8 @@
                           }
                       }
                       else {
  +                        bEntry.setIsReferenced(false);
  +
                           // If a binding is not of type TYPE_SOAP, then mark its portType
as
                           // unused ONLY if it hasn't already been marked as used.
                           if (!usedPortTypes.contains(ptEntry)) {
  @@ -368,7 +391,7 @@
               PortTypeEntry ptEntry = (PortTypeEntry) unusedPortTypes.get(i);
               ptEntry.setIsReferenced(false);
           }
  -    } // ignoreNonSOAPBindingPortTypes
  +    } // ignoreNonSOAPBindings
   
       private void constructSignatures(SymbolTable symbolTable) {
           Iterator it = symbolTable.getHashMap().values().iterator();
  
  
  
  1.3       +0 -2      xml-axis/java/src/org/apache/axis/wsdl/toJava/PortTypeEntry.java
  
  Index: PortTypeEntry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/PortTypeEntry.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PortTypeEntry.java	24 Jan 2002 23:12:59 -0000	1.2
  +++ PortTypeEntry.java	6 Feb 2002 21:08:54 -0000	1.3
  @@ -83,6 +83,4 @@
       public PortType getPortType() {
           return portType;
       } // getPortType
  -
  -
   } // class PortTypeEntry
  
  
  
  1.16      +8 -0      xml-axis/java/test/wsdl/Wsdl2javaAntTask.java
  
  Index: Wsdl2javaAntTask.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaAntTask.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Wsdl2javaAntTask.java	27 Jan 2002 02:43:35 -0000	1.15
  +++ Wsdl2javaAntTask.java	6 Feb 2002 21:08:54 -0000	1.16
  @@ -77,6 +77,7 @@
       private boolean skeleton = true ;
       private boolean testCase = false;
       private boolean noImports = false;
  +    private boolean all = false;
       private HashMap namespaceMap = new HashMap();
       private String output = "." ;
       private String deployScope = "";
  @@ -94,6 +95,7 @@
               log("\toutput:" + output, Project.MSG_VERBOSE);
               log("\tdeployScope:" + deployScope, Project.MSG_VERBOSE);
               log("\tURL:" + url, Project.MSG_VERBOSE);
  +            log("\tall:" + all, Project.MSG_VERBOSE);
               
               // Instantiate the emitter
               WSDL2Java emitter = new WSDL2Java();
  @@ -118,6 +120,7 @@
               }
               emitter.generateTestCase(testCase);
               emitter.generateImports(!noImports);
  +            emitter.generateAll(all);
               emitter.setOutputDir(output);
               emitter.generateSkeleton(skeleton);
               emitter.verbose(verbose);
  @@ -182,6 +185,11 @@
       // The setter for the "url" attribute
       public void setURL(String parameter) {
           this.url = parameter;
  +    }
  +
  +    // The setter for the "all" attribute
  +    public void setAll(String parameter) {
  +        this.all = Project.toBoolean(parameter);
       }
   
       /** the command arguments */
  
  
  
  1.68      +8 -0      xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml
  
  Index: Wsdl2javaTestSuite.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
  retrieving revision 1.67
  retrieving revision 1.68
  diff -u -r1.67 -r1.68
  --- Wsdl2javaTestSuite.xml	5 Feb 2002 19:36:31 -0000	1.67
  +++ Wsdl2javaTestSuite.xml	6 Feb 2002 21:08:54 -0000	1.68
  @@ -427,6 +427,14 @@
           <mapping namespace="http://test.com/reference" package="test.wsdl.filegen"/>
       </wsdl2java>
       
  +    <!-- Same test as above but this time the -a flag is turned on -->
  +    <wsdl2java url="test/wsdl/filegen/FileGen.wsdl"
  +               output="build/work"
  +               skeleton="no"
  +               all="yes">
  +        <mapping namespace="http://test.com/reference" package="test.wsdl.filegenAll"/>
  +    </wsdl2java>
  +    
       <!-- Check to make sure we map XML names that are illegal Java correctly -->
       <wsdl2java url="test/wsdl/names/JavaNames.wsdl"
                  output="build/work"
  
  
  
  1.3       +1 -1      xml-axis/java/test/wsdl/filegen/FileGen.wsdl
  
  Index: FileGen.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/filegen/FileGen.wsdl,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FileGen.wsdl	13 Dec 2001 17:33:19 -0000	1.2
  +++ FileGen.wsdl	6 Feb 2002 21:08:54 -0000	1.3
  @@ -99,7 +99,7 @@
     <!-- Non-soap binding, no code should be emitted for it -->
     <binding name="ReferenceHttpGet" type="serviceNS:PortTypeNotSoap">
       <http:binding verb="GET" />
  -    <operation name="myop">
  +    <operation name="otherop">
         <http:operation location="/GetReference" />
         <input>
           <http:urlEncoded />
  
  
  
  1.4       +1 -0      xml-axis/java/test/wsdl/filegen/FileGenTestCase.java
  
  Index: FileGenTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/filegen/FileGenTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- FileGenTestCase.java	5 Feb 2002 16:22:40 -0000	1.3
  +++ FileGenTestCase.java	6 Feb 2002 21:08:54 -0000	1.4
  @@ -80,6 +80,7 @@
        */
       protected Set shouldExist() {
           HashSet set = new HashSet();
  +        set.add("AllOptionTestCase.java");
           set.add("FileGenTestCase.java");
           set.add("OpFault.java");
           set.add("PortTypeSoap.java");
  
  
  
  1.1                  xml-axis/java/test/wsdl/filegen/AllOptionTestCase.java
  
  Index: AllOptionTestCase.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 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/>.
   */
  
  /**
   * This tests the file generation of only the items that are referenced in WSDL
   * 
   */ 
  package test.wsdl.filegen;
  
  import java.io.File;
  
  import java.util.HashSet;
  import java.util.Set;
  
  public class AllOptionTestCase extends FileGenTestCase {
      public AllOptionTestCase(String name) {
          super(name);
      }
  
      /**
       * List of files which should be generated.
       */
      protected Set shouldExist() {
          HashSet set = new HashSet();
          set.add("Address.java");
          set.add("InvalidTickerFaultMessage.java");
          set.add("OpFault.java");
          set.add("PortTypeNotSoap.java");
          set.add("PortTypeSoap.java");
          set.add("ReferenceHttpGetStub.java");
          set.add("ReferenceService.java");
          set.add("ReferenceServiceLocator.java");
          set.add("ReferenceSoapBindingStub.java");
          set.add("StateType.java");
          return set;
      } // shouldExist
  
      /**
       * The directory containing the files that should exist.
       */
      protected String rootDir() {
          return "build" + File.separator + "work" + File.separator + 
                  "test" + File.separator + "wsdl" + File.separator +
                  "filegenAll";
      } // rootDir
  
  } // class AllOptionTestCase
  
  
  

Mime
View raw message