cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r527395 - in /incubator/cxf/trunk: rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/javato/ tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/ tools/javato/src/test/java/org/apache/cxf/...
Date Wed, 11 Apr 2007 06:07:28 GMT
Author: jliu
Date: Tue Apr 10 23:07:26 2007
New Revision: 527395

URL: http://svn.apache.org/viewvc?view=rev&rev=527395
Log:
* CXF-511: Add a populateFromClass flag on service model,  we need to set this flag to true
explictly when we do javatowsdl.
* Porting test from WSDLToServiceProcessorTest to JaxwsServiceBuilderTest, prepare for using
runtime service model in tooling. 

Added:
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl
  (with props)
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl
  (with props)
Modified:
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/tools/javato/pom.xml
    incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilder.java
    incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?view=diff&rev=527395&r1=527394&r2=527395
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Tue Apr 10 23:07:26 2007
@@ -107,6 +107,7 @@
     private Boolean wrappedStyle;
     private Map<String, Object> properties;
     private QName endpointName;
+    private boolean populateFromClass;
     
     public ReflectionServiceFactoryBean() {
         getServiceConfigurations().add(0, new DefaultServiceConfiguration());
@@ -221,13 +222,21 @@
     protected void initializeServiceModel() {
         String wsdlurl = getWsdlURL();
 
-        if (wsdlurl != null) {
+        if (!populateFromClass && wsdlurl != null) {
             buildServiceFromWSDL(wsdlurl);
         } else {
             buildServiceFromClass();
         }
     }
+    
+    public boolean isPopulateFromClass() {
+        return populateFromClass;
+    }
 
+    public void setPopulateFromClass(boolean fomClass) {
+        this.populateFromClass = fomClass;
+    }
+    
     protected void initializeWSDLOperations() {
         Method[] methods = serviceClass.getMethods();
         Arrays.sort(methods, new MethodComparator());

Modified: incubator/cxf/trunk/tools/javato/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/pom.xml?view=diff&rev=527395&r1=527394&r2=527395
==============================================================================
--- incubator/cxf/trunk/tools/javato/pom.xml (original)
+++ incubator/cxf/trunk/tools/javato/pom.xml Tue Apr 10 23:07:26 2007
@@ -125,4 +125,30 @@
         <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/cxf/trunk/tools/javato</developerConnection>
     </scm>
 
+    <build>
+        <plugins>
+	    <plugin>
+		<groupId>org.apache.cxf</groupId>
+		<artifactId>cxf-codegen-plugin</artifactId>
+		<version>${project.version}</version>
+		<executions>
+		    <execution>
+			<id>generate-sources</id>
+			<phase>generate-sources</phase>
+			<configuration>
+			    <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
+			    <wsdlOptions>
+				<wsdlOption>
+				    <wsdl>${basedir}/src/test/resources/java2wsdl_wsdl/hello_world_async.wsdl</wsdl>
+				</wsdlOption>
+			    </wsdlOptions>
+			</configuration>
+			<goals>
+			    <goal>wsdl2java</goal>
+			</goals>
+		    </execution>
+		</executions>
+	    </plugin>
+       </plugins>
+    </build>
 </project>

Modified: incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilder.java?view=diff&rev=527395&r1=527394&r2=527395
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilder.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilder.java
Tue Apr 10 23:07:26 2007
@@ -31,7 +31,11 @@
     
     public JaxwsServiceBuilder() {
         super();
-        setServiceFactory(new JaxWsServiceFactoryBean());
+        JaxWsServiceFactoryBean serviceFactory = new JaxWsServiceFactoryBean();
+        //As this is a javatowsdl tool, explictly populate service model from class
+        serviceFactory.setPopulateFromClass(true);
+        
+        setServiceFactory(serviceFactory);
     }
 
     public File getOutputFile() {

Modified: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java?view=diff&rev=527395&r1=527394&r2=527395
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/JaxwsServiceBuilderTest.java
Tue Apr 10 23:07:26 2007
@@ -19,7 +19,12 @@
 
 package org.apache.cxf.tools.java2wsdl.processor.internal.jaxws;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.StringTokenizer;
 
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.service.model.ServiceInfo;
@@ -51,11 +56,6 @@
     }
 
     public void testBare() {
-        // REVISIT: Wrong part name
-        //    <wsdl:message name="getPrice">
-        //        <wsdl:part name="arg00" type="xsd:string">
-        //    </wsdl:part>
-
         builder.setServiceClass(Stock.class);
         ServiceInfo service =  builder.build();
         generator.setServiceModel(service);
@@ -63,28 +63,106 @@
         assertNotNull(output);
         generator.generate(output);
         assertTrue(output.exists());
+        
+        String expectedFile = this.getClass().getResource("resources/expected_stock_bare.wsdl").getFile();
+        compareTextFile(expectedFile, output.getAbsolutePath());
     }
 
-    public void testWrapped() {
-        // REVIST: If there is wsdlLocation annotation, but the serviceBuilder can not load
the wsdl,
-        // we should print WARNs not throw exceptions and fail the build.
-        // builder.setServiceClass(org.apache.cxf.tools.fortest.withannotation.doc.Hello.class);
-
-        // REVISIT: Wrong part name
-        //    <wsdl:message name="getPrice">
-        //        <wsdl:part name="arg00" type="xsd:string">
-        //    </wsdl:part>
-
-        builder.setServiceClass(org.apache.cxf.tools.fortest.withannotation.doc.HelloWrapped.class);
+    public void xtestWrapped() {
+        builder.setServiceClass(org.apache.cxf.tools.fortest.withannotation.doc.Hello.class);
         ServiceInfo service =  builder.build();
         generator.setServiceModel(service);
         File output = getOutputFile("hello_wrapped.wsdl");
         assertNotNull(output);
         generator.generate(output);
-        assertTrue(output.exists());
+        assertTrue(output.exists());        
     }
+    
+    //TODO: CXF-519
+    public void xtestAsyn() throws Exception {
+        builder.setServiceClass(org.apache.hello_world_async_soap_http.GreeterAsync.class);
+        ServiceInfo service =  builder.build();
+        generator.setServiceModel(service);
+        File output = getOutputFile("hello_async.wsdl");
+        assertNotNull(output);
+        generator.generate(output);
+        assertTrue(output.exists());   
 
+        String expectedFile = this.getClass().getResource("resources/expected_hello_world_async.wsdl")
+            .getFile();
+        compareTextFile(expectedFile, output.getAbsolutePath());
+    }
+    
     private File getOutputFile(String fileName) {
         return new File(output, fileName);
+    }
+    
+    public static void compareTextFile(String location1, String location2) {
+        String str1 = getStringFromFile(location1);
+        String str2 = getStringFromFile(location2);
+
+        StringTokenizer st1 = new StringTokenizer(str1);
+        StringTokenizer st2 = new StringTokenizer(str2);
+
+        while (st1.hasMoreTokens() && st2.hasMoreTokens()) {
+            String tok1 = st1.nextToken();
+            String tok2 = st2.nextToken();
+
+            assertEquals("Compare failed", tok1, tok2);
+        }
+
+        assertTrue(!st1.hasMoreTokens());
+    }
+
+    private static String getStringFromFile(String location) {
+        InputStream is = null;
+        String result = null;
+
+        try {
+            is = new FileInputStream(new File(location));
+            result = normalizeCRLF(is);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (Exception e) {
+                    //do nothing
+                }
+            }
+        }
+
+        return result;
+    }
+    
+    private static String normalizeCRLF(InputStream instream) {
+        BufferedReader in = new BufferedReader(new InputStreamReader(instream));
+        StringBuffer result = new StringBuffer();
+        String line = null;
+        boolean commentChecked = false;
+        String comment = "<!-- Generated by <javatowsdl>";
+
+        try {
+            while ((line = in.readLine()) != null) {
+                if (!commentChecked) {
+                    if (line.startsWith(comment)) {
+                        commentChecked = true;
+                        continue;
+                    }
+                }
+
+                StringTokenizer tok = new StringTokenizer(line);
+
+                while (tok.hasMoreTokens()) {
+                    String token = tok.nextToken();
+                    result.append("  " + token);
+                }
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+        return result.toString();
     }
 }

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl?view=auto&rev=527395
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl
(added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl
Tue Apr 10 23:07:26 2007
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions 
+    xmlns="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:http-conf="http://schemas.iona.com/transports/http/configuration" 
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
+    xmlns:tns="http://apache.org/hello_world_async_soap_http" 
+    xmlns:x1="http://apache.org/hello_world_async_soap_http/types" 
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
+    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
+    targetNamespace="http://apache.org/hello_world_async_soap_http" 
+    name="HelloWorld">
+    <jaxws:bindings>
+	<enableAsyncMapping>true</enableAsyncMapping>
+    </jaxws:bindings>
+    <wsdl:types>
+	<schema 
+	    targetNamespace="http://apache.org/hello_world_async_soap_http/types" 
+	    xmlns="http://www.w3.org/2001/XMLSchema" 
+	    xmlns:x1="http://apache.org/hello_world_async_soap_http/types" 
+	    elementFormDefault="qualified">
+	    <element name="greetMeSometime">
+		<complexType>
+		    <sequence>
+			<element name="requestType" type="xsd:string"/>
+		    </sequence>
+		</complexType>
+	    </element>
+	    <element name="greetMeSometimeResponse">
+		<complexType>
+		    <sequence>
+			<element name="responseType" type="xsd:string"/>
+		    </sequence>
+		</complexType>
+	    </element>		
+	</schema>
+    </wsdl:types>
+    <wsdl:message name="greetMeSometimeRequest">
+	<wsdl:part name="in" element="x1:greetMeSometime"/>
+    </wsdl:message>
+    <wsdl:message name="greetMeSometimeResponse">
+	<wsdl:part name="out" element="x1:greetMeSometimeResponse"/>
+    </wsdl:message>
+    <wsdl:portType name="GreeterAsync">
+	<wsdl:operation name="greetMeSometime">
+	    <wsdl:input name="greetMeSometimeRequest" message="tns:greetMeSometimeRequest"/>
+	    <wsdl:output name="greetMeSometimeResponse" message="tns:greetMeSometimeResponse"/>
+	</wsdl:operation>
+    </wsdl:portType>
+    <wsdl:binding name="GreeterAsync_SOAPBinding" type="tns:GreeterAsync">
+	<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+	<wsdl:operation name="greetMeSometime">
+	    <soap:operation style="document"/>
+	    <wsdl:input>
+		<soap:body use="literal"/>
+	    </wsdl:input>
+	    <wsdl:output>
+		<soap:body use="literal"/>
+	    </wsdl:output>
+	</wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="SOAPService">
+	<wsdl:port name="SoapPort" binding="tns:GreeterAsync_SOAPBinding">
+	    <soap:address location="http://localhost:9000/SoapContext/SoapPort"/>
+	    <http-conf:client/>
+	    <http-conf:server/>
+	</wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_hello_world_async.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl?view=auto&rev=527395
==============================================================================
--- incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl
(added)
+++ incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl
Tue Apr 10 23:07:26 2007
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<wsdl:definitions name="StockService" targetNamespace="http://docbare.classnoanno.fortest.tools.cxf.apache.org/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://docbare.classnoanno.fortest.tools.cxf.apache.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+  <wsdl:message name="getPriceResponse">
+    <wsdl:part name="return" type="xsd:float">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="getPrice">
+    <wsdl:part name="arg0" type="xsd:string">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="Stock">
+    <wsdl:operation name="getPrice">
+      <wsdl:input name="getPrice" message="ns1:getPrice">
+    </wsdl:input>
+      <wsdl:output name="getPriceResponse" message="ns1:getPriceResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="StockServiceSoapBinding" type="ns1:Stock">
+    <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="getPrice">
+      <wsdlsoap:operation soapAction="" style="document"/>
+      <wsdl:input name="getPrice">
+        <wsdlsoap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="getPriceResponse">
+        <wsdlsoap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="StockService">
+    <wsdl:port name="StockPort" binding="ns1:StockServiceSoapBinding">
+      <wsdlsoap:address/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Propchange: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/tools/javato/src/test/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/resources/expected_stock_bare.wsdl
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message