cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r594415 - in /incubator/cxf/trunk: common/common/src/main/java/org/apache/cxf/helpers/ tools/common/src/main/java/org/apache/cxf/tools/common/ tools/javato/ws/ tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/...
Date Tue, 13 Nov 2007 03:45:31 GMT
Author: ema
Date: Mon Nov 12 19:45:30 2007
New Revision: 594415

URL: http://svn.apache.org/viewvc?rev=594415&view=rev
Log:
[CXF-1205] Add service name annotation for generated impl class

Modified:
    incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
    incubator/cxf/trunk/tools/javato/ws/pom.xml
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
    incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
    incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java

Modified: incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
(original)
+++ incubator/cxf/trunk/common/common/src/main/java/org/apache/cxf/helpers/FileUtils.java
Mon Nov 12 19:45:30 2007
@@ -19,8 +19,12 @@
 
 package org.apache.cxf.helpers;
 
+import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.util.Locale;
 
 public final class FileUtils {
@@ -166,4 +170,66 @@
         }
         return result;
     }
+    
+    public static String getStringFromFile(File location) {
+        InputStream is = null;
+        String result = null;
+
+        try {
+            is = new FileInputStream(location);
+            result = normalizeCRLF(is);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (Exception e) {
+                    //do nothing
+                }
+            }
+        }
+
+        return result;
+    }
+
+    public static String normalizeCRLF(InputStream instream) {
+        BufferedReader in = new BufferedReader(new InputStreamReader(instream));
+        StringBuffer result = new StringBuffer();
+        String line = null;
+
+        try {
+            line = in.readLine();
+            while (line != null) {
+                String[] tok = line.split("\\s");
+
+                for (int x = 0; x < tok.length; x++) {
+                    String token = tok[x];
+                    result.append("  " + token);
+                }
+                line = in.readLine();
+            }
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+        String rtn = result.toString();
+
+        rtn = ignoreTokens(rtn, "<!--", "-->");
+        rtn = ignoreTokens(rtn, "/*", "*/");
+        return rtn;
+    }
+    
+    private static String ignoreTokens(final String contents, 
+                                       final String startToken, final String endToken) {
+        String rtn = contents;
+        int headerIndexStart = rtn.indexOf(startToken);
+        int headerIndexEnd = rtn.indexOf(endToken);
+        if (headerIndexStart != -1 && headerIndexEnd != -1 && headerIndexStart
< headerIndexEnd) {
+            rtn = rtn.substring(0, headerIndexStart - 1)
+                + rtn.substring(headerIndexEnd + endToken.length() + 1);
+        }
+        return rtn;
+    }
+    
 }

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
Mon Nov 12 19:45:30 2007
@@ -19,11 +19,10 @@
 
 package org.apache.cxf.tools.common;
 
