Skip to content

Commit dbd854d

Browse files
committed
Test improvements; remove unused class (ObjectIdMap)
1 parent f47b4fd commit dbd854d

File tree

3 files changed

+20
-50
lines changed

3 files changed

+20
-50
lines changed

src/main/java/com/fasterxml/jackson/databind/util/JSONWrappedObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class JSONWrappedObject implements JsonSerializable
4141
* to include (if any).
4242
*/
4343
protected final JavaType _serializationType;
44-
44+
4545
public JSONWrappedObject(String prefix, String suffix, Object value) {
4646
this(prefix, suffix, value, (JavaType) null);
4747
}

src/main/java/com/fasterxml/jackson/databind/util/ObjectIdMap.java

Lines changed: 0 additions & 38 deletions
This file was deleted.
Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.fasterxml.jackson.databind.misc;
22

3-
import com.fasterxml.jackson.databind.*;
3+
import java.util.Arrays;
44

5+
import com.fasterxml.jackson.databind.*;
56
import com.fasterxml.jackson.databind.util.JSONPObject;
7+
import com.fasterxml.jackson.databind.util.JSONWrappedObject;
68

79
public class TestJSONP
810
extends BaseMapTest
@@ -18,23 +20,23 @@ public Impl(String a, String b) {
1820
this.b = b;
1921
}
2022
}
21-
23+
24+
private final ObjectMapper MAPPER = new ObjectMapper();
25+
2226
public void testSimpleScalars() throws Exception
2327
{
24-
ObjectMapper m = new ObjectMapper();
2528
assertEquals("callback(\"abc\")",
26-
serializeAsString(m, new JSONPObject("callback", "abc")));
29+
MAPPER.writeValueAsString(new JSONPObject("callback", "abc")));
2730
assertEquals("calc(123)",
28-
serializeAsString(m, new JSONPObject("calc", Integer.valueOf(123))));
31+
MAPPER.writeValueAsString(new JSONPObject("calc", Integer.valueOf(123))));
2932
assertEquals("dummy(null)",
30-
serializeAsString(m, new JSONPObject("dummy", null)));
33+
MAPPER.writeValueAsString(new JSONPObject("dummy", null)));
3134
}
3235

3336
public void testSimpleBean() throws Exception
3437
{
35-
ObjectMapper m = new ObjectMapper();
3638
assertEquals("xxx({\"a\":\"123\",\"b\":\"456\"})",
37-
serializeAsString(m, new JSONPObject("xxx",
39+
MAPPER.writeValueAsString(new JSONPObject("xxx",
3840
new Impl("123", "456"))));
3941
}
4042

@@ -44,10 +46,16 @@ public void testSimpleBean() throws Exception
4446
*/
4547
public void testWithType() throws Exception
4648
{
47-
ObjectMapper m = new ObjectMapper();
4849
Object ob = new Impl("abc", "def");
49-
JavaType type = m.constructType(Base.class);
50+
JavaType type = MAPPER.constructType(Base.class);
5051
assertEquals("do({\"a\":\"abc\"})",
51-
serializeAsString(m, new JSONPObject("do", ob, type)));
52+
MAPPER.writeValueAsString(new JSONPObject("do", ob, type)));
53+
}
54+
55+
public void testGeneralWrapping() throws Exception
56+
{
57+
JSONWrappedObject input = new JSONWrappedObject("/*Foo*/", "\n// the end",
58+
Arrays.asList());
59+
assertEquals("/*Foo*/[]\n// the end", MAPPER.writeValueAsString(input));
5260
}
5361
}

0 commit comments

Comments
 (0)