You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/06/15 22:06:03 UTC

svn commit: r955030 - in /pivot/branches/1.5.x: demos/src/org/apache/pivot/demos/rest/ tests/src/org/apache/pivot/tests/ wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtkx/

Author: gbrown
Date: Tue Jun 15 20:06:03 2010
New Revision: 955030

URL: http://svn.apache.org/viewvc?rev=955030&view=rev
Log:
Various minor updates.

Modified:
    pivot/branches/1.5.x/demos/src/org/apache/pivot/demos/rest/RESTDemoTest.java
    pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/WTKXDictionaryTest.java
    pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test.wtkx
    pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test_include.wtkx
    pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/Form.java
    pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java

Modified: pivot/branches/1.5.x/demos/src/org/apache/pivot/demos/rest/RESTDemoTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/demos/src/org/apache/pivot/demos/rest/RESTDemoTest.java?rev=955030&r1=955029&r2=955030&view=diff
==============================================================================
--- pivot/branches/1.5.x/demos/src/org/apache/pivot/demos/rest/RESTDemoTest.java (original)
+++ pivot/branches/1.5.x/demos/src/org/apache/pivot/demos/rest/RESTDemoTest.java Tue Jun 15 20:06:03 2010
@@ -64,7 +64,9 @@ public class RESTDemoTest {
         // Read
         GetQuery getQuery = new GetQuery(hostname, port, path, secure);
 
-        assertEquals(contact, getQuery.execute());
+        Object result = getQuery.execute();
+        assertEquals(JSON.get(contact, "address.street"), JSON.get(result, "address.street"));
+        assertEquals(contact, result);
 
         // Update
         JSON.put(contact, "name", "Joseph User");
@@ -81,4 +83,10 @@ public class RESTDemoTest {
 
         assertEquals(deleteQuery.getStatus(), Query.Status.NO_CONTENT);
     }
+
+    @Test(expected=QueryException.class)
+    public void testException() throws IOException, SerializationException, QueryException {
+        GetQuery getQuery = new GetQuery(hostname, port, "/pivot-demos/rest_demo/foo", secure);
+        getQuery.execute();
+    }
 }

