cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r678820 - in /cxf/trunk/rt/javascript/src: main/java/org/apache/cxf/javascript/service/ main/resources/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/fortest/ test/resources/org/apache/cx...
Date Tue, 22 Jul 2008 17:30:47 GMT
Author: bimargulies
Date: Tue Jul 22 10:30:46 2008
New Revision: 678820

URL: http://svn.apache.org/viewvc?rev=678820&view=rev
Log:
Fix Javascript tests to actually run asynchronously. Now I can actually work on the problem
with
multiple requests.

Modified:
    cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
    cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
    cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
    cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js

Modified: cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
(original)
+++ cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/service/ServiceJavascriptBuilder.java
Tue Jul 22 10:30:46 2008
@@ -397,8 +397,10 @@
         // service model?
         String syncAsyncFlag;
         if (currentOperation.isOneWay()) {
+            utils.appendLine("this.jsutils.trace('oneway operation');");
             syncAsyncFlag = "false";
         } else {
+            utils.appendLine("this.jsutils.trace('synchronous = ' + this.synchronous);");
             syncAsyncFlag = "this.synchronous";
         }
         utils.appendLine("this.client.request(this.url, xml, null, "

Modified: cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js (original)
+++ cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js Tue
Jul 22 10:30:46 2008
@@ -29,6 +29,7 @@
 	// Set up tracing if there is a trace object.
 	if ("function" == typeof(org_apache_cxf_trace)) {
 		this.trace = org_apache_cxf_trace.trace;
+		this.trace("Javascript tracing enabled.");
 	} else {
 		this.trace = cxf_apache_org_util_null_trace;
 	}

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java (original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AegisTest.java Tue Jul
22 10:30:46 2008
@@ -67,8 +67,10 @@
     
     private Void acceptAny(Context context) {
         LOG.info("About to call acceptAny with Raw XML" + getAddress());
+        implementor.prepareToWaitForOneWay();
         testUtilities.rhinoCall("testAnyNToServerRaw",  
                                 testUtilities.javaToJS(getAddress()));
+        implementor.waitForOneWay();
         assertEquals("before items", implementor.getAcceptedString());
         Collection<org.jdom.Element> something = implementor.getAcceptedCollection();
         assertNotNull(something);
@@ -86,8 +88,10 @@
     
     private Void acceptAnyTyped(Context context) {
         LOG.info("About to call acceptAny with Raw XML and xsi:type" + getAddress());
+        implementor.prepareToWaitForOneWay();
         testUtilities.rhinoCall("testAnyNToServerRawTyped",  
                                 testUtilities.javaToJS(getAddress()));
+        implementor.waitForOneWay();
         Collection<Object> something = implementor.getAcceptedObjects();
         assertNotNull(something);
         return null;

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java (original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java Tue Jul 22
10:30:46 2008
@@ -68,8 +68,10 @@
     
     private Void acceptOneChalk(Context context) {
         LOG.info("About to call accept1 with Chalk" + getAddress());
+        implementor.prepareToWaitForOneWay();
         testUtilities.rhinoCall("testAny1ToServerChalk",  
                                 testUtilities.javaToJS(getAddress()));
+        implementor.waitForOneWay();
         assertEquals("before chalk", implementor.getBefore());
         Object someAlternative = implementor.getAny1value();
         assertTrue(someAlternative instanceof Alternative1);
@@ -90,8 +92,10 @@
     
     private Void acceptOneRaw(Context context) {
         LOG.info("About to call accept1 with Raw XML" + getAddress());
+        implementor.prepareToWaitForOneWay();
         testUtilities.rhinoCall("testAny1ToServerRaw",  
                                 testUtilities.javaToJS(getAddress()));
+        implementor.waitForOneWay();
         assertEquals("before chalk", implementor.getBefore());
         Object something = implementor.getAny1value();
         assertNotNull(something);
@@ -114,8 +118,10 @@
     
     private Void acceptNRaw(Context context) {
         LOG.info("About to call acceptN with Raw XML" + getAddress());
+        implementor.prepareToWaitForOneWay();
         testUtilities.rhinoCall("testAnyNToServerRaw",  
                                 testUtilities.javaToJS(getAddress()));
+        implementor.waitForOneWay();
         assertEquals("before chalk", implementor.getBefore());
         Object[] something = implementor.getAnyNvalue();
         assertNotNull(something);

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/DocLitBareClientTest.java
Tue Jul 22 10:30:46 2008
@@ -162,9 +162,11 @@
     
     private Void onewayCaller(Context context) {
         LOG.info("About to call onewayMethod" + getAddress());
-        testUtilities.rhinoCall("actionMethodTest",  
+        implementor.prepareToWaitForOneWay();
+        testUtilities.rhinoCall("onewayTest",  
                                 testUtilities.javaToJS(getAddress()),
                                 "corrigan");
+        implementor.waitForOneWay();
         assertEquals("corrigan", implementor.getLastString());
         return null;
     }

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/GreeterClientTest.java
Tue Jul 22 10:30:46 2008
@@ -79,6 +79,35 @@
             }
         });
     }
+    
+    private Void sayHiClosureCaller(Context context) {
+        Notifier notifier = 
+            testUtilities.rhinoCallConvert("requestClosureTest", Notifier.class, 
+                                           testUtilities.javaToJS(getAddress()));
+        
+        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 inside of an object, since there's an @WebResponse
+        String responseObject = testUtilities.rhinoEvaluateConvert("globalResponseObject.getResponseType()",

+                                                                   String.class);
+        assertEquals("Bonjour", responseObject);
+        return null;
+    }
+    
+    @org.junit.Ignore
+    @Test
+    public void testRequestClosure() throws Exception {
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return sayHiClosureCaller(context);
+            }
+        });
+    }
 
     public String getStaticResourceURL() throws Exception {
         File staticFile = new File(this.getClass().getResource("test.html").toURI());

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
Tue Jul 22 10:30:46 2008
@@ -331,7 +331,7 @@
                         Context.exit();
                     }
                 }
-            } .run();
+            } .start();
         } else {
             communicate(Context.getCurrentContext());
         }

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AegisServiceImpl.java
Tue Jul 22 10:30:46 2008
@@ -20,6 +20,7 @@
 package org.apache.cxf.javascript.fortest;
 
 import java.util.Collection;
