Commits

Anonymous committed 03f4852

Add additional test case.

git-svn-id: http://svn.opensymphony.com/svn/xwork/trunk@321e221344d-f017-0410-9bd5-d282ab1896d7

Comments (0)

Files changed (1)

src/test/com/opensymphony/xwork/util/OgnlUtilTest.java

 
         Owner owner = new Owner();
         Map context = Ognl.createDefaultContext(owner);
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("dog.name", dogName);
 
         OgnlUtil.setProperties(props, owner, context);
         EmailAction action = new EmailAction();
         Map context = Ognl.createDefaultContext(action);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("email[0].address", "addr1");
         props.put("email[1].address", "addr2");
         props.put("email[2].address", "addr3");
 
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("bar.title", "i am barbaz");
         OgnlUtil.setProperties(props, foo, context);
 
         Foo foo = new Foo();
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("aLong", "123a");
 
         OgnlUtil.setProperties(props, foo, context);
         assertEquals(0, foo.getALong());
     }
 
+    /**
+     * Test that type conversion is performed on indexed collection properties.
+     */
+    public void testSetIndexedValue() {
+        OgnlValueStack stack = new OgnlValueStack();
+        Map stackContext = stack.getContext();
+        stackContext.put(InstantiatingNullHandler.CREATE_NULL_OBJECTS, Boolean.TRUE);
+        stackContext.put(XWorkMethodAccessor.DENY_METHOD_EXECUTION, Boolean.TRUE);
+        stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
+
+        User user = new User();
+        stack.push(user);
+
+        // indexed string w/ existing array
+        user.setList(new ArrayList());
+        user.getList().add("");
+
+        String[] foo = new String[] {"asdf"};
+        stack.setValue("list[0]", foo);
+        assertNotNull(user.getList());
+        assertEquals(1, user.getList().size());
+        assertEquals(String.class, user.getList().get(0).getClass());
+        assertEquals("asdf", user.getList().get(0));
+    }
+
     public void testSetPropertiesBoolean() {
         Foo foo = new Foo();
 
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("useful", "true");
         OgnlUtil.setProperties(props, foo, context);
 
 
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("birthday", "02/12/1982");
         OgnlUtil.setProperties(props, foo, context);
 
 
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("number", "2");
         OgnlUtil.setProperties(props, foo, context);
 
 
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("points", new String[] {"1", "2"});
         OgnlUtil.setProperties(props, foo, context);
 
 
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("title", "this is a title");
         OgnlUtil.setProperties(props, foo, context);
 
 
         Map context = Ognl.createDefaultContext(foo);
 
-        HashMap props = new HashMap();
+        Map props = new HashMap();
         props.put("aLong", "123");
 
         OgnlUtil.setProperties(props, foo, context);
             return super.get(index);
         }
     }
-
-    /**
-     * Test that type conversion is performed on indexed collection properties.
-     */
-    public void testSetIndexedValue() {
-        OgnlValueStack stack = new OgnlValueStack();
-        Map stackContext = stack.getContext();
-        stackContext.put(InstantiatingNullHandler.CREATE_NULL_OBJECTS, Boolean.TRUE);
-        stackContext.put(XWorkMethodAccessor.DENY_METHOD_EXECUTION, Boolean.TRUE);
-        stackContext.put(XWorkConverter.REPORT_CONVERSION_ERRORS, Boolean.TRUE);
-
-        User user = new User();
-        stack.push(user);
-
-        // indexed string w/ existing array
-        user.setList(new ArrayList());
-        user.getList().add("");
-
-        String[] foo = new String[] {"asdf"};
-        stack.setValue("list[0]", foo);
-        assertNotNull(user.getList());
-        assertEquals(1, user.getList().size());
-        assertEquals(String.class, user.getList().get(0).getClass());
-        assertEquals("asdf", user.getList().get(0));
-    }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.