cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r601164 - in /incubator/cxf/trunk/rt/javascript/src: main/java/org/apache/cxf/javascript/service/ test/java/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/fortest/ test/resources/org/apache/cxf/javascript/
Date Wed, 05 Dec 2007 00:06:29 GMT
Author: bimargulies
Date: Tue Dec  4 16:06:27 2007
New Revision: 601164

URL: http://svn.apache.org/viewvc?rev=601164&view=rev
Log:
Implement Oneway for Javascript, add test for action dispatch.

Modified:
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBare.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=601164&r1=601163&r2=601164&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
Tue Dec  4 16:06:27 2007
@@ -227,9 +227,11 @@
         buildParameterList(parameterList);
 
         MessageInfo outputMessage = op.getOutput();
-        buildSuccessFunction(outputMessage);
 
-        buildErrorFunction(); // fault part some day.
+        if (!op.isOneWay()) {
+            buildSuccessFunction(outputMessage);
+            buildErrorFunction(); // fault part some day.
+        }
 
         buildOperationFunction(parameterList);
 
@@ -255,10 +257,16 @@
     }
 
     private void buildOperationFunction(StringBuilder parameterList) {
+        String responseCallbackParams = "";
+        if (!currentOperation.isOneWay()) {
+            responseCallbackParams = "successCallback, errorCallback";
+        }
+            
         code.append("function " 
                     +  opFunctionGlobalName
-                    + "(successCallback, errorCallback"
-                    + ((parameterList.length() > 0) ? ", " + parameterList : "") + ")
{\n");
+                    + "("  + responseCallbackParams
+                    + ((parameterList.length() > 0 && !currentOperation.isOneWay())

+                        ? ", " + parameterList : "") + ") {\n");
         utils.appendLine("var xml = null;");
         MessageInfo inputMessage = currentOperation.getInput();
         if (inputMessage != null) {
@@ -278,16 +286,17 @@
         utils.appendLine("this.client = new CxfApacheOrgClient(this.jsutils);");
         // we need to pass the caller's callback functions to our callback
         // functions.
-        utils.appendLine("this._onsuccess = successCallback;");
-        utils.appendLine("this._onerror = errorCallback;");
-        utils.appendLine("var closureThis = this;");
-        utils.appendLine("this.client.onsuccess = function(that) { closureThis." 
-                         + opFunctionPropertyName
-                         + "_onsuccess(that); };");
-        utils.appendLine("this.client.onerror = function(that) { closureThis."
-                         + opFunctionPropertyName
-                         + "_onerror(that); };");
-
+        if (!currentOperation.isOneWay()) {
+            utils.appendLine("this._onsuccess = successCallback;");
+            utils.appendLine("this._onerror = errorCallback;");
+            utils.appendLine("var closureThis = this;");
+            utils.appendLine("this.client.onsuccess = function(that) { closureThis." 
+                             + opFunctionPropertyName
+                             + "_onsuccess(that); };");
+            utils.appendLine("this.client.onerror = function(that) { closureThis."
+                             + opFunctionPropertyName
+                             + "_onerror(that); };");
+        }
         utils.appendLine("var requestHeaders = [];");
 
         if (soapBindingInfo != null) {
@@ -295,9 +304,16 @@
             utils.appendLine("requestHeaders['SOAPAction'] = '" + action + "';");
         }
 
-        // default method by passing null. Is there some place this lives in the
+        // default 'method' by passing null. Is there some place this lives in the
         // service model?
-        utils.appendLine("this.client.request(this.url, xml, null, this.synchronous, requestHeaders);");
+        String syncAsyncFlag;
+        if (currentOperation.isOneWay()) {
+            syncAsyncFlag = "false";
+        } else {
+            syncAsyncFlag = "this.synchronous";
+        }
+        utils.appendLine("this.client.request(this.url, xml, null, "
+                         + syncAsyncFlag + ", requestHeaders);");
 
         code.append("}\n\n");
         code.append(currentInterfaceClassName + ".prototype." 
@@ -384,8 +400,6 @@
     private String outputDeserializerFunctionName(MessageInfo message) {
         return getFunctionGlobalName(message.getName(), "deserializeResponse");
     }
-    
-
 
     // This ignores 'wrapped', because it assumes one part that we can use one way or 
     // the other. For simple cases, this is certainly OK.

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java?rev=601164&r1=601163&r2=601164&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
Tue Dec  4 16:06:27 2007
@@ -27,6 +27,7 @@
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
+import org.apache.cxf.javascript.fortest.SimpleDocLitBareImpl;
 import org.apache.cxf.javascript.fortest.SimpleDocLitWrappedImpl;
 import org.apache.cxf.javascript.fortest.TestBean1;
 import org.apache.cxf.javascript.fortest.TestBean2;
@@ -53,6 +54,7 @@
     private JavascriptTestUtilities testUtilities;
     private JaxWsProxyFactoryBean clientProxyFactory;
     private EndpointImpl endpoint;
+    private SimpleDocLitBareImpl implementor;
 
     public DocLitBareClientTest() throws Exception {
         testUtilities = new JavascriptTestUtilities(getClass());
@@ -73,6 +75,8 @@
         testUtilities.loadJavascriptForService(serviceInfo);
         testUtilities.readResourceIntoRhino("/org/apache/cxf/javascript/DocLitBareTests.js");
         endpoint = getBean(EndpointImpl.class, "dlb-service-endpoint");
+        implementor = (SimpleDocLitBareImpl)endpoint.getImplementor();
+        implementor.resetLastValues();
     }
     
     @Override
@@ -154,6 +158,34 @@
         return null;
     }
     
+    private Void actionMethodCaller(Context context) {
+        LOG.info("About to call actionMethod" + endpoint.getAddress());
+        Notifier notifier = 
+            testUtilities.rhinoCallConvert("actionMethodTest", Notifier.class, 
+                                           testUtilities.javaToJS(endpoint.getAddress()),
+                                           "wrong");
+        boolean notified = notifier.waitForJavascript(1000 * 10);
+        assertTrue(notified);
+        Integer errorStatus = testUtilities.rhinoEvaluateConvert("globalErrorStatus", Integer.class);
+        assertNull(errorStatus);
+        String errorText = testUtilities.rhinoEvaluateConvert("globalErrorStatusText", String.class);
+        assertNull(errorText);
+
+        //This method returns a String
+        String response = (String)testUtilities.rhinoEvaluate("globalResponseObject");
+        assertEquals("wrong", response);
+        return null;
+    }
+    
+    private Void onewayCaller(Context context) {
+        LOG.info("About to call actionMethod" + endpoint.getAddress());
+        testUtilities.rhinoCall("actionMethodTest",  
+                                testUtilities.javaToJS(endpoint.getAddress()),
+                                "corrigan");
+        assertEquals("corrigan", implementor.getLastString());
+        return null;
+    }
+    
     private Void compliantNoArgsCaller(Context context) {
         LOG.info("About to call compliantNoArgs " + endpoint.getAddress());
         Notifier notifier = 
@@ -173,7 +205,9 @@
         assertEquals("horsefeathers", item);
         return null;
     }
-    @org.junit.Ignore
+    
+    @org.junit.Ignore // This runs into a param name conflict since the JAXWS names
+    // are overriden by the XmlRootElement names.
     @Test
     public void callFunctionWithBeans() {
         LOG.info("about to call beanFunctionTest");
@@ -190,6 +224,26 @@
         testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
             public Void run(Context context) {
                 return compliantCaller(context);
+            }
+        });
+    }
+
+    @Test
+    public void callActionMethod() {
+        LOG.info("about to call actionMethod");
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return actionMethodCaller(context);
+            }
+        });
+    }
+
+    @Test
+    public void callOneway() {
+        LOG.info("about to call oneway");
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return onewayCaller(context);
             }
         });
     }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBare.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBare.java?rev=601164&r1=601163&r2=601164&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBare.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBare.java
