Skip to content

Commit 9efe621

Browse files
committed
Test clean up
1 parent adcc4d0 commit 9efe621

File tree

9 files changed

+18
-23
lines changed

9 files changed

+18
-23
lines changed

guava/src/test/java/com/fasterxml/jackson/datatype/guava/HashCodeTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public void testSerialization() throws Exception
2525
public void testDeserialization() throws Exception
2626
{
2727
// success:
28-
HashCode result = MAPPER.readValue(quote("0123456789cAfEbAbE"), HashCode.class);
28+
HashCode result = MAPPER.readValue(q("0123456789cAfEbAbE"), HashCode.class);
2929
assertEquals("0123456789cafebabe", result.toString());
3030

3131
// and ... error:
3232
try {
33-
result = MAPPER.readValue(quote("ghijklmn0123456789"), HashCode.class);
33+
result = MAPPER.readValue(q("ghijklmn0123456789"), HashCode.class);
3434
fail("Should not deserialize from non-hex string: got "+result);
3535
} catch (MismatchedInputException e) {
3636
verifyException(e, "Illegal hexadecimal character");

guava/src/test/java/com/fasterxml/jackson/datatype/guava/HostAndPortTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,19 @@ public void testDeserializationOk() throws Exception
2727
// Actually, let's support both old style and new style
2828

2929
// old:
30-
HostAndPort result = MAPPER.readValue(aposToQuotes("{'hostText':'localhost','port':9090}"),
30+
HostAndPort result = MAPPER.readValue(a2q("{'hostText':'localhost','port':9090}"),
3131
HostAndPort.class);
3232
assertEquals("localhost", result.getHost());
3333
assertEquals(9090, result.getPort());
3434

3535
// and Alt Old too:
36-
result = MAPPER.readValue(aposToQuotes("{'port':8080, 'host':'foobar.com'}"),
36+
result = MAPPER.readValue(a2q("{'port':8080, 'host':'foobar.com'}"),
3737
HostAndPort.class);
3838
assertEquals("foobar.com", result.getHost());
3939
assertEquals(8080, result.getPort());
4040

4141
// and new:
42-
result = MAPPER.readValue(quote("localhost:7070"), HostAndPort.class);
42+
result = MAPPER.readValue(q("localhost:7070"), HostAndPort.class);
4343
assertEquals("localhost", result.getHost());
4444
assertEquals(7070, result.getPort());
4545

guava/src/test/java/com/fasterxml/jackson/datatype/guava/IterablesTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,10 @@ public String apply(String x) {
4747
}
4848
});
4949
String json = MAPPER.writeValueAsString(input);
50-
assertEquals(aposToQuotes("['rm','ob','selgnaj']"), json);
50+
assertEquals(a2q("['rm','ob','selgnaj']"), json);
5151

5252
// and then as property?
5353
json = MAPPER.writeValueAsString(new IterableWrapper(input));
54-
assertEquals(aposToQuotes("{'values':['rm','ob','selgnaj']}"), json);
54+
assertEquals(a2q("{'values':['rm','ob','selgnaj']}"), json);
5555
}
5656
}

guava/src/test/java/com/fasterxml/jackson/datatype/guava/ModuleTestBase.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@ protected JsonMapper.Builder builderWithModule(boolean absentsAsNulls) {
3636
}
3737

3838
protected String a2q(String json) {
39-
return aposToQuotes(json);
40-
}
41-
42-
protected String aposToQuotes(String json) {
4339
return json.replace("'", "\"");
4440
}
4541

46-
public String quote(String str) {
42+
public String q(String str) {
4743
return '"'+str+'"';
4844
}
4945

guava/src/test/java/com/fasterxml/jackson/datatype/guava/MultimapsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public void testNullHandling() throws Exception
205205
Multimap<String,Integer> input = ArrayListMultimap.create();
206206
input.put("empty", null);
207207
String json = MAPPER.writeValueAsString(input);
208-
assertEquals(aposToQuotes("{'empty':[null]}"), json);
208+
assertEquals(a2q("{'empty':[null]}"), json);
209209
}
210210

211211
// [datatypes-collections#27]:

guava/src/test/java/com/fasterxml/jackson/datatype/guava/ScalarTypesTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ public void testInternetDomainNameSerialization() throws Exception
1616
{
1717
final String INPUT = "google.com";
1818
InternetDomainName name = InternetDomainName.from(INPUT);
19-
assertEquals(quote(INPUT), MAPPER.writeValueAsString(name));
19+
assertEquals(q(INPUT), MAPPER.writeValueAsString(name));
2020
}
2121

