cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r606656 - in /incubator/cxf/trunk/rt/javascript/src: main/java/org/apache/cxf/javascript/ main/resources/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/fortest/ test/resources/org/apache/...
Date Mon, 24 Dec 2007 02:13:53 GMT
Author: bimargulies
Date: Sun Dec 23 18:13:49 2007
New Revision: 606656

URL: http://svn.apache.org/viewvc?rev=606656&view=rev
Log:
Add a feature to allow arbitrary XML to be sent from javascript to java for xs:any. 

Modified:
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
    incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java?rev=606656&r1=606655&r2=606656&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/JavascriptUtils.java
Sun Dec 23 18:13:49 2007
@@ -309,7 +309,7 @@
         appendLine("var anyData = null;");
         appendLine("var anyStartTag;");
         
-        startIf("anyHolder != null");
+        startIf("anyHolder != null && !anyHolder.raw");
         appendLine("anySerializer = "
                              + "cxfjsutils.interfaceObject.globalElementSerializers[anyHolder.qname];");
         appendLine("anyXmlTag = '" + prefix + ":' + anyHolder.localName;");
@@ -319,7 +319,9 @@
         appendLine("anyEmptyTag = '<' + anyXmlTag + ' ' + anyXmlNsDef + '/>';");
         appendLine("anyData = anyHolder.object;");
         endBlock();
-
+        startIf("anyHolder != null && anyHolder.raw");
+        appendExpression("anyHolder.xml");
+        appendElse();
         // first question: optional?
         if (optional) {
             startIf("anyHolder != null && anyData != null");
@@ -358,6 +360,7 @@
         if (optional) {
             endBlock();
         }
+        endBlock(); // for raw
     }
 
 }

Modified: incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js?rev=606656&r1=606655&r2=606656&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/resources/org/apache/cxf/javascript/cxf-utils.js
Sun Dec 23 18:13:49 2007
@@ -411,4 +411,12 @@
 	this.localName = localName;
 	this.qname = "{" + namespaceURI + "}" + localName;
 	this.object = object;
+	this.raw = false;
 }
+
+function org_apache_cxf_raw_any_holder(xml)
+{
+	this.xml = xml;
+	this.raw = true;
+}
+	

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java?rev=606656&r1=606655&r2=606656&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/AnyTest.java
Sun Dec 23 18:13:49 2007
@@ -21,6 +21,8 @@
 
 import java.util.logging.Logger;
 
+import org.w3c.dom.Element;
+
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.javascript.JavascriptTestUtilities.JSRunnable;
 import org.apache.cxf.javascript.JavascriptTestUtilities.Notifier;
@@ -87,6 +89,30 @@
         });
     }
     
+    private Void acceptOneRaw(Context context) {
+        LOG.info("About to call accept1 with Raw XML" + endpoint.getAddress());
+        testUtilities.rhinoCall("testAny1ToServerRaw",  
+                                testUtilities.javaToJS(endpoint.getAddress()));
+        assertEquals("before chalk", implementor.getBefore());
+        Object something = implementor.getAny1value();
+        assertNotNull(something);
+        assertTrue(something instanceof Element);
+        Element walrus = (Element) something;
+        assertEquals("walrus", walrus.getNodeName());
+        assertEquals("tusks", walrus.getTextContent());
+        assertEquals("after chalk", implementor.getAfter());
+        return null;
+    }
+    
+    @Test
+    public void callAcceptOneRaw() {
+        testUtilities.runInsideContext(Void.class, new JSRunnable<Void>() {
+            public Void run(Context context) {
+                return acceptOneRaw(context);
+            }
+        });
+    }
+
     private Void returnAny1(Context context) {
         Notifier notifier = 
             testUtilities.rhinoCallConvert("testAny1ToClientChalk", Notifier.class, 

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java?rev=606656&r1=606655&r2=606656&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JsXMLHttpRequest.java
Sun Dec 23 18:13:49 2007
@@ -127,7 +127,7 @@
 
     private void notifyReadyStateChangeListener() {
         if (readyStateChangeListener instanceof Function) {
-            LOG.info("notify " + readyState);
+            LOG.fine("notify " + readyState);
             // for now, call with no args.
             Function listenerFunction = (Function)readyStateChangeListener;
             listenerFunction.call(Context.getCurrentContext(), getParentScope(), null, new
Object[] {});
@@ -136,7 +136,7 @@
 
     private void doOpen(String method, String urlString, boolean async, String user, String
password) {
         // ignoring auth for now.
-        LOG.info("doOpen " + method + " " + urlString + " " + Boolean.toString(async));
+        LOG.fine("doOpen " + method + " " + urlString + " " + Boolean.toString(async));
 
         storedAsync = async;
         responseText = null;
@@ -145,7 +145,7 @@
         method = method.toUpperCase();
         // 1 check method
         if (!validMethods.contains(method)) {
-            LOG.info("Invalid method syntax error.");
+            LOG.fine("Invalid method syntax error.");
             throwError("SYNTAX_ERR");
         }
         // 2 security check (we don't have any)
@@ -157,7 +157,7 @@
         try {
             URI tempUri = new URI(urlString);
             if (tempUri.isOpaque()) { 
-                LOG.info("Relative URL syntax error.");
+                LOG.fine("Relative URL syntax error.");
                 throwError("SYNTAX_ERR");
             }
             

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java?rev=606656&r1=606655&r2=606656&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/AnyImpl.java
Sun Dec 23 18:13:49 2007
@@ -34,7 +34,7 @@
 /**
  * 
  */
-@org.apache.cxf.feature.Features(features = "org.apache.cxf.feature.LoggingFeature")   
+//@org.apache.cxf.feature.Features(features = "org.apache.cxf.feature.LoggingFeature")  

 public class AnyImpl implements AcceptAny {
 
     private Object any1value;

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js?rev=606656&r1=606655&r2=606656&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/org/apache/cxf/javascript/AnyTests.js
Sun Dec 23 18:13:49 2007
@@ -48,6 +48,18 @@
 	service.acceptAny1(param);
 }
 
+function testAny1ToServerRaw(url)
+{
+	var service = new cxf_apache_org_jstest_any_AcceptAny();
+	service.url = url;
+	var param = new cxf_apache_org_jstest_types_any_acceptAny1();
+	param.setBefore("before chalk");
+	var holder = new org_apache_cxf_raw_any_holder("<walrus xmlns='uri:iam'>tusks</walrus>");
+	param.setAny(holder);
+	param.setAfter("after chalk");
+	service.acceptAny1(param);
+}
+
 function errorCallback(httpStatus, httpStatusText) 
 {
     org_apache_cxf_trace.trace("error");



Mime
View raw message