-import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
-import java.io.InputStreamReader;
+
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.net.URLClassLoader;
@@ -100,8 +99,8 @@
     }
 
     protected void assertFileEquals(File location1, File location2) {
-        String str1 = getStringFromFile(location1);
-        String str2 = getStringFromFile(location2);
+        String str1 = FileUtils.getStringFromFile(location1);
+        String str2 = FileUtils.getStringFromFile(location2);
 
         StringTokenizer st1 = new StringTokenizer(str1, " \t\n\r\f(),");
         StringTokenizer st2 = new StringTokenizer(str2, " \t\n\r\f(),");
@@ -143,7 +142,7 @@
 
         try {
             is = new FileInputStream(location);
-            result = normalizeCRLF(is);
+            result = FileUtils.normalizeCRLF(is);
         } catch (Exception e) {
             e.printStackTrace();
         } finally {
@@ -157,44 +156,6 @@
         }
 
         return result;
-    }
-
-    private String normalizeCRLF(InputStream instream) {
-        BufferedReader in = new BufferedReader(new InputStreamReader(instream));
-        StringBuffer result = new StringBuffer();
-        String line = null;
-
-        try {
-            line = in.readLine();
-            while (line != null) {
-                String[] tok = line.split("\\s");
-
-                for (int x = 0; x < tok.length; x++) {
-                    String token = tok[x];
-                    result.append("  " + token);
-                }
-                line = in.readLine();
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        }
-
-        String rtn = result.toString();
-
-        rtn = ignoreTokens(rtn, "<!--", "-->");
-        rtn = ignoreTokens(rtn, "/*", "*/");
-        return rtn;
-    }
-
-    private String ignoreTokens(final String contents, final String startToken, final String
endToken) {
-        String rtn = contents;
-        int headerIndexStart = rtn.indexOf(startToken);
-        int headerIndexEnd = rtn.indexOf(endToken);
-        if (headerIndexStart != -1 && headerIndexEnd != -1 && headerIndexStart
< headerIndexEnd) {
-            rtn = rtn.substring(0, headerIndexStart - 1)
-                + rtn.substring(headerIndexEnd + endToken.length() + 1);
-        }
-        return rtn;
     }
 
     public boolean assertXmlEquals(final File expected, final File source) throws Exception
{

Modified: incubator/cxf/trunk/tools/javato/ws/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/pom.xml?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/pom.xml (original)
+++ incubator/cxf/trunk/tools/javato/ws/pom.xml Mon Nov 12 19:45:30 2007
@@ -32,7 +32,7 @@
         <relativePath>../../parent/pom.xml</relativePath>
     </parent>
 
-    <dependencies>
+    <dependencies>    
         <dependency>
             <groupId>org.apache.cxf</groupId>
             <artifactId>cxf-tools-common</artifactId>

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/JaxwsImplGenerator.java
Mon Nov 12 19:45:30 2007
@@ -20,6 +20,8 @@
 
 import java.util.Map;
 
+import javax.xml.namespace.QName;
+
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolContext;
 import org.apache.cxf.tools.common.ToolException;
@@ -40,9 +42,7 @@
             && (!env.optionSet(ToolConstants.IMPL_CLASS))) {
             return false;
         }
-
         return true;
-
     }
 
     public void generate(ToolContext penv) throws ToolException {
@@ -54,10 +54,11 @@
         }
 
         Map<String, JavaInterface> interfaces = javaModel.getInterfaces();
-
+        QName service = (QName)env.get(ToolConstants.SERVICE_NAME);
         for (JavaInterface intf : interfaces.values()) {
             clearAttributes();
             setAttributes("intf", intf);
+            setAttributes("service", service);
             setCommonAttributes();
 
             doWrite(IMPL_TEMPLATE, parseOutputName(intf.getPackageName(), intf.getName()
+ "Impl"));

Modified: incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/main/java/org/apache/cxf/tools/java2wsdl/processor/internal/jaxws/generator/template/javafirst-impl.vm
Mon Nov 12 19:45:30 2007
@@ -29,7 +29,7 @@
  * Generated source version: $version
  * 
  */
-@WebService(endpointInterface = "${intf.FullClassName}")                      
+@WebService(endpointInterface = "${intf.FullClassName}", serviceName="${service.LocalPart}")
                     
 public class ${intf.Name}Impl implements $intf.Name {
 #foreach ($method in $intf.Methods)
   public $method.return.ClassName ${method.Name}(#if($method.ParameterList.size() == 0))#end#if($method.ParameterList.size()
!= 0)#foreach ($param in ${method.ParameterList})$param#end)#end#if($method.Exceptions.size()
> 0) throws#foreach($exception in $method.Exceptions) $exception.ClassName#if($method.Exceptions.size()
!= $velocityCount),#end#end#end {  

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2ws/JavaToWSTest.java
Mon Nov 12 19:45:30 2007
@@ -30,7 +30,6 @@
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class JavaToWSTest extends ToolTestBase {
@@ -159,17 +158,20 @@
     }
 
     @Test
-    @Ignore // CXF-1024
     public void testGenServerAndClient() throws Exception {
         File client = outputFile("org/apache/hello_world_soap12_http/GreeterClient.java");
         File server = outputFile("org/apache/hello_world_soap12_http/GreeterServer.java");
-
+        File impl = outputFile("org/apache/hello_world_soap12_http/GreeterImpl.java");
         String[] args = new String[] {"-s", output.getPath(), "-client", "-server",
                                       "org.apache.hello_world_soap12_http.Greeter"};
         JavaToWS.main(args);
         checkStdErr();
         assertTrue("Client was not generated", client.exists());
         assertTrue("Greeter_GreeterPort_Server.java was not generated", server.exists());
+        assertTrue("Impl was not generated", impl.exists());
+        String implContent = FileUtils.getStringFromFile(impl);
+        assertTrue("serviceName annotation was not generated", 
+                   implContent.indexOf("serviceName=\"GreeterService\"") > -1);      

     }
 
     @Test

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
Mon Nov 12 19:45:30 2007
@@ -29,6 +29,7 @@
 import javax.xml.ws.WebServiceClient;
 
 import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.util.AnnotationUtil;
