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 di...@apache.org on 2004/12/14 16:14:39 UTC

cvs commit: ws-axis/java/src/org/apache/axis/wsdl/fromJava Types.java

dims        2004/12/14 07:14:39

  Modified:    java/test/typedesc PackageTests.java
               java/src/org/apache/axis/wsdl/fromJava Types.java
  Added:       java/test/typedesc TestTypesNonBeanCompatible.java
  Log:
  Fix for AXIS-1720 - Java2WSDL, repeated types auto-mapping to xsd:anyType causes bad definition in schema
  from Brett Randall (brett_s_r@yahoo.com.au)
  
  Revision  Changes    Path
  1.2       +1 -0      ws-axis/java/test/typedesc/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/typedesc/PackageTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageTests.java	30 Aug 2003 05:20:58 -0000	1.1
  +++ PackageTests.java	14 Dec 2004 15:14:38 -0000	1.2
  @@ -14,6 +14,7 @@
           TestSuite suite = new TestSuite();
   
           suite.addTestSuite(TestTypeDescSynch.class);
  +        suite.addTestSuite(TestTypesNonBeanCompatible.class);
   
           return suite;
       }
  
  
  
  1.1                  ws-axis/java/test/typedesc/TestTypesNonBeanCompatible.java
  
  Index: TestTypesNonBeanCompatible.java
  ===================================================================
  package test.typedesc;
  import java.util.ArrayList;
  import java.util.Locale;
  
  import javax.wsdl.Definition;
  import javax.wsdl.factory.WSDLFactory;
  
  import org.apache.axis.description.JavaServiceDesc;
  import org.apache.axis.description.ServiceDesc;
  import org.apache.axis.encoding.DefaultTypeMappingImpl;
  import org.apache.axis.encoding.TypeMapping;
  import org.apache.axis.wsdl.fromJava.Namespaces;
  import org.apache.axis.wsdl.fromJava.Types;
  
  import junit.framework.TestCase;
  
  public class TestTypesNonBeanCompatible extends TestCase {
  
  	private Types types;
  
  	protected void setUp() throws Exception {
  
  		Definition def = WSDLFactory.newInstance().newDefinition();
  		TypeMapping tm = DefaultTypeMappingImpl.getSingleton();
  		Namespaces namespaces = new Namespaces();
  		ServiceDesc serviceDesc = new JavaServiceDesc();
  		
  		types = new Types(def, tm, tm, namespaces, "any:name.space", new ArrayList(), serviceDesc);
  	}
  	
  	public void testWriteTypeNonBeanCompatibleOnce() throws Exception {
  		
  		String schema = types.writeType(Locale.class);
  		assertEquals("Schema should be null for non-bean-compatible types", null, schema);
  	}
  	
  	public void testWriteTypeNonBeanCompatibleTwice() throws Exception {
  		
  		String schema = types.writeType(Locale.class);
  		assertEquals("Schema should be null for non-bean-compatible types", null, schema);
  		
  		schema = types.writeType(Locale.class);
  		assertEquals("Schema should be null for non-bean-compatible types", null, schema);
  	}
  	
  	public void testWriteTypeNonBeanCompatibleDifferent() throws Exception {
  		
  		String schema = types.writeType(Locale.class);
  		assertEquals("Schema should be null for non-bean-compatible types", null, schema);
  		
  		schema = types.writeType(Locale.class);
  		assertEquals("Schema should be null for non-bean-compatible types", null, schema);
  	}
  }
  
  
  1.104     +11 -11    ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java
  
  Index: Types.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/wsdl/fromJava/Types.java,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- Types.java	21 Nov 2004 19:47:47 -0000	1.103
  +++ Types.java	14 Dec 2004 15:14:39 -0000	1.104
  @@ -1728,17 +1728,6 @@
                               "noContainerForAnonymousType", qName.toString()));
           }
   
  -        // If we've already got this type (because it's a native type or
  -        // because we've already written it), just add the type="" attribute
  -        // (if appropriate) and return.
  -        if (!addToTypesList(qName) && !anonymous) {
  -        	if (containingElement != null) {
  -                containingElement.setAttribute("type", getQNameString(qName));
  -            }
  -
  -            return true;
  -        }
  -
           // look up the serializer in the TypeMappingRegistry
           SerializerFactory factory;
           if (tm != null) {
  @@ -1768,6 +1757,17 @@
                       type.getName()));
           }
   
  +        // If we've already got this type (because it's a native type or
  +        // because we've already written it), just add the type="" attribute
  +        // (if appropriate) and return.
  +        if (!addToTypesList(qName) && !anonymous) {
  +        	if (containingElement != null) {
  +                containingElement.setAttribute("type", getQNameString(qName));
  +            }
  +
  +            return true;
  +        }
  +        
           Element typeEl;
   
           try {