Skip to content

Commit

Permalink
Add unit test to make sure that subclasses of generic types are deser…
Browse files Browse the repository at this point in the history
…ialized properly.

git-svn-id: https://svn.apache.org/repos/asf/pivot/trunk@1039425 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
Gregory K. Brown committed Nov 26, 2010
1 parent 2670e03 commit b7136e6
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/test/org/apache/pivot/json/test/BindTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testListSubclass() throws IOException, SerializationException {
List<Object> list =
(List<Object>)listSerializer.readObject(getClass().getResourceAsStream("list.json"));

JSONSerializer typedListSerializer = new JSONSerializer(TestBean2List.class);
JSONSerializer typedListSerializer = new JSONSerializer(TestBean2ListSubclass.class);
TestBean2List typedList =
(TestBean2List)typedListSerializer.readObject(getClass().getResourceAsStream("list.json"));

Expand All @@ -103,7 +103,7 @@ public void testSequence() throws IOException, SerializationException {
List<Object> list =
(List<Object>)listSerializer.readObject(getClass().getResourceAsStream("list.json"));

JSONSerializer sequenceSerializer = new JSONSerializer(TestBean2Sequence.class);
JSONSerializer sequenceSerializer = new JSONSerializer(TestBean2SequenceSubclass.class);
TestBean2Sequence sequence =
(TestBean2Sequence)sequenceSerializer.readObject(getClass().getResourceAsStream("list.json"));

Expand Down Expand Up @@ -153,7 +153,7 @@ public void testTypedMap() throws IOException, SerializationException {
*/
@Test
public void testMapSubclass() throws IOException, SerializationException {
JSONSerializer typedMapSerializer = new JSONSerializer(TestBean2Map.class);
JSONSerializer typedMapSerializer = new JSONSerializer(TestBean2MapSubclass.class);

TestBean2Map map =
(TestBean2Map)typedMapSerializer.readObject(new StringReader("{foo: {a:1, b:2, c:'3'}}"));
Expand All @@ -170,7 +170,7 @@ public void testMapSubclass() throws IOException, SerializationException {
*/
@Test
public void testDictionary() throws IOException, SerializationException {
JSONSerializer dictionarySerializer = new JSONSerializer(TestBean2Dictionary.class);
JSONSerializer dictionarySerializer = new JSONSerializer(TestBean2DictionarySubclass.class);

TestBean2Dictionary dictionary =
(TestBean2Dictionary)dictionarySerializer.readObject(new StringReader("{foo: {a:1, b:2, c:'3'}}"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.pivot.json.test;

public class TestBean2DictionarySubclass extends TestBean2Dictionary {
private static final long serialVersionUID = 0;
}
21 changes: 21 additions & 0 deletions core/test/org/apache/pivot/json/test/TestBean2ListSubclass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.pivot.json.test;

public class TestBean2ListSubclass extends TestBean2List {
private static final long serialVersionUID = 0;
}
21 changes: 21 additions & 0 deletions core/test/org/apache/pivot/json/test/TestBean2MapSubclass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.pivot.json.test;

public class TestBean2MapSubclass extends TestBean2Map {
private static final long serialVersionUID = 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.pivot.json.test;

public class TestBean2SequenceSubclass extends TestBean2Sequence {
private static final long serialVersionUID = 0;
}

0 comments on commit b7136e6

Please sign in to comment.