@@ -216,7 +217,7 @@
         assertFalse("Generated file has been excluded", iona.exists());
 
         File implFile = new File(output, "org/apache/hello_world_soap_http/Greeter.java");
-        String str = getStringFromFile(implFile);
+        String str = FileUtils.getStringFromFile(implFile);
         assertTrue(str.indexOf("com.iona.BareDocumentResponse") > 0);
 
         File org = new File(output, "org");
@@ -511,7 +512,7 @@
         processor.setContext(env);
         processor.execute();
 
-        String results = getStringFromFile(new File(output.getCanonicalPath(), 
+        String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),

                                                     "org/apache/sayhi/SayHi.java"));
         assertTrue(results.trim().length() > 0);
         assertTrue(results.indexOf("@WebResult(name  =  \"return\",  " 
@@ -623,7 +624,7 @@
         
         processor.execute();
         File file = new File(output.getCanonicalPath() + "/build.xml");
-        String str = getStringFromFile(file);
+        String str = FileUtils.getStringFromFile(file);
         assertTrue(str.indexOf("org.apache.hello_world_soap_http.Greeter_SoapPortTest1_Client")
> -1);
         assertTrue(str.indexOf("org.apache.hello_world_soap_http.Greeter_SoapPortTest2_Client")
> -1);
         assertTrue(str.indexOf("org.apache.hello_world_soap_http.Greeter_SoapPortTest1_Server")
> -1);
@@ -688,7 +689,7 @@
             processor.setContext(env);
             processor.execute();
 
-            String results = getStringFromFile(new File(output.getCanonicalPath(), 
+            String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),

                                                         "org/tempuri/GreeterRPCLit.java"));
             assertTrue(results.indexOf("@WebParam(partName  =  \"inInt\",  name  =  \"inInt\")")
!= -1);
         } catch (Exception e) {
@@ -721,7 +722,7 @@
         processor.setContext(env);
         processor.execute();
 
-        String results = getStringFromFile(new File(output.getCanonicalPath(), 
+        String results = FileUtils.getStringFromFile(new File(output.getCanonicalPath(),

                                                     "soapinterface/ems/esendex/com/AccountServiceSoap.java"));
         assertTrue(results.indexOf("public  int  getMessageLimit") != -1);
         assertTrue(results.indexOf("name  =  \"MessengerHeader") != -1);

Modified: incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java?rev=594415&r1=594414&r2=594415&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
(original)
+++ incubator/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenTest.java
Mon Nov 12 19:45:30 2007
@@ -38,6 +38,7 @@
 import javax.xml.ws.ResponseWrapper;
 import javax.xml.ws.WebFault;
 
+import org.apache.cxf.helpers.FileUtils;
 import org.apache.cxf.tools.common.ProcessorTestBase;
 import org.apache.cxf.tools.common.ToolConstants;
 import org.apache.cxf.tools.common.ToolException;
@@ -1117,7 +1118,7 @@
 
         File greeter = new File(output, "org/apache/hello_world_soap_http/Greeter.java");
         assertTrue(output.exists());
-        String contents = getStringFromFile(greeter);
+        String contents = FileUtils.getStringFromFile(greeter);
         assertTrue(contents.indexOf("SOAPBinding.ParameterStyle.BARE") != -1);
         assertTrue(contents.indexOf("@ResponseWrapper") == -1);
     }
@@ -1131,7 +1132,7 @@
 
         File sei = new File(output, "type_substitution/server/CarDealer.java");
         assertTrue(output.exists());
-        String contents = getStringFromFile(sei);
+        String contents = FileUtils.getStringFromFile(sei);
         assertTrue(contents.indexOf("@XmlSeeAlso({ObjectFactory.class})") != -1);
     }
 
@@ -1144,7 +1145,7 @@
 
         File sei = new File(output, "com/example/AddNumbersPortType.java");
         assertTrue(sei.exists());
-        String contents = getStringFromFile(sei).replace("  ", " ");
+        String contents = FileUtils.getStringFromFile(sei).replace("  ", " ");
         String expected = "@Action(input = \"3in\", output = \"3out\", "
             + "fault = {@FaultAction(className = AddNumbersFault_Exception.class, value =
\"3fault\")})";
         assertTrue(contents.indexOf("import javax.xml.ws.Action;") != -1);



Mime
View raw message