cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r590992 - in /incubator/cxf/trunk/rt/javascript/src: main/java/org/apache/cxf/javascript/types/ test/java/org/apache/cxf/javascript/ test/java/org/apache/cxf/javascript/fortest/ test/java/org/apache/cxf/javascript/types/ test/resources/
Date Thu, 01 Nov 2007 13:15:46 GMT
Author: bimargulies
Date: Thu Nov  1 06:15:45 2007
New Revision: 590992

URL: http://svn.apache.org/viewvc?rev=590992&view=rev
Log:
More deserialization testing. Still needs tests of bean->bean references.


Modified:
    incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
    incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTests.java
    incubator/cxf/trunk/rt/javascript/src/test/resources/deserializationTests.js

Modified: incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=590992&r1=590991&r2=590992&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Thu Nov  1 06:15:45 2007
@@ -535,13 +535,18 @@
             utils.endBlock(); // the if for the nil.
             if (isParticleArray(elChild)) {
                 utils.appendLine("item.push(arrayItem);");
+                utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);");
                 utils.endBlock();
-                utils.appendLine("while(cfjsutils.isNodeNamedNS(curElement, '" 
+                utils.appendLine("  while(curElement != null && cxfjsutils.isNodeNamedNS(curElement,
'" 
                                   + elementNamespaceURI + "', '" 
                                   + elChild.getName() + "'));");
             }
             utils.appendLine("newobject." + accessorName + "(item);");
-            utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);");
+            if (!isParticleArray(elChild)) {
+                utils.startIf("curElement != null");
+                utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);");
+                utils.endBlock();
+            }
             if (isParticleOptional(elChild) || isParticleArray(elChild)) {
                 utils.endBlock();
             }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java?rev=590992&r1=590991&r2=590992&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/JavascriptTestUtilities.java
Thu Nov  1 06:15:45 2007
@@ -51,6 +51,7 @@
 
         public Assert() { }
         public void jsConstructor(String exp) {
+            LOG.severe("Assertion failed: " + exp);
             throw new JavaScriptAssertionFailed(exp);
         }
         @Override
@@ -71,7 +72,7 @@
         
         //CHECKSTYLE:OFF
         public static void jsStaticFunction_trace(String message) {
-            LOG.info(message);
+            LOG.fine(message);
         }
         //CHECKSTYLE:ON
         

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java?rev=590992&r1=590991&r2=590992&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
Thu Nov  1 06:15:45 2007
@@ -42,6 +42,8 @@
     public String optionalStringItem;
     @XmlElement(required = false)
     public int[] optionalIntArrayItem;
+    @XmlElement(defaultValue = "-1.0")
+    public double doubleItem;
     
     //CHECKSTYLE:ON
 }

Modified: incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTests.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTests.java?rev=590992&r1=590991&r2=590992&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTests.java
(original)
+++ incubator/cxf/trunk/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTests.java
Thu Nov  1 06:15:45 2007
@@ -28,6 +28,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
@@ -80,13 +81,24 @@
         try {
             TestBean1 bean = new TestBean1();
             bean.stringItem = "bean1>stringItem";
-            DataWriter<XMLStreamWriter> writer = dataBinding.createWriter(XMLStreamWriter.class);
-            StringWriter stringWriter = new StringWriter();
-            XMLStreamWriter xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(stringWriter);
-            writer.write(bean, xmlStreamWriter);
-            xmlStreamWriter.flush();
-            xmlStreamWriter.close();
-            testUtilities.rhinoCall("deserializeTestBean1_1", stringWriter.toString());
+            bean.doubleItem = -1.0;
+            String serialized = serializeObject(dataBinding, bean);
+            testUtilities.rhinoCall("deserializeTestBean1_1", serialized);
+            
+            bean = new TestBean1();
+            bean.stringItem = null;
+            bean.intItem = 21;
+            bean.longItem = 200000001;
+            bean.optionalIntItem = 456123;
+            bean.optionalIntArrayItem = new int[4];
+            bean.optionalIntArrayItem[0] = 3;
+            bean.optionalIntArrayItem[1] = 1;
+            bean.optionalIntArrayItem[2] = 4;
+            bean.optionalIntArrayItem[3] = 1;
+            bean.doubleItem = -1.0;
+            serialized = serializeObject(dataBinding, bean);
+            testUtilities.rhinoCall("deserializeTestBean1_2", serialized);
+
         } catch (JavaScriptAssertionFailed assertion) {
             fail(assertion.getMessage());
         } catch (RhinoException angryRhino) {
@@ -94,6 +106,16 @@
             Assert.fail("Javascript error: " + angryRhino.toString() + " " + trace);
         }
 
