axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject cvs commit: xml-axis/java/test/encoding TestDeser2000.java TestDeser2001.java PackageTests.java TestDeser.java
Date Fri, 04 May 2001 06:09:54 GMT
rubys       01/05/03 23:09:54

  Modified:    java/src/org/apache/axis Constants.java
               java/src/org/apache/axis/encoding SOAPEncoding.java
                        SOAPTypeMappingRegistry.java
               java/src/org/apache/axis/message MessageElement.java
                        RPCParam.java SOAPEnvelope.java
               java/test/encoding PackageTests.java TestDeser.java
  Added:       java/test/encoding TestDeser2000.java TestDeser2001.java
  Log:
  Add support for multiple schemas
  
  Revision  Changes    Path
  1.11      +29 -4     xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Constants.java	2001/05/02 14:37:08	1.10
  +++ Constants.java	2001/05/04 06:09:49	1.11
  @@ -78,12 +78,37 @@
                                  "http://schemas.xmlsoap.org/soap/envelope/" ;
     public static String URI_SOAP_ENC =
                                  "http://schemas.xmlsoap.org/soap/encoding/" ;
  -  public static String URI_SCHEMA_XSI =
  -                               "http://www.w3.org/1999/XMLSchema-instance" ;
  -  public static String URI_SCHEMA_XSD =
  -                               "http://www.w3.org/1999/XMLSchema" ;
     public static String URI_NEXT_ACTOR = 
                                  "http://schemas.xmlsoap.org/soap/actor/next" ;
  +
  +  
  +  // Schema namespaces
  +  public static final String URI_1999_SCHEMA_XSI =
  +    "http://www.w3.org/1999/XMLSchema-instance";
  +  public static final String URI_1999_SCHEMA_XSD =
  +    "http://www.w3.org/1999/XMLSchema";
  +  public static final String URI_2000_SCHEMA_XSI =
  +    "http://www.w3.org/2000/10/XMLSchema-instance";
  +  public static final String URI_2000_SCHEMA_XSD =
  +    "http://www.w3.org/2000/10/XMLSchema";
  +  public static final String URI_2001_SCHEMA_XSI =
  +    "http://www.w3.org/2001/XMLSchema-instance";
  +  public static final String URI_2001_SCHEMA_XSD =
  +    "http://www.w3.org/2001/XMLSchema";
  +  public static final String URI_CURRENT_SCHEMA_XSI = URI_1999_SCHEMA_XSI;
  +  public static final String URI_CURRENT_SCHEMA_XSD = URI_1999_SCHEMA_XSD;
  +  
  +  public static final String[] URIS_SCHEMA_XSI = {
  +    URI_1999_SCHEMA_XSI,
  +    URI_2000_SCHEMA_XSI,
  +    URI_2001_SCHEMA_XSI,
  +  };
  +  
  +  public static final String[] URIS_SCHEMA_XSD = {
  +    URI_1999_SCHEMA_XSD,
  +    URI_2000_SCHEMA_XSD,
  +    URI_2001_SCHEMA_XSD,
  +  };
   
     public static String ELEM_ENVELOPE = "Envelope" ;
     public static String ELEM_HEADER   = "Header" ;
  
  
  
  1.3       +2 -2      xml-axis/java/src/org/apache/axis/encoding/SOAPEncoding.java
  
  Index: SOAPEncoding.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SOAPEncoding.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SOAPEncoding.java	2001/05/03 14:31:46	1.2
  +++ SOAPEncoding.java	2001/05/04 06:09:50	1.3
  @@ -63,14 +63,14 @@
                                         attributes.getLocalName(i),
                                         attributes.getQName(i), "CDATA",
                                         attributes.getValue(i));
  -                    if (attributes.getURI(i).equals(Constants.URI_SCHEMA_XSI) &&
  +                    if (attributes.getURI(i).equals(Constants.URI_CURRENT_SCHEMA_XSI) &&
                           attributes.getLocalName(i).equals("type"))
                           gotType = true;
                   }
               }
               
               if (!gotType) {
  -                impl.addAttribute(Constants.URI_SCHEMA_XSI,
  +                impl.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI,
                                  "type", "xsi:type",
                                  "CDATA", str);
               }
  
  
  
  1.4       +31 -14    xml-axis/java/src/org/apache/axis/encoding/SOAPTypeMappingRegistry.java
  
  Index: SOAPTypeMappingRegistry.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SOAPTypeMappingRegistry.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SOAPTypeMappingRegistry.java	2001/05/04 01:17:28	1.3
  +++ SOAPTypeMappingRegistry.java	2001/05/04 06:09:50	1.4
  @@ -6,13 +6,13 @@
   
   public class SOAPTypeMappingRegistry extends TypeMappingRegistry { 
       
  -    public static final QName XSD_STRING = new QName(Constants.URI_SCHEMA_XSD, "string");
  -    public static final QName XSD_BOOLEAN = new QName(Constants.URI_SCHEMA_XSD, "boolean");
  -    public static final QName XSD_DOUBLE = new QName(Constants.URI_SCHEMA_XSD, "double");
  -    public static final QName XSD_FLOAT = new QName(Constants.URI_SCHEMA_XSD, "float");
  -    public static final QName XSD_INT = new QName(Constants.URI_SCHEMA_XSD, "int");
  -    public static final QName XSD_LONG = new QName(Constants.URI_SCHEMA_XSD, "long");
  -    public static final QName XSD_SHORT = new QName(Constants.URI_SCHEMA_XSD, "short");
  +    public static final QName XSD_STRING = new QName(Constants.URI_CURRENT_SCHEMA_XSD,
"string");
  +    public static final QName XSD_BOOLEAN = new QName(Constants.URI_CURRENT_SCHEMA_XSD,
"boolean");
  +    public static final QName XSD_DOUBLE = new QName(Constants.URI_CURRENT_SCHEMA_XSD,
"double");
  +    public static final QName XSD_FLOAT = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "float");
  +    public static final QName XSD_INT = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "int");
  +    public static final QName XSD_LONG = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "long");
  +    public static final QName XSD_SHORT = new QName(Constants.URI_CURRENT_SCHEMA_XSD, "short");
       public static final QName SOAP_STRING = new QName(Constants.URI_SOAP_ENC, "string");
       public static final QName SOAP_BOOLEAN = new QName(Constants.URI_SOAP_ENC, "boolean");
       public static final QName SOAP_DOUBLE = new QName(Constants.URI_SOAP_ENC, "double");
  @@ -83,6 +83,22 @@
           public DeserializerBase getDeserializer() { return new ShortDeser(); }
       }
   
  +    /**
  +     * Alias common DeserializerFactories across the various popular schemas
  +     * @param base QName based on the current Schema namespace
  +     * @param factory common factory to be used across all schemas
  +     */
  +    private void addDeserializersFor(QName base, DeserializerFactory factory) {
  +        addDeserializerFactory(base, factory);
  +        String localPart = base.getLocalPart();
  +        for (int i=0; i<Constants.URIS_SCHEMA_XSD.length; i++) {
  +            if (!Constants.URIS_SCHEMA_XSD[i].equals(base.getNamespaceURI())) {
  +               QName qname = new QName(Constants.URIS_SCHEMA_XSD[i], localPart);
  +               addDeserializerFactory(qname, factory);
  +            }
  +        }
  +    }
  +
       public SOAPTypeMappingRegistry() {
           SOAPEncoding se = new SOAPEncoding();
           addSerializer(java.lang.String.class, XSD_STRING, se);
  @@ -93,13 +109,14 @@
           addSerializer(java.lang.Long.class, XSD_LONG, se);
           addSerializer(java.lang.Short.class, XSD_SHORT, se);
           
  -        addDeserializerFactory(XSD_STRING, new StringDeserializerFactory());    
  -        addDeserializerFactory(XSD_BOOLEAN, new BooleanDeserializerFactory());
  -        addDeserializerFactory(XSD_DOUBLE, new DoubleDeserializerFactory());
  -        addDeserializerFactory(XSD_FLOAT, new FloatDeserializerFactory());
  -        addDeserializerFactory(XSD_INT, new IntDeserializerFactory());
  -        addDeserializerFactory(XSD_LONG, new LongDeserializerFactory());
  -        addDeserializerFactory(XSD_SHORT, new ShortDeserializerFactory());
  +        addDeserializersFor(XSD_STRING, new StringDeserializerFactory());    
  +        addDeserializersFor(XSD_BOOLEAN, new BooleanDeserializerFactory());
  +        addDeserializersFor(XSD_DOUBLE, new DoubleDeserializerFactory());
  +        addDeserializersFor(XSD_FLOAT, new FloatDeserializerFactory());
  +        addDeserializersFor(XSD_INT, new IntDeserializerFactory());
  +        addDeserializersFor(XSD_LONG, new LongDeserializerFactory());
  +        addDeserializersFor(XSD_SHORT, new ShortDeserializerFactory());
  +
           /*
           addDeserializerFactory(SOAP_STRING, se);
           addDeserializerFactory(SOAP_BOOLEAN, se);
  
  
  
  1.13      +2 -2      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- MessageElement.java	2001/05/03 15:35:40	1.12
  +++ MessageElement.java	2001/05/04 06:09:51	1.13
  @@ -225,14 +225,14 @@
                   ServiceDescription desc = getEnvelope().getServiceDescription();
                   if ((desc == null) || desc.getSendTypeAttr()) {
                       if (typeQName != null) {
  -                        attrs.addAttribute(Constants.URI_SCHEMA_XSI, "type", "xsi:type",
  +                        attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI, "type", "xsi:type",
                                              "CDATA",
                                              context.qName2String(typeQName));
                       }
                   }
                   
                   if (val == null)
  -                    attrs.addAttribute(Constants.URI_SCHEMA_XSI, "null", "xsi:null",
  +                    attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI, "null", "xsi:null",
                                          "CDATA", "1");
               } else {
                   attrs = new AttributesImpl(attributes);
  
  
  
  1.9       +5 -3      xml-axis/java/src/org/apache/axis/message/RPCParam.java
  
  Index: RPCParam.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RPCParam.java	2001/05/04 04:10:51	1.8
  +++ RPCParam.java	2001/05/04 06:09:52	1.9
  @@ -84,7 +84,9 @@
           name = localName;
   
           // Check for type
  -        String type = attrs.getValue(Constants.URI_SCHEMA_XSI, "type");
  +        String type = null;
  +        for (int i=0; i<Constants.URIS_SCHEMA_XSI.length && type==null; i++)
  +            type = attrs.getValue(Constants.URIS_SCHEMA_XSI[i], "type");
           
           if (DEBUG_LOG)
               System.out.println("Got param.  Name ='" + name + "' Type is '" + type + "'");
  @@ -223,14 +225,14 @@
               if ((desc == null) || desc.getSendTypeAttr()) {
                   
                   if (typeQName != null) {
  -                    attrs.addAttribute(Constants.URI_SCHEMA_XSI, "type", "xsi:type",
  +                    attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI, "type", "xsi:type",
                                          "CDATA",
                                          context.qName2String(typeQName));
                   }
               }
           
               if (value == null)
  -                attrs.addAttribute(Constants.URI_SCHEMA_XSI, "null", "xsi:null",
  +                attrs.addAttribute(Constants.URI_CURRENT_SCHEMA_XSI, "null", "xsi:null",
                                      "CDATA", "1");
           }
   
  
  
  
  1.21      +2 -2      xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
  
  Index: SOAPEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- SOAPEnvelope.java	2001/05/01 22:05:25	1.20
  +++ SOAPEnvelope.java	2001/05/04 06:09:52	1.21
  @@ -89,8 +89,8 @@
       public SOAPEnvelope()
       {
           nsDecls.put(Constants.URI_SOAP_ENV, Constants.NSPREFIX_SOAP_ENV);
  -        nsDecls.put(Constants.URI_SCHEMA_XSD, Constants.NSPREFIX_SCHEMA_XSD);
  -        nsDecls.put(Constants.URI_SCHEMA_XSI, Constants.NSPREFIX_SCHEMA_XSI);
  +        nsDecls.put(Constants.URI_CURRENT_SCHEMA_XSD, Constants.NSPREFIX_SCHEMA_XSD);
  +        nsDecls.put(Constants.URI_CURRENT_SCHEMA_XSI, Constants.NSPREFIX_SCHEMA_XSI);
           handler = null;
       }
       
  
  
  
  1.4       +2 -0      xml-axis/java/test/encoding/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/PackageTests.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PackageTests.java	2001/05/04 04:10:53	1.3
  +++ PackageTests.java	2001/05/04 06:09:53	1.4
  @@ -20,6 +20,8 @@
           TestSuite suite = new TestSuite();
   
           suite.addTestSuite(TestDeser.class);
  +        suite.addTestSuite(TestDeser2000.class);
  +        suite.addTestSuite(TestDeser2001.class);
           suite.addTestSuite(TestSer.class);
           suite.addTestSuite(TestString.class);
   
  
  
  
  1.2       +23 -15    xml-axis/java/test/encoding/TestDeser.java
  
  Index: TestDeser.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/encoding/TestDeser.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestDeser.java	2001/05/04 04:10:53	1.1
  +++ TestDeser.java	2001/05/04 06:09:53	1.2
  @@ -1,5 +1,6 @@
   package test.encoding;
   
  +import org.apache.axis.Constants;
   import org.apache.axis.Message;
   import org.apache.axis.message.*;
   import org.apache.axis.encoding.*;
  @@ -16,25 +17,32 @@
    */
   public class TestDeser extends TestCase {
   
  +    private String header;
  +    private String footer;
  +
       public TestDeser(String name) {
  -        super(name);
  +        this(name, Constants.URI_CURRENT_SCHEMA_XSI, 
  +                   Constants.URI_CURRENT_SCHEMA_XSD);
       }
   
  -    private static final String header =
  -        "<?xml version=\"1.0\"?>\n" +
  -        "<soap:Envelope " +
  -          "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
  -          "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
  -          "xmlns:xsi=\"http://www.w3.org/1999/XMLSchema-instance\" " +
  -          "xmlns:xsd=\"http://www.w3.org/1999/XMLSchema\">\n" +
  -          "<soap:Body>\n" +
  -            "<methodResult xmlns=\"http://tempuri.org/\">\n";
  -
  -    private static final String footer =
  -            "</methodResult>\n" +
  -          "</soap:Body>\n" +
  -        "</soap:Envelope>\n";
  +    public TestDeser(String name, String NS_XSI, String NS_XSD) {
  +        super(name);
   
  +        header =
  +            "<?xml version=\"1.0\"?>\n" +
  +            "<soap:Envelope " +
  +              "xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" " +
  +              "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
  +              "xmlns:xsi=\"" + NS_XSI + "\" " +
  +              "xmlns:xsd=\"" + NS_XSD + "\">\n" +
  +              "<soap:Body>\n" +
  +                "<methodResult xmlns=\"http://tempuri.org/\">\n";
  +
  +        footer =
  +                "</methodResult>\n" +
  +              "</soap:Body>\n" +
  +            "</soap:Envelope>\n";
  +    }
   
       private void deserialize(String data, Object expected) {
          Message message = new Message(header + data + footer, "String");
  
  
  
  1.1                  xml-axis/java/test/encoding/TestDeser2000.java
  
  Index: TestDeser2000.java
  ===================================================================
  package test.encoding;
  
  import org.apache.axis.Constants;
  import junit.framework.TestCase;
  
  /** 
   * Test deserialization of SOAP responses
   */
  public class TestDeser2001 extends TestDeser {
  
      public TestDeser2001(String name) {
          super(name, Constants.URI_2000_SCHEMA_XSI, 
                      Constants.URI_2000_SCHEMA_XSD);
      }
  }
  
  
  
  1.1                  xml-axis/java/test/encoding/TestDeser2001.java
  
  Index: TestDeser2001.java
  ===================================================================
  package test.encoding;
  
  import org.apache.axis.Constants;
  import junit.framework.TestCase;
  
  /** 
   * Test deserialization of SOAP responses
   */
  public class TestDeser2001 extends TestDeser {
  
      public TestDeser2001(String name) {
          super(name, Constants.URI_2001_SCHEMA_XSI, 
                      Constants.URI_2001_SCHEMA_XSD);
      }
  }
  
  
  

Mime
View raw message