Modified: pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/WTKXDictionaryTest.java
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/WTKXDictionaryTest.java?rev=955030&r1=955029&r2=955030&view=diff
==============================================================================
--- pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/WTKXDictionaryTest.java (original)
+++ pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/WTKXDictionaryTest.java Tue Jun 15 20:06:03 2010
@@ -24,7 +24,7 @@ public class WTKXDictionaryTest {
     @SuppressWarnings("unchecked")
     public static void main(String[] args) throws Exception {
         WTKXSerializer wtkxSerializer = new WTKXSerializer();
-        HashMap<String, Object> hashMap = 
+        HashMap<String, Object> hashMap =
             (HashMap<String, Object>)wtkxSerializer.readObject(WTKXDictionaryTest.class.getResource("wtkx_dictionary_test.wtkx"));
         System.out.println(JSONSerializer.toString(hashMap));
     }

Modified: pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test.wtkx
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test.wtkx?rev=955030&r1=955029&r2=955030&view=diff
==============================================================================
--- pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test.wtkx (original)
+++ pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test.wtkx Tue Jun 15 20:06:03 2010
@@ -24,4 +24,5 @@ limitations under the License.
     <bar>
         <wtkx:include src="wtkx_dictionary_test_include.wtkx"/>
     </bar>
+    <baz>Quux</baz>
 </HashMap>

Modified: pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test_include.wtkx
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test_include.wtkx?rev=955030&r1=955029&r2=955030&view=diff
==============================================================================
--- pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test_include.wtkx (original)
+++ pivot/branches/1.5.x/tests/src/org/apache/pivot/tests/wtkx_dictionary_test_include.wtkx Tue Jun 15 20:06:03 2010
@@ -16,6 +16,6 @@ See the License for the specific languag
 limitations under the License.
 -->
 
-<HashMap a="456" 
+<HashMap a="456"
     xmlns:wtkx="http://pivot.apache.org/wtkx"
     xmlns="org.apache.pivot.collections"/>

Modified: pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/Form.java
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/Form.java?rev=955030&r1=955029&r2=955030&view=diff
==============================================================================
--- pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/Form.java (original)
+++ pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtk/Form.java Tue Jun 15 20:06:03 2010
@@ -252,13 +252,12 @@ public class Form extends Container {
         public static final String MESSAGE_KEY = "message";
 
         /**
-         * Creates a new flag with a type of {@link MessageType.ERROR} and
-         * no message.
+         * Creates a new flag with a type of "error" and no message.
          */
         public Flag() {
             this(MessageType.ERROR, null);
         }
-        
+
         /**
          * Creates a new flag with the given message type and no message.
          *
@@ -297,30 +296,30 @@ public class Form extends Container {
         public MessageType getMessageType() {
             return messageType;
         }
-        
+
         /**
          * Sets the flag's message type.
-         * 
+         *
          * @param messageType
          */
         public void setMessageType(MessageType messageType) {
             if (messageType == null) {
                 throw new IllegalArgumentException();
             }
-            
+
             this.messageType = messageType;
         }
-        
+
         /**
          * Sets the flag's message type.
-         * 
+         *
          * @param messageType
          */
         public void setMessageType(String messageType) {
             if (messageType == null) {
                 throw new IllegalArgumentException();
             }
-            
+
             setMessageType(MessageType.valueOf(messageType.toUpperCase()));
         }
 
@@ -334,10 +333,10 @@ public class Form extends Container {
         public String getMessage() {
             return message;
         }
-        
+
         /**
          * Sets the flag message.
-         * 
+         *
          * @param message
          * The message text associated with the flag, or <tt>null</tt> if
          * there is no message.

Modified: pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java
URL: http://svn.apache.org/viewvc/pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java?rev=955030&r1=955029&r2=955030&view=diff
==============================================================================
--- pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java (original)
+++ pivot/branches/1.5.x/wtk/src/org/apache/pivot/wtkx/WTKXSerializer.java Tue Jun 15 20:06:03 2010
@@ -170,7 +170,7 @@ public class WTKXSerializer implements S
         public Object value;
         public final int lineNumber;
 
-        public Element(Element parent, String namespaceURI, String localName, List<Attribute> attributes, 
+        public Element(Element parent, String namespaceURI, String localName, List<Attribute> attributes,
             Type type, String id, Object value, int lineNumber) {
             this.parent = parent;
             this.namespaceURI = namespaceURI;
@@ -681,7 +681,7 @@ public class WTKXSerializer implements S
         }
 
         Location xmlStreamLocation = xmlStreamReader.getLocation();
-        element = new Element(element, namespaceURI, localName, attributes, elementType, 
+        element = new Element(element, namespaceURI, localName, attributes, elementType,
             id, value, xmlStreamLocation.getLineNumber());
 
         // If this is the root, set it
@@ -829,10 +829,10 @@ public class WTKXSerializer implements S
                         // Split the local name
                         String[] localNameComponents = attribute.localName.split("\\.");
                         if (localNameComponents.length != 2) {
-                            throw new SerializationException("\"" + attribute.localName 
+                            throw new SerializationException("\"" + attribute.localName
                                 + "\" is not a valid attribute name.");
                         }
-                        
+
                         // Determine the type of the attribute
                         String propertyClassName = attribute.namespaceURI + "." + localNameComponents[0];
 
@@ -868,7 +868,7 @@ public class WTKXSerializer implements S
                             }
 
                             // Create an invocation handler for this listener
-                            ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(language);                            
+                            ScriptEngine scriptEngine = scriptEngineManager.getEngineByName(language);
                             AttributeInvocationHandler handler =
                                 new AttributeInvocationHandler(scriptEngine,
                                     localNameComponents[1],
@@ -895,7 +895,7 @@ public class WTKXSerializer implements S
                             }
                         } else {
                             // The attribute represents a static setter
-                            setStaticProperty(element.value, propertyClass, localNameComponents[1], 
+                            setStaticProperty(element.value, propertyClass, localNameComponents[1],
                                 resolve(attribute.value));
                         }
                     }
@@ -934,37 +934,37 @@ public class WTKXSerializer implements S
                 if (element.parent.value instanceof Dictionary) {
                     dictionary = (Dictionary<String, Object>)element.parent.value;
                 } else {
-                    dictionary = new BeanAdapter(element.parent.value);                    
+                    dictionary = new BeanAdapter(element.parent.value);
                 }
-                
+
                 if (Character.isUpperCase(element.localName.charAt(0))) {
                     if (element.parent == null
                         || element.parent.value == null) {
                         throw new SerializationException("Element does not have a parent.");
                     }
-                                        
+
                     // Set static property
                     String[] localNameComponents = element.localName.split("\\.");
                     if (localNameComponents.length != 2) {
-                        throw new SerializationException("\"" + element.localName 
+                        throw new SerializationException("\"" + element.localName
                             + "\" is not a valid attribute name.");
                     }
-                    
+
                     String propertyClassName = element.namespaceURI + "." + localNameComponents[0];
-                    
+
                     Class<?> propertyClass = null;
                     try {
                         propertyClass = Class.forName(propertyClassName);
                     } catch (ClassNotFoundException exception) {
                         throw new SerializationException(exception);
                     }
-                    
-                    setStaticProperty(element.parent.value, propertyClass, localNameComponents[1], 
-                        element.value);                    
+
+                    setStaticProperty(element.parent.value, propertyClass, localNameComponents[1],
+                        element.value);
                 } else {
                     dictionary.put(localName, element.value);
                 }
-                
+
                 break;
             }
 
@@ -1517,9 +1517,9 @@ public class WTKXSerializer implements S
 
         return method;
     }
-    
-    private static void setStaticProperty(Object object, Class<?> propertyClass, 
-        String propertyName, Object value) 
+
+    private static void setStaticProperty(Object object, Class<?> propertyClass,
+        String propertyName, Object value)
         throws SerializationException {
         Class<?> objectType = object.getClass();
         propertyName = Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1);
@@ -1545,7 +1545,7 @@ public class WTKXSerializer implements S
         }
 
         if (setterMethod == null) {
-            throw new SerializationException(propertyClass.getName() + "." + propertyName 
+            throw new SerializationException(propertyClass.getName() + "." + propertyName
                 + " is not valid static property.");
         }