+    }
+
+    private String serializeObject(DataBinding dataBinding, TestBean1 bean) throws XMLStreamException
{
+        DataWriter<XMLStreamWriter> writer = dataBinding.createWriter(XMLStreamWriter.class);
+        StringWriter stringWriter = new StringWriter();
+        XMLStreamWriter xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(stringWriter);
+        writer.write(bean, xmlStreamWriter);
+        xmlStreamWriter.flush();
+        xmlStreamWriter.close();
+        return stringWriter.toString();
     }
     
     @Test

Modified: incubator/cxf/trunk/rt/javascript/src/test/resources/deserializationTests.js
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/javascript/src/test/resources/deserializationTests.js?rev=590992&r1=590991&r2=590992&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/javascript/src/test/resources/deserializationTests.js (original)
+++ incubator/cxf/trunk/rt/javascript/src/test/resources/deserializationTests.js Thu Nov 
1 06:15:45 2007
@@ -35,6 +35,51 @@
 	var dom = parseXml(xml);
 	var bean = org_apache_cxf_javascript_testns_testBean1_deserialize(jsutils, dom);
 	if(bean.getStringItem() != "bean1>stringItem")
-		assertionFailed("deserializeTestBean1_1 stringItem " + bean.getStringItem()); 
+		assertionFailed("deserializeTestBean1_1 stringItem " + bean.getStringItem());
+	if(bean.getIntItem() != 0)
+		assertionFailed("deserializeTestBean1_1 intItem " + bean.getIntItem());
+	if(bean.getLongItem() != 0)
+		assertionFailed("deserializeTestBean1_1 longItem " + bean.getLongItem());
+	if(bean.getOptionalIntItem() != 0)
+		assertionFailed("deserializeTestBean1_1 optionalIntItem " + bean.getOptionalIntItem());
+	if(bean.getOptionalStringItem() != null)
+		assertionFailed("deserializeTestBean1_1 optionalStringItem " + bean.getOptionalStringItem());
+	if(bean.getOptionalIntArrayItem() == null)
+		assertionFailed("deserializeTestBean1_1 optionalIntArrayItem null");
+	if(bean.getOptionalIntArrayItem().length != 0)
+		assertionFailed("deserializeTestBean1_1 optionalIntArrayItem length != 0");
+	if(bean.getDoubleItem() != -1.0)
+		assertionFailed("deserializeTestBean1_1 doubleItem " + bean.getDoubleItem());
+}
+
+function deserializeTestBean1_2(xml)
+{
+	var dom = parseXml(xml);
+	var bean = org_apache_cxf_javascript_testns_testBean1_deserialize(jsutils, dom);
+	if(bean.getStringItem() != null)
+		assertionFailed("deserializeTestBean1_2 stringItem not null: " + bean.getStringItem());
+	if(bean.getIntItem() != 21)
+		assertionFailed("deserializeTestBean1_2 intItem " + bean.getIntItem());
+ 	if(bean.getLongItem() != 200000001)
+		assertionFailed("deserializeTestBean1_2 longItem " + bean.getLongItem());
+	if(bean.getOptionalIntItem() != 456123)
+		assertionFailed("deserializeTestBean1_2 optionalIntItem " + bean.getOptionalIntItem());
+	if(bean.getOptionalStringItem() != null)
+		assertionFailed("deserializeTestBean1_2 optionalStringItem " + bean.getOptionalStringItem());
+	if(bean.getOptionalIntArrayItem() == null)
+		assertionFailed("deserializeTestBean1_2 optionalIntArrayItem null");
+	if(bean.getOptionalIntArrayItem().length != 4)
+		assertionFailed("deserializeTestBean1_2 optionalIntArrayItem length != 4");
+	if(bean.getOptionalIntArrayItem()[0] != 3)
+		assertionFailed("deserializeTestBean1_2 optionalIntArrayItem[0] " + bean.getOptionalIntArrayItem()[0]);
+	if(bean.getOptionalIntArrayItem()[1] != 1)
+		assertionFailed("deserializeTestBean1_2 optionalIntArrayItem[1] " + bean.getOptionalIntArrayItem()[1]);
+	if(bean.getOptionalIntArrayItem()[2] != 4)
+		assertionFailed("deserializeTestBean1_2 optionalIntArrayItem[2] " + bean.getOptionalIntArrayItem()[2]);
+	if(bean.getOptionalIntArrayItem()[3] != 1)
+		assertionFailed("deserializeTestBean1_2 optionalIntArrayItem[3] " + bean.getOptionalIntArrayItem()[3]);
+	if(bean.getDoubleItem() != -1.0)
+		assertionFailed("deserializeTestBean1_2 doubleItem " + bean.getDoubleItem());
+		
 }
 



Mime
View raw message