http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java b/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java deleted file mode 100644 index 5bc0e65..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/transforms/ReaderObjectSwapTest.java +++ /dev/null @@ -1,494 +0,0 @@ -// *************************************************************************************************************************** -// * 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.juneau.transforms; - -import java.io.*; -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.http.*; -import org.apache.juneau.transform.*; -import org.apache.juneau.utils.*; -import org.junit.runner.*; -import org.junit.runners.*; - -/** - * Verifies that Reader and InputStream objects are serialized correctly. - * Note that these are one-way serializations and you're not guaranteed to produce parsable output. - */ -@RunWith(Parameterized.class) -@SuppressWarnings({"javadoc"}) -public class ReaderObjectSwapTest extends ComboSerializeTest { - - @Parameterized.Parameters - public static Collection<Object[]> getParameters() { - return Arrays.asList(new Object[][] { - { /* 0 */ - new ComboInput<PojoToSimpleReader>( - "PojoToSimpleReader", - PojoToSimpleReader.class, - new PojoToSimpleReader(), - /* Json */ "foo", - /* JsonT */ "foo", - /* JsonR */ "foo", - /* Xml */ "foo", - /* XmlT */ "foo", - /* XmlR */ "foo\n", - /* XmlNs */ "foo", - /* Html */ "foo", - /* HtmlT */ "foo", - /* HtmlR */ "foo", - /* Uon */ "foo", - /* UonT */ "foo", - /* UonR */ "foo", - /* UrlEnc */ "foo", - /* UrlEncT */ "foo", - /* UrlEncR */ "foo", - /* MsgPack */ "666F6F", - /* MsgPackT */ "666F6F", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo</j:value>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo</j:value>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foo</j:value>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 1 */ - new ComboInput<PojoToDynamicReader>( - "PojoToDynamicReader", - PojoToDynamicReader.class, - new PojoToDynamicReader("foo"), - /* Json */ "foo-json", - /* JsonT */ "foo-json", - /* JsonR */ "foo-json", - /* Xml */ "foo-xml", - /* XmlT */ "foo-xml", - /* XmlR */ "foo-xml\n", - /* XmlNs */ "foo-xml", - /* Html */ "foo-html", - /* HtmlT */ "foo-html", - /* HtmlR */ "foo-html", - /* Uon */ "foo-uon", - /* UonT */ "foo-uon", - /* UonR */ "foo-uon", - /* UrlEnc */ "foo-x-www-form-urlencoded", - /* UrlEncT */ "foo-x-www-form-urlencoded", - /* UrlEncR */ "foo-x-www-form-urlencoded", - /* MsgPack */ "666F6F2D6D73677061636B", - /* MsgPackT */ "666F6F2D6D73677061636B", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-xml</j:value>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-xml</j:value>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foo-xml</j:value>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 2 */ - new ComboInput<SometimesSwappedBean1>( - "SometimesSwappedBean1", - SometimesSwappedBean1.class, - new SometimesSwappedBean1("foo"), - /* Json */ "foo-application/json", - /* JsonT */ "foo-application/json", - /* JsonR */ "foo-application/json", - /* Xml */ "foo-text/xml", - /* XmlT */ "foo-text/xml", - /* XmlR */ "foo-text/xml\n", - /* XmlNs */ "foo-text/xml", - /* Html */ "<table><tr><td>f</td><td>foo</td></tr></table>", - /* HtmlT */ "<table><tr><td>f</td><td>foo</td></tr></table>", - /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>foo</td>\n\t</tr>\n</table>\n", - /* Uon */ "(f=foo)", - /* UonT */ "(f=foo)", - /* UonR */ "(\n\tf=foo\n)", - /* UrlEnc */ "f=foo", - /* UrlEncT */ "f=foo", - /* UrlEncR */ "f=foo", - /* MsgPack */ "81A166A3666F6F", - /* MsgPackT */ "81A166A3666F6F", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-text/xml+rdf</j:value>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<j:value>foo-text/xml+rdf</j:value>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <j:value>foo-text/xml+rdf</j:value>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 3 */ - new ComboInput<SometimesSwappedBean2>( - "SometimesSwappedBean2", - SometimesSwappedBean2.class, - new SometimesSwappedBean2("foo"), - /* Json */ "{f:'foo'}", - /* JsonT */ "{f:'foo'}", - /* JsonR */ "{\n\tf: 'foo'\n}", - /* Xml */ "<object><f>foo</f></object>", - /* XmlT */ "<object><f>foo</f></object>", - /* XmlR */ "<object>\n\t<f>foo</f>\n</object>\n", - /* XmlNs */ "<object><f>foo</f></object>", - /* Html */ "foo-text/html", - /* HtmlT */ "foo-text/html", - /* HtmlR */ "foo-text/html", - /* Uon */ "foo-text/uon", - /* UonT */ "foo-text/uon", - /* UonR */ "foo-text/uon", - /* UrlEnc */ "foo-application/x-www-form-urlencoded", - /* UrlEncT */ "foo-application/x-www-form-urlencoded", - /* UrlEncR */ "foo-application/x-www-form-urlencoded", - /* MsgPack */ "666F6F2D6F6374616C2F6D73677061636B", - /* MsgPackT */ "666F6F2D6F6374616C2F6D73677061636B", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>foo</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>foo</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>foo</jp:f>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 4 */ - new ComboInput<BeanWithSwappedField>( - "BeanWithSwappedField", - BeanWithSwappedField.class, - new BeanWithSwappedField("x"), - /* Json */ "{f:x-json}", - /* JsonT */ "{f:x-json}", - /* JsonR */ "{\n\tf: x-json\n}", - /* Xml */ "<object><f>x-xml</f></object>", - /* XmlT */ "<object><f>x-xml</f></object>", - /* XmlR */ "<object>\n\t<f>x-xml</f>\n</object>\n", - /* XmlNs */ "<object><f>x-xml</f></object>", - /* Html */ "<table><tr><td>f</td><td>x-html</td></tr></table>", - /* HtmlT */ "<table><tr><td>f</td><td>x-html</td></tr></table>", - /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>x-html</td>\n\t</tr>\n</table>\n", - /* Uon */ "(f=x-uon)", - /* UonT */ "(f=x-uon)", - /* UonR */ "(\n\tf=x-uon\n)", - /* UrlEnc */ "f=x-x-www-form-urlencoded", - /* UrlEncT */ "f=x-x-www-form-urlencoded", - /* UrlEncR */ "f=x-x-www-form-urlencoded", - /* MsgPack */ "81A166782D6D73677061636B", - /* MsgPackT */ "81A166782D6D73677061636B", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>x-xml</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>x-xml</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>x-xml</jp:f>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 5 */ - new ComboInput<BeanWithSwapped1dField>( - "BeanWithSwapped1dField", - BeanWithSwapped1dField.class, - new BeanWithSwapped1dField("x"), - /* Json */ "{f:[x1-json,x2-json,null]}", - /* JsonT */ "{f:[x1-json,x2-json,null]}", - /* JsonR */ "{\n\tf: [\n\t\tx1-json,\n\t\tx2-json,\n\t\tnull\n\t]\n}", - /* Xml */ "<object><f>x1-xmlx2-xml<null/></f></object>", - /* XmlT */ "<object><f>x1-xmlx2-xml<null/></f></object>", - /* XmlR */ "<object>\n\t<f>\n\t\tx1-xml\n\t\tx2-xml\n\t\t<null/>\n\t</f>\n</object>\n", - /* XmlNs */ "<object><f>x1-xmlx2-xml<null/></f></object>", - /* Html */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", - /* HtmlT */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", - /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<ul>\n\t\t\t\t<li>x1-html</li>\n\t\t\t\t<li>x2-html</li>\n\t\t\t\t<li><null/></li>\n\t\t\t</ul>\n\t\t</td>\n\t</tr>\n</table>\n", - /* Uon */ "(f=@(x1-uon,x2-uon,null))", - /* UonT */ "(f=@(x1-uon,x2-uon,null))", - /* UonR */ "(\n\tf=@(\n\t\tx1-uon,\n\t\tx2-uon,\n\t\tnull\n\t)\n)", - /* UrlEnc */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", - /* UrlEncT */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", - /* UrlEncR */ "f=@(\n\tx1-x-www-form-urlencoded,\n\tx2-x-www-form-urlencoded,\n\tnull\n)", - /* MsgPack */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", - /* MsgPackT */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>\n <rdf:Seq>\n <rdf:li>x1-xml</rdf:li>\n <rdf:li>x2-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 6 */ - new ComboInput<BeanWithSwappedNullField>( - "BeanWithSwappedNullField", - BeanWithSwappedNullField.class, - new BeanWithSwappedNullField(), - /* Json */ "{}", - /* JsonT */ "{}", - /* JsonR */ "{\n}", - /* Xml */ "<object/>", - /* XmlT */ "<object/>", - /* XmlR */ "<object/>\n", - /* XmlNs */ "<object/>", - /* Html */ "<table></table>", - /* HtmlT */ "<table></table>", - /* HtmlR */ "<table>\n</table>\n", - /* Uon */ "()", - /* UonT */ "()", - /* UonR */ "(\n)", - /* UrlEnc */ "", - /* UrlEncT */ "", - /* UrlEncR */ "", - /* MsgPack */ "80", - /* MsgPackT */ "80", - /* RdfXml */ "<rdf:RDF>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n</rdf:RDF>\n" - ) - }, - { /* 7 */ - new ComboInput<BeanWithSwappedListField>( - "BeanWithSwappedListField", - BeanWithSwappedListField.class, - new BeanWithSwappedListField("x"), - /* Json */ "{f:[x1-json,x2-json,null]}", - /* JsonT */ "{f:[x1-json,x2-json,null]}", - /* JsonR */ "{\n\tf: [\n\t\tx1-json,\n\t\tx2-json,\n\t\tnull\n\t]\n}", - /* Xml */ "<object><f>x1-xmlx2-xml<null/></f></object>", - /* XmlT */ "<object><f>x1-xmlx2-xml<null/></f></object>", - /* XmlR */ "<object>\n\t<f>\n\t\tx1-xml\n\t\tx2-xml\n\t\t<null/>\n\t</f>\n</object>\n", - /* XmlNs */ "<object><f>x1-xmlx2-xml<null/></f></object>", - /* Html */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", - /* HtmlT */ "<table><tr><td>f</td><td><ul><li>x1-html</li><li>x2-html</li><li><null/></li></ul></td></tr></table>", - /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<ul>\n\t\t\t\t<li>x1-html</li>\n\t\t\t\t<li>x2-html</li>\n\t\t\t\t<li><null/></li>\n\t\t\t</ul>\n\t\t</td>\n\t</tr>\n</table>\n", - /* Uon */ "(f=@(x1-uon,x2-uon,null))", - /* UonT */ "(f=@(x1-uon,x2-uon,null))", - /* UonR */ "(\n\tf=@(\n\t\tx1-uon,\n\t\tx2-uon,\n\t\tnull\n\t)\n)", - /* UrlEnc */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", - /* UrlEncT */ "f=@(x1-x-www-form-urlencoded,x2-x-www-form-urlencoded,null)", - /* UrlEncR */ "f=@(\n\tx1-x-www-form-urlencoded,\n\tx2-x-www-form-urlencoded,\n\tnull\n)", - /* MsgPack */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", - /* MsgPackT */ "81A1669378312D6D73677061636B78322D6D73677061636BC0", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li>x1-xml</rdf:li>\n<rdf:li>x2-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>\n <rdf:Seq>\n <rdf:li>x1-xml</rdf:li>\n <rdf:li>x2-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 8 */ - new ComboInput<BeanWithSwappedMapField>( - "BeanWithSwappedMapField", - BeanWithSwappedMapField.class, - new BeanWithSwappedMapField("x"), - /* Json */ "{f:{foo:x1-json,bar:null,null:x2-json}}", - /* JsonT */ "{f:{foo:x1-json,bar:null,null:x2-json}}", - /* JsonR */ "{\n\tf: {\n\t\tfoo: x1-json,\n\t\tbar: null,\n\t\tnull: x2-json\n\t}\n}", - /* Xml */ "<object><f><foo>x1-xml</foo><bar _type='null'/><_x0000_>x2-xml</_x0000_></f></object>", - /* XmlT */ "<object><f><foo>x1-xml</foo><bar t='null'/><_x0000_>x2-xml</_x0000_></f></object>", - /* XmlR */ "<object>\n\t<f>\n\t\t<foo>x1-xml</foo>\n\t\t<bar _type='null'/>\n\t\t<_x0000_>x2-xml</_x0000_>\n\t</f>\n</object>\n", - /* XmlNs */ "<object><f><foo>x1-xml</foo><bar _type='null'/><_x0000_>x2-xml</_x0000_></f></object>", - /* Html */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td>x1-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x2-html</td></tr></table></td></tr></table>", - /* HtmlT */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td>x1-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x2-html</td></tr></table></td></tr></table>", - /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t<td>x1-html</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t<td>x2-html</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n</table>\n", - /* Uon */ "(f=(foo=x1-uon,bar=null,null=x2-uon))", - /* UonT */ "(f=(foo=x1-uon,bar=null,null=x2-uon))", - /* UonR */ "(\n\tf=(\n\t\tfoo=x1-uon,\n\t\tbar=null,\n\t\tnull=x2-uon\n\t)\n)", - /* UrlEnc */ "f=(foo=x1-x-www-form-urlencoded,bar=null,null=x2-x-www-form-urlencoded)", - /* UrlEncT */ "f=(foo=x1-x-www-form-urlencoded,bar=null,null=x2-x-www-form-urlencoded)", - /* UrlEncR */ "f=(\n\tfoo=x1-x-www-form-urlencoded,\n\tbar=null,\n\tnull=x2-x-www-form-urlencoded\n)", - /* MsgPack */ "81A16683A3666F6F78312D6D73677061636BA3626172C0C078322D6D73677061636B", - /* MsgPackT */ "81A16683A3666F6F78312D6D73677061636BA3626172C0C078322D6D73677061636B", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo>x1-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x2-xml</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo>x1-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x2-xml</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f rdf:parseType='Resource'>\n <jp:foo>x1-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x2-xml</jp:_x0000_>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 9 */ - new ComboInput<BeanWithListBeanSwappedField>( - "BeanWithListBeanSwappedField", - BeanWithListBeanSwappedField.class, - new BeanWithListBeanSwappedField("x"), - /* Json */ "{f:[{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},null]}", - /* JsonT */ "{f:[{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},null]}", - /* JsonR */ "{\n\tf: [\n\t\t{\n\t\t\tf1: x1a-json,\n\t\t\tf2: [\n\t\t\t\tx2a-json,\n\t\t\t\tx2b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf4: [\n\t\t\t\tx4a-json,\n\t\t\t\tx4b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: x5a-json,\n\t\t\t\tbar: null,\n\t\t\t\tnull: x5c-json\n\t\t\t}\n\t\t},\n\t\tnull\n\t]\n}", - /* Xml */ "<object><f><object><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></object><null/></f></object>", - /* XmlT */ "<object><f><object><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar t='null'/><_x0000_>x5c-xml</_x0000_></f5></object><null/></f></object>", - /* XmlR */ "<object>\n\t<f>\n\t\t<object>\n\t\t\t<f1>x1a-xml</f1>\n\t\t\t<f2>\n\t\t\t\tx2a-xml\n\t\t\t\tx2b-xml\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f4>\n\t\t\t\tx4a-xml\n\t\t\t\tx4b-xml\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>x5a-xml</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>x5c-xml</_x0000_>\n\t\t\t</f5>\n\t\t</object>\n\t\t<null/>\n\t</f>\n</object>\n", - /* XmlNs */ "<object><f><object><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></object><null/></f></object>", - /* Html */ "<table><tr><td>f</td><td><table _type='array'><tr><th>f1</th><th>f2</th><th>f4</th><th>f5</th></tr><tr><td>x1a-html</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr><tr><null/></tr></table></td></tr></table>", - /* HtmlT */ "<table><tr><td>f</td><td><table t='array'><tr><th>f1</th><th>f2</th><th>f4</th><th>f5</th></tr><tr><td>x1a-html</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr><tr><null/></tr></table></td></tr></table>", - /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<table _type='array'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>f1</th>\n\t\t\t\t\t<th>f2</th>\n\t\t\t\t\t<th>f4</th>\n\t\t\t\t\t<th>f5</th>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>x1a-html</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>x2a-html</li>\n\t\t\t\t\t\t\t<li>x2b-html</li>\n\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t<li>x4a-html</li>\n\t\t\t\t\t\t\t<li>x4b-html</li>\n\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t</ul>\n\t\t\t\t\t</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t\t\t\t<td>x5a-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t<td>x5c-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t< /tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<null/>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n</table>\n", - /* Uon */ "(f=@((f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),null))", - /* UonT */ "(f=@((f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),null))", - /* UonR */ "(\n\tf=@(\n\t\t(\n\t\t\tf1=x1a-uon,\n\t\t\tf2=@(\n\t\t\t\tx2a-uon,\n\t\t\t\tx2b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf4=@(\n\t\t\t\tx4a-uon,\n\t\t\t\tx4b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=x5a-uon,\n\t\t\t\tbar=null,\n\t\t\t\tnull=x5c-uon\n\t\t\t)\n\t\t),\n\t\tnull\n\t)\n)", - /* UrlEnc */ "f=@((f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),null)", - /* UrlEncT */ "f=@((f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),null)", - /* UrlEncR */ "f=@(\n\t(\n\t\tf1=x1a-x-www-form-urlencoded,\n\t\tf2=@(\n\t\t\tx2a-x-www-form-urlencoded,\n\t\t\tx2b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf4=@(\n\t\t\tx4a-x-www-form-urlencoded,\n\t\t\tx4b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=x5a-x-www-form-urlencoded,\n\t\t\tbar=null,\n\t\t\tnull=x5c-x-www-form-urlencoded\n\t\t)\n\t),\n\tnull\n)", - /* MsgPack */ "81A1669284A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BC0", - /* MsgPackT */ "81A1669284A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BC0", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f>\n<rdf:Seq>\n<rdf:li rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f>\n <rdf:Seq>\n <rdf:li rdf:parseType='Resource'>\n <jp:f1>x1a-xml</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>x2a-xml</rdf:li>\n <rdf:li>x2b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f2>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>x4a-xml</rdf:li>\n <rdf:li>x4b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f4>\n <jp:f5 rdf:parseType='Resource'>\n <jp:foo>x5a-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x5c-xml</jp:_x0000_>\n </jp:f5>\n </rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - { /* 10 */ - new ComboInput<BeanWithMapBeanSwappedField>( - "BeanWithMapBeanSwappedField", - BeanWithMapBeanSwappedField.class, - new BeanWithMapBeanSwappedField("x"), - /* Json */ "{f:{foo:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},bar:null,null:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}}}}", - /* JsonT */ "{f:{foo:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}},bar:null,null:{f1:x1a-json,f2:[x2a-json,x2b-json,null],f4:[x4a-json,x4b-json,null],f5:{foo:x5a-json,bar:null,null:x5c-json}}}}", - /* JsonR */ "{\n\tf: {\n\t\tfoo: {\n\t\t\tf1: x1a-json,\n\t\t\tf2: [\n\t\t\t\tx2a-json,\n\t\t\t\tx2b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf4: [\n\t\t\t\tx4a-json,\n\t\t\t\tx4b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: x5a-json,\n\t\t\t\tbar: null,\n\t\t\t\tnull: x5c-json\n\t\t\t}\n\t\t},\n\t\tbar: null,\n\t\tnull: {\n\t\t\tf1: x1a-json,\n\t\t\tf2: [\n\t\t\t\tx2a-json,\n\t\t\t\tx2b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf4: [\n\t\t\t\tx4a-json,\n\t\t\t\tx4b-json,\n\t\t\t\tnull\n\t\t\t],\n\t\t\tf5: {\n\t\t\t\tfoo: x5a-json,\n\t\t\t\tbar: null,\n\t\t\t\tnull: x5c-json\n\t\t\t}\n\t\t}\n\t}\n}", - /* Xml */ "<object><f><foo><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></foo><bar _type='null'/><_x0000_><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></_x0000_></f></object>", - /* XmlT */ "<object><f><foo><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar t='null'/><_x0000_>x5c-xml</_x0000_></f5></foo><bar t='null'/><_x0000_><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar t='null'/><_x0000_>x5c-xml</_x0000_></f5></_x0000_></f></object>", - /* XmlR */ "<object>\n\t<f>\n\t\t<foo>\n\t\t\t<f1>x1a-xml</f1>\n\t\t\t<f2>\n\t\t\t\tx2a-xml\n\t\t\t\tx2b-xml\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f4>\n\t\t\t\tx4a-xml\n\t\t\t\tx4b-xml\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>x5a-xml</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>x5c-xml</_x0000_>\n\t\t\t</f5>\n\t\t</foo>\n\t\t<bar _type='null'/>\n\t\t<_x0000_>\n\t\t\t<f1>x1a-xml</f1>\n\t\t\t<f2>\n\t\t\t\tx2a-xml\n\t\t\t\tx2b-xml\n\t\t\t\t<null/>\n\t\t\t</f2>\n\t\t\t<f4>\n\t\t\t\tx4a-xml\n\t\t\t\tx4b-xml\n\t\t\t\t<null/>\n\t\t\t</f4>\n\t\t\t<f5>\n\t\t\t\t<foo>x5a-xml</foo>\n\t\t\t\t<bar _type='null'/>\n\t\t\t\t<_x0000_>x5c-xml</_x0000_>\n\t\t\t</f5>\n\t\t</_x0000_>\n\t</f>\n</object>\n", - /* XmlNs */ "<object><f><foo><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></foo><bar _type='null'/><_x0000_><f1>x1a-xml</f1><f2>x2a-xmlx2b-xml<null/></f2><f4>x4a-xmlx4b-xml<null/></f4><f5><foo>x5a-xml</foo><bar _type='null'/><_x0000_>x5c-xml</_x0000_></f5></_x0000_></f></object>", - /* Html */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr></table></td></tr></table>", - /* HtmlT */ "<table><tr><td>f</td><td><table><tr><td>foo</td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td><table><tr><td>f1</td><td>x1a-html</td></tr><tr><td>f2</td><td><ul><li>x2a-html</li><li>x2b-html</li><li><null/></li></ul></td></tr><tr><td>f4</td><td><ul><li>x4a-html</li><li>x4b-html</li><li><null/></li></ul></td></tr><tr><td>f5</td><td><table><tr><td>foo</td><td>x5a-html</td></tr><tr><td>bar</td><td><null/></td></tr><tr><td><null/></td><td>x5c-html</td></tr></table></td></tr></table></td></tr></table></td></tr></table>", - /* HtmlR */ "<table>\n\t<tr>\n\t\t<td>f</td>\n\t\t<td>\n\t\t\t<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f1</td>\n\t\t\t\t\t\t\t\t<td>x1a-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f2</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x2a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x2b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f4</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x4a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x4b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f5</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t\t\t\t\t\t \t<td>x5a-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t\t<td>x5c-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t</tr>\n\t\t\t\t<tr>\n\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f1</td>\n\t\t\t\t\t\t\t\t<td>x1a-html</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f2</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x2a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x2b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t< tr>\n\t\t\t\t\t\t\t\t<td>f4</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<ul>\n\t\t\t\t\t\t\t\t\t\t<li>x4a-html</li>\n\t\t\t\t\t\t\t\t\t\t<li>x4b-html</li>\n\t\t\t\t\t\t\t\t\t\t<li><null/></li>\n\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td>f5</td>\n\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>foo</td>\n\t\t\t\t\t\t\t\t\t\t\t<td>x5a-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td>bar</td>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t\t\t<td><null/></td>\n\t\t\t\t\t\t\t\t\t\t\t<td>x5c-html</td>\n\t\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t\t</table>\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</td>\n\t\t\t\t</tr>\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n</table>\n", - /* Uon */ "(f=(foo=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),bar=null,null=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon))))", - /* UonT */ "(f=(foo=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon)),bar=null,null=(f1=x1a-uon,f2=@(x2a-uon,x2b-uon,null),f4=@(x4a-uon,x4b-uon,null),f5=(foo=x5a-uon,bar=null,null=x5c-uon))))", - /* UonR */ "(\n\tf=(\n\t\tfoo=(\n\t\t\tf1=x1a-uon,\n\t\t\tf2=@(\n\t\t\t\tx2a-uon,\n\t\t\t\tx2b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf4=@(\n\t\t\t\tx4a-uon,\n\t\t\t\tx4b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=x5a-uon,\n\t\t\t\tbar=null,\n\t\t\t\tnull=x5c-uon\n\t\t\t)\n\t\t),\n\t\tbar=null,\n\t\tnull=(\n\t\t\tf1=x1a-uon,\n\t\t\tf2=@(\n\t\t\t\tx2a-uon,\n\t\t\t\tx2b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf4=@(\n\t\t\t\tx4a-uon,\n\t\t\t\tx4b-uon,\n\t\t\t\tnull\n\t\t\t),\n\t\t\tf5=(\n\t\t\t\tfoo=x5a-uon,\n\t\t\t\tbar=null,\n\t\t\t\tnull=x5c-uon\n\t\t\t)\n\t\t)\n\t)\n)", - /* UrlEnc */ "f=(foo=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),bar=null,null=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)))", - /* UrlEncT */ "f=(foo=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)),bar=null,null=(f1=x1a-x-www-form-urlencoded,f2=@(x2a-x-www-form-urlencoded,x2b-x-www-form-urlencoded,null),f4=@(x4a-x-www-form-urlencoded,x4b-x-www-form-urlencoded,null),f5=(foo=x5a-x-www-form-urlencoded,bar=null,null=x5c-x-www-form-urlencoded)))", - /* UrlEncR */ "f=(\n\tfoo=(\n\t\tf1=x1a-x-www-form-urlencoded,\n\t\tf2=@(\n\t\t\tx2a-x-www-form-urlencoded,\n\t\t\tx2b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf4=@(\n\t\t\tx4a-x-www-form-urlencoded,\n\t\t\tx4b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=x5a-x-www-form-urlencoded,\n\t\t\tbar=null,\n\t\t\tnull=x5c-x-www-form-urlencoded\n\t\t)\n\t),\n\tbar=null,\n\tnull=(\n\t\tf1=x1a-x-www-form-urlencoded,\n\t\tf2=@(\n\t\t\tx2a-x-www-form-urlencoded,\n\t\t\tx2b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf4=@(\n\t\t\tx4a-x-www-form-urlencoded,\n\t\t\tx4b-x-www-form-urlencoded,\n\t\t\tnull\n\t\t),\n\t\tf5=(\n\t\t\tfoo=x5a-x-www-form-urlencoded,\n\t\t\tbar=null,\n\t\t\tnull=x5c-x-www-form-urlencoded\n\t\t)\n\t)\n)", - /* MsgPack */ "81A16683A3666F6F84A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BA3626172C0C084A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636B", - /* MsgPackT */ "81A16683A3666F6F84A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636BA3626172C0C084A266317831612D6D73677061636BA26632937832612D6D73677061636B7832622D6D73677061636BC0A26634937834612D6D73677061636B7834622D6D73677061636BC0A2663583A3666F6F7835612D6D73677061636BA3626172C0C07835632D6D73677061636B", - /* RdfXml */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_ rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a -xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlT */ "<rdf:RDF>\n<rdf:Description>\n<jp:f rdf:parseType='Resource'>\n<jp:foo rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_ rdf:parseType='Resource'>\n<jp:f1>x1a-xml</jp:f1>\n<jp:f2>\n<rdf:Seq>\n<rdf:li>x2a-xml</rdf:li>\n<rdf:li>x2b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f2>\n<jp:f4>\n<rdf:Seq>\n<rdf:li>x4 a-xml</rdf:li>\n<rdf:li>x4b-xml</rdf:li>\n<rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n</rdf:Seq>\n</jp:f4>\n<jp:f5 rdf:parseType='Resource'>\n<jp:foo>x5a-xml</jp:foo>\n<jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n<jp:_x0000_>x5c-xml</jp:_x0000_>\n</jp:f5>\n</jp:_x0000_>\n</jp:f>\n</rdf:Description>\n</rdf:RDF>\n", - /* RdfXmlR */ "<rdf:RDF>\n <rdf:Description>\n <jp:f rdf:parseType='Resource'>\n <jp:foo rdf:parseType='Resource'>\n <jp:f1>x1a-xml</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>x2a-xml</rdf:li>\n <rdf:li>x2b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f2>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>x4a-xml</rdf:li>\n <rdf:li>x4b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f4>\n <jp:f5 rdf:parseType='Resource'>\n <jp:foo>x5a-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x5c-xml</jp:_x0000_>\n </jp:f5>\n </jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_ rdf:parseType='Resou rce'>\n <jp:f1>x1a-xml</jp:f1>\n <jp:f2>\n <rdf:Seq>\n <rdf:li>x2a-xml</rdf:li>\n <rdf:li>x2b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f2>\n <jp:f4>\n <rdf:Seq>\n <rdf:li>x4a-xml</rdf:li>\n <rdf:li>x4b-xml</rdf:li>\n <rdf:li rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n </rdf:Seq>\n </jp:f4>\n <jp:f5 rdf:parseType='Resource'>\n <jp:foo>x5a-xml</jp:foo>\n <jp:bar rdf:resource='http://www.w3.org/1999/02/22-rdf-syntax-ns#nil'/>\n <jp:_x0000_>x5c-xml</jp:_x0000_>\n </jp:f5>\n </jp:_x0000_>\n </jp:f>\n </rdf:Description>\n</rdf:RDF>\n" - ) - }, - }); - } - - public ReaderObjectSwapTest(ComboInput<?> comboInput) { - super(comboInput); - } - - @Pojo(swap=PojoToSimpleReaderSwap.class) - public static class PojoToSimpleReader {} - - public static class PojoToSimpleReaderSwap extends PojoSwap<PojoToSimpleReader,Reader> { - public Reader swap(BeanSession session, PojoToSimpleReader o) throws Exception { - return new StringReader("foo"); - } - } - - @Pojo(swap=PojoToDynamicReaderSwap.class) - public static class PojoToDynamicReader { - private String f; - public PojoToDynamicReader(String f) { - this.f = f; - } - } - - public static class PojoToDynamicReaderSwap extends PojoSwap<PojoToDynamicReader,Object> { - public Object swap(BeanSession session, PojoToDynamicReader o) throws Exception { - return new StringReader(o.f + "-" + session.getMediaType().getSubTypes().get(0)); - } - } - - @Pojo(swap=SometimesSwappedBeanSwap1.class) - public static class SometimesSwappedBean1 { - public String f; - public SometimesSwappedBean1(String f) { - this.f = f; - } - } - - public static class SometimesSwappedBeanSwap1 extends PojoSwap<SometimesSwappedBean1,Object> { - public Object swap(BeanSession session, SometimesSwappedBean1 o) throws Exception { - MediaType mt = session.getMediaType(); - if (mt.hasSubType("json") || mt.hasSubType("xml")) - return new StringReader(o.f + "-" + mt); - return o; - } - } - - @Pojo(swap=SometimesSwappedBeanSwap2.class) - public static class SometimesSwappedBean2 { - public String f; - public SometimesSwappedBean2(String f) { - this.f = f; - } - } - - public static class SometimesSwappedBeanSwap2 extends PojoSwap<SometimesSwappedBean2,Object> { - public Object swap(BeanSession session, SometimesSwappedBean2 o) throws Exception { - MediaType mt = session.getMediaType(); - if (mt.hasSubType("json") || mt.hasSubType("xml")) - return o; - return new StringReader(o.f + "-" + mt); - } - } - - - public static class BeanWithSwappedField { - public PojoToDynamicReader f; - public BeanWithSwappedField(String f) { - this.f = new PojoToDynamicReader(f); - } - } - - public static class BeanWithSwapped1dField { - public PojoToDynamicReader[] f; - public BeanWithSwapped1dField(String f) { - this.f = new PojoToDynamicReader[]{new PojoToDynamicReader(f + "1"),new PojoToDynamicReader(f + 2),null}; - } - } - - public static class BeanWithSwappedNullField { - public PojoToDynamicReader f; - } - - public static class BeanWithSwappedListField { - public List<PojoToDynamicReader> f; - public BeanWithSwappedListField(String f) { - this.f = new AList<PojoToDynamicReader>() - .append(new PojoToDynamicReader(f + "1")) - .append(new PojoToDynamicReader(f + "2")) - .append(null) - ; - } - } - - public static class BeanWithSwappedMapField { - public Map<String,PojoToDynamicReader> f; - public BeanWithSwappedMapField(String f) { - this.f = new AMap<String,PojoToDynamicReader>() - .append("foo", new PojoToDynamicReader(f + "1")) - .append("bar", null) - .append(null, new PojoToDynamicReader(f + "2")) - ; - } - } - - public static class BeanWithListBeanSwappedField { - public List<B> f; - public BeanWithListBeanSwappedField(String f) { - this.f = new AList<B>() - .append(new B(f)) - .append(null) - ; - } - } - - public static class BeanWithMapBeanSwappedField { - public Map<String,B> f; - public BeanWithMapBeanSwappedField(String f) { - this.f = new AMap<String,B>() - .append("foo", new B(f)) - .append("bar", null) - .append(null, new B(f)) - ; - } - } - - public static class B { - public PojoToDynamicReader f1; - public PojoToDynamicReader[] f2; - public PojoToDynamicReader f3; - public List<PojoToDynamicReader> f4; - public Map<String,PojoToDynamicReader> f5; - - public B(String f) { - f1 = new PojoToDynamicReader(f + "1a"); - f2 = new PojoToDynamicReader[]{new PojoToDynamicReader(f + "2a"),new PojoToDynamicReader(f + "2b"),null}; - f3 = null; - f4 = new AList<PojoToDynamicReader>() - .append(new PojoToDynamicReader(f + "4a")) - .append(new PojoToDynamicReader(f + "4b")) - .append(null) - ; - f5 = new AMap<String,PojoToDynamicReader>() - .append("foo", new PojoToDynamicReader(f + "5a")) - .append("bar", null) - .append(null, new PojoToDynamicReader(f + "5c")) - ; - } - } -}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UonTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UonTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UonTest.java deleted file mode 100755 index b3aa2f2..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UonTest.java +++ /dev/null @@ -1,169 +0,0 @@ -// *************************************************************************************************************************** -// * 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.juneau.urlencoding; - -import static org.junit.Assert.*; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.parser.*; -import org.apache.juneau.uon.*; -import org.junit.*; - -@SuppressWarnings({"rawtypes","serial","javadoc"}) -public class CommonParser_UonTest { - - ReaderParser p = new UonParserBuilder().beanDictionary(A1.class).build(); - ReaderParser pe = UonParser.DEFAULT_DECODING; - - //==================================================================================================== - // testFromSerializer - //==================================================================================================== - @Test - public void testFromSerializer() throws Exception { - Map m = null; - String in; - - in = "(a=1)"; - m = (Map)p.parse(in, Object.class); - assertEquals(1, m.get("a")); - - in = "(a=1,b='foo+bar')"; - m = (Map)p.parse(in, Object.class); - assertEquals(1, m.get("a")); - assertEquals("foo+bar", m.get("b")); - m = (Map)pe.parse(in, Object.class); - assertEquals(1, m.get("a")); - assertEquals("foo bar", m.get("b")); - - in = "(a=1,b='foo+bar',c=false)"; - m = (Map)pe.parse(in, Object.class); - assertEquals(1, m.get("a")); - assertEquals("foo bar", m.get("b")); - assertEquals(false, m.get("c")); - - in = "(a=1,b='foo%20bar',c=false)"; - m = (Map)pe.parse(in, Object.class); - assertEquals(1, m.get("a")); - assertEquals("foo bar", m.get("b")); - assertEquals(false, m.get("c")); - - ObjectList jl = (ObjectList)p.parse("@((attribute=value),(attribute=~'value~'))", Object.class); - assertEquals("value", jl.getObjectMap(0).getString("attribute")); - assertEquals("'value'", jl.getObjectMap(1).getString("attribute")); - - A1 b = new A1(); - A2 tl = new A2(); - tl.add(new A3("name0","value0")); - tl.add(new A3("name1","value1")); - b.list = tl; - - in = new UonSerializerBuilder().addBeanTypeProperties(true).build().serialize(b); - b = (A1)p.parse(in, Object.class); - assertEquals("value1", b.list.get(1).value); - - in = UonSerializer.DEFAULT.serialize(b); - b = p.parse(in, A1.class); - assertEquals("value1", b.list.get(1).value); - } - - @Bean(typeName="A1") - public static class A1 { - public A2 list; - } - - public static class A2 extends LinkedList<A3> { - } - - public static class A3 { - public String name, value; - public A3(){} - public A3(String name, String value) { - this.name = name; - this.value = value; - } - } - - //==================================================================================================== - // Correct handling of unknown properties. - //==================================================================================================== - @Test - public void testCorrectHandlingOfUnknownProperties() throws Exception { - ReaderParser p = new UonParserBuilder().ignoreUnknownBeanProperties(true).build(); - B t; - - String in = "(a=1,unknown=3,b=2)"; - t = p.parse(in, B.class); - assertEquals(t.a, 1); - assertEquals(t.b, 2); - - try { - p = UonParser.DEFAULT; - p.parse(in, B.class); - fail("Exception expected"); - } catch (ParseException e) {} - } - - public static class B { - public int a, b; - } - - //==================================================================================================== - // Writing to Collection properties with no setters. - //==================================================================================================== - @Test - public void testCollectionPropertiesWithNoSetters() throws Exception { - - ReaderParser p = UonParser.DEFAULT; - - String json = "(ints=@(1,2,3),beans=@((a=1,b=2)))"; - C t = p.parse(json, C.class); - assertEquals(t.getInts().size(), 3); - assertEquals(t.getBeans().get(0).b, 2); - } - - public static class C { - private Collection<Integer> ints = new LinkedList<Integer>(); - private List<B> beans = new LinkedList<B>(); - public Collection<Integer> getInts() { - return ints; - } - public List<B> getBeans() { - return beans; - } - } - - //==================================================================================================== - // Parser listeners. - //==================================================================================================== - @Test - public void testParserListeners() throws Exception { - UonParser p = new UonParserBuilder().ignoreUnknownBeanProperties(true).listener(MyParserListener.class).build(); - - String in = "(a=1,unknownProperty=foo,b=2)"; - p.parse(in, B.class); - assertEquals(1, MyParserListener.events.size()); - assertEquals("unknownProperty,1,5", MyParserListener.events.get(0)); - } - - public static class MyParserListener extends ParserListener { - final static List<String> events = new LinkedList<String>(); - - @Override /* ParserListener */ - public <T> void onUnknownBeanProperty(ParserSession session, ParserPipe pipe, String propertyName, Class<T> beanClass, T bean, int line, int col) { - events.add(propertyName + "," + line + "," + col); - } - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UrlEncodingTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UrlEncodingTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UrlEncodingTest.java deleted file mode 100755 index 3b5fadd..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/CommonParser_UrlEncodingTest.java +++ /dev/null @@ -1,184 +0,0 @@ -// *************************************************************************************************************************** -// * 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.juneau.urlencoding; - -import static org.apache.juneau.TestUtils.*; -import static org.junit.Assert.*; - -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.parser.*; -import org.apache.juneau.serializer.*; -import org.apache.juneau.uon.*; -import org.junit.*; - -@SuppressWarnings({"rawtypes","serial","javadoc"}) -public class CommonParser_UrlEncodingTest { - - ReaderParser p = new UrlEncodingParserBuilder().beanDictionary(A1.class).build(); - - //==================================================================================================== - // testFromSerializer - //==================================================================================================== - @Test - public void testFromSerializer() throws Exception { - Map m = null; - String in; - - in = "a=1"; - m = (Map)p.parse(in, Object.class); - assertEquals(1, m.get("a")); - - in = "a=1&b='foo+bar'"; - m = (Map)p.parse(in, Object.class); - assertEquals(1, m.get("a")); - assertEquals("foo bar", m.get("b")); - - in = "a=1&b='foo+bar'&c=false"; - m = (Map)p.parse(in, Object.class); - assertEquals(1, m.get("a")); - assertEquals("foo bar", m.get("b")); - assertEquals(false, m.get("c")); - - in = "a=1&b='foo%20bar'&c=false"; - m = (Map)p.parse(in, Object.class); - assertEquals(1, m.get("a")); - assertEquals("foo bar", m.get("b")); - assertEquals(false, m.get("c")); - - ObjectMap jm = (ObjectMap)p.parse("x=@((attribute=value),(attribute=~'value~'))", Object.class); - assertEquals("value", jm.getObjectList("x").getObjectMap(0).getString("attribute")); - assertEquals("'value'", jm.getObjectList("x").getObjectMap(1).getString("attribute")); - - ObjectList jl = (ObjectList)p.parse("_value=@((attribute=value),(attribute=~'value~'))", Object.class); - assertEquals("value", jl.getObjectMap(0).getString("attribute")); - assertEquals("'value'", jl.getObjectMap(1).getString("attribute")); - - A1 b = new A1(); - A2 tl = new A2(); - tl.add(new A3("name0","value0")); - tl.add(new A3("name1","value1")); - b.list = tl; - - in = new UrlEncodingSerializerBuilder().addBeanTypeProperties(true).build().serialize(b); - b = (A1)p.parse(in, Object.class); - assertEquals("value1", b.list.get(1).value); - - in = UrlEncodingSerializer.DEFAULT.serialize(b); - b = p.parse(in, A1.class); - assertEquals("value1", b.list.get(1).value); - } - - @Bean(typeName="A1") - public static class A1 { - public A2 list; - } - - public static class A2 extends LinkedList<A3> { - } - - public static class A3 { - public String name, value; - public A3(){} - public A3(String name, String value) { - this.name = name; - this.value = value; - } - } - - //==================================================================================================== - // Correct handling of unknown properties. - //==================================================================================================== - @Test - public void testCorrectHandlingOfUnknownProperties() throws Exception { - ReaderParser p = new UrlEncodingParserBuilder().ignoreUnknownBeanProperties(true).build(); - B t; - - String in = "a=1&unknown=3&b=2"; - t = p.parse(in, B.class); - assertEquals(t.a, 1); - assertEquals(t.b, 2); - - try { - p = UrlEncodingParser.DEFAULT; - p.parse(in, B.class); - fail("Exception expected"); - } catch (ParseException e) {} - } - - public static class B { - public int a, b; - } - - //==================================================================================================== - // Writing to Collection properties with no setters. - //==================================================================================================== - @Test - public void testCollectionPropertiesWithNoSetters() throws Exception { - - ReaderParser p = UrlEncodingParser.DEFAULT; - - String json = "ints=@(1,2,3)&beans=@((a=1,b=2))"; - C t = p.parse(json, C.class); - assertEquals(t.getInts().size(), 3); - assertEquals(t.getBeans().get(0).b, 2); - } - - public static class C { - private Collection<Integer> ints = new LinkedList<Integer>(); - private List<B> beans = new LinkedList<B>(); - public Collection<Integer> getInts() { - return ints; - } - public List<B> getBeans() { - return beans; - } - } - - //==================================================================================================== - // Parser listeners. - //==================================================================================================== - @Test - public void testParserListeners() throws Exception { - UonParser p = new UrlEncodingParserBuilder().ignoreUnknownBeanProperties(true).listener(MyParserListener.class).build(); - - String in = "a=1&unknownProperty=foo&b=2"; - p.parse(in, B.class); - assertEquals(1, MyParserListener.events.size()); - assertEquals("unknownProperty,1,4", MyParserListener.events.get(0)); - } - - public static class MyParserListener extends ParserListener { - final static List<String> events = new LinkedList<String>(); - - @Override /* ParserListener */ - public <T> void onUnknownBeanProperty(ParserSession session, ParserPipe pipe, String propertyName, Class<T> beanClass, T bean, int line, int col) { - events.add(propertyName + "," + line + "," + col); - } - } - - @Test - public void testCollections() throws Exception { - WriterSerializer s = UrlEncodingSerializer.DEFAULT; - ReaderParser p = UrlEncodingParser.DEFAULT; - - List l = new ObjectList("foo","bar"); - assertEquals("0=foo&1=bar", s.serialize(l)); - - String in = "0=foo&1=bar"; - l = p.parse(in, LinkedList.class, String.class); - assertObjectEquals("['foo','bar']",l); - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java deleted file mode 100755 index 3bc6fa4..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UonTest.java +++ /dev/null @@ -1,284 +0,0 @@ -// *************************************************************************************************************************** -// * 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.juneau.urlencoding; - -import static org.apache.juneau.TestUtils.*; -import static org.junit.Assert.*; - -import java.net.*; -import java.net.URI; -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.uon.*; -import org.apache.juneau.utils.*; -import org.junit.*; - -@SuppressWarnings({"serial","javadoc"}) -public class Common_UonTest { - UonParser p = UonParser.DEFAULT; - UonParser pe = UonParser.DEFAULT_DECODING; - - //==================================================================================================== - // Trim nulls from beans - //==================================================================================================== - @Test - public void testTrimNullsFromBeans() throws Exception { - UonSerializerBuilder s = new UonSerializerBuilder().encoding(); - A t1 = A.create(), t2; - - s.trimNullProperties(false); - String r = s.build().serialize(t1); - assertEquals("(s1=null,s2=s2)", r); - t2 = pe.parse(r, A.class); - assertEqualObjects(t1, t2); - - s.trimNullProperties(true); - r = s.build().serialize(t1); - assertEquals("(s2=s2)", r); - t2 = p.parse(r, A.class); - assertEqualObjects(t1, t2); - } - - public static class A { - public String s1, s2; - - public static A create() { - A t = new A(); - t.s2 = "s2"; - return t; - } - } - - //==================================================================================================== - // Trim empty maps - //==================================================================================================== - @Test - public void testTrimEmptyMaps() throws Exception { - UonSerializerBuilder s = new UonSerializerBuilder().encoding(); - B t1 = B.create(), t2; - String r; - - s.trimEmptyMaps(false); - r = s.build().serialize(t1); - assertEquals("(f1=(),f2=(f2a=null,f2b=(s2=s2)))", r); - t2 = pe.parse(r, B.class); - assertEqualObjects(t1, t2); - - s.trimEmptyMaps(true); - r = s.build().serialize(t1); - assertEquals("(f2=(f2a=null,f2b=(s2=s2)))", r); - t2 = pe.parse(r, B.class); - assertNull(t2.f1); - } - - public static class B { - public TreeMap<String,A> f1, f2; - - public static B create() { - B t = new B(); - t.f1 = new TreeMap<String,A>(); - t.f2 = new TreeMap<String,A>(){{put("f2a",null);put("f2b",A.create());}}; - return t; - } - } - - //==================================================================================================== - // Trim empty lists - //==================================================================================================== - @Test - public void testTrimEmptyLists() throws Exception { - UonSerializerBuilder s = new UonSerializerBuilder().encoding(); - C t1 = C.create(), t2; - String r; - - s.trimEmptyCollections(false); - r = s.build().serialize(t1); - assertEquals("(f1=@(),f2=@(null,(s2=s2)))", r); - t2 = pe.parse(r, C.class); - assertEqualObjects(t1, t2); - - s.trimEmptyCollections(true); - r = s.build().serialize(t1); - assertEquals("(f2=@(null,(s2=s2)))", r); - t2 = pe.parse(r, C.class); - assertNull(t2.f1); - } - - public static class C { - public List<A> f1, f2; - - public static C create() { - C t = new C(); - t.f1 = new AList<A>(); - t.f2 = new AList<A>().append(null).append(A.create()); - return t; - } - } - - //==================================================================================================== - // Trim empty arrays - //==================================================================================================== - @Test - public void testTrimEmptyArrays() throws Exception { - UonSerializerBuilder s = new UonSerializerBuilder().encoding(); - D t1 = D.create(), t2; - String r; - - s.trimEmptyCollections(false); - r = s.build().serialize(t1); - assertEquals("(f1=@(),f2=@(null,(s2=s2)))", r); - t2 = pe.parse(r, D.class); - assertEqualObjects(t1, t2); - - s.trimEmptyCollections(true); - r = s.build().serialize(t1); - assertEquals("(f2=@(null,(s2=s2)))", r); - t2 = pe.parse(r, D.class); - assertNull(t2.f1); - } - - public static class D { - public A[] f1, f2; - - public static D create() { - D t = new D(); - t.f1 = new A[]{}; - t.f2 = new A[]{null, A.create()}; - return t; - } - } - - //==================================================================================================== - // @BeanProperty.properties annotation. - //==================================================================================================== - @Test - public void testBeanPropertyProperies() throws Exception { - UonSerializer s = UonSerializer.DEFAULT; - String ue = s.serialize(new E1()); - assertEquals("(x1=(f1=1),x2=(f1=1),x3=@((f1=1)),x4=@((f1=1)),x5=@((f1=1)),x6=@((f1=1)))", ue); - } - - public static class E1 { - @BeanProperty(properties="f1") public E2 x1 = new E2(); - @BeanProperty(properties="f1") public Map<String,Integer> x2 = new AMap<String,Integer>().append("f1",1).append("f2",2); - @BeanProperty(properties="f1") public E2[] x3 = {new E2()}; - @BeanProperty(properties="f1") public List<E2> x4 = new AList<E2>().append(new E2()); - @BeanProperty(properties="f1") public ObjectMap[] x5 = {new ObjectMap().append("f1",1).append("f2",2)}; - @BeanProperty(properties="f1") public List<ObjectMap> x6 = new AList<ObjectMap>().append(new ObjectMap().append("f1",1).append("f2",2)); - } - - public static class E2 { - public int f1 = 1; - public int f2 = 2; - } - - //==================================================================================================== - // @BeanProperty.properties annotation on list of beans. - //==================================================================================================== - @Test - public void testBeanPropertyPropertiesOnListOfBeans() throws Exception { - UonSerializer s = UonSerializer.DEFAULT; - List<F> l = new LinkedList<F>(); - F t = new F(); - t.x1.add(new F()); - l.add(t); - String xml = s.serialize(l); - assertEquals("@((x1=@((x2=2)),x2=2))", xml); - } - - public static class F { - @BeanProperty(properties="x2") public List<F> x1 = new LinkedList<F>(); - public int x2 = 2; - } - - //==================================================================================================== - // Test URIAttr - Test that URLs and URIs are serialized and parsed correctly. - //==================================================================================================== - @Test - public void testURIAttr() throws Exception { - UonSerializer s = UonSerializer.DEFAULT; - UonParser p = UonParser.DEFAULT; - - G t = new G(); - t.uri = new URI("http://uri"); - t.f1 = new URI("http://f1"); - t.f2 = new URL("http://f2"); - - String r = s.serialize(t); - t = p.parse(r, G.class); - assertEquals("http://uri", t.uri.toString()); - assertEquals("http://f1", t.f1.toString()); - assertEquals("http://f2", t.f2.toString()); - } - - public static class G { - public URI uri; - public URI f1; - public URL f2; - } - - //==================================================================================================== - // Recursion - //==================================================================================================== - @Test - public void testRecursion() throws Exception { - UonSerializerBuilder s = new UonSerializerBuilder(); - - R1 r1 = new R1(); - R2 r2 = new R2(); - R3 r3 = new R3(); - r1.r2 = r2; - r2.r3 = r3; - r3.r1 = r1; - - // No recursion detection - try { - s.build().serialize(r1); - fail("Exception expected!"); - } catch (Exception e) { - String msg = e.getLocalizedMessage(); - assertTrue(msg.contains("It's recommended you use the SerializerContext.SERIALIZER_detectRecursions setting to help locate the loop.")); - } - - // Recursion detection, no ignore - s.detectRecursions(true); - try { - s.build().serialize(r1); - fail("Exception expected!"); - } catch (Exception e) { - String msg = e.getLocalizedMessage(); - assertTrue(msg.contains("[0]root:org.apache.juneau.urlencoding.Common_UonTest$R1")); - assertTrue(msg.contains("->[1]r2:org.apache.juneau.urlencoding.Common_UonTest$R2")); - assertTrue(msg.contains("->[2]r3:org.apache.juneau.urlencoding.Common_UonTest$R3")); - assertTrue(msg.contains("->[3]r1:org.apache.juneau.urlencoding.Common_UonTest$R1")); - } - - s.ignoreRecursions(true); - assertEquals("(name=foo,r2=(name=bar,r3=(name=baz)))", s.build().serialize(r1)); - } - - public static class R1 { - public String name = "foo"; - public R2 r2; - } - public static class R2 { - public String name = "bar"; - public R3 r3; - } - public static class R3 { - public String name = "baz"; - public R1 r1; - } -} http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java ---------------------------------------------------------------------- diff --git a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java b/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java deleted file mode 100755 index e4f2d1b..0000000 --- a/juneau-core-test/src/test/java/org/apache/juneau/urlencoding/Common_UrlEncodingTest.java +++ /dev/null @@ -1,285 +0,0 @@ -// *************************************************************************************************************************** -// * 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.juneau.urlencoding; - -import static org.apache.juneau.TestUtils.*; -import static org.junit.Assert.*; - -import java.net.*; -import java.net.URI; -import java.util.*; - -import org.apache.juneau.*; -import org.apache.juneau.annotation.*; -import org.apache.juneau.utils.*; -import org.junit.*; - -@SuppressWarnings({"serial","javadoc"}) -public class Common_UrlEncodingTest { - UrlEncodingParser p = UrlEncodingParser.DEFAULT; - - //==================================================================================================== - // Trim nulls from beans - //==================================================================================================== - @Test - public void testTrimNullsFromBeans() throws Exception { - UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder(); - A t1 = A.create(), t2; - - s.trimNullProperties(false); - String r = s.build().serialize(t1); - assertEquals("s1=null&s2=s2", r); - t2 = p.parse(r, A.class); - assertEqualObjects(t1, t2); - - s.trimNullProperties(true); - r = s.build().serialize(t1); - assertEquals("s2=s2", r); - t2 = p.parse(r, A.class); - assertEqualObjects(t1, t2); - } - - public static class A { - public String s1, s2; - - public static A create() { - A t = new A(); - t.s2 = "s2"; - return t; - } - } - - //==================================================================================================== - // Trim empty maps - //==================================================================================================== - @Test - public void testTrimEmptyMaps() throws Exception { - UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder(); - B t1 = B.create(), t2; - String r; - - s.trimEmptyMaps(false); - r = s.build().serialize(t1); - assertEquals("f1=()&f2=(f2a=null,f2b=(s2=s2))", r); - t2 = p.parse(r, B.class); - assertEqualObjects(t1, t2); - - s.trimEmptyMaps(true); - r = s.build().serialize(t1); - assertEquals("f2=(f2a=null,f2b=(s2=s2))", r); - t2 = p.parse(r, B.class); - assertNull(t2.f1); - } - - public static class B { - public TreeMap<String,A> f1, f2; - - public static B create() { - B t = new B(); - t.f1 = new TreeMap<String,A>(); - t.f2 = new TreeMap<String,A>(){{put("f2a",null);put("f2b",A.create());}}; - return t; - } - } - - //==================================================================================================== - // Trim empty lists - //==================================================================================================== - @Test - public void testTrimEmptyLists() throws Exception { - UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder(); - C t1 = C.create(), t2; - String r; - - s.trimEmptyCollections(false); - r = s.build().serialize(t1); - assertEquals("f1=@()&f2=@(null,(s2=s2))", r); - t2 = p.parse(r, C.class); - assertEqualObjects(t1, t2); - - s.trimEmptyCollections(true); - r = s.build().serialize(t1); - assertEquals("f2=@(null,(s2=s2))", r); - t2 = p.parse(r, C.class); - assertNull(t2.f1); - } - - public static class C { - public List<A> f1, f2; - - public static C create() { - C t = new C(); - t.f1 = new AList<A>(); - t.f2 = new AList<A>().append(null).append(A.create()); - return t; - } - } - - //==================================================================================================== - // Trim empty arrays - //==================================================================================================== - @Test - public void testTrimEmptyArrays() throws Exception { - UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder(); - D t1 = D.create(), t2; - String r; - - s.trimEmptyCollections(false); - r = s.build().serialize(t1); - assertEquals("f1=@()&f2=@(null,(s2=s2))", r); - t2 = p.parse(r, D.class); - assertEqualObjects(t1, t2); - - s.trimEmptyCollections(true); - r = s.build().serialize(t1); - assertEquals("f2=@(null,(s2=s2))", r); - t2 = p.parse(r, D.class); - assertNull(t2.f1); - } - - public static class D { - public A[] f1, f2; - - public static D create() { - D t = new D(); - t.f1 = new A[]{}; - t.f2 = new A[]{null, A.create()}; - return t; - } - } - - //==================================================================================================== - // @BeanProperty.properties annotation. - //==================================================================================================== - @Test - public void testBeanPropertyProperies() throws Exception { - UrlEncodingSerializer s = UrlEncodingSerializer.DEFAULT; - String ue = s.serialize(new E1()); - assertEquals("x1=(f1=1)&x2=(f1=1)&x3=@((f1=1))&x4=@((f1=1))&x5=@((f1=1))&x6=@((f1=1))", ue); - } - - public static class E1 { - @BeanProperty(properties="f1") public E2 x1 = new E2(); - @BeanProperty(properties="f1") public Map<String,Integer> x2 = new AMap<String,Integer>().append("f1",1).append("f2",2); - @BeanProperty(properties="f1") public E2[] x3 = {new E2()}; - @BeanProperty(properties="f1") public List<E2> x4 = new AList<E2>().append(new E2()); - @BeanProperty(properties="f1") public ObjectMap[] x5 = {new ObjectMap().append("f1",1).append("f2",2)}; - @BeanProperty(properties="f1") public List<ObjectMap> x6 = new AList<ObjectMap>().append(new ObjectMap().append("f1",1).append("f2",2)); - } - - public static class E2 { - public int f1 = 1; - public int f2 = 2; - } - - //==================================================================================================== - // @BeanProperty.properties annotation on list of beans. - //==================================================================================================== - @Test - public void testBeanPropertyPropertiesOnListOfBeans() throws Exception { - UrlEncodingSerializer s = UrlEncodingSerializer.DEFAULT; - List<F> l = new LinkedList<F>(); - F t = new F(); - t.x1.add(new F()); - l.add(t); - ObjectMap m = new ObjectMap().append("t", l); - String xml = s.serialize(m); - assertEquals("t=@((x1=@((x2=2)),x2=2))", xml); - xml = s.serialize(l); - assertEquals("0=(x1=@((x2=2)),x2=2)", xml); - } - - public static class F { - @BeanProperty(properties="x2") public List<F> x1 = new LinkedList<F>(); - public int x2 = 2; - } - - //==================================================================================================== - // Test URIAttr - Test that URLs and URIs are serialized and parsed correctly. - //==================================================================================================== - @Test - public void testURIAttr() throws Exception { - UrlEncodingSerializer s = UrlEncodingSerializer.DEFAULT; - UrlEncodingParser p = UrlEncodingParser.DEFAULT; - - G t = new G(); - t.uri = new URI("http://uri"); - t.f1 = new URI("http://f1"); - t.f2 = new URL("http://f2"); - - String r = s.serialize(t); - t = p.parse(r, G.class); - assertEquals("http://uri", t.uri.toString()); - assertEquals("http://f1", t.f1.toString()); - assertEquals("http://f2", t.f2.toString()); - } - - public static class G { - public URI uri; - public URI f1; - public URL f2; - } - - //==================================================================================================== - // Recursion - //==================================================================================================== - @Test - public void testRecursion() throws Exception { - UrlEncodingSerializerBuilder s = new UrlEncodingSerializerBuilder(); - - R1 r1 = new R1(); - R2 r2 = new R2(); - R3 r3 = new R3(); - r1.r2 = r2; - r2.r3 = r3; - r3.r1 = r1; - - // No recursion detection - try { - s.build().serialize(r1); - fail("Exception expected!"); - } catch (Exception e) { - String msg = e.getLocalizedMessage(); - assertTrue(msg.contains("It's recommended you use the SerializerContext.SERIALIZER_detectRecursions setting to help locate the loop.")); - } - - // Recursion detection, no ignore - s.detectRecursions(true); - try { - s.build().serialize(r1); - fail("Exception expected!"); - } catch (Exception e) { - String msg = e.getLocalizedMessage(); - assertTrue(msg.contains("[0]root:org.apache.juneau.urlencoding.Common_UrlEncodingTest$R1")); - assertTrue(msg.contains("->[1]r2:org.apache.juneau.urlencoding.Common_UrlEncodingTest$R2")); - assertTrue(msg.contains("->[2]r3:org.apache.juneau.urlencoding.Common_UrlEncodingTest$R3")); - assertTrue(msg.contains("->[3]r1:org.apache.juneau.urlencoding.Common_UrlEncodingTest$R1")); - } - - s.ignoreRecursions(true); - assertEquals("name=foo&r2=(name=bar,r3=(name=baz))", s.build().serialize(r1)); - } - - public static class R1 { - public String name = "foo"; - public R2 r2; - } - public static class R2 { - public String name = "bar"; - public R3 r3; - } - public static class R3 { - public String name = "baz"; - public R1 r1; - } -}