2222
@Test
2323
public void testInternetDomainNameDeserialization() throws Exception
2424
{
2525
final String INPUT = "google.com";
26-
// InternetDomainName name = MAPPER.readValue(quote(INPUT), InternetDomainName.class);
27-
InternetDomainName name = new ObjectMapper().readValue(quote(INPUT), InternetDomainName.class);
26+
InternetDomainName name = MAPPER.readValue(q(INPUT), InternetDomainName.class);
2827
assertNotNull(name);
2928
assertEquals(INPUT, name.toString());
3029
}

guava/src/test/java/com/fasterxml/jackson/datatype/guava/optional/OptionalBasicTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ public void testPolymorphic() throws Exception
377377
@Test
378378
public void testWithCustomDeserializer() throws Exception
379379
{
380-
CaseChangingStringWrapper w = MAPPER.readValue(aposToQuotes("{'value':'FoobaR'}"),
380+
CaseChangingStringWrapper w = MAPPER.readValue(a2q("{'value':'FoobaR'}"),
381381
CaseChangingStringWrapper.class);
382382
assertEquals("foobar", w.value.get());
383383
}
@@ -387,6 +387,6 @@ public void testCustomSerializer() throws Exception
387387
{
388388
final String VALUE = "fooBAR";
389389
String json = MAPPER.writeValueAsString(new CaseChangingStringWrapper(VALUE));
390-
assertEquals(json, aposToQuotes("{'value':'FOOBAR'}"));
390+
assertEquals(json, a2q("{'value':'FOOBAR'}"));
391391
}
392392
}

guava/src/test/java/com/fasterxml/jackson/datatype/guava/optional/OptionalMergingTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,22 @@ public POJO(int x, int y) {
5555
@Test
5656
public void testStringReferenceMerging() throws Exception
5757
{
58-
MergedStringReference result = MAPPER.readValue(aposToQuotes("{'value':'override'}"),
58+
MergedStringReference result = MAPPER.readValue(a2q("{'value':'override'}"),
5959
MergedStringReference.class);
6060
assertEquals("override", result.value.get());
6161
}
6262

6363
@Test
6464
public void testPOJOReferenceMerging() throws Exception
6565
{
66-
MergedPOJOReference result = MAPPER.readValue(aposToQuotes("{'value':{'y':-6}}"),
66+
MergedPOJOReference result = MAPPER.readValue(a2q("{'value':{'y':-6}}"),
6767
MergedPOJOReference.class);
6868
assertEquals(7, result.value.get().x);
6969
assertEquals(-6, result.value.get().y);
7070

7171
// Also should retain values we pass
7272
result = MAPPER.readerForUpdating(new MergedPOJOReference(10, 20))
73-
.readValue(aposToQuotes("{'value':{'x':11}}"));
73+
.readValue(a2q("{'value':{'x':11}}"));
7474
assertEquals(11, result.value.get().x);
7575
assertEquals(20, result.value.get().y);
7676
}

guava/src/test/java/com/fasterxml/jackson/datatype/guava/optional/OptionalUnwrappedTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static class OptionalParent {
3535
public void testUntypedWithOptionalsNotNulls() throws Exception
3636
{
3737
final ObjectMapper mapper = mapperWithModule(false);
38-
String jsonExp = aposToQuotes("{'XX.name':'Bob'}");
38+
String jsonExp = a2q("{'XX.name':'Bob'}");
3939
String jsonAct = mapper.writeValueAsString(new OptionalParent());
4040
assertEquals(jsonExp, jsonAct);
4141
}
@@ -46,7 +46,7 @@ public void testUntypedWithOptionalsNotNulls() throws Exception
4646
public void testUntypedWithNullEqOptionals() throws Exception
4747
{
4848
final ObjectMapper mapper = mapperWithModule(true);
49-
String jsonExp = aposToQuotes("{'XX.name':'Bob'}");
49+
String jsonExp = a2q("{'XX.name':'Bob'}");
5050
String jsonAct = mapper.writeValueAsString(new OptionalParent());
5151
assertEquals(jsonExp, jsonAct);
5252
}

0 commit comments

Comments
 (0)