-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a8a1d46
commit b5dc929
Showing
2 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
src/test/java/com/fasterxml/jackson/failing/DeprecatedTypeHandlingTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package com.fasterxml.jackson.failing; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.databind.*; | ||
import com.fasterxml.jackson.databind.type.CollectionType; | ||
import com.fasterxml.jackson.databind.type.SimpleType; | ||
|
||
/** | ||
* Set of tests to ensure that changes between 2.6 and 2.7 can | ||
* be handled somewhat gracefully. | ||
*/ | ||
public class DeprecatedTypeHandlingTest extends BaseMapTest | ||
{ | ||
static class Point { | ||
public int x; | ||
|
||
int _y; | ||
|
||
public void setY(int y0) { _y = y0; } | ||
public int getY() { return _y; } | ||
} | ||
|
||
final ObjectMapper MAPPER = objectMapper(); | ||
|
||
@SuppressWarnings("deprecation") | ||
public void testExplicitCollectionType() throws Exception | ||
{ | ||
JavaType elem = SimpleType.construct(Point.class); | ||
|
||
Point p = MAPPER.readValue(aposToQuotes("{'x':1,'y':2}"), elem); | ||
assertNotNull(p); | ||
assertEquals(1, p.x); | ||
assertEquals(2, p.getY()); | ||
|
||
final String json = aposToQuotes("[ {'x':1,'y':2}, {'x':3,'y':6 }]"); | ||
|
||
System.err.println("ELEM -> "+elem); | ||
System.err.println("ELEM.raw -> "+elem.getRawClass()); | ||
JavaType t = CollectionType.construct(List.class, elem); | ||
List<Point> l = MAPPER.readValue(json, t); | ||
assertNotNull(l); | ||
assertEquals(2, l.size()); | ||
Object ob = l.get(0); | ||
assertEquals(Point.class, ob.getClass()); | ||
p = (Point) ob; | ||
assertEquals(1, p.x); | ||
assertEquals(2, p.getY()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters