axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/extensibility ExtensibilityQueryBindingImpl.java ExtensibilityQueryTestCase.java QueryTypes.wsdl server-deploy.wsdd
Date Wed, 08 May 2002 13:04:47 GMT
dims        02/05/08 06:04:46

  Modified:    java/test/wsdl/extensibility
                        ExtensibilityQueryBindingImpl.java
                        ExtensibilityQueryTestCase.java QueryTypes.wsdl
                        server-deploy.wsdd
  Log:
  Patch for "updated the extensibility test to handle arrays" from "Thomas Sandholm" <sandholm@mcs.anl.gov>
  
  Revision  Changes    Path
  1.2       +19 -11    xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java
  
  Index: ExtensibilityQueryBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryBindingImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExtensibilityQueryBindingImpl.java	7 May 2002 16:08:51 -0000	1.1
  +++ ExtensibilityQueryBindingImpl.java	8 May 2002 13:04:46 -0000	1.2
  @@ -9,22 +9,30 @@
   import javax.xml.rpc.namespace.QName;
   
   public class ExtensibilityQueryBindingImpl implements ExtensibilityQueryBinding {
  +    private final static String[] books = new String[] { "The Grid", "The Oxford Dictionary"
}; 
  +    private final static String[] subjects = new String[] { "Computer Science", "English"
}; 
   
       public ExtensibilityType query(ExtensibilityType query) throws java.rmi.RemoteException
{
           ExtensibilityType result = new ExtensibilityType();
           Object obj = query.getAny();
  -        if (obj instanceof BookQuery) {
  -            System.out.println("ExtensibilityQueryBindingImpl: Found book");
  -            BookQuery bookQuery = (BookQuery) obj;
  +        if (obj instanceof BookType) {
  +            BookType bookQuery = (BookType) obj;
               String subject = bookQuery.getSubject();
  -            QueryResultType queryResultType = new QueryResultType();
  -            QueryResult queryResult = new QueryResult(); 
  -            queryResult.setName(subject);
  -            queryResult.setValue("The Grid");
  -            queryResult.setTime(Calendar.getInstance());
  -            queryResult.setQueryType(new QName("urn:QueryType","BookQuery"));
  -            queryResultType.setQueryResult(queryResult);
  -            result.setAny(queryResultType);
  +            System.out.println("ExtensibilityQueryBindingImpl: Found book subject query
" + subject);
  +  
  +            QueryResultElement resultElement = new QueryResultElement();
  +            ResultListType resultList = new ResultListType();
  +            resultElement.setResultList(resultList);
  +            QueryResultType[] queryResult = new QueryResultType[books.length];
  +            for (int i = 0; i < books.length; i++) {
  +                queryResult[i] = new QueryResultType();
  +                queryResult[i].setName(subjects[i]);
  +                queryResult[i].setValue(books[i]);
  +                queryResult[i].setTime(Calendar.getInstance());
  +                queryResult[i].setQueryType(new QName("urn:QueryType","BookQuery"));
  +            }
  +            resultList.setResult(queryResult);
  +            result.setAny(resultElement);
           }
           return result;
       }
  
  
  
  1.2       +32 -27    xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java
  
  Index: ExtensibilityQueryTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/ExtensibilityQueryTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ExtensibilityQueryTestCase.java	7 May 2002 16:08:51 -0000	1.1
  +++ ExtensibilityQueryTestCase.java	8 May 2002 13:04:46 -0000	1.2
  @@ -39,49 +39,54 @@
           assertTrue("binding is null", binding != null);
   
           try {
  -           
               ExtensibilityType expression = new ExtensibilityType(); 
  -            FindBooksQueryExpressionType bookQuery = new FindBooksQueryExpressionType();

  -            BookQuery book = new BookQuery();
  -            book.setSubject("Computer Science");
  +            FindBooksQueryExpressionElement bookQuery = new FindBooksQueryExpressionElement();

  +            BookType book = new BookType();
  +            book.setSubject("all");
               bookQuery.setBookQuery(book);
               expression.setAny(bookQuery); 
               ExtensibilityType any = binding.query(expression);
  -            QueryResult result = (QueryResult) any.getAny();
  -            System.out.println("ExtensibilityQueryTestCase: Result name: " + result.getName()
+ " value: " + result.getValue() +
  -                               " date: " + result.getTime().getTime() + " type: " + result.getQueryType());
  -            assertTrue(result.getName().equals("Computer Science"));
  -            assertTrue(result.getValue().equals("The Grid"));
  -            assertTrue(result.getTime().before(Calendar.getInstance()));
  -            assertTrue(result.getQueryType().getNamespaceURI().equals("urn:QueryType"));
  -            assertTrue(result.getQueryType().getLocalPart().equals("BookQuery"));
  +            ResultListType result = (ResultListType) any.getAny();
  +            QueryResultType[] queryResult = result.getResult();
  +            assertTrue(queryResult.length == 2); 
  +            isValid(queryResult[0], "Computer Science", "The Grid"); 
  +            isValid(queryResult[1], "English", "The Oxford Dictionary"); 
           }
           catch (java.rmi.RemoteException re) {
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
           }
       }
   
  +    private void isValid(QueryResultType result, String name, String value) {
  +        System.out.println("ExtensibilityQueryTestCase: Result name: [" + result.getName()
+ "] value: [" + 
  +                           result.getValue() + "] date: [" + result.getTime().getTime()
+ "] type: [" + 
  +                           result.getQueryType() + "]");
  +                               
  +        assertTrue(result.getName().equals(name));
  +        assertTrue(result.getValue().equals(value));
  +        assertTrue(result.getTime().before(Calendar.getInstance()));
  +        assertTrue(result.getQueryType().getNamespaceURI().equals("urn:QueryType"));
  +        assertTrue(result.getQueryType().getLocalPart().equals("BookQuery"));
  +    }
  +
       private void addDynamicTypeMappings(AxisEngine engine) throws Exception {
           TypeMappingRegistry registry = engine.getTypeMappingRegistry(); 
           TypeMapping mapping = registry.createTypeMapping();
  -        QName queryQname = new QName("urn:QueryTypes", "FindBooksQueryExpressionType");
  -        mapping.register(FindBooksQueryExpressionType.class,
  -                         queryQname,
  -                         new BeanSerializerFactory(FindBooksQueryExpressionType.class,
queryQname),
  -                         new BeanDeserializerFactory(FindBooksQueryExpressionType.class,
queryQname));
  -        QName bookQname = new QName("urn:QueryTypes", "BookQuery");
  -        mapping.register(BookQuery.class,
  -                         bookQname,
  -                         new BeanSerializerFactory(BookQuery.class, bookQname),
  -                         new BeanDeserializerFactory(BookQuery.class, bookQname));
  -        QName resultQname = new QName("urn:QueryTypes", "queryResult");
  -        mapping.register(QueryResult.class,
  -                         resultQname,
  -                         new BeanSerializerFactory(QueryResult.class, resultQname),
  -                         new BeanDeserializerFactory(QueryResult.class, resultQname));
  +        addBeanMapping(mapping, "FindBooksQueryExpressionElement", FindBooksQueryExpressionElement.class);
  +        addBeanMapping(mapping, "BookType", BookType.class);
  +        addBeanMapping(mapping, "resultList", ResultListType.class);
  +        addBeanMapping(mapping, "result", QueryResultType.class);
           registry.register("",mapping);
           EngineConfiguration config = engine.getConfig();
           config.writeEngineConfig(engine);
  +    }
  +
  +    private void addBeanMapping(TypeMapping mapping, String localName, Class javaClass)
{
  +        QName qname = new QName("urn:QueryTypes", localName);
  +        mapping.register(javaClass,
  +                         qname,
  +                         new BeanSerializerFactory(javaClass, qname),
  +                         new BeanDeserializerFactory(javaClass, qname));
       }
   
       private void deployServer() {
  
  
  
  1.2       +21 -15    xml-axis/java/test/wsdl/extensibility/QueryTypes.wsdl
  
  Index: QueryTypes.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/QueryTypes.wsdl,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- QueryTypes.wsdl	7 May 2002 16:08:51 -0000	1.1
  +++ QueryTypes.wsdl	8 May 2002 13:04:46 -0000	1.2
  @@ -7,32 +7,38 @@
       <xsd:schema attributeFormDefault="qualified"
       elementFormDefault="qualified" targetNamespace="urn:QueryTypes">
   
  -      <xsd:element name="FindBooksQueryExpressionType">
  +      <xsd:element name="FindBooksQueryExpressionElement">
           <xsd:complexType>
             <xsd:sequence>
  -            <xsd:element name="bookQuery">
  -              <xsd:complexType>
  -                <xsd:attribute name="subject" type="xsd:string"/>
  -              </xsd:complexType>
  -            </xsd:element>
  +            <xsd:element name="bookQuery" type="tns:BookType"/>
             </xsd:sequence>
           </xsd:complexType>
         </xsd:element>
   
  -      <xsd:element name="QueryResultType">
  +      <xsd:element name="QueryResultElement">
           <xsd:complexType>
               <xsd:sequence>
  -              <xsd:element name="queryResult">
  -                <xsd:complexType>
  -                  <xsd:attribute name="name" type="xsd:string"/>
  -                  <xsd:attribute name="value" type="xsd:string"/>
  -                  <xsd:attribute name="time" type="xsd:dateTime"/>
  -                  <xsd:attribute name="queryType" type="xsd:QName"/>
  -                </xsd:complexType>
  -              </xsd:element>
  +               <xsd:element name="resultList" type="tns:ResultListType"/>
               </xsd:sequence>
           </xsd:complexType>
         </xsd:element>
  +
  +      <xsd:complexType name="ResultListType">
  +        <xsd:sequence>
  +          <xsd:element name="result" minOccurs="0" maxOccurs="unbounded" type="tns:QueryResultType"/>
  +        </xsd:sequence>
  +      </xsd:complexType>
  +
  +      <xsd:complexType name="BookType">
  +        <xsd:attribute name="subject" type="xsd:string"/>
  +      </xsd:complexType>
  +
  +      <xsd:complexType name="QueryResultType">
  +        <xsd:attribute name="name" type="xsd:string"/>
  +        <xsd:attribute name="value" type="xsd:string"/>
  +        <xsd:attribute name="time" type="xsd:dateTime"/>
  +        <xsd:attribute name="queryType" type="xsd:QName"/>
  +      </xsd:complexType>
   
       </xsd:schema>
     </types>
  
  
  
  1.2       +11 -3     xml-axis/java/test/wsdl/extensibility/server-deploy.wsdd
  
  Index: server-deploy.wsdd
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/extensibility/server-deploy.wsdd,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- server-deploy.wsdd	7 May 2002 16:08:51 -0000	1.1
  +++ server-deploy.wsdd	8 May 2002 13:04:46 -0000	1.2
  @@ -36,7 +36,15 @@
   
         <typeMapping
           qname="query:bookQuery"
  -        type="java:test.wsdl.extensibility.BookQuery"
  +        type="java:test.wsdl.extensibility.BookType"
  +        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
  +        deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
  +        encodingStyle=""
  +      />
  +
  +      <typeMapping
  +        qname="query:QueryResultElement"
  +        type="java:test.wsdl.extensibility.QueryResultElement"
           serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
           deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
           encodingStyle=""
  @@ -51,8 +59,8 @@
         />
   
         <typeMapping
  -        qname="query:QueryResult"
  -        type="java:test.wsdl.extensibility.QueryResult"
  +        qname="query:ResultListType"
  +        type="java:test.wsdl.extensibility.ResultListType"
           serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
           deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
           encodingStyle=""
  
  
  

Mime
View raw message