cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r886949 - in /cxf/branches/2.2.x-fixes: ./ rt/javascript/src/main/java/org/apache/cxf/javascript/ rt/javascript/src/main/java/org/apache/cxf/javascript/types/ rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/ rt/javascript/src/...
Date Thu, 03 Dec 2009 22:17:33 GMT
Author: dkulp
Date: Thu Dec  3 22:17:33 2009
New Revision: 886949

URL: http://svn.apache.org/viewvc?rev=886949&view=rev
Log:
Merged revisions 885760 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r885760 | bimargulies | 2009-12-01 08:28:42 -0500 (Tue, 01 Dec 2009) | 1 line
  
  CXF-2568
........

Modified:
    cxf/branches/2.2.x-fixes/   (props changed)
    cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
    cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
    cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
    cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
    cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
    cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean3.java
    cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java
    cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/serializationTests.js

Propchange: cxf/branches/2.2.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/ParticleInfo.java
Thu Dec  3 22:17:33 2009
@@ -189,7 +189,15 @@
             // with elements with identical local names and different
             // namespaces.
             elementInfo.javascriptName = elementQName.getLocalPart();
-            elementInfo.defaultValue = element.getDefaultValue();
+            String schemaDefaultValue = element.getDefaultValue();
+            /*
+             * Schema default values are carried as strings. 
+             * In javascript, for actual strings, we need quotes, but not for
+             * numbers. The following is a trick.
+             */
+            schemaDefaultValue = protectDefaultValue(schemaDefaultValue);
+
+            elementInfo.defaultValue = schemaDefaultValue;
             factorySetupType(element, schemaCollection, elementInfo);
         } else { // any
             elementInfo.any = true;
@@ -201,6 +209,40 @@
         }
     }
 
+    private static String protectDefaultValue(String schemaDefaultValue) {
+        if (schemaDefaultValue == null) {
+            return null;
+        }
+        boolean leaveAlone = false;
+        try {
+            Long.parseLong(schemaDefaultValue);
+            leaveAlone = true;
+        } catch (NumberFormatException nfe) {
+            try {
+                Double.parseDouble(schemaDefaultValue);
+                leaveAlone = true;
+            } catch (NumberFormatException nfe2) {
+                //
+            }
+        }
+        if (!leaveAlone) {
+            StringBuilder builder = new StringBuilder();
+            builder.append("'");
+            for (char c : schemaDefaultValue.toCharArray()) {
+                if (c == '\'') {
+                    builder.append("\\'");
+                } else if (c == '\\') {
+                    builder.append("\\\\");
+                } else {
+                    builder.append(c);
+                }
+            }
+            builder.append('\'');
+            schemaDefaultValue = builder.toString(); 
+        }
+        return schemaDefaultValue;
+    }
+
     private static void factorySetupType(XmlSchemaElement element, SchemaCollection schemaCollection,
                                          ParticleInfo elementInfo) {
         elementInfo.type = element.getSchemaType();
@@ -351,4 +393,9 @@
     public boolean isGlobal() {
         return global;
     }
+
+    @Override
+    public String toString() {
+        return "ItemInfo: " + javascriptName;
+    }
 }

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/main/java/org/apache/cxf/javascript/types/SchemaJavascriptBuilder.java
Thu Dec  3 22:17:33 2009
@@ -230,7 +230,6 @@
                                   final String elementPrefix, 
                                   String typeObjectName, 
                                   ItemInfo itemInfo) {
-
             
         String accessorSuffix = StringUtils.capitalize(itemInfo.getJavascriptName());
 
@@ -287,6 +286,7 @@
             // application code is responsible for this.
             utils.appendLine("this._" + itemInfo.getJavascriptName() + " = null;");
         } else {
+
             if (itemInfo.getDefaultValue() == null) {
                 itemInfo.setDefaultValue(utils.getDefaultValueForSimpleType(itemInfo.getType()));
             }

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrapped.java
Thu Dec  3 22:17:33 2009
@@ -76,4 +76,7 @@
     
     @WebMethod 
     void inheritanceTestFunction(@WebParam(name = "d") InheritanceTestDerived d);
+    
+    @WebMethod
+    AnEnum enumEcho(@WebParam(name = "ev") AnEnum value);
 }

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/SimpleDocLitWrappedImpl.java
Thu Dec  3 22:17:33 2009
@@ -163,4 +163,8 @@
         return lastInheritanceTestDerived;
     }
 