Tue Dec  4 16:06:27 2007
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.javascript.fortest;
 
+import javax.jws.Oneway;
 import javax.jws.WebMethod;
 import javax.jws.WebParam;
 import javax.jws.WebService;
@@ -48,6 +49,13 @@
     @WebMethod 
     String compliant(@WebParam(name = "beanParam") TestBean1 green);
     
+    @WebMethod(action = "lightsCamera") 
+    String actionMethod(@WebParam(name = "stringParam") String param);
+    
     @WebMethod
     TestBean2 compliantNoArgs();
+    
+    @Oneway
+    @WebMethod
+    void oneWay(@WebParam(name = "corrigan") String param);
 }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java?rev=601164&r1=601163&r2=601164&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
Tue Dec  4 16:06:27 2007
@@ -35,6 +35,14 @@
     private TestBean1 lastBean1;
     private TestBean1[] lastBean1Array;
     
+    public void resetLastValues() {
+        lastString = null;
+        lastInt = -1;
+        lastDouble = -1;
+        lastBean1 = null;
+        lastBean1Array = null;
+    }
+    
 
     public int basicTypeFunctionReturnInt(String s, double d) {
         lastString = s;
@@ -90,4 +98,12 @@
         return lastBean1Array;
     }
 
+    public String actionMethod(String param) {
+        lastString = param;
+        return param;
+    }
+
+    public void oneWay(String param) {
+        lastString = param;
+    }
 }

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js?rev=601164&r1=601163&r2=601164&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/DocLitBareTests.js
Tue Dec  4 16:06:27 2007
@@ -100,4 +100,31 @@
 	return globalNotifier;
 }
 
-    
\ No newline at end of file
+function actionMethodTest(url, param)
+{
+	org_apache_cxf_trace.trace("Enter actionMethodTest.");
+	resetGlobals();
+	globalNotifier = new org_apache_cxf_notifier();
+	
+	var intf;
+    intf = new org_apache_cxf_javascript_fortest_SimpleDocLitBare();
+	  
+	intf.url = url;
+
+    intf.actionMethod(test1SuccessCallback, test1ErrorCallback, param); 
+    // Return the notifier as a convenience to the Java code.
+	return globalNotifier;
+}
+
+function onewayTest(url, param)
+{
+	org_apache_cxf_trace.trace("Enter onewayTest.");
+	resetGlobals();
+	globalNotifier = null; // no notifications.
+	var intf;
+    intf = new org_apache_cxf_javascript_fortest_SimpleDocLitBare();
+	  
+	intf.url = url;
+
+    intf.oneWay(param); 
+}



Mime
View raw message