struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From musa...@apache.org
Subject svn commit: r799110 [6/7] - in /struts/sandbox/trunk/struts2-json-plugin: ./ src/main/java/org/apache/struts2/json/ src/main/java/org/apache/struts2/json/annotations/ src/main/java/org/apache/struts2/json/rpc/ src/main/java/org/apache/struts2/json/smd/...
Date Wed, 29 Jul 2009 22:44:29 GMT
Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONResultTest.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONResultTest.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONResultTest.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONResultTest.java Wed Jul 29 22:44:26 2009
@@ -1,534 +1,534 @@
-/*
- + * $Id$
- + *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.struts2.json;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.StrutsStatics;
-import org.apache.struts2.StrutsTestCase;
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.springframework.mock.web.MockServletContext;
-
-import com.opensymphony.xwork2.ActionContext;
-import com.opensymphony.xwork2.mock.MockActionInvocation;
-import com.opensymphony.xwork2.util.ValueStack;
-
-/**
- * JSONResultTest
- */
-public class JSONResultTest extends StrutsTestCase {
-    MockActionInvocation invocation;
-    MockHttpServletResponse response;
-    MockServletContext servletContext;
-    ActionContext context;
-    ValueStack stack;
-    MockHttpServletRequest request;
-
-    public void testJSONUtilNPEOnNullMehtod() {
-        Map map = new HashMap();
-        map.put("createtime", new Date());
-        try {
-            JSONUtil.serialize(map);
-        } catch (JSONException e) {
-            fail(e.getMessage());
-        }
-    }
-
-    public void testJSONWriterEndlessLoopOnExludedProperties() throws JSONException {
-        Pattern all = Pattern.compile(".*");
-
-        JSONWriter writer = new JSONWriter();
-        writer.write(Arrays.asList("a", "b"), Arrays.asList(all), null, false);
-    }
-
-    public void testSMDDisabledSMD() throws Exception {
-        JSONResult result = new JSONResult();
-        SMDActionTest1 action = new SMDActionTest1();
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String smd = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(smd, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-8.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-    }
-
-    public void testSMDDefault() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setEnableSMD(true);
-        SMDActionTest1 action = new SMDActionTest1();
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String smd = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(smd, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-1.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    public void testSMDDefaultAnnotations() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setEnableSMD(true);
-        SMDActionTest2 action = new SMDActionTest2();
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String smd = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(smd, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-2.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    public void testExcludeNullPropeties() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setExcludeNullProperties(true);
-        TestAction action = new TestAction();
-        action.setFoo("fool");
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String smd = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(smd, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("nulls-1.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-    }
-
-    public void testWrapPrefix() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setWrapPrefix("_prefix_");
-        TestAction2 action = new TestAction2();
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String out = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(out, true);
-        String normalizedExpected = "_prefix_{\"name\":\"name\"}";
-        assertEquals(normalizedExpected, normalizedActual);
-    }
-
-    public void testSuffix() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setWrapSuffix("_suffix_");
-        TestAction2 action = new TestAction2();
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String out = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(out, true);
-        String normalizedExpected = "{\"name\":\"name\"}_suffix_";
-        assertEquals(normalizedExpected, normalizedActual);
-    }
-
-    public void testPrefixAndSuffix() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setWrapPrefix("_prefix_");
-        result.setWrapSuffix("_suffix_");
-        TestAction2 action = new TestAction2();
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String out = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(out, true);
-        String normalizedExpected = "_prefix_{\"name\":\"name\"}_suffix_";
-        assertEquals(normalizedExpected, normalizedActual);
-    }
-
-    public void testPrefix() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setExcludeNullProperties(true);
-        result.setPrefix(true);
-        TestAction action = new TestAction();
-        action.setFoo("fool");
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String smd = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(smd, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("prefix-1.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-    }
-
-    @SuppressWarnings("unchecked")
-    public void test() throws Exception {
-        JSONResult result = new JSONResult();
-
-        TestAction action = new TestAction();
-
-        // test scape characters
-        action.setArray(new String[] { "a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t" });
-
-        List list = new ArrayList();
-
-        list.add("b");
-        list.add(1);
-        list.add(new int[] { 10, 12 });
-        action.setCollection(list);
-
-        // beans
-        List collection2 = new ArrayList();
-        Bean bean1 = new Bean();
-
-        bean1.setBigDecimal(new BigDecimal("111111.111111"));
-        bean1.setBigInteger(new BigInteger("111111111111"));
-        bean1.setStringField("str");
-        bean1.setBooleanField(true);
-        bean1.setCharField('s');
-        bean1.setDoubleField(10.1);
-        bean1.setFloatField(1.5f);
-        bean1.setIntField(10);
-        bean1.setLongField(100);
-        bean1.setEnumField(AnEnum.ValueA);
-        bean1.setEnumBean(AnEnumBean.One);
-
-        Bean bean2 = new Bean();
-
-        bean2.setStringField("  ");
-        bean2.setBooleanField(false);
-        bean2.setFloatField(1.1f);
-        bean2.setDoubleField(2.2);
-        bean2.setEnumField(AnEnum.ValueB);
-        bean2.setEnumBean(AnEnumBean.Two);
-
-        // circular reference
-        bean1.setObjectField(bean2);
-        bean2.setObjectField(bean1);
-
-        collection2.add(bean1);
-        action.setCollection2(collection2);
-
-        // keep order in map
-        Map map = new LinkedHashMap();
-
-        map.put("a", 1);
-        map.put("c", new float[] { 1.0f, 2.0f });
-        action.setMap(map);
-
-        action.setFoo("foo");
-        // should be ignored, marked 'transient'
-        action.setBar("bar");
-
-        // date
-        Calendar calendar = Calendar.getInstance();
-        calendar.set(Calendar.YEAR, 1999);
-        calendar.set(Calendar.MONTH, Calendar.DECEMBER);
-        calendar.set(Calendar.DAY_OF_MONTH, 31);
-        calendar.set(Calendar.HOUR_OF_DAY, 11);
-        calendar.set(Calendar.MINUTE, 59);
-        calendar.set(Calendar.SECOND, 59);
-        action.setDate(calendar.getTime());
-        action.setDate2(calendar.getTime());
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String json = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    @SuppressWarnings("unchecked")
-    public void testHierarchy() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setIgnoreHierarchy(false);
-
-        TestAction3 action = new TestAction3();
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String json = response.getContentAsString();
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-4.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    @SuppressWarnings("unchecked")
-    public void testCommentWrap() throws Exception {
-        JSONResult result = new JSONResult();
-
-        TestAction action = new TestAction();
-
-        // test scape characters
-        action.setArray(new String[] { "a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t" });
-
-        List list = new ArrayList();
-
-        list.add("b");
-        list.add(1);
-        list.add(new int[] { 10, 12 });
-        action.setCollection(list);
-
-        // beans
-        List collection2 = new ArrayList();
-        Bean bean1 = new Bean();
-
-        bean1.setStringField("str");
-        bean1.setBooleanField(true);
-        bean1.setCharField('s');
-        bean1.setDoubleField(10.1);
-        bean1.setFloatField(1.5f);
-        bean1.setIntField(10);
-        bean1.setLongField(100);
-        bean1.setEnumField(null);
-        bean1.setEnumBean(null);
-
-        Bean bean2 = new Bean();
-
-        bean2.setStringField("  ");
-        bean2.setBooleanField(false);
-        bean2.setFloatField(1.1f);
-        bean2.setDoubleField(2.2);
-        bean2.setEnumField(AnEnum.ValueC);
-        bean2.setEnumBean(AnEnumBean.Three);
-
-        // circular reference
-        bean1.setObjectField(bean2);
-        bean2.setObjectField(bean1);
-
-        collection2.add(bean1);
-        action.setCollection2(collection2);
-
-        // keep order in map
-        Map map = new LinkedHashMap();
-
-        map.put("a", 1);
-        map.put("c", new float[] { 1.0f, 2.0f });
-        action.setMap(map);
-
-        action.setFoo("foo");
-        // should be ignored, marked 'transient'
-        action.setBar("bar");
-
-        // date
-        Calendar calendar = Calendar.getInstance();
-        calendar.set(Calendar.YEAR, 1999);
-        calendar.set(Calendar.MONTH, Calendar.DECEMBER);
-        calendar.set(Calendar.DAY_OF_MONTH, 31);
-        calendar.set(Calendar.HOUR_OF_DAY, 11);
-        calendar.set(Calendar.MINUTE, 59);
-        calendar.set(Calendar.SECOND, 59);
-        action.setDate(calendar.getTime());
-        action.setDate2(calendar.getTime());
-
-        this.invocation.setAction(action);
-        result.setWrapWithComments(true);
-        result.execute(this.invocation);
-
-        String json = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-3.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    private void executeTest2Action(JSONResult result) throws Exception {
-        TestAction action = new TestAction();
-
-        // beans
-        Bean bean1 = new Bean();
-
-        bean1.setStringField("str");
-        bean1.setBooleanField(true);
-        bean1.setCharField('s');
-        bean1.setDoubleField(10.1);
-        bean1.setFloatField(1.5f);
-        bean1.setIntField(10);
-        bean1.setLongField(100);
-        bean1.setEnumField(AnEnum.ValueA);
-        bean1.setEnumBean(AnEnumBean.One);
-
-        // set root
-        action.setBean(bean1);
-        result.setRoot("bean");
-
-        stack.push(action);
-        this.invocation.setStack(stack);
-        this.invocation.setAction(action);
-
-        result.execute(this.invocation);
-    }
-
-    public void test2() throws Exception {
-        JSONResult result = new JSONResult();
-
-        executeTest2Action(result);
-        String json = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-2.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    public void testJSONP() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setCallbackParameter("callback");
-        request.addParameter("callback", "exec");
-
-        executeTest2Action(result);
-        String json = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("jsonp-1.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    public void testNoCache() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setNoCache(true);
-
-        executeTest2Action(result);
-
-        assertEquals("no-cache", response.getHeader("Cache-Control"));
-        assertEquals("0", response.getHeader("Expires"));
-        assertEquals("No-cache", response.getHeader("Pragma"));
-    }
-
-    public void testContentType() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setContentType("some_super_content");
-
-        executeTest2Action(result);
-
-        assertEquals("some_super_content;charset=ISO-8859-1", response.getContentType());
-    }
-
-    public void testStatusCode() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setStatusCode(HttpServletResponse.SC_CONTINUE);
-
-        executeTest2Action(result);
-
-        assertEquals(HttpServletResponse.SC_CONTINUE, response.getStatus());
-    }
-
-    /**
-     * Repeats test2 but with the Enum serialized as a bean
-     */
-    public void test2WithEnumBean() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setEnumAsBean(true);
-
-        executeTest2Action(result);
-
-        String json = response.getContentAsString();
-
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-2-enum.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    /**
-     * Ensures that properties of given root object are read as shallow
-     * (non-recursive) unless specifically included.
-     */
-    public void testIncludeProperties() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setIncludeProperties("foo");
-        TestAction action = new TestAction();
-        action.setFoo("fooValue");
-        action.setBean(new Bean());
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String json = response.getContentAsString();
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-9.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    public void testIncludePropertiesWithList() throws Exception {
-        JSONResult result = new JSONResult();
-        result.setIncludeProperties("^list\\[\\d+\\]\\.booleanField");
-        TestAction action = new TestAction();
-
-        List list = new ArrayList();
-
-        list.add(new Bean());
-        list.add(new Bean());
-        list.add(new Bean());
-
-        action.setList(list);
-
-        this.invocation.setAction(action);
-        result.execute(this.invocation);
-
-        String json = response.getContentAsString();
-        String normalizedActual = TestUtils.normalize(json, true);
-        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-10.txt"));
-        assertEquals(normalizedExpected, normalizedActual);
-        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-        this.response = new MockHttpServletResponse();
-        this.request = new MockHttpServletRequest();
-        this.request.setRequestURI("http://sumeruri");
-        this.context = ActionContext.getContext();
-        this.context.put(StrutsStatics.HTTP_RESPONSE, this.response);
-        this.context.put(StrutsStatics.HTTP_REQUEST, this.request);
-        this.stack = context.getValueStack();
-        this.servletContext = new MockServletContext();
-        this.context.put(StrutsStatics.SERVLET_CONTEXT, this.servletContext);
-        this.invocation = new MockActionInvocation();
-        this.invocation.setInvocationContext(this.context);
-    }
-}
+/*
+ + * $Id$
+ + *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.struts2.StrutsStatics;
+import org.apache.struts2.StrutsTestCase;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.mock.web.MockServletContext;
+
+import com.opensymphony.xwork2.ActionContext;
+import com.opensymphony.xwork2.mock.MockActionInvocation;
+import com.opensymphony.xwork2.util.ValueStack;
+
+/**
+ * JSONResultTest
+ */
+public class JSONResultTest extends StrutsTestCase {
+    MockActionInvocation invocation;
+    MockHttpServletResponse response;
+    MockServletContext servletContext;
+    ActionContext context;
+    ValueStack stack;
+    MockHttpServletRequest request;
+
+    public void testJSONUtilNPEOnNullMehtod() {
+        Map map = new HashMap();
+        map.put("createtime", new Date());
+        try {
+            JSONUtil.serialize(map);
+        } catch (JSONException e) {
+            fail(e.getMessage());
+        }
+    }
+
+    public void testJSONWriterEndlessLoopOnExludedProperties() throws JSONException {
+        Pattern all = Pattern.compile(".*");
+
+        JSONWriter writer = new JSONWriter();
+        writer.write(Arrays.asList("a", "b"), Arrays.asList(all), null, false);
+    }
+
+    public void testSMDDisabledSMD() throws Exception {
+        JSONResult result = new JSONResult();
+        SMDActionTest1 action = new SMDActionTest1();
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String smd = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(smd, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-8.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+    }
+
+    public void testSMDDefault() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setEnableSMD(true);
+        SMDActionTest1 action = new SMDActionTest1();
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String smd = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(smd, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-1.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    public void testSMDDefaultAnnotations() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setEnableSMD(true);
+        SMDActionTest2 action = new SMDActionTest2();
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String smd = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(smd, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("smd-2.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    public void testExcludeNullPropeties() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setExcludeNullProperties(true);
+        TestAction action = new TestAction();
+        action.setFoo("fool");
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String smd = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(smd, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("nulls-1.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+    }
+
+    public void testWrapPrefix() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setWrapPrefix("_prefix_");
+        TestAction2 action = new TestAction2();
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String out = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(out, true);
+        String normalizedExpected = "_prefix_{\"name\":\"name\"}";
+        assertEquals(normalizedExpected, normalizedActual);
+    }
+
+    public void testSuffix() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setWrapSuffix("_suffix_");
+        TestAction2 action = new TestAction2();
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String out = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(out, true);
+        String normalizedExpected = "{\"name\":\"name\"}_suffix_";
+        assertEquals(normalizedExpected, normalizedActual);
+    }
+
+    public void testPrefixAndSuffix() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setWrapPrefix("_prefix_");
+        result.setWrapSuffix("_suffix_");
+        TestAction2 action = new TestAction2();
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String out = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(out, true);
+        String normalizedExpected = "_prefix_{\"name\":\"name\"}_suffix_";
+        assertEquals(normalizedExpected, normalizedActual);
+    }
+
+    public void testPrefix() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setExcludeNullProperties(true);
+        result.setPrefix(true);
+        TestAction action = new TestAction();
+        action.setFoo("fool");
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String smd = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(smd, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("prefix-1.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+    }
+
+    @SuppressWarnings("unchecked")
+    public void test() throws Exception {
+        JSONResult result = new JSONResult();
+
+        TestAction action = new TestAction();
+
+        // test scape characters
+        action.setArray(new String[] { "a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t" });
+
+        List list = new ArrayList();
+
+        list.add("b");
+        list.add(1);
+        list.add(new int[] { 10, 12 });
+        action.setCollection(list);
+
+        // beans
+        List collection2 = new ArrayList();
+        Bean bean1 = new Bean();
+
+        bean1.setBigDecimal(new BigDecimal("111111.111111"));
+        bean1.setBigInteger(new BigInteger("111111111111"));
+        bean1.setStringField("str");
+        bean1.setBooleanField(true);
+        bean1.setCharField('s');
+        bean1.setDoubleField(10.1);
+        bean1.setFloatField(1.5f);
+        bean1.setIntField(10);
+        bean1.setLongField(100);
+        bean1.setEnumField(AnEnum.ValueA);
+        bean1.setEnumBean(AnEnumBean.One);
+
+        Bean bean2 = new Bean();
+
+        bean2.setStringField("  ");
+        bean2.setBooleanField(false);
+        bean2.setFloatField(1.1f);
+        bean2.setDoubleField(2.2);
+        bean2.setEnumField(AnEnum.ValueB);
+        bean2.setEnumBean(AnEnumBean.Two);
+
+        // circular reference
+        bean1.setObjectField(bean2);
+        bean2.setObjectField(bean1);
+
+        collection2.add(bean1);
+        action.setCollection2(collection2);
+
+        // keep order in map
+        Map map = new LinkedHashMap();
+
+        map.put("a", 1);
+        map.put("c", new float[] { 1.0f, 2.0f });
+        action.setMap(map);
+
+        action.setFoo("foo");
+        // should be ignored, marked 'transient'
+        action.setBar("bar");
+
+        // date
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.YEAR, 1999);
+        calendar.set(Calendar.MONTH, Calendar.DECEMBER);
+        calendar.set(Calendar.DAY_OF_MONTH, 31);
+        calendar.set(Calendar.HOUR_OF_DAY, 11);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        action.setDate(calendar.getTime());
+        action.setDate2(calendar.getTime());
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String json = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testHierarchy() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setIgnoreHierarchy(false);
+
+        TestAction3 action = new TestAction3();
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String json = response.getContentAsString();
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-4.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    @SuppressWarnings("unchecked")
+    public void testCommentWrap() throws Exception {
+        JSONResult result = new JSONResult();
+
+        TestAction action = new TestAction();
+
+        // test scape characters
+        action.setArray(new String[] { "a", "a", "\"", "\\", "/", "\b", "\f", "\n", "\r", "\t" });
+
+        List list = new ArrayList();
+
+        list.add("b");
+        list.add(1);
+        list.add(new int[] { 10, 12 });
+        action.setCollection(list);
+
+        // beans
+        List collection2 = new ArrayList();
+        Bean bean1 = new Bean();
+
+        bean1.setStringField("str");
+        bean1.setBooleanField(true);
+        bean1.setCharField('s');
+        bean1.setDoubleField(10.1);
+        bean1.setFloatField(1.5f);
+        bean1.setIntField(10);
+        bean1.setLongField(100);
+        bean1.setEnumField(null);
+        bean1.setEnumBean(null);
+
+        Bean bean2 = new Bean();
+
+        bean2.setStringField("  ");
+        bean2.setBooleanField(false);
+        bean2.setFloatField(1.1f);
+        bean2.setDoubleField(2.2);
+        bean2.setEnumField(AnEnum.ValueC);
+        bean2.setEnumBean(AnEnumBean.Three);
+
+        // circular reference
+        bean1.setObjectField(bean2);
+        bean2.setObjectField(bean1);
+
+        collection2.add(bean1);
+        action.setCollection2(collection2);
+
+        // keep order in map
+        Map map = new LinkedHashMap();
+
+        map.put("a", 1);
+        map.put("c", new float[] { 1.0f, 2.0f });
+        action.setMap(map);
+
+        action.setFoo("foo");
+        // should be ignored, marked 'transient'
+        action.setBar("bar");
+
+        // date
+        Calendar calendar = Calendar.getInstance();
+        calendar.set(Calendar.YEAR, 1999);
+        calendar.set(Calendar.MONTH, Calendar.DECEMBER);
+        calendar.set(Calendar.DAY_OF_MONTH, 31);
+        calendar.set(Calendar.HOUR_OF_DAY, 11);
+        calendar.set(Calendar.MINUTE, 59);
+        calendar.set(Calendar.SECOND, 59);
+        action.setDate(calendar.getTime());
+        action.setDate2(calendar.getTime());
+
+        this.invocation.setAction(action);
+        result.setWrapWithComments(true);
+        result.execute(this.invocation);
+
+        String json = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-3.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    private void executeTest2Action(JSONResult result) throws Exception {
+        TestAction action = new TestAction();
+
+        // beans
+        Bean bean1 = new Bean();
+
+        bean1.setStringField("str");
+        bean1.setBooleanField(true);
+        bean1.setCharField('s');
+        bean1.setDoubleField(10.1);
+        bean1.setFloatField(1.5f);
+        bean1.setIntField(10);
+        bean1.setLongField(100);
+        bean1.setEnumField(AnEnum.ValueA);
+        bean1.setEnumBean(AnEnumBean.One);
+
+        // set root
+        action.setBean(bean1);
+        result.setRoot("bean");
+
+        stack.push(action);
+        this.invocation.setStack(stack);
+        this.invocation.setAction(action);
+
+        result.execute(this.invocation);
+    }
+
+    public void test2() throws Exception {
+        JSONResult result = new JSONResult();
+
+        executeTest2Action(result);
+        String json = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-2.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    public void testJSONP() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setCallbackParameter("callback");
+        request.addParameter("callback", "exec");
+
+        executeTest2Action(result);
+        String json = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("jsonp-1.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    public void testNoCache() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setNoCache(true);
+
+        executeTest2Action(result);
+
+        assertEquals("no-cache", response.getHeader("Cache-Control"));
+        assertEquals("0", response.getHeader("Expires"));
+        assertEquals("No-cache", response.getHeader("Pragma"));
+    }
+
+    public void testContentType() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setContentType("some_super_content");
+
+        executeTest2Action(result);
+
+        assertEquals("some_super_content;charset=ISO-8859-1", response.getContentType());
+    }
+
+    public void testStatusCode() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setStatusCode(HttpServletResponse.SC_CONTINUE);
+
+        executeTest2Action(result);
+
+        assertEquals(HttpServletResponse.SC_CONTINUE, response.getStatus());
+    }
+
+    /**
+     * Repeats test2 but with the Enum serialized as a bean
+     */
+    public void test2WithEnumBean() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setEnumAsBean(true);
+
+        executeTest2Action(result);
+
+        String json = response.getContentAsString();
+
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-2-enum.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    /**
+     * Ensures that properties of given root object are read as shallow
+     * (non-recursive) unless specifically included.
+     */
+    public void testIncludeProperties() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setIncludeProperties("foo");
+        TestAction action = new TestAction();
+        action.setFoo("fooValue");
+        action.setBean(new Bean());
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String json = response.getContentAsString();
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-9.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    public void testIncludePropertiesWithList() throws Exception {
+        JSONResult result = new JSONResult();
+        result.setIncludeProperties("^list\\[\\d+\\]\\.booleanField");
+        TestAction action = new TestAction();
+
+        List list = new ArrayList();
+
+        list.add(new Bean());
+        list.add(new Bean());
+        list.add(new Bean());
+
+        action.setList(list);
+
+        this.invocation.setAction(action);
+        result.execute(this.invocation);
+
+        String json = response.getContentAsString();
+        String normalizedActual = TestUtils.normalize(json, true);
+        String normalizedExpected = TestUtils.normalize(JSONResultTest.class.getResource("json-10.txt"));
+        assertEquals(normalizedExpected, normalizedActual);
+        assertEquals("application/json;charset=ISO-8859-1", response.getContentType());
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.response = new MockHttpServletResponse();
+        this.request = new MockHttpServletRequest();
+        this.request.setRequestURI("http://sumeruri");
+        this.context = ActionContext.getContext();
+        this.context.put(StrutsStatics.HTTP_RESPONSE, this.response);
+        this.context.put(StrutsStatics.HTTP_REQUEST, this.request);
+        this.stack = context.getValueStack();
+        this.servletContext = new MockServletContext();
+        this.context.put(StrutsStatics.SERVLET_CONTEXT, this.servletContext);
+        this.invocation = new MockActionInvocation();
+        this.invocation.setInvocationContext(this.context);
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONResultTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONResultTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONUtilTest.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONUtilTest.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONUtilTest.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONUtilTest.java Wed Jul 29 22:44:26 2009
@@ -1,46 +1,66 @@
-package org.apache.struts2.json;
-
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-public class JSONUtilTest extends TestCase {
-
-    /**
-     * Asserts that a bean can be serialized to JSON and restored as a map
-     */
-    public void testSerializeDeserialize() throws Exception {
-        Bean bean1 = new Bean();
-
-        bean1.setStringField("str");
-        bean1.setBooleanField(true);
-        bean1.setCharField('s');
-        bean1.setDoubleField(10.1);
-        bean1.setFloatField(1.5f);
-        bean1.setIntField(10);
-        bean1.setLongField(100);
-        bean1.setEnumField(AnEnum.ValueA);
-        bean1.setEnumBean(AnEnumBean.Two);
-
-        String json = JSONUtil.serialize(bean1);
-
-        Map result = (Map) JSONUtil.deserialize(json);
-        assertEquals("str", result.get("stringField"));
-        assertEquals(true, result.get("booleanField"));
-        assertEquals("s", result.get("charField")); // note: this is a
-                                                            // String
-        assertEquals(10.1, result.get("doubleField"));
-        assertEquals(1.5, result.get("floatField")); // note: this is a
-                                                            // Double
-        assertEquals(10L, result.get("intField")); // note: this is a
-                                                            // Long
-        assertEquals(AnEnum.ValueA, AnEnum.valueOf((String) result.get("enumField"))); // note:
-                                                                                        // this
-                                                                                        // is a
-                                                                                        // String
-        assertEquals(AnEnumBean.Two, AnEnumBean.valueOf((String) result.get("enumBean"))); // note:
-                                                                                            // this
-                                                                                            // is a
-                                                                                            // String
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+public class JSONUtilTest extends TestCase {
+
+    /**
+     * Asserts that a bean can be serialized to JSON and restored as a map
+     */
+    public void testSerializeDeserialize() throws Exception {
+        Bean bean1 = new Bean();
+
+        bean1.setStringField("str");
+        bean1.setBooleanField(true);
+        bean1.setCharField('s');
+        bean1.setDoubleField(10.1);
+        bean1.setFloatField(1.5f);
+        bean1.setIntField(10);
+        bean1.setLongField(100);
+        bean1.setEnumField(AnEnum.ValueA);
+        bean1.setEnumBean(AnEnumBean.Two);
+
+        String json = JSONUtil.serialize(bean1);
+
+        Map result = (Map) JSONUtil.deserialize(json);
+        assertEquals("str", result.get("stringField"));
+        assertEquals(true, result.get("booleanField"));
+        assertEquals("s", result.get("charField")); // note: this is a
+                                                            // String
+        assertEquals(10.1, result.get("doubleField"));
+        assertEquals(1.5, result.get("floatField")); // note: this is a
+                                                            // Double
+        assertEquals(10L, result.get("intField")); // note: this is a
+                                                            // Long
+        assertEquals(AnEnum.ValueA, AnEnum.valueOf((String) result.get("enumField"))); // note:
+                                                                                        // this
+                                                                                        // is a
+                                                                                        // String
+        assertEquals(AnEnumBean.Two, AnEnumBean.valueOf((String) result.get("enumBean"))); // note:
+                                                                                            // this
+                                                                                            // is a
+                                                                                            // String
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONUtilTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/JSONUtilTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/OtherBean.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/OtherBean.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/OtherBean.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/OtherBean.java Wed Jul 29 22:44:26 2009
@@ -1,97 +1,97 @@
-/*
- * $Id$
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.struts2.json;
-
-public class OtherBean {
-    private int primitiveInt;
-
-    private Integer intField;
-    private Boolean booleanField;
-    private Character charField;
-    private Long longField;
-    private Float floatField;
-    private Double doubleField;
-    private Byte byteField;
-
-    public Boolean isBooleanField() {
-        return booleanField;
-    }
-
-    public void setBooleanField(Boolean booleanField) {
-        this.booleanField = booleanField;
-    }
-
-    public Byte getByteField() {
-        return byteField;
-    }
-
-    public void setByteField(Byte byteField) {
-        this.byteField = byteField;
-    }
-
-    public Character getCharField() {
-        return charField;
-    }
-
-    public void setCharField(Character charField) {
-        this.charField = charField;
-    }
-
-    public Double getDoubleField() {
-        return doubleField;
-    }
-
-    public void setDoubleField(Double doubleField) {
-        this.doubleField = doubleField;
-    }
-
-    public Float getFloatField() {
-        return floatField;
-    }
-
-    public void setFloatField(Float floatField) {
-        this.floatField = floatField;
-    }
-
-    public Integer getIntField() {
-        return intField;
-    }
-
-    public void setIntField(Integer intField) {
-        this.intField = intField;
-    }
-
-    public Long getLongField() {
-        return longField;
-    }
-
-    public void setLongField(Long longField) {
-        this.longField = longField;
-    }
-
-    public int getPrimitiveInt() {
-        return primitiveInt;
-    }
-
-    public void setPrimitiveInt(int primitiveInt) {
-        this.primitiveInt = primitiveInt;
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+public class OtherBean {
+    private int primitiveInt;
+
+    private Integer intField;
+    private Boolean booleanField;
+    private Character charField;
+    private Long longField;
+    private Float floatField;
+    private Double doubleField;
+    private Byte byteField;
+
+    public Boolean isBooleanField() {
+        return booleanField;
+    }
+
+    public void setBooleanField(Boolean booleanField) {
+        this.booleanField = booleanField;
+    }
+
+    public Byte getByteField() {
+        return byteField;
+    }
+
+    public void setByteField(Byte byteField) {
+        this.byteField = byteField;
+    }
+
+    public Character getCharField() {
+        return charField;
+    }
+
+    public void setCharField(Character charField) {
+        this.charField = charField;
+    }
+
+    public Double getDoubleField() {
+        return doubleField;
+    }
+
+    public void setDoubleField(Double doubleField) {
+        this.doubleField = doubleField;
+    }
+
+    public Float getFloatField() {
+        return floatField;
+    }
+
+    public void setFloatField(Float floatField) {
+        this.floatField = floatField;
+    }
+
+    public Integer getIntField() {
+        return intField;
+    }
+
+    public void setIntField(Integer intField) {
+        this.intField = intField;
+    }
+
+    public Long getLongField() {
+        return longField;
+    }
+
+    public void setLongField(Long longField) {
+        this.longField = longField;
+    }
+
+    public int getPrimitiveInt() {
+        return primitiveInt;
+    }
+
+    public void setPrimitiveInt(int primitiveInt) {
+        this.primitiveInt = primitiveInt;
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/OtherBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/OtherBean.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest1.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest1.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest1.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest1.java Wed Jul 29 22:44:26 2009
@@ -1,3 +1,23 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.struts2.json;
 
 import java.util.List;

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest1.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest1.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest2.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest2.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest2.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest2.java Wed Jul 29 22:44:26 2009
@@ -1,3 +1,23 @@
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
 package org.apache.struts2.json;
 
 import org.apache.struts2.json.annotations.SMD;

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDActionTest2.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDMethodInterfaceTest.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDMethodInterfaceTest.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDMethodInterfaceTest.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDMethodInterfaceTest.java Wed Jul 29 22:44:26 2009
@@ -1,175 +1,195 @@
-package org.apache.struts2.json;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import junit.framework.TestCase;
-
-import org.apache.struts2.json.annotations.SMDMethod;
-
-/**
- * Tests that the SMDMethod annotation can be found in interfaces when
- * ignoreSMDMethodInterface is false
- */
-public class SMDMethodInterfaceTest extends TestCase {
-
-    public interface InterfaceA {
-        String getA();
-    }
-
-    public interface InterfaceB {
-        @SMDMethod
-        String getB();
-    }
-
-    public interface InterfaceC {
-        String getC();
-    }
-
-    public interface InterfaceD {
-        String getD();
-    }
-
-    public interface InterfaceE {
-        String getE();
-    }
-
-    public static class ClassA extends ClassB implements InterfaceA {
-
-        private String a;
-        private String z;
-
-        public ClassA(String a, String b, String c, String d, String e, String x, String y, String z) {
-            super(b, c, d, e, x, y);
-            this.a = a;
-            this.z = z;
-        }
-
-        public String getA() {
-            return a;
-        }
-
-        @SMDMethod
-        public String getZ() {
-            return z;
-        }
-    }
-
-    public static class ClassB extends ClassC implements InterfaceB, InterfaceC {
-
-        private String b;
-        private String c;
-        private String y;
-
-        public ClassB(String b, String c, String d, String e, String x, String y) {
-            super(d, e, x);
-            this.b = b;
-            this.c = c;
-            this.y = y;
-        }
-
-        public String getC() {
-            return c;
-        }
-
-        public String getB() {
-            return b;
-        }
-
-        public String getY() {
-            return y;
-        }
-    }
-
-    public static class ClassC implements InterfaceD, InterfaceE {
-
-        private String d;
-        private String e;
-        private String x;
-
-        public ClassC(String d, String e, String x) {
-            this.d = d;
-            this.e = e;
-            this.x = x;
-        }
-
-        public String getD() {
-            return d;
-        }
-
-        public String getE() {
-            return e;
-        }
-
-        @SMDMethod
-        public String getX() {
-            return x;
-        }
-    }
-
-    /**
-     * Asserts that the SMDMethod annotation is only detected on the classes
-     * when ignoreSMDMethodInterfaces is true
-     */
-    public void testBaseClassOnly() {
-        Method[] smdMethodsA = JSONUtil.listSMDMethods(ClassA.class, true);
-        assertEquals(2, smdMethodsA.length);
-        assertEquals("getZ", smdMethodsA[0].getName());
-        assertEquals("getX", smdMethodsA[1].getName());
-
-        Method[] smdMethodsB = JSONUtil.listSMDMethods(ClassB.class, true);
-        assertEquals(1, smdMethodsB.length);
-        assertEquals("getX", smdMethodsB[0].getName());
-
-        Method[] smdMethodsC = JSONUtil.listSMDMethods(ClassC.class, true);
-        assertEquals(1, smdMethodsC.length);
-        assertEquals("getX", smdMethodsC[0].getName());
-    }
-
-    /**
-     * Asserts that the SMDMethod annotation is also detected on the interfaces
-     * and superclasses when ignoreSMDMethodInterfaces is false
-     */
-    public void testInterfaces() {
-        Method[] smdMethodsA = JSONUtil.listSMDMethods(ClassA.class, false);
-        assertEquals(3, smdMethodsA.length);
-        assertEquals("getZ", smdMethodsA[0].getName());
-        assertEquals("getX", smdMethodsA[1].getName());
-        assertEquals("getB", smdMethodsA[2].getName());
-
-        Method[] smdMethodsB = JSONUtil.listSMDMethods(ClassB.class, false);
-        assertEquals(2, smdMethodsB.length);
-        assertEquals("getX", smdMethodsB[0].getName());
-        assertEquals("getB", smdMethodsB[1].getName());
-
-        Method[] smdMethodsC = JSONUtil.listSMDMethods(ClassC.class, false);
-        assertEquals(1, smdMethodsC.length);
-        assertEquals("getX", smdMethodsC[0].getName());
-    }
-
-    /**
-     * This is the important case: detects the SMDMethod annotation on a proxy
-     */
-    public void testWithProxy() {
-
-        InvocationHandler handler = new InvocationHandler() {
-            // dummy implementation
-            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-                return null;
-            }
-        };
-        // proxy is proxy to an impl of ClassA
-        InterfaceA proxy = (InterfaceA) Proxy.newProxyInstance(ClassA.class.getClassLoader(), new Class[] {
-                InterfaceA.class, InterfaceB.class, InterfaceC.class }, handler);
-
-        // first, without the recursion
-        Method[] smdMethodsA = JSONUtil.listSMDMethods(proxy.getClass(), true);
-        assertEquals(0, smdMethodsA.length);
-
-        // now with the recursion
-        Method[] smdMethodsB = JSONUtil.listSMDMethods(proxy.getClass(), false);
-        assertEquals(1, smdMethodsB.length);
-        assertEquals("getB", smdMethodsB[0].getName());
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+
+import junit.framework.TestCase;
+
+import org.apache.struts2.json.annotations.SMDMethod;
+
+/**
+ * Tests that the SMDMethod annotation can be found in interfaces when
+ * ignoreSMDMethodInterface is false
+ */
+public class SMDMethodInterfaceTest extends TestCase {
+
+    public interface InterfaceA {
+        String getA();
+    }
+
+    public interface InterfaceB {
+        @SMDMethod
+        String getB();
+    }
+
+    public interface InterfaceC {
+        String getC();
+    }
+
+    public interface InterfaceD {
+        String getD();
+    }
+
+    public interface InterfaceE {
+        String getE();
+    }
+
+    public static class ClassA extends ClassB implements InterfaceA {
+
+        private String a;
+        private String z;
+
+        public ClassA(String a, String b, String c, String d, String e, String x, String y, String z) {
+            super(b, c, d, e, x, y);
+            this.a = a;
+            this.z = z;
+        }
+
+        public String getA() {
+            return a;
+        }
+
+        @SMDMethod
+        public String getZ() {
+            return z;
+        }
+    }
+
+    public static class ClassB extends ClassC implements InterfaceB, InterfaceC {
+
+        private String b;
+        private String c;
+        private String y;
+
+        public ClassB(String b, String c, String d, String e, String x, String y) {
+            super(d, e, x);
+            this.b = b;
+            this.c = c;
+            this.y = y;
+        }
+
+        public String getC() {
+            return c;
+        }
+
+        public String getB() {
+            return b;
+        }
+
+        public String getY() {
+            return y;
+        }
+    }
+
+    public static class ClassC implements InterfaceD, InterfaceE {
+
+        private String d;
+        private String e;
+        private String x;
+
+        public ClassC(String d, String e, String x) {
+            this.d = d;
+            this.e = e;
+            this.x = x;
+        }
+
+        public String getD() {
+            return d;
+        }
+
+        public String getE() {
+            return e;
+        }
+
+        @SMDMethod
+        public String getX() {
+            return x;
+        }
+    }
+
+    /**
+     * Asserts that the SMDMethod annotation is only detected on the classes
+     * when ignoreSMDMethodInterfaces is true
+     */
+    public void testBaseClassOnly() {
+        Method[] smdMethodsA = JSONUtil.listSMDMethods(ClassA.class, true);
+        assertEquals(2, smdMethodsA.length);
+        assertEquals("getZ", smdMethodsA[0].getName());
+        assertEquals("getX", smdMethodsA[1].getName());
+
+        Method[] smdMethodsB = JSONUtil.listSMDMethods(ClassB.class, true);
+        assertEquals(1, smdMethodsB.length);
+        assertEquals("getX", smdMethodsB[0].getName());
+
+        Method[] smdMethodsC = JSONUtil.listSMDMethods(ClassC.class, true);
+        assertEquals(1, smdMethodsC.length);
+        assertEquals("getX", smdMethodsC[0].getName());
+    }
+
+    /**
+     * Asserts that the SMDMethod annotation is also detected on the interfaces
+     * and superclasses when ignoreSMDMethodInterfaces is false
+     */
+    public void testInterfaces() {
+        Method[] smdMethodsA = JSONUtil.listSMDMethods(ClassA.class, false);
+        assertEquals(3, smdMethodsA.length);
+        assertEquals("getZ", smdMethodsA[0].getName());
+        assertEquals("getX", smdMethodsA[1].getName());
+        assertEquals("getB", smdMethodsA[2].getName());
+
+        Method[] smdMethodsB = JSONUtil.listSMDMethods(ClassB.class, false);
+        assertEquals(2, smdMethodsB.length);
+        assertEquals("getX", smdMethodsB[0].getName());
+        assertEquals("getB", smdMethodsB[1].getName());
+
+        Method[] smdMethodsC = JSONUtil.listSMDMethods(ClassC.class, false);
+        assertEquals(1, smdMethodsC.length);
+        assertEquals("getX", smdMethodsC[0].getName());
+    }
+
+    /**
+     * This is the important case: detects the SMDMethod annotation on a proxy
+     */
+    public void testWithProxy() {
+
+        InvocationHandler handler = new InvocationHandler() {
+            // dummy implementation
+            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+                return null;
+            }
+        };
+        // proxy is proxy to an impl of ClassA
+        InterfaceA proxy = (InterfaceA) Proxy.newProxyInstance(ClassA.class.getClassLoader(), new Class[] {
+                InterfaceA.class, InterfaceB.class, InterfaceC.class }, handler);
+
+        // first, without the recursion
+        Method[] smdMethodsA = JSONUtil.listSMDMethods(proxy.getClass(), true);
+        assertEquals(0, smdMethodsA.length);
+
+        // now with the recursion
+        Method[] smdMethodsB = JSONUtil.listSMDMethods(proxy.getClass(), false);
+        assertEquals(1, smdMethodsB.length);
+        assertEquals("getB", smdMethodsB[0].getName());
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDMethodInterfaceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SMDMethodInterfaceTest.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SimpleValue.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SimpleValue.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SimpleValue.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SimpleValue.java Wed Jul 29 22:44:26 2009
@@ -1,17 +1,37 @@
-package org.apache.struts2.json;
-
-public class SimpleValue {
-
-    private String value;
-
-    public SimpleValue() {
-    }
-
-    public String getValue() {
-        return value;
-    }
-
-    public void setValue(String v) {
-        this.value = v;
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+public class SimpleValue {
+
+    private String value;
+
+    public SimpleValue() {
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String v) {
+        this.value = v;
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SimpleValue.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/SimpleValue.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction.java Wed Jul 29 22:44:26 2009
@@ -1,188 +1,188 @@
-/*
- * $Id: TestAction.java 471756 2006-11-06 15:01:43Z husted $
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.struts2.json;
-
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.struts2.json.annotations.JSON;
-
-import com.opensymphony.xwork2.Action;
-import com.opensymphony.xwork2.ActionSupport;
-
-/**
- */
-@SuppressWarnings("unchecked")
-public class TestAction extends ActionSupport {
-    private static final long serialVersionUID = -8891365561914451494L;
-    private List collection;
-    private List collection2;
-    private Map map;
-    private String foo;
-    private String result;
-    private String[] array;
-    private Bean[] beanArray;
-    private int[] intArray;
-    private List list;
-    private String bar;
-    private String nogetter;
-    private Date date2;
-    private Bean bean;
-    private Date date;
-    private String foo2 = null;
-
-    public Bean getBean() {
-        return this.bean;
-    }
-
-    public void setBean(Bean bean) {
-        this.bean = bean;
-    }
-
-    public List getCollection() {
-        return this.collection;
-    }
-
-    public void setCollection(List collection) {
-        this.collection = collection;
-    }
-
-    public List getCollection2() {
-        return this.collection2;
-    }
-
-    public void setCollection2(List collection2) {
-        this.collection2 = collection2;
-    }
-
-    public Map getMap() {
-        return this.map;
-    }
-
-    public void setMap(Map map) {
-        this.map = map;
-    }
-
-    public String getFoo() {
-        return this.foo;
-    }
-
-    public void setFoo(String foo) {
-        this.foo = foo;
-    }
-
-    public String getResult() {
-        return this.result;
-    }
-
-    public void setResult(String result) {
-        this.result = result;
-    }
-
-    public String[] getArray() {
-        return this.array;
-    }
-
-    public void setArray(String[] array) {
-        this.array = array;
-    }
-
-    public List getList() {
-        return this.list;
-    }
-
-    public void setList(List list) {
-        this.list = list;
-    }
-
-    @Override
-    public String execute() throws Exception {
-        if (this.result == null) {
-            this.result = Action.SUCCESS;
-        }
-
-        return this.result;
-    }
-
-    public String doInput() throws Exception {
-        return INPUT;
-    }
-
-    public void setBar(String bar) {
-        this.bar = bar;
-    }
-
-    @JSON(serialize = false)
-    public String getBar() {
-        return this.bar;
-    }
-
-    public void setNogetter(String nogetter) {
-        this.nogetter = nogetter;
-    }
-
-    @JSON(serialize = false)
-    public int[] getIntArray() {
-        return this.intArray;
-    }
-
-    public void setIntArray(int[] intArray) {
-        this.intArray = intArray;
-    }
-
-    @JSON(serialize = false)
-    public Bean[] getBeanArray() {
-        return this.beanArray;
-    }
-
-    public void setBeanArray(Bean[] beanArray) {
-        this.beanArray = beanArray;
-    }
-
-    public Date getDate() {
-        return this.date;
-    }
-
-    public void setDate(Date date) {
-        this.date = date;
-    }
-
-    @JSON(format = "dd/MM/yy")
-    public Date getDate2() {
-        return this.date2;
-    }
-
-    @JSON(format = "dd/MM/yy")
-    public void setDate2(Date date2) {
-        this.date2 = date2;
-    }
-
-    @JSON(serialize = false)
-    public String getFoo2() {
-        return this.foo2;
-    }
-
-    @JSON(deserialize = false)
-    public void setFoo2(String foo2) {
-        this.foo2 = foo2;
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.struts2.json.annotations.JSON;
+
+import com.opensymphony.xwork2.Action;
+import com.opensymphony.xwork2.ActionSupport;
+
+/**
+ */
+@SuppressWarnings("unchecked")
+public class TestAction extends ActionSupport {
+    private static final long serialVersionUID = -8891365561914451494L;
+    private List collection;
+    private List collection2;
+    private Map map;
+    private String foo;
+    private String result;
+    private String[] array;
+    private Bean[] beanArray;
+    private int[] intArray;
+    private List list;
+    private String bar;
+    private String nogetter;
+    private Date date2;
+    private Bean bean;
+    private Date date;
+    private String foo2 = null;
+
+    public Bean getBean() {
+        return this.bean;
+    }
+
+    public void setBean(Bean bean) {
+        this.bean = bean;
+    }
+
+    public List getCollection() {
+        return this.collection;
+    }
+
+    public void setCollection(List collection) {
+        this.collection = collection;
+    }
+
+    public List getCollection2() {
+        return this.collection2;
+    }
+
+    public void setCollection2(List collection2) {
+        this.collection2 = collection2;
+    }
+
+    public Map getMap() {
+        return this.map;
+    }
+
+    public void setMap(Map map) {
+        this.map = map;
+    }
+
+    public String getFoo() {
+        return this.foo;
+    }
+
+    public void setFoo(String foo) {
+        this.foo = foo;
+    }
+
+    public String getResult() {
+        return this.result;
+    }
+
+    public void setResult(String result) {
+        this.result = result;
+    }
+
+    public String[] getArray() {
+        return this.array;
+    }
+
+    public void setArray(String[] array) {
+        this.array = array;
+    }
+
+    public List getList() {
+        return this.list;
+    }
+
+    public void setList(List list) {
+        this.list = list;
+    }
+
+    @Override
+    public String execute() throws Exception {
+        if (this.result == null) {
+            this.result = Action.SUCCESS;
+        }
+
+        return this.result;
+    }
+
+    public String doInput() throws Exception {
+        return INPUT;
+    }
+
+    public void setBar(String bar) {
+        this.bar = bar;
+    }
+
+    @JSON(serialize = false)
+    public String getBar() {
+        return this.bar;
+    }
+
+    public void setNogetter(String nogetter) {
+        this.nogetter = nogetter;
+    }
+
+    @JSON(serialize = false)
+    public int[] getIntArray() {
+        return this.intArray;
+    }
+
+    public void setIntArray(int[] intArray) {
+        this.intArray = intArray;
+    }
+
+    @JSON(serialize = false)
+    public Bean[] getBeanArray() {
+        return this.beanArray;
+    }
+
+    public void setBeanArray(Bean[] beanArray) {
+        this.beanArray = beanArray;
+    }
+
+    public Date getDate() {
+        return this.date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+
+    @JSON(format = "dd/MM/yy")
+    public Date getDate2() {
+        return this.date2;
+    }
+
+    @JSON(format = "dd/MM/yy")
+    public void setDate2(Date date2) {
+        this.date2 = date2;
+    }
+
+    @JSON(serialize = false)
+    public String getFoo2() {
+        return this.foo2;
+    }
+
+    @JSON(deserialize = false)
+    public void setFoo2(String foo2) {
+        this.foo2 = foo2;
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction2.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction2.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction2.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction2.java Wed Jul 29 22:44:26 2009
@@ -1,7 +1,27 @@
-package org.apache.struts2.json;
-
-public class TestAction2 {
-    public String getName() {
-        return "name";
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+public class TestAction2 {
+    public String getName() {
+        return "name";
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction2.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction3.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction3.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction3.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction3.java Wed Jul 29 22:44:26 2009
@@ -1,7 +1,27 @@
-package org.apache.struts2.json;
-
-public class TestAction3 extends TestAction2 {
-    public String getName2() {
-        return "name";
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+public class TestAction3 extends TestAction2 {
+    public String getName2() {
+        return "name";
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction3.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction4.java
URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction4.java?rev=799110&r1=799109&r2=799110&view=diff
==============================================================================
--- struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction4.java (original)
+++ struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction4.java Wed Jul 29 22:44:26 2009
@@ -1,15 +1,35 @@
-package org.apache.struts2.json;
-
-public class TestAction4 {
-    private Bean bean;
-
-    public Bean getBean() {
-        if (this.bean == null)
-            this.bean = new Bean();
-        return this.bean;
-    }
-
-    public void setBean(Bean bean) {
-        this.bean = bean;
-    }
-}
+/*
+ * $Id$
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.struts2.json;
+
+public class TestAction4 {
+    private Bean bean;
+
+    public Bean getBean() {
+        if (this.bean == null)
+            this.bean = new Bean();
+        return this.bean;
+    }
+
+    public void setBean(Bean bean) {
+        this.bean = bean;
+    }
+}

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction4.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: struts/sandbox/trunk/struts2-json-plugin/src/test/java/org/apache/struts2/json/TestAction4.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message