+    public AnEnum enumEcho(AnEnum value) {
+        return value;
+    }
+
 }

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean1.java
Thu Dec  3 22:17:33 2009
@@ -22,11 +22,13 @@
 import java.util.Arrays;
 
 import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlType;
 
 /**
  * Bean with a selection of elements suitable for testing the JavaScript client.
  */
+@XmlRootElement(namespace = "uri:org.apache.cxf.javascript.testns")
 @XmlType(namespace = "uri:org.apache.cxf.javascript.testns")
 public class TestBean1 {
     
@@ -35,6 +37,7 @@
         doubleItem = -1.0;
         beanTwoItem = new TestBean2("required=true");
         beanTwoNotRequiredItem = null;
+        enumeration = AnEnum.Animal;
     }
     
     //CHECKSTYLE:OFF
@@ -56,13 +59,12 @@
     public TestBean2 beanTwoItem;
     @XmlElement(required = false)
     public TestBean2 beanTwoNotRequiredItem;
+    @XmlElement(defaultValue = "Animal", required = true)
     public AnEnum enumeration;
+    @XmlElement 
+    public AnEnum enum2;
     //CHECKSTYLE:ON
     
-    public AnEnum getEnumeration() {
-        return enumeration;
-    }
-    
     @Override
     public boolean equals(Object obj) {
         if (!(obj instanceof TestBean1)) {

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean3.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean3.java?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean3.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/fortest/TestBean3.java
Thu Dec  3 22:17:33 2009
@@ -123,7 +123,7 @@
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
-        builder.append("TestBean1");
+        builder.append("TestBean3");
         builder.append(" stringItem ");
         builder.append(stringItem == null ? "Null" : stringItem);
         builder.append(" intItem ");

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java
(original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/test/java/org/apache/cxf/javascript/types/SerializationTest.java
Thu Dec  3 22:17:33 2009
@@ -43,7 +43,6 @@
 import org.apache.cxf.javascript.NamespacePrefixAccumulator;
 import org.apache.cxf.javascript.fortest.TestBean1;
 import org.apache.cxf.javascript.fortest.TestBean2;
-import org.apache.cxf.javascript.fortest.TestBean3;
 import org.apache.cxf.jaxb.JAXBDataBinding;
 import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
 import org.apache.cxf.service.model.SchemaInfo;
@@ -86,15 +85,15 @@
     public void testDeserialization() throws Exception {
         setupClientAndRhino("simple-dlwu-proxy-factory");
         testUtilities.readResourceIntoRhino("/deserializationTests.js");
-        DataBinding dataBinding = new JAXBDataBinding(TestBean3.class, TestBean2.class);
+        DataBinding dataBinding = new JAXBDataBinding(TestBean1.class, TestBean2.class);
         assertNotNull(dataBinding);
-        TestBean3 bean = new TestBean3();
+        TestBean1 bean = new TestBean1();
         bean.stringItem = "bean1>stringItem";
         bean.doubleItem = -1.0;
         String serialized = serializeObject(dataBinding, bean);
         testUtilities.rhinoCallInContext("deserializeTestBean3_1", serialized);
 
-        bean = new TestBean3();
+        bean = new TestBean1();
         bean.stringItem = null;
         bean.intItem = 21;
         bean.longItem = 200000001;
@@ -109,7 +108,7 @@
         testUtilities.rhinoCallInContext("deserializeTestBean3_2", serialized);
     }
 
-    private String serializeObject(DataBinding dataBinding, TestBean3 bean) throws XMLStreamException
{
+    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);

Modified: cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/serializationTests.js
URL: http://svn.apache.org/viewvc/cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/serializationTests.js?rev=886949&r1=886948&r2=886949&view=diff
==============================================================================
--- cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/serializationTests.js (original)
+++ cxf/branches/2.2.x-fixes/rt/javascript/src/test/resources/serializationTests.js Thu Dec
 3 22:17:33 2009
@@ -39,6 +39,7 @@
  	var a = [];
  	a.push(543);
  	bean1.setOptionalIntArrayItem(a);
+ 	bean1.setEnum2('Mineral');
 	return bean1.serialize(jsutils, "testBean1");
 } 
 



Mime
View raw message