+import java.util.concurrent.CountDownLatch;
 
 import org.apache.cxf.javascript.fortest.aegis.BeanWithAnyTypeArray;
 import org.apache.cxf.javascript.fortest.aegis.Mammal;
@@ -33,6 +34,7 @@
     private Collection<org.jdom.Element> acceptedCollection;
     private Collection<String> acceptedStrings;
     private Collection<Object> acceptedObjects;
+    private CountDownLatch oneWayLatch;
     
     public Collection<Object> getAcceptedObjects() {
         return acceptedObjects;
@@ -47,6 +49,9 @@
     public void acceptAny(String before, Collection<org.jdom.Element> anything) {
         acceptedString = before;
         acceptedCollection = anything;
+        if (oneWayLatch != null) {
+            oneWayLatch.countDown();
+        }
     }
 
     /**
@@ -76,6 +81,9 @@
 
     public void acceptObjects(Collection<Object> anything) {
         acceptedObjects = anything;
+        if (oneWayLatch != null) {
+            oneWayLatch.countDown();
+        }
     }
 
     public BeanWithAnyTypeArray returnBeanWithAnyTypeArray() {
@@ -88,4 +96,20 @@
         bwata.setObjects(obs);
         return bwata;
     }
+    
+    public void prepareToWaitForOneWay() {
+        oneWayLatch = new CountDownLatch(1);
+    }
+    
+    public void waitForOneWay() {
+        if (oneWayLatch != null) {
+            try {
+                oneWayLatch.await();
+            } catch (InterruptedException e) {
+                // 
+            }
+            oneWayLatch = null;
+        }
+    }
+
 }

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java (original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java Tue
Jul 22 10:30:46 2008
@@ -20,6 +20,7 @@
 package org.apache.cxf.javascript.fortest;
 
 import java.util.Arrays;
+import java.util.concurrent.CountDownLatch;
 
 import uri.cxf_apache_org.jstest.any.AcceptAny;
 import uri.cxf_apache_org.jstest.types.any.AcceptAny1;
@@ -42,10 +43,8 @@
     private Object anyOptionalValue;
     private String before;
     private String after;
-    /**
-     *
-     */
     private boolean returnOptional;
+    private CountDownLatch onewayNotify;
     
     public void reset() {
         any1value = null;
@@ -117,18 +116,21 @@
         before = in.getBefore();
         after = in.getAfter();
         any1value = in.getAny();
+        onewayNotify.countDown();
     }
 
     public void acceptAnyN(AcceptAnyN in) {
         before = in.getBefore();
         after = in.getAfter();
         anyNvalue = in.getAny().toArray();
+        onewayNotify.countDown();
     }
 
     public void acceptAnyOptional(AcceptAnyOptional in) {
         before = in.getBefore();
         after = in.getAfter();
         anyOptionalValue = in.getAny();
+        onewayNotify.countDown();
     }
 
     public AcceptAny1 returnAny1(ReturnAny1 in) {
@@ -177,5 +179,21 @@
     public void dummyAlts(uri.cxf_apache_org.jstest.types.any.alts.Alternative1 in) {
         // not used, just here to force some types into sight.
     }
+
+    public void prepareToWaitForOneWay() { 
+        onewayNotify = new CountDownLatch(1);
+    }
+    
+    public void waitForOneWay() {
+        if (onewayNotify == null) {
+            return;
+        }
+        try {
+            onewayNotify.await();
+            onewayNotify = null;
+        } catch (InterruptedException e) {
+            //
+        }
+    }
 }
 

Modified: cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
(original)
+++ cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitBareImpl.java
Tue Jul 22 10:30:46 2008
@@ -19,6 +19,8 @@
 
 package org.apache.cxf.javascript.fortest;
 
+import java.util.concurrent.CountDownLatch;
+
 import javax.jws.WebService;
 
 /**
@@ -34,6 +36,7 @@
     private double lastDouble;
     private TestBean1 lastBean1;
     private TestBean1[] lastBean1Array;
+    private CountDownLatch oneWayLatch;
     
     public void resetLastValues() {
         lastString = null;
@@ -100,10 +103,31 @@
 
     public String actionMethod(String param) {
         lastString = param;
+        if (oneWayLatch != null) {
+            oneWayLatch.countDown();
+        }
         return param;
     }
 
     public void oneWay(String param) {
         lastString = param;
+        if (oneWayLatch != null) {
+            oneWayLatch.countDown();
+        }
+    }
+    
+    public void prepareToWaitForOneWay() {
+        oneWayLatch = new CountDownLatch(1);
+    }
+    
+    public void waitForOneWay() {
+        if (oneWayLatch != null) {
+            try {
+                oneWayLatch.await();
+            } catch (InterruptedException e) {
+                // 
+            }
+            oneWayLatch = null;
+        }
     }
 }

Modified: cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js?rev=678820&r1=678819&r2=678820&view=diff
==============================================================================
--- cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js (original)
+++ cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/GreeterTests.js Tue
Jul 22 10:30:46 2008
@@ -52,6 +52,12 @@
 	globalNotifier.notify();
 }
 
+function dummy()
+{
+	// for now, dummy. later, we'll want to verify correct operation
+	// of both requests.
+}
+
 function sayHiTest(url)
 {
 	org_apache_cxf_trace.trace("Enter sayHi.");
@@ -67,3 +73,21 @@
 	return globalNotifier;
 }
 
+function requestClosureTest(url)
+{
+	org_apache_cxf_trace.trace("Enter sayHi.");
+	resetGlobals();
+	globalNotifier = new org_apache_cxf_notifier();
+	
+	var intf;
+    intf = new cxf_apache_org_jstest_Greeter();
+	  
+	intf.url = url;
+    intf.sayHi(testSuccessCallback, testErrorCallback);
+    intf.sayHi(null, null);
+    // Return the notifier as a convenience to the Java code.
+	return globalNotifier;
+
+	
+}
+



Mime
View raw message