Skip to content

Commit 552a543

Browse files
committed
Test cleanup
1 parent 292f05b commit 552a543

File tree

8 files changed

+28
-33
lines changed

8 files changed

+28
-33
lines changed

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadSimpleTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ static class DateWrapper {
3636
*/
3737

3838
public void testByteArray() throws Exception {
39-
byte[] result = JSON.std.beanFrom(byte[].class, quote("YWJj"));
39+
byte[] result = JSON.std.beanFrom(byte[].class, q("YWJj"));
4040
assertEquals("abc", new String(result, "UTF-8"));
4141
}
4242

4343
public void testCharArray() throws Exception {
44-
char[] result = JSON.std.beanFrom(char[].class, quote("abc"));
44+
char[] result = JSON.std.beanFrom(char[].class, q("abc"));
4545
assertEquals("abc", new String(result));
4646
}
4747

@@ -174,7 +174,7 @@ public void testBooleanFail() throws Exception {
174174

175175
public void testMiscScalars() throws Exception {
176176
assertEquals(new Date(123456L), JSON.std.beanFrom(Date.class,"123456"));
177-
assertEquals(Object.class, JSON.std.beanFrom(Class.class, quote(Object.class.getName())));
177+
assertEquals(Object.class, JSON.std.beanFrom(Class.class, q(Object.class.getName())));
178178
}
179179

180180
public void testMiscScalarFail() throws Exception {
@@ -264,7 +264,7 @@ public void testSimpleEnums() throws Exception
264264
assertEquals(ABC.B, abc);
265265

266266
// then from name
267-
abc = JSON.std.beanFrom(ABC.class, quote("C"));
267+
abc = JSON.std.beanFrom(ABC.class, q("C"));
268268
assertEquals(ABC.C, abc);
269269

270270
// `null`s ok too
@@ -303,7 +303,7 @@ public void testTreeReadWithoutCodec() throws Exception
303303
}
304304

305305
try {
306-
JSON.std.beanFrom(TreeNode.class, quote("abc"));
306+
JSON.std.beanFrom(TreeNode.class, q("abc"));
307307
fail("Should not pass");
308308
} catch (JSONObjectException e) {
309309
verifyException(e, "No `TreeCodec` specified");

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/ReadWithCtorsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ static class FromLong2 {
2525

2626
public void testStringCtor() throws Exception
2727
{
28-
FromString output = JSON.std.beanFrom(FromString.class, quote("abc"));
28+
FromString output = JSON.std.beanFrom(FromString.class, q("abc"));
2929
assertNotNull(output);
3030
assertEquals("abc", output.value);
3131
}

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/TestBase.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,14 @@ protected JsonParser parserFor(JSON json, String source) throws IOException {
5252
return json.getStreamingFactory().createParser(source.toCharArray());
5353
}
5454

55-
protected String quote(String str) {
55+
protected String q(String str) {
5656
return "\"" + str + "\"";
5757
}
5858

5959
protected String a2q(String json) {
6060
return json.replace('\'', '"');
6161
}
6262

63-
@Deprecated
64-
protected String aposToQuotes(String json) {
65-
return a2q(json);
66-
}
67-
6863
protected JSON jsonWithModifier(final ReaderWriterModifier modifier) {
6964
return JSON.builder().register(new JacksonJrExtension() {
7065
@Override

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/WriteSimpleTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,13 @@ public void testNest() throws Exception
103103
public void testKnownSimpleTypes() throws Exception
104104
{
105105
final String URL_STR = "http://fasterxml.com";
106-
assertEquals(quote(URL_STR),
106+
assertEquals(q(URL_STR),
107107
JSON.std.asString(new URI(URL_STR)));
108108
final String PATH = "/foo/bar.txt";
109-
assertEquals(quote(PATH),
109+
assertEquals(q(PATH),
110110
JSON.std.asString(new File(PATH)));
111111

112-
assertEquals(quote("B"), JSON.std.asString(ABC.B));
112+
assertEquals(q("B"), JSON.std.asString(ABC.B));
113113
assertEquals("1", JSON.std.with(Feature.WRITE_ENUMS_USING_INDEX).asString(ABC.B));
114114
}
115115

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/CustomValueReadersTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -224,21 +224,21 @@ public void testCustomEnumReader() throws Exception
224224
{
225225
// First: without handler, will fail to map
226226
try {
227-
JSON.std.beanFrom(ABC.class, quote("n/a"));
227+
JSON.std.beanFrom(ABC.class, q("n/a"));
228228
fail("Should not pass");
229229
} catch (JSONObjectException e) {
230230
verifyException(e, "Failed to find Enum of type");
231231
}
232232

233233
// then with custom, should be fine
234234
JSON json = jsonWithProvider(new CustomReaders(0));
235-
ABC v = json.beanFrom(ABC.class, quote("n/a"));
235+
ABC v = json.beanFrom(ABC.class, q("n/a"));
236236
assertEquals(ABC.DEF, v);
237237

238238
// but if we remove, again error
239239
JSON json2 = jsonWithProvider((ReaderWriterProvider) null);
240240
try {
241-
json2.beanFrom(ABC.class, quote("n/a"));
241+
json2.beanFrom(ABC.class, q("n/a"));
242242
fail("Should not pass");
243243
} catch (JSONObjectException e) {
244244
verifyException(e, "Failed to find Enum of type");
@@ -249,31 +249,31 @@ public void testCustomEnumReader() throws Exception
249249
public void testCustomStringReader() throws Exception
250250
{
251251
String allCaps = jsonWithProvider(new CapStringReaderProvider())
252-
.beanFrom(String.class, quote("Some text"));
252+
.beanFrom(String.class, q("Some text"));
253253
assertEquals("SOME TEXT", allCaps);
254254
}
255255

256256
public void testChainedStringReaders() throws Exception {
257257
String result = jsonWithProviders(new CapStringReaderProvider(),
258258
new OverrideStringReaderProvider("foo"))
259-
.beanFrom(String.class, quote("Some text"));
259+
.beanFrom(String.class, q("Some text"));
260260
assertEquals("SOME TEXT", result);
261261

262262
result = jsonWithProviders(new NoOpProvider(), new OverrideStringReaderProvider("foo"))
263-
.beanFrom(String.class, quote("Some text"));
263+
.beanFrom(String.class, q("Some text"));
264264
assertEquals("foo", result);
265265

266266
// and ok not to have anything, too
267267
result = jsonWithProviders(new NoOpProvider(), new NoOpProvider())
268-
.beanFrom(String.class, quote("Some text"));
268+
.beanFrom(String.class, q("Some text"));
269269
assertEquals("Some text", result);
270270

271271
// Plus nulls fine too
272272
result = jsonWithProviders(null, new OverrideStringReaderProvider("foo"))
273-
.beanFrom(String.class, quote("Some text"));
273+
.beanFrom(String.class, q("Some text"));
274274
assertEquals("foo", result);
275275
result = jsonWithProviders(new OverrideStringReaderProvider("foo"), null)
276-
.beanFrom(String.class, quote("Some text"));
276+
.beanFrom(String.class, q("Some text"));
277277
assertEquals("foo", result);
278278
}
279279

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/CustomValueWritersTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public void testCustomBeanWriter() throws Exception
8585
assertEquals("{\"wrapped\":{}}", JSON.std.asString(new CustomBeanWrapper()));
8686

8787
final JSON withCustom = jsonWithProvider(new CustomWriters());
88-
assertEquals(quote("xxx"), withCustom.asString(new CustomBean()));
88+
assertEquals(q("xxx"), withCustom.asString(new CustomBean()));
8989
assertEquals("{\"wrapped\":\"xxx\"}", withCustom.asString(new CustomBeanWrapper()));
9090
assertEquals("[\"xxx\"]", withCustom.asString(new CustomBean[] { new CustomBean() }));
9191
assertEquals("{\"value\":\"xxx\"}",
@@ -100,18 +100,18 @@ public void testCustomBeanWriter() throws Exception
100100

101101
public void testChainedBeanWriters() throws Exception
102102
{
103-
assertEquals(quote("abc"),
103+
assertEquals(q("abc"),
104104
jsonWithProviders(new CustomWriters("abc"), new CustomWriters("def"))
105105
.asString(new CustomBean()));
106-
assertEquals(quote("def"),
106+
assertEquals(q("def"),
107107
jsonWithProviders(new BogusProvider(), new CustomWriters("def"))
108108
.asString(new CustomBean()));
109109

110110
// as well as passing `null`
111-
assertEquals(quote("xxx"),
111+
assertEquals(q("xxx"),
112112
jsonWithProviders(null, new CustomWriters("xxx"))
113113
.asString(new CustomBean()));
114-
assertEquals(quote("yyy"),
114+
assertEquals(q("yyy"),
115115
jsonWithProviders(new CustomWriters("yyy"), null)
116116
.asString(new CustomBean()));
117117
}

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/ValueReaderModifierTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public ValueReader modifyValueReader(JSONReader readContext,
6969

7070
public void testStringReaderReplacement() throws Exception
7171
{
72-
final String input = quote("foobar");
72+
final String input = q("foobar");
7373
assertEquals("foobar", JSON.std.beanFrom(String.class, input));
7474

7575
// but then with modifier

jr-objects/src/test/java/com/fasterxml/jackson/jr/ob/impl/ValueWriterModifierTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ public Class<?> valueType() {
107107
final String input = "foobar";
108108
final JSON jsonWithMod = jsonWithModifier(mod);
109109
String result = jsonWithMod.asString(input);
110-
assertEquals(quote("FOOBAR"), result);
110+
assertEquals(q("FOOBAR"), result);
111111
// but also verify that no caching occurs wrt global standard variant:
112-
assertEquals(quote("foobar"), JSON.std.asString(input));
112+
assertEquals(q("foobar"), JSON.std.asString(input));
113113

114114
// And then also applicable for multiple POJO properties
115115
assertEquals(a2q("{'first':'BOB','last':'HOPE'}"),
@@ -138,7 +138,7 @@ public Class<?> valueType() {
138138
});
139139
final NameBean input = new NameBean("Foo", "Bar");
140140
String json = jsonWithModifier(mod).asString(input);
141-
assertEquals(quote("Foo-Bar"), json);
141+
assertEquals(q("Foo-Bar"), json);
142142
// but also verify that no caching occurs wrt global standard variant:
143143
assertEquals(a2q("{'first':'Foo','last':'Bar'}"),
144144
JSON.std.asString(input));

0 commit comments

Comments
 (0)