You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2017/09/02 14:11:57 UTC
[41/51] [partial] incubator-juneau git commit: Add project
hierarchies, part 2.
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripGenericsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripGenericsTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripGenericsTest.java
deleted file mode 100755
index 924a6dd..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripGenericsTest.java
+++ /dev/null
@@ -1,98 +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.a.rttests;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.junit.Assert.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.junit.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@SuppressWarnings("javadoc")
-public class RoundTripGenericsTest extends RoundTripTest {
-
- public RoundTripGenericsTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- //====================================================================================================
- // testBeansWithUnboundTypeVars
- //====================================================================================================
- @SuppressWarnings("rawtypes")
- @Test
- public void testBeansWithUnboundTypeVars() throws Exception {
-
- if (returnOriginalObject)
- return;
-
- // Unbound type variables should be interpreted as Object.
- // During parsing, these become ObjectMaps.
- Pair pair = new Pair<Source,Target>(new Source().init(), new Target().init());
- pair = roundTrip(pair);
- assertSortedObjectEquals("{s:{s1:'a1'},t:{t1:'b1'}}", pair);
- assertEquals("ObjectMap", pair.getS().getClass().getSimpleName());
- assertEquals("ObjectMap", pair.getT().getClass().getSimpleName());
-
- // If you specify a concrete class, the type variables become bound and
- // the property types correctly resolve.
- pair = roundTrip(pair, RealPair.class);
- assertSortedObjectEquals("{s:{s1:'a1'},t:{t1:'b1'}}", pair);
- assertEquals("Source", pair.getS().getClass().getSimpleName());
- assertEquals("Target", pair.getT().getClass().getSimpleName());
- }
-
- // Class with unbound type variables.
- @Bean(properties="s,t")
- public static class Pair<S,T> {
- private S s;
- private T t;
-
- public Pair() {}
-
- public Pair(S s, T t) {
- this.s = s;
- this.t = t;
- }
-
- // Getters/setters
- public S getS() { return s; }
- public void setS(S s) { this.s = s; }
- public T getT() { return t; }
- public void setT(T t) { this.t = t; }
- }
-
- // Sublcass with bound type variables.
- public static class RealPair extends Pair<Source,Target> {}
-
- public static class Source {
- public String s1;
- public Source init() {
- this.s1 = "a1";
- return this;
- }
- }
-
- public static class Target {
- public String t1;
- public Target init() {
- this.t1 = "b1";
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripLargeObjectsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripLargeObjectsTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripLargeObjectsTest.java
deleted file mode 100755
index c4f11ba..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripLargeObjectsTest.java
+++ /dev/null
@@ -1,191 +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.a.rttests;
-
-import static org.apache.juneau.a.rttests.RoundTripTest.Flags.*;
-import static org.apache.juneau.internal.StringUtils.*;
-
-import java.util.*;
-
-import org.apache.juneau.html.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.msgpack.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.uon.*;
-import org.apache.juneau.urlencoding.*;
-import org.apache.juneau.xml.*;
-import org.junit.*;
-import org.junit.runners.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@Ignore
-@SuppressWarnings({"serial","javadoc"})
-public class RoundTripLargeObjectsTest extends RoundTripTest {
-
- private static final int NUM_RUNS = 10;
- private static final int SIZE_PARAM = 20000;
-
- public RoundTripLargeObjectsTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- @Parameterized.Parameters
- public static Collection<Object[]> getPairs() {
- return Arrays.asList(new Object[][] {
- // Full round-trip testing
- { /* 0 */
- "Json DEFAULT",
- new JsonSerializerBuilder().trimNullProperties(false),
- new JsonParserBuilder(),
- 0
- },
- { /* 1 */
- "Json DEFAULT_LAX",
- new JsonSerializerBuilder().simple().trimNullProperties(false),
- new JsonParserBuilder(),
- 0
- },
- { /* 2 */
- "Json DEFAULT_SQ",
- new JsonSerializerBuilder().simple().trimNullProperties(false),
- new JsonParserBuilder(),
- 0
- },
- { /* 3 */
- "Xml DEFAULT w/namespaces,validation",
- new XmlSerializerBuilder().sq().ns().trimNullProperties(false).addNamespaceUrisToRoot(true).useWhitespace(true),
- new XmlParserBuilder(),
- CHECK_XML_WHITESPACE | VALIDATE_XML
- },
- { /* 4 */
- "Xml DEFAULT wo/namespaces,validation",
- new XmlSerializerBuilder().sq().trimNullProperties(false),
- new XmlParserBuilder(),
- CHECK_XML_WHITESPACE
- },
- { /* 5 */
- "Html",
- new HtmlSerializerBuilder().trimNullProperties(false),
- new HtmlParserBuilder(),
- CHECK_XML_WHITESPACE
- },
- { /* 6 */
- "UrlEncoding",
- new UrlEncodingSerializerBuilder().trimNullProperties(false),
- new UrlEncodingParserBuilder(),
- 0
- },
- { /* 7 */
- "Uon",
- new UonSerializerBuilder().trimNullProperties(false),
- new UonParserBuilder(),
- 0
- },
- { /* 8 */
- "MsgPack",
- new MsgPackSerializerBuilder().trimNullProperties(false),
- new MsgPackParserBuilder(),
- 0
- },
-// { /* 9 */
-// "Rdf.Xml",
-// new RdfSerializer.Xml().setTrimNullProperties(false).setAddLiteralTypes(true),
-// RdfParser.DEFAULT_XML,
-// 0
-// },
-// { /* 10 */
-// "Rdf.XmlAbbrev",
-// new RdfSerializer.XmlAbbrev().setTrimNullProperties(false).setAddLiteralTypes(true),
-// RdfParser.DEFAULT_XML,
-// 0
-// },
-// { /* 11 */
-// "Rdf.Turtle",
-// new RdfSerializer.Turtle().setTrimNullProperties(false).setAddLiteralTypes(true),
-// RdfParser.DEFAULT_TURTLE,
-// 0
-// },
-// { /* 12 */
-// "Rdf.NTriple",
-// new RdfSerializer.NTriple().setTrimNullProperties(false).setAddLiteralTypes(true),
-// RdfParser.DEFAULT_NTRIPLE,
-// 0
-// },
-// { /* 13 */
-// "Rdf.N3",
-// new RdfSerializer.N3().setTrimNullProperties(false).setAddLiteralTypes(true),
-// RdfParser.DEFAULT_N3,
-// 0
-// },
- });
- }
-
- //====================================================================================================
- // test
- //====================================================================================================
- @Test
- public void testLargeMap() throws Exception {
- long startTime;
- int numRuns = NUM_RUNS;
-
- A a = A.create();
- Serializer s = getSerializer();
- Parser p = getParser();
- System.err.println("\n---Speed test on " + label + "---"); // NOT DEBUG
- Object r = "";
-
- // Initialization run.
- r = s.serialize(a);
- System.err.println(format("Serialized size: {0,number} ", (r instanceof String ? r.toString().length() : ((byte[])r).length))); // NOT DEBUG
- p.parse(r, A.class);
-
- startTime = System.currentTimeMillis();
- for (int i = 0; i < numRuns; i++)
- r = s.serialize(a);
- System.err.println(format("Average serialize time: {0,number}ms", (System.currentTimeMillis()-startTime)/numRuns)); // NOT DEBUG
- startTime = System.currentTimeMillis();
- for (int i = 0; i < numRuns; i++)
- a = p.parse(r, A.class);
- System.err.println(format("Average parsed time: {0,number}ms", (System.currentTimeMillis()-startTime)/numRuns)); // NOT DEBUG
- }
-
- public static class A {
- public A1Map a1Map;
- public A1List a1List;
- public A1[] a1Array;
-
- static A create() {
- A a = new A();
- a.a1Map = new A1Map();
- a.a1List = new A1List();
- for (int i = 0; i < SIZE_PARAM; i++) {
- a.a1Map.put(String.valueOf(i), new A1());
- a.a1List.add(new A1());
- }
- a.a1Array = a.a1List.toArray(new A1[0]);
- return a;
- }
- }
-
- public static class A1 {
- public String f1 = "a123456789b123456789c123456789d123456789e123456789f123456789g123456789h123456789i123456789j123456789";
- }
-
- public static class A1Map extends LinkedHashMap<String,A1> {}
-
- public static class A1List extends LinkedList<A1> {}
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripMapsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripMapsTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripMapsTest.java
deleted file mode 100755
index 7a3ecca..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripMapsTest.java
+++ /dev/null
@@ -1,213 +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.a.rttests;
-
-import static org.junit.Assert.*;
-
-import java.util.*;
-
-import org.apache.juneau.html.*;
-import org.apache.juneau.json.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.transforms.*;
-import org.apache.juneau.uon.*;
-import org.apache.juneau.urlencoding.*;
-import org.apache.juneau.xml.*;
-import org.junit.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@SuppressWarnings({"deprecation","javadoc"})
-public class RoundTripMapsTest extends RoundTripTest {
-
- public RoundTripMapsTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- @Override /* RoundTripTest */
- public Class<?>[] getPojoSwaps() {
- return new Class<?>[]{
- ByteArrayBase64Swap.class,
- DateSwap.ISO8601DTZ.class,
- CalendarLongSwap.class,
- };
- }
-
- //====================================================================================================
- // Map<Integer,String> test
- //====================================================================================================
- @Test
- public void testMapIntegerString() throws Exception {
- Map<Integer,String> t = new TreeMap<Integer,String>();
- t.put(1, "a");
- t.put(2, null);
- t = roundTrip(t, TreeMap.class, Integer.class, String.class);
- assertEquals("a", t.get(1));
- assertNull(null, t.get(2));
-
- t = new HashMap<Integer,String>();
- t.put(1, "a");
- t.put(2, null);
- t.put(null, "b");
- t = roundTrip(t, HashMap.class, Integer.class, String.class);
- assertEquals("a", t.get(1));
- assertNull(t.get(2));
- assertEquals("b", t.get(null));
- }
-
- //====================================================================================================
- // Map<Boolean,String> test
- //====================================================================================================
- @Test
- public void testMapBooleanString() throws Exception {
- Map<Boolean,String> t = new TreeMap<Boolean,String>();
- t.put(true, "a");
- t.put(false, null);
- t = roundTrip(t, TreeMap.class, Boolean.class, String.class);
- assertEquals("a", t.get(true));
- assertNull(null, t.get(false));
-
- t = new HashMap<Boolean,String>();
- t.put(true, "a");
- t.put(false, null);
- t.put(null, "b");
- t = roundTrip(t, HashMap.class, Boolean.class, String.class);
- assertEquals("a", t.get(true));
- assertNull(t.get(false));
- assertEquals("b", t.get(null));
- }
-
- //====================================================================================================
- // Map<byte[],String> test
- //====================================================================================================
- @Test
- public void testMapByteArrayString() throws Exception {
-
- // Note, you cannot really test maps with byte[] keys since byte[] does not test for equality.
- // So just test serialization.
- String e;
- Object r;
-
- Map<byte[],String> t = new LinkedHashMap<byte[],String>();
- t.put(new byte[]{1,2,3}, "a");
- t.put(new byte[]{4,5,6}, null);
- t.put(null, "b");
-
- s = new JsonSerializerBuilder().simple().pojoSwaps(getPojoSwaps()).trimNullProperties(false).build();
- e = "{AQID:'a',BAUG:null,null:'b'}";
- r = s.serialize(t);
- assertEquals(e, r);
-
- s = new XmlSerializerBuilder().ns().sq().pojoSwaps(getPojoSwaps()).trimNullProperties(false).build();
- e = "<object><AQID>a</AQID><BAUG _type='null'/><_x0000_>b</_x0000_></object>";
- r = s.serialize(t);
- assertEquals(e, r);
-
- s = new HtmlSerializerBuilder().sq().pojoSwaps(getPojoSwaps()).trimNullProperties(false).addKeyValueTableHeaders(true).build();
- e = "<table><tr><th>key</th><th>value</th></tr><tr><td>AQID</td><td>a</td></tr><tr><td>BAUG</td><td><null/></td></tr><tr><td><null/></td><td>b</td></tr></table>";
- r = s.serialize(t);
- assertEquals(e, r);
-
- s = new UonSerializerBuilder().encoding().pojoSwaps(getPojoSwaps()).trimNullProperties(false).build();
- e = "(AQID=a,BAUG=null,null=b)";
- r = s.serialize(t);
- assertEquals(e, r);
-
- s = new UrlEncodingSerializerBuilder().pojoSwaps(getPojoSwaps()).trimNullProperties(false).build();
- e = "AQID=a&BAUG=null&null=b";
- r = s.serialize(t);
- assertEquals(e, r);
- }
-
- //====================================================================================================
- // Map<Date,String> test
- //====================================================================================================
- @Test
- public void testMapDateString() throws Exception {
- Date td1 = new Date(1,2,3,4,5,6);
- Date td2 = new Date(2,3,4,5,6,7);
-
- Map<Date,String> t = new TreeMap<Date,String>();
- t.put(td1, "a");
- t.put(td2, null);
- t = roundTrip(t, TreeMap.class, Date.class, String.class);
- assertEquals("a", t.get(td1));
- assertNull(null, t.get(td2));
-
- t = new HashMap<Date,String>();
- t.put(td1, "a");
- t.put(td2, null);
- t.put(null, "b");
- t = roundTrip(t, HashMap.class, Date.class, String.class);
- assertEquals("a", t.get(td1));
- assertNull(t.get(td2));
- assertEquals("b", t.get(null));
- }
-
- //====================================================================================================
- // Map<Calendar,String> test
- //====================================================================================================
- @Test
- public void testMapCalendarString() throws Exception {
- Calendar td1 = new GregorianCalendar();
- td1.setTime(new Date(1,2,3,4,5,6));
- Calendar td2 = new GregorianCalendar();
- td2.setTime(new Date(2,3,4,5,6,7));
-
- Map<Calendar,String> t = new TreeMap<Calendar,String>();
- t.put(td1, "a");
- t.put(td2, null);
- t = roundTrip(t, TreeMap.class, GregorianCalendar.class, String.class);
- assertEquals("a", t.get(td1));
- assertNull(null, t.get(td2));
-
- t = new HashMap<Calendar,String>();
- t.put(td1, "a");
- t.put(td2, null);
- t.put(null, "b");
- t = roundTrip(t, HashMap.class, GregorianCalendar.class, String.class);
- assertEquals("a", t.get(td1));
- assertNull(t.get(td2));
- assertEquals("b", t.get(null));
- }
-
- //====================================================================================================
- // Map<Enum,String> test
- //====================================================================================================
- @Test
- public void testMapEnumString() throws Exception {
-
- Map<TestEnum,String> t = new TreeMap<TestEnum,String>();
- t.put(TestEnum.FOO, "a");
- t.put(TestEnum.BAR, null);
- t = roundTrip(t, TreeMap.class, TestEnum.class, String.class);
- assertEquals("a", t.get(TestEnum.FOO));
- assertNull(null, t.get(TestEnum.BAR));
-
- t = new HashMap<TestEnum,String>();
- t.put(TestEnum.FOO, "a");
- t.put(TestEnum.BAR, null);
- t.put(null, "b");
- t = roundTrip(t, HashMap.class, TestEnum.class, String.class);
- assertEquals("a", t.get(TestEnum.FOO));
- assertNull(t.get(TestEnum.BAR));
- assertEquals("b", t.get(null));
- }
-
- public enum TestEnum {
- FOO,BAR,BAZ
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripNumericConstructorsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripNumericConstructorsTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripNumericConstructorsTest.java
deleted file mode 100644
index 8177638..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripNumericConstructorsTest.java
+++ /dev/null
@@ -1,50 +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.a.rttests;
-
-import static org.junit.Assert.*;
-
-import java.util.*;
-
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.junit.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@SuppressWarnings({"javadoc","deprecation"})
-public class RoundTripNumericConstructorsTest extends RoundTripTest {
-
- public RoundTripNumericConstructorsTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- //====================================================================================================
- // Test parsing numbers to dates.
- //====================================================================================================
- @Test
- public void testParseNumberToDate() throws Exception {
- if (isValidationOnly())
- return;
-
- Serializer s = getSerializer();
- Parser p = getParser();
- Date d = new Date(100, 1, 1);
-
- Object r = s.serialize(d.getTime());
- Date d2 = p.parse(r, Date.class);
- assertEquals(d.getTime(), d2.getTime());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsAsStringsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsAsStringsTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsAsStringsTest.java
deleted file mode 100755
index 3b1aefa..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsAsStringsTest.java
+++ /dev/null
@@ -1,272 +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.a.rttests;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.junit.Assert.*;
-
-import org.apache.juneau.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.junit.*;
-
-/**
- * Tests to ensure the valueOf(String), fromString(String), parse(String), and parseString(String) methods
- * are used correctly by parsers.
- */
-@SuppressWarnings({"unused","javadoc"})
-public class RoundTripObjectsAsStringsTest extends RoundTripTest {
-
- public RoundTripObjectsAsStringsTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- //====================================================================================================
- // testBasic
- //====================================================================================================
- @Test
- public void testBasic() throws Exception {
- A t = new A().init();
- t = roundTrip(t);
- assertObjectEquals("{a1:{f:'1'},a2:{f:'2'},a3:{f:'3'},a4:{f:'4'}}", t);
- }
-
- public static class A {
- public A1 a1;
- public A2 a2;
- public A3 a3;
- public A4 a4;
-
- public A init() {
- a1 = new A1();
- a1.f = "1";
- a2 = new A2();
- a2.f = "2";
- a3 = new A3();
- a3.f = "3";
- a4 = new A4();
- a4.f = "4";
- return this;
- }
- }
-
- public static class A1 {
- public String f;
- public static A1 fromString(String s) {
- A1 x = new A1();
- x.f = s.substring(3);
- return x;
- }
- @Override /* Object */
- public String toString() {
- return "A1-" + f;
- }
- }
-
- public static class A2 {
- public String f;
- public static A2 valueOf(String s) {
- A2 x = new A2();
- x.f = s.substring(3);
- return x;
- }
- @Override /* Object */
- public String toString() {
- return "A2-" + f;
- }
- }
-
- public static class A3 {
- public String f;
- public static A3 parse(String s) {
- A3 x = new A3();
- x.f = s.substring(3);
- return x;
- }
- @Override /* Object */
- public String toString() {
- return "A3-" + f;
- }
- }
-
- public static class A4 {
- public String f;
- public static A4 parseString(String s) {
- A4 x = new A4();
- x.f = s.substring(3);
- return x;
- }
- @Override /* Object */
- public String toString() {
- return "A4-" + f;
- }
- }
-
- //====================================================================================================
- // testEnumWithOverriddenStringValue
- // The B1 enum should serialize as "X1" but the B2 enum should serialize as "X-1".
- //====================================================================================================
- @Test
- public void testEnumWithOverriddenStringValue() throws Exception {
- B t = new B().init();
- if (! returnOriginalObject) {
- Object r = getSerializer().serialize(t);
- assertTrue(TestUtils.toString(r).contains("X-2"));
- }
- t = roundTrip(t);
- assertObjectEquals("{b1:'X1',b2:'X-2'}", t);
- }
-
- public static class B {
- public B1 b1;
- public B2 b2;
-
- public B init() {
- b1 = B1.X1;
- b2 = B2.X2;
- return this;
- }
-
- }
-
- public static enum B1 {
- X1(1),
- X2(2),
- X3(3);
-
- private int i;
- B1(int i) {
- this.i = i;
- }
- }
-
- public static enum B2 {
- X1(1),
- X2(2),
- X3(3);
-
- private int i;
- B2(int i) {
- this.i = i;
- }
-
- @Override /* Object */
- public String toString() {
- return "X-" + i;
- }
-
- public static B2 fromString(String s) {
- return valueOf("X" + s.substring(2));
- }
- }
-
- //====================================================================================================
- // testMethodOrdering
- //====================================================================================================
- @Test
- public void testOrdering() throws Exception {
- C t = new C().init();
- t = roundTrip(t);
- assertObjectEquals("{c1:{f:'1'},c2:{f:'2'},c3:{f:'3'},c4:{f:'4'}}", t);
- }
-
- public static class C {
- public C1 c1;
- public C2 c2;
- public C3 c3;
- public C4 c4;
-
- public C init() {
- c1 = new C1();
- c1.f = "1";
- c2 = new C2();
- c2.f = "2";
- c3 = new C3();
- c3.f = "3";
- c4 = new C4();
- c4.f = "4";
- return this;
- }
- }
-
- public static class C1 {
- public String f;
- public static C2 valueOf(String s) {
- throw new RuntimeException("Shouldn't be called!");
- }
- public static C2 parse(String s) {
- throw new RuntimeException("Shouldn't be called!");
- }
- public static C2 parseString(String s) {
- throw new RuntimeException("Shouldn't be called!");
- }
- public static C1 fromString(String s) {
- C1 x = new C1();
- x.f = s.substring(3);
- return x;
- }
-
- @Override /* Object */
- public String toString() {
- return "C1-" + f;
- }
- }
-
- public static class C2 {
- public String f;
- public static C2 parse(String s) {
- throw new RuntimeException("Shouldn't be called!");
- }
- public static C2 parseString(String s) {
- throw new RuntimeException("Shouldn't be called!");
- }
- public static C2 valueOf(String s) {
- C2 x = new C2();
- x.f = s.substring(3);
- return x;
- }
- @Override /* Object */
- public String toString() {
- return "C2-" + f;
- }
- }
-
- public static class C3 {
- public String f;
- public static C2 parseString(String s) {
- throw new RuntimeException("Shouldn't be called!");
- }
- public static C3 parse(String s) {
- C3 x = new C3();
- x.f = s.substring(3);
- return x;
- }
- @Override /* Object */
- public String toString() {
- return "C3-" + f;
- }
- }
-
- public static class C4 {
- public String f;
- public static C4 parseString(String s) {
- C4 x = new C4();
- x.f = s.substring(3);
- return x;
- }
- @Override /* Object */
- public String toString() {
- return "C4" + f;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsWithSpecialMethodsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsWithSpecialMethodsTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsWithSpecialMethodsTest.java
deleted file mode 100755
index a3fc073..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripObjectsWithSpecialMethodsTest.java
+++ /dev/null
@@ -1,114 +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.a.rttests;
-
-import static org.apache.juneau.TestUtils.*;
-import static org.junit.Assert.*;
-
-import java.util.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.junit.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@SuppressWarnings("javadoc")
-public class RoundTripObjectsWithSpecialMethodsTest extends RoundTripTest {
-
- public RoundTripObjectsWithSpecialMethodsTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- //====================================================================================================
- // @NameProperty method.
- //====================================================================================================
- @Test
- public void testNameProperty() throws Exception {
- A t = new A().init();
- t = roundTrip(t);
- assertObjectEquals("{a2:{f2:2},m:{k1:{f2:2}}}", t);
- if (isValidationOnly())
- return;
- assertEquals("a2", t.a2.name);
- assertEquals("k1", t.m.get("k1").name);
- }
-
- public static class A {
- public A2 a2;
- public Map<String,A2> m;
-
- A init() {
- a2 = new A2().init();
- m = new LinkedHashMap<String,A2>();
- m.put("k1", new A2().init());
- return this;
- }
-
- }
- public static class A2 {
- String name;
- public int f2;
-
- @NameProperty
- protected void setName(String name) {
- this.name = name;
- }
-
- A2 init() {
- f2 = 2;
- return this;
- }
- }
-
- //====================================================================================================
- // @ParentProperty method.
- //====================================================================================================
- @Test
- public void testParentProperty() throws Exception {
- B t = new B().init();
- t = roundTrip(t);
- if (isValidationOnly())
- return;
- assertEquals(t.f1, t.b2.parent.f1);
- }
-
- public static class B {
- public int f1;
- public B2 b2;
-
- B init() {
- f1 = 1;
- b2 = new B2().init();
- return this;
- }
-
- }
- public static class B2 {
- B parent;
- public int f2;
-
- @ParentProperty
- protected void setParent(B parent) {
- this.parent = parent;
- }
-
- B2 init() {
- f2 = 2;
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitiveObjectBeansTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitiveObjectBeansTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitiveObjectBeansTest.java
deleted file mode 100755
index fb3f952..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitiveObjectBeansTest.java
+++ /dev/null
@@ -1,198 +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.a.rttests;
-
-import static org.junit.Assert.*;
-
-import org.apache.juneau.jena.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.testbeans.*;
-import org.junit.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@SuppressWarnings("javadoc")
-public class RoundTripPrimitiveObjectBeansTest extends RoundTripTest {
-
- public RoundTripPrimitiveObjectBeansTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- //====================================================================================================
- // testPrimitiveObjectsBean
- //====================================================================================================
- @Test
- public void testPrimitiveObjectsBean() throws Exception {
- PrimitiveObjectsBean t = new PrimitiveObjectsBean().init();
- t = roundTrip(t, PrimitiveObjectsBean.class);
- t = roundTrip(t, PrimitiveObjectsBean.class);
-
- // primitives
- assertEquals(Boolean.valueOf(true), t.poBoolean);
- assertEquals(Byte.valueOf((byte)1), t.poByte);
- assertEquals(Character.valueOf('a'), t.poChar);
- assertEquals(Short.valueOf("2"), t.poShort);
- assertEquals(Integer.valueOf(3), t.poInt);
- assertEquals(Long.valueOf(4), t.poLong);
- assertEquals(Float.valueOf(5), t.poFloat);
- assertEquals(Double.valueOf(6), t.poDouble);
- assertEquals(Integer.valueOf(7), t.poNumber);
- assertEquals(8, t.poBigInteger.intValue());
- assertTrue(t.poBigDecimal.floatValue() == 9f);
-
- // uninitialized primitives
- assertNull(t.pouBoolean);
- assertNull(t.pouByte);
- assertNull(t.pouChar);
- assertNull(t.pouShort);
- assertNull(t.pouInt);
- assertNull(t.pouLong);
- assertNull(t.pouFloat);
- assertNull(t.pouDouble);
- assertNull(t.pouNumber);
- assertNull(t.pouBigInteger);
- assertNull(t.pouBigDecimal);
-
- // primitive arrays
- assertEquals(Boolean.valueOf(false), t.poaBoolean[1][0]);
- assertEquals(Byte.valueOf((byte)2), t.poaByte[1][0]);
- assertEquals(Character.valueOf('b'), t.poaChar[1][0]);
- assertEquals(Short.valueOf("2"), t.poaShort[1][0]);
- assertEquals(Integer.valueOf(2), t.poaInt[1][0]);
- assertEquals(Long.valueOf(2), t.poaLong[1][0]);
- assertEquals(Float.valueOf(2), t.poaFloat[1][0]);
- assertEquals(Double.valueOf(2), t.poaDouble[1][0]);
- assertEquals(Integer.valueOf(2), t.poaNumber[1][0]);
- assertEquals(2, t.poaBigInteger[1][0].intValue());
- assertEquals(2, t.poaBigDecimal[1][0].intValue());
- assertNull(t.poaBoolean[2]);
- assertNull(t.poaByte[2]);
- assertNull(t.poaChar[2]);
- assertNull(t.poaShort[2]);
- assertNull(t.poaInt[2]);
- assertNull(t.poaLong[2]);
- assertNull(t.poaFloat[2]);
- assertNull(t.poaDouble[2]);
- assertNull(t.poaNumber[2]);
- assertNull(t.poaBigInteger[2]);
- assertNull(t.poaBigDecimal[2]);
-
- // uninitialized primitive arrays
- assertNull(t.poauBoolean);
- assertNull(t.poauByte);
- assertNull(t.poauChar);
- assertNull(t.poauShort);
- assertNull(t.poauInt);
- assertNull(t.poauLong);
- assertNull(t.poauFloat);
- assertNull(t.poauDouble);
- assertNull(t.poauNumber);
- assertNull(t.poauBigInteger);
- assertNull(t.poauBigDecimal);
-
- // anonymous list of object primitive arrays
- assertEquals(Boolean.valueOf(true), t.poalBoolean.get(0)[0]);
- assertEquals(Byte.valueOf((byte)1), t.poalByte.get(0)[0]);
- assertEquals(Character.valueOf('a'), t.poalChar.get(0)[0]);
- assertEquals(Short.valueOf((short)1), t.poalShort.get(0)[0]);
- assertEquals(Integer.valueOf(1), t.poalInt.get(0)[0]);
- assertEquals(Long.valueOf(1l), t.poalLong.get(0)[0]);
- assertEquals(Float.valueOf(1f), t.poalFloat.get(0)[0]);
- assertEquals(Double.valueOf(1d), t.poalDouble.get(0)[0]);
- assertEquals(1, t.poalBigInteger.get(0)[0].intValue());
- assertEquals(1, t.poalBigDecimal.get(0)[0].intValue());
- assertNull(t.poalBoolean.get(1));
- assertNull(t.poalByte.get(1));
- assertNull(t.poalChar.get(1));
- assertNull(t.poalShort.get(1));
- assertNull(t.poalInt.get(1));
- assertNull(t.poalLong.get(1));
- assertNull(t.poalFloat.get(1));
- assertNull(t.poalDouble.get(1));
- assertNull(t.poalNumber.get(1));
- assertNull(t.poalBigInteger.get(1));
- assertNull(t.poalBigDecimal.get(1));
-
- // regular list of object primitive arrays
- assertEquals(Boolean.valueOf(true), t.polBoolean.get(0)[0]);
- assertEquals(Byte.valueOf((byte)1), t.polByte.get(0)[0]);
- assertEquals(Character.valueOf('a'), t.polChar.get(0)[0]);
- assertEquals(Short.valueOf((short)1), t.polShort.get(0)[0]);
- assertEquals(Integer.valueOf(1), t.polInt.get(0)[0]);
- assertEquals(Long.valueOf(1l), t.polLong.get(0)[0]);
- assertEquals(Float.valueOf(1f), t.polFloat.get(0)[0]);
- assertEquals(Double.valueOf(1d), t.polDouble.get(0)[0]);
- assertEquals(1, t.polBigInteger.get(0)[0].intValue());
- assertEquals(1, t.polBigDecimal.get(0)[0].intValue());
- assertNull(t.polBoolean.get(1));
- assertNull(t.polByte.get(1));
- assertNull(t.polChar.get(1));
- assertNull(t.polShort.get(1));
- assertNull(t.polInt.get(1));
- assertNull(t.polLong.get(1));
- assertNull(t.polFloat.get(1));
- assertNull(t.polDouble.get(1));
- assertNull(t.polNumber.get(1));
- assertNull(t.polBigInteger.get(1));
- assertNull(t.polBigDecimal.get(1));
- }
-
- //====================================================================================================
- // testPrimitiveAtomicObjectsBean
- //====================================================================================================
- @Test
- public void testPrimitiveAtomicObjectsBean() throws Exception {
-
- // Jena does not support parsing into AtomicIntegers and AtomicLongs.
- if (getSerializer() instanceof RdfSerializer)
- return;
-
- PrimitiveAtomicObjectsBean t = new PrimitiveAtomicObjectsBean().init();
- t = roundTrip(t, PrimitiveAtomicObjectsBean.class);
- t = roundTrip(t, PrimitiveAtomicObjectsBean.class);
-
- // primitives
- assertEquals(1, t.poAtomicInteger.intValue());
- assertEquals(2, t.poAtomicLong.intValue());
-
- // uninitialized primitives
- assertNull(t.pouAtomicInteger);
- assertNull(t.pouAtomicLong);
-
- // primitive arrays
- assertEquals(2, t.poaAtomicInteger[1][0].intValue());
- assertEquals(2, t.poaAtomicLong[1][0].intValue());
- assertNull(t.poaAtomicInteger[2]);
- assertNull(t.poaAtomicLong[2]);
-
- // uninitialized primitive arrays
- assertNull(t.poauAtomicInteger);
- assertNull(t.poauAtomicLong);
-
- // anonymous list of object primitive arrays
- assertEquals(1, t.poalAtomicInteger.get(0)[0].intValue());
- assertEquals(1, t.poalAtomicLong.get(0)[0].intValue());
- assertNull(t.poalAtomicInteger.get(1));
- assertNull(t.poalAtomicLong.get(1));
-
- // regular list of object primitive arrays
- assertEquals(1, t.polAtomicInteger.get(0)[0].intValue());
- assertEquals(1, t.polAtomicLong.get(0)[0].intValue());
- assertNull(t.polAtomicInteger.get(1));
- assertNull(t.polAtomicLong.get(1));
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitivesBeansTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitivesBeansTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitivesBeansTest.java
deleted file mode 100755
index 85a87b2..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripPrimitivesBeansTest.java
+++ /dev/null
@@ -1,352 +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.a.rttests;
-
-import static org.junit.Assert.*;
-
-import java.util.*;
-
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.apache.juneau.utils.*;
-import org.junit.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@SuppressWarnings({"javadoc"})
-public class RoundTripPrimitivesBeansTest extends RoundTripTest {
-
- public RoundTripPrimitivesBeansTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- //====================================================================================================
- // testPrimitivesBean
- //====================================================================================================
- @Test
- public void testPrimitivesBean() throws Exception {
- PrimitivesBean t = new PrimitivesBean().init();
- t = roundTrip(t, PrimitivesBean.class);
-
- // primitives
- assertEquals(true, t.pBoolean);
- assertEquals(1, t.pByte);
- assertEquals('a', t.pChar);
- assertEquals(2, t.pShort);
- assertEquals(3, t.pInt);
- assertEquals(4l, t.pLong);
- assertEquals(5f, t.pFloat, 0.1f);
- assertEquals(6d, t.pDouble, 0.1f);
-
- // uninitialized primitives
- assertEquals(false, t.puBoolean);
- assertEquals(0, t.puByte);
- assertEquals((char)0, t.puChar);
- assertEquals(0, t.puShort);
- assertEquals(0, t.puInt);
- assertEquals(0l, t.puLong);
- assertEquals(0f, t.puFloat, 0.1f);
- assertEquals(0d, t.puDouble, 0.1f);
-
- // primitive arrays
- assertEquals(false, t.paBoolean[1][0]);
- assertEquals(2, t.paByte[1][0]);
- assertEquals('b', t.paChar[1][0]);
- assertEquals(2, t.paShort[1][0]);
- assertEquals(2, t.paInt[1][0]);
- assertEquals(2l, t.paLong[1][0]);
- assertEquals(2f, t.paFloat[1][0], 0.1f);
- assertEquals(2d, t.paDouble[1][0], 0.1f);
- assertNull(t.paBoolean[2]);
- assertNull(t.paByte[2]);
- assertNull(t.paChar[2]);
- assertNull(t.paShort[2]);
- assertNull(t.paInt[2]);
- assertNull(t.paLong[2]);
- assertNull(t.paFloat[2]);
- assertNull(t.paDouble[2]);
-
- // uninitialized primitive arrays
- assertNull(t.pauBoolean);
- assertNull(t.pauByte);
- assertNull(t.pauChar);
- assertNull(t.pauShort);
- assertNull(t.pauInt);
- assertNull(t.pauLong);
- assertNull(t.pauFloat);
- assertNull(t.pauDouble);
-
- // anonymous list of primitive arrays
- assertEquals(true, t.palBoolean.get(0)[0]);
- assertEquals(1, t.palByte.get(0)[0]);
- assertEquals('a', t.palChar.get(0)[0]);
- assertEquals(1, t.palShort.get(0)[0]);
- assertEquals(1, t.palInt.get(0)[0]);
- assertEquals(1l, t.palLong.get(0)[0]);
- assertEquals(1f, t.palFloat.get(0)[0], 0.1f);
- assertEquals(1d, t.palDouble.get(0)[0], 0.1f);
- assertNull(t.palBoolean.get(1));
- assertNull(t.palByte.get(1));
- assertNull(t.palChar.get(1));
- assertNull(t.palShort.get(1));
- assertNull(t.palInt.get(1));
- assertNull(t.palLong.get(1));
- assertNull(t.palFloat.get(1));
- assertNull(t.palDouble.get(1));
-
- // regular list of primitive arrays
- assertEquals(true, t.plBoolean.get(0)[0]);
- assertEquals(1, t.plByte.get(0)[0]);
- assertEquals('a', t.plChar.get(0)[0]);
- assertEquals(1, t.plShort.get(0)[0]);
- assertEquals(1, t.plInt.get(0)[0]);
- assertEquals(1l, t.plLong.get(0)[0]);
- assertEquals(1f, t.plFloat.get(0)[0], 0.1f);
- assertEquals(1d, t.plDouble.get(0)[0], 0.1f);
- assertNull(t.plBoolean.get(1));
- assertNull(t.plByte.get(1));
- assertNull(t.plChar.get(1));
- assertNull(t.plShort.get(1));
- assertNull(t.plInt.get(1));
- assertNull(t.plLong.get(1));
- assertNull(t.plFloat.get(1));
- assertNull(t.plDouble.get(1));
- }
-
- public static class PrimitivesBean {
-
- // primitives
- public boolean pBoolean;
- public byte pByte;
- public char pChar;
- public short pShort;
- public int pInt;
- public long pLong;
- public float pFloat;
- public double pDouble;
-
- // uninitialized primitives
- public boolean puBoolean;
- public byte puByte;
- public char puChar;
- public short puShort;
- public int puInt;
- public long puLong;
- public float puFloat;
- public double puDouble;
-
- // primitive arrays
- public boolean[][] paBoolean;
- public byte[][] paByte;
- public char[][] paChar;
- public short[][] paShort;
- public int[][] paInt;
- public long[][] paLong;
- public float[][] paFloat;
- public double[][] paDouble;
-
- // uninitialized primitive arrays
- public boolean[][] pauBoolean;
- public byte[][] pauByte;
- public char[][] pauChar;
- public short[][] pauShort;
- public int[][] pauInt;
- public long[][] pauLong;
- public float[][] pauFloat;
- public double[][] pauDouble;
-
- // Regular lists of primitives
- public List<boolean[]> plBoolean;
- public List<byte[]> plByte;
- public List<char[]> plChar;
- public List<short[]> plShort;
- public List<int[]> plInt;
- public List<long[]> plLong;
- public List<float[]> plFloat;
- public List<double[]> plDouble;
-
- // Anonymous list of primitives
- public List<boolean[]> palBoolean;
- public List<byte[]> palByte;
- public List<char[]> palChar;
- public List<short[]> palShort;
- public List<int[]> palInt;
- public List<long[]> palLong;
- public List<float[]> palFloat;
- public List<double[]> palDouble;
-
- public PrimitivesBean init() {
- // primitives
- pBoolean = true;
- pByte = 1;
- pChar = 'a';
- pShort = 2;
- pInt = 3;
- pLong = 4l;
- pFloat = 5f;
- pDouble = 6d;
-
- // primitive arrays
- paBoolean = new boolean[][]{{true},{false},null};
- paByte = new byte[][]{{1},{2},null};
- paChar = new char[][]{{'a'},{'b'},null};
- paShort = new short[][]{{1},{2},null};
- paInt = new int[][]{{1},{2},null};
- paLong = new long[][]{{1},{2},null};
- paFloat = new float[][]{{1},{2},null};
- paDouble = new double[][]{{1},{2},null};
-
- // Regular lists of primitives
- plBoolean = new AList<boolean[]>().append(new boolean[]{true}).append(null);
- plByte = new AList<byte[]>().append(new byte[]{1}).append(null);
- plChar = new AList<char[]>().append(new char[]{'a'}).append(null);
- plShort = new AList<short[]>().append(new short[]{1}).append(null);
- plInt = new AList<int[]>().append(new int[]{1}).append(null);
- plLong = new AList<long[]>().append(new long[]{1}).append(null);
- plFloat = new AList<float[]>().append(new float[]{1}).append(null);
- plDouble = new AList<double[]>().append(new double[]{1}).append(null);
-
- // Anonymous list of primitives
- palBoolean = new ArrayList<boolean[]>();
- palBoolean.add(new boolean[]{true});
- palBoolean.add(null);
- palByte = new ArrayList<byte[]>();
- palByte.add(new byte[]{1});
- palByte.add(null);
- palChar = new ArrayList<char[]>();
- palChar.add(new char[]{'a'});
- palChar.add(null);
- palShort = new ArrayList<short[]>();
- palShort.add(new short[]{1});
- palShort.add(null);
- palInt = new ArrayList<int[]>();
- palInt.add(new int[]{1});
- palInt.add(null);
- palLong = new ArrayList<long[]>();
- palLong.add(new long[]{1});
- palLong.add(null);
- palFloat = new ArrayList<float[]>();
- palFloat.add(new float[]{1});
- palFloat.add(null);
- palDouble = new ArrayList<double[]>();
- palDouble.add(new double[]{1});
- palDouble.add(null);
- return this;
- }
- }
-
- //====================================================================================================
- // List of PrimitivesBean
- //====================================================================================================
- @Test
- public void testPrimitivesBeanList() throws Exception {
- List<PrimitivesBean> t = new AList<PrimitivesBean>()
- .append(new PrimitivesBean().init())
- .append(null)
- .append(new PrimitivesBean().init())
- ;
- if (p == null)
- return;
- t = roundTrip(t, List.class, PrimitivesBean.class);
-
- PrimitivesBean t2 = t.get(2);
-
- // primitives
- assertEquals(true, t2.pBoolean);
- assertEquals(1, t2.pByte);
- assertEquals('a', t2.pChar);
- assertEquals(2, t2.pShort);
- assertEquals(3, t2.pInt);
- assertEquals(4l, t2.pLong);
- assertEquals(5f, t2.pFloat, 0.1f);
- assertEquals(6d, t2.pDouble, 0.1f);
-
- // uninitialized primitives
- assertEquals(false, t2.puBoolean);
- assertEquals(0, t2.puByte);
- assertEquals((char)0, t2.puChar);
- assertEquals(0, t2.puShort);
- assertEquals(0, t2.puInt);
- assertEquals(0l, t2.puLong);
- assertEquals(0f, t2.puFloat, 0.1f);
- assertEquals(0d, t2.puDouble, 0.1f);
-
- // primitive arrays
- assertEquals(false, t2.paBoolean[1][0]);
- assertEquals(2, t2.paByte[1][0]);
- assertEquals('b', t2.paChar[1][0]);
- assertEquals(2, t2.paShort[1][0]);
- assertEquals(2, t2.paInt[1][0]);
- assertEquals(2l, t2.paLong[1][0]);
- assertEquals(2f, t2.paFloat[1][0], 0.1f);
- assertEquals(2d, t2.paDouble[1][0], 0.1f);
- assertNull(t2.paBoolean[2]);
- assertNull(t2.paByte[2]);
- assertNull(t2.paChar[2]);
- assertNull(t2.paShort[2]);
- assertNull(t2.paInt[2]);
- assertNull(t2.paLong[2]);
- assertNull(t2.paFloat[2]);
- assertNull(t2.paDouble[2]);
-
- // uninitialized primitive arrays
- assertNull(t2.pauBoolean);
- assertNull(t2.pauByte);
- assertNull(t2.pauChar);
- assertNull(t2.pauShort);
- assertNull(t2.pauInt);
- assertNull(t2.pauLong);
- assertNull(t2.pauFloat);
- assertNull(t2.pauDouble);
-
- // anonymous list of primitive arrays
- assertEquals(true, t2.palBoolean.get(0)[0]);
- assertEquals(1, t2.palByte.get(0)[0]);
- assertEquals('a', t2.palChar.get(0)[0]);
- assertEquals(1, t2.palShort.get(0)[0]);
- assertEquals(1, t2.palInt.get(0)[0]);
- assertEquals(1l, t2.palLong.get(0)[0]);
- assertEquals(1f, t2.palFloat.get(0)[0], 0.1f);
- assertEquals(1d, t2.palDouble.get(0)[0], 0.1f);
- assertNull(t2.palBoolean.get(1));
- assertNull(t2.palByte.get(1));
- assertNull(t2.palChar.get(1));
- assertNull(t2.palShort.get(1));
- assertNull(t2.palInt.get(1));
- assertNull(t2.palLong.get(1));
- assertNull(t2.palFloat.get(1));
- assertNull(t2.palDouble.get(1));
-
- // regular list of primitive arrays
- assertEquals(true, t2.plBoolean.get(0)[0]);
- assertEquals(1, t2.plByte.get(0)[0]);
- assertEquals('a', t2.plChar.get(0)[0]);
- assertEquals(1, t2.plShort.get(0)[0]);
- assertEquals(1, t2.plInt.get(0)[0]);
- assertEquals(1l, t2.plLong.get(0)[0]);
- assertEquals(1f, t2.plFloat.get(0)[0], 0.1f);
- assertEquals(1d, t2.plDouble.get(0)[0], 0.1f);
- assertNull(t2.plBoolean.get(1));
- assertNull(t2.plByte.get(1));
- assertNull(t2.plChar.get(1));
- assertNull(t2.plShort.get(1));
- assertNull(t2.plInt.get(1));
- assertNull(t2.plLong.get(1));
- assertNull(t2.plFloat.get(1));
- assertNull(t2.plDouble.get(1));
-
- assertNull(t.get(1));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-juneau/blob/ab15d45b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripReadOnlyBeansTest.java
----------------------------------------------------------------------
diff --git a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripReadOnlyBeansTest.java b/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripReadOnlyBeansTest.java
deleted file mode 100755
index ce4e5c4..0000000
--- a/juneau-core-test/src/test/java/org/apache/juneau/a/rttests/RoundTripReadOnlyBeansTest.java
+++ /dev/null
@@ -1,101 +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.a.rttests;
-
-import static org.junit.Assert.*;
-
-import org.apache.juneau.annotation.*;
-import org.apache.juneau.parser.*;
-import org.apache.juneau.serializer.*;
-import org.junit.*;
-
-/**
- * Tests designed to serialize and parse objects to make sure we end up
- * with the same objects for all serializers and parsers.
- */
-@SuppressWarnings("javadoc")
-public class RoundTripReadOnlyBeansTest extends RoundTripTest {
-
- public RoundTripReadOnlyBeansTest(String label, SerializerBuilder s, ParserBuilder p, int flags) throws Exception {
- super(label, s, p, flags);
- }
-
- //====================================================================================================
- // test
- //====================================================================================================
- @Test
- public void test() throws Exception {
- B t1 = new B(1, "a"), t2 = new B(2, "b");
- A t3 = new A(t1, t2);
-
- t3 = roundTrip(t3, A.class);
- assertEquals(1, t3.getF1().getF1());
- assertEquals("a", t3.getF1().getF2());
- assertEquals(2, t3.getF2().getF1());
- assertEquals("b", t3.getF2().getF2());
- }
-
- public static class A {
- private B f1;
- private final B f2;
-
- @BeanConstructor(properties="f2")
- public A(B f2) {
- this.f2 = f2;
- }
-
- public A(B f1, B f2) {
- this.f1 = f1;
- this.f2 = f2;
- }
-
- public B getF1() {
- return f1;
- }
-
- public void setF1(B f1) {
- this.f1 = f1;
- }
-
- public B getF2() {
- return f2;
- }
- }
-
- public static class B {
- private int f1;
- private final String f2;
-
- @BeanConstructor(properties="f2")
- public B(String sField) {
- this.f2 = sField;
- }
-
- public B(int iField, String sField) {
- this.f1 = iField;
- this.f2 = sField;
- }
-
- public int getF1() {
- return f1;
- }
-
- public void setF1(int f1) {
- this.f1 = f1;
- }
-
- public String getF2() {
- return f2;
- }
- }
-}