Skip to content

Commit

Permalink
Merge branch '2.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 16, 2024
2 parents 41585cc + 72724b7 commit e9cf682
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 36 deletions.
16 changes: 8 additions & 8 deletions jr-objects/src/test/java/tools/jackson/jr/ob/ReadBeansTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static class URLBean {

public void testSimpleBean() throws Exception
{
final String INPUT = aposToQuotes("{'name':{'first':'Bob','last':'Burger'},'x':13, 'option': 'Option1'}");
final String INPUT = a2q("{'name':{'first':'Bob','last':'Burger'},'x':13, 'option': 'Option1'}");
TestBean bean = JSON.std.beanFrom(TestBean.class, INPUT);

assertNotNull(bean);
Expand All @@ -83,7 +83,7 @@ public void testSimpleBean() throws Exception

public void testSimpleBeanCaseInsensitive() throws Exception
{
final String INPUT = aposToQuotes(
final String INPUT = a2q(
"{'NaMe':{'FIRST':'Bob','last':'Burger'},'x':13, 'optioN': 'opTIOn1'}");
TestBean bean =
JSON.builder()
Expand All @@ -102,7 +102,7 @@ public void testSimpleBeanCaseInsensitive() throws Exception

public void testUnknownProps() throws Exception
{
final String INPUT = aposToQuotes("{'first':'Bob','middle':'Eugene', 'last':'Smith'}");
final String INPUT = a2q("{'first':'Bob','middle':'Eugene', 'last':'Smith'}");

// First: fine if marked as such
NameBean name = JSON.std
Expand All @@ -126,7 +126,7 @@ public void testUnknownProps() throws Exception

public void testPOJOWithList() throws Exception
{
final String INPUT = aposToQuotes("{'names': [ { 'first':'John','last':'Smith' },"
final String INPUT = a2q("{'names': [ { 'first':'John','last':'Smith' },"
+"{'first':'Bob','last':'Burger' } ] }");
NameListBean list = JSON.std.beanFrom(NameListBean.class, INPUT);
assertNotNull(list);
Expand All @@ -138,7 +138,7 @@ public void testPOJOWithList() throws Exception

public void testPOJOWithMap() throws Exception
{
final String INPUT = aposToQuotes("{'stuff': { 'a':3, 'b':4 } }");
final String INPUT = a2q("{'stuff': { 'a':3, 'b':4 } }");
MapBean map = JSON.std.beanFrom(MapBean.class, INPUT);
assertNotNull(map);
assertNotNull(map.stuff);
Expand All @@ -148,7 +148,7 @@ public void testPOJOWithMap() throws Exception

public void testSimpleBeanCollections() throws Exception
{
final String INPUT = aposToQuotes("["
final String INPUT = a2q("["
+"{'name':{'first':'Bob','last':'Burger'},'x':13}"
+",{'x':-145,'name':{'first':'Billy','last':'Bacon'}}"
+"]");
Expand Down Expand Up @@ -183,7 +183,7 @@ private void _verifySimpleBeanCollections(List<TestBean> beans) {
// @since 2.10
public void testSimpleBeanMaps() throws Exception
{
final String INPUT = aposToQuotes("{ 'first':"
final String INPUT = a2q("{ 'first':"
+"{'name':{'first':'Bob','last':'Burger'},'x':13}"
+", 'second':{'x':-145,'name':{'first':'Billy','last':'Bacon'}}"
+"}");
Expand Down Expand Up @@ -278,7 +278,7 @@ public void testNameWithLeadingUppers() throws Exception
final String expURL = "http://foo";
URLBean bean = JSON.std
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.beanFrom(URLBean.class, aposToQuotes("{'URL':'"+expURL+"'}"));
.beanFrom(URLBean.class, a2q("{'URL':'"+expURL+"'}"));
assertEquals(expURL, bean.url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ public void testPojoWithIsGetter() throws Exception

json = JSON.std.asString(new IsBean());
// by default, will use 'is-getter':
assertEquals(aposToQuotes("{'enabled':true,'value':42}"), json);
assertEquals(a2q("{'enabled':true,'value':42}"), json);

// but can disable
json = JSON.std
.without(JSON.Feature.USE_IS_GETTERS)
.asString(new IsBean());
assertEquals(aposToQuotes("{'value':42}"), json);
assertEquals(a2q("{'value':42}"), json);

// .... as well as using alternative
json = JSON.builder()
.disable(JSON.Feature.USE_IS_GETTERS)
.build()
.asString(new IsBean());
assertEquals(aposToQuotes("{'value':42}"), json);
assertEquals(a2q("{'value':42}"), json);

// and go back as well
json = JSON.std
.with(JSON.Feature.USE_IS_GETTERS)
.asString(new IsBean());
assertEquals(aposToQuotes("{'enabled':true,'value':42}"), json);
assertEquals(a2q("{'enabled':true,'value':42}"), json);
}

public void testFailOnDupMapKeys() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void testListOfMaps() throws Exception
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS)
.beanFrom(ListHolder.class,
aposToQuotes("{'stuff':[{'a':4}, {'a':6}]}"));
a2q("{'stuff':[{'a':4}, {'a':6}]}"));
List<Map<String, Integer>> list = h.stuff;
assertNotNull(list);
assertEquals(2, list.size());
Expand All @@ -100,7 +100,7 @@ public void testInvalidListOfMaps() throws Exception
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS)
.beanFrom(ListHolder.class,
aposToQuotes("{'stuff':{ 'a' : 3 }}"));
a2q("{'stuff':{ 'a' : 3 }}"));
} catch (JSONObjectException e) {
verifyException(e, "Unexpected token START_OBJECT");
}
Expand Down
4 changes: 2 additions & 2 deletions jr-objects/src/test/java/tools/jackson/jr/ob/ReadMapTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Map<String, Object> build() {

public void testMapOfLists() throws Exception
{
final String INPUT = aposToQuotes("{'stuff':{'a':[1, 2, 3], 'b' : [7, 2]}}");
final String INPUT = a2q("{'stuff':{'a':[1, 2, 3], 'b' : [7, 2]}}");
final JSON j = JSON.std
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS);
Expand All @@ -82,7 +82,7 @@ public void testInvalidMapOfLists() throws Exception
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS)
.beanFrom(MapHolder.class,
aposToQuotes("{'stuff':[ 1 ]}"));
a2q("{'stuff':[ 1 ]}"));
} catch (JSONObjectException e) {
verifyException(e, "Unexpected token START_ARRAY");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static class Bean {

public void testAnySequence() throws Exception
{
final String INPUT = aposToQuotes("'hello world!' 127 true [ 1, 2, 3]\nnull { 'msg':'none'} ");
final String INPUT = a2q("'hello world!' 127 true [ 1, 2, 3]\nnull { 'msg':'none'} ");

// First, managed
ValueIterator<Object> it = JSON.std.anySequenceFrom(INPUT);
Expand Down Expand Up @@ -104,7 +104,7 @@ private void _verifyAnySequence(ValueIterator<Object> it) throws Exception

public void testBeanSequence() throws Exception
{
final String INPUT = aposToQuotes("{'id':1, 'msg':'foo'} {'id':2, 'msg':'Same'} null ");
final String INPUT = a2q("{'id':1, 'msg':'foo'} {'id':2, 'msg':'Same'} null ");

// First, managed
ValueIterator<Bean> it = JSON.std.beanSequenceFrom(Bean.class, INPUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,13 @@ public void testNullForMiscScalars() throws Exception {

// Testing that `null` will not cause an exception, for now at least
public void testNullForPrimitiveProperties() throws Exception {
BooleanWrapper w = JSON.std.beanFrom(BooleanWrapper.class, aposToQuotes("{'value':null}"));
BooleanWrapper w = JSON.std.beanFrom(BooleanWrapper.class, a2q("{'value':null}"));
assertNotNull(w);
assertFalse(w.value);
}

public void testNullForScalarProperties() throws Exception {
DateWrapper w = JSON.std.beanFrom(DateWrapper.class, aposToQuotes("{'value':null}"));
DateWrapper w = JSON.std.beanFrom(DateWrapper.class, a2q("{'value':null}"));
assertNotNull(w);
assertNull(w.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void testComposerWithPojo() throws Exception
.end()
.end()
.finish();
assertEquals(aposToQuotes("[{'first':'Bob'},{'name':{'first':'Bill'}}]"), json);
assertEquals(a2q("[{'first':'Bob'},{'name':{'first':'Bill'}}]"), json);
}

public void testComposerWithIndent() throws Exception
Expand All @@ -136,7 +136,7 @@ public void testComposerWithIndent() throws Exception
.put("name", "Bill")
.end()
.finish();
assertEquals(aposToQuotes("{\n"
assertEquals(a2q("{\n"
+" 'name' : 'Bill'\n"
+"}"),
json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ public void testSerializeWithoutField() throws Exception
{
String json = JSON.std.without(JSON.Feature.USE_FIELDS)
.asString(new XY(1, 2));
assertEquals(aposToQuotes("{'y':2}"), json);
assertEquals(a2q("{'y':2}"), json);
}

public void testSerializeWithField() throws Exception
{
String json = JSON.std.with(JSON.Feature.USE_FIELDS)
.asString(new XY(1, 2));
assertEquals(aposToQuotes("{'x':1,'y':2}"), json);
assertEquals(a2q("{'x':1,'y':2}"), json);
}

public void testDeserializeWithField() throws Exception
{
XY result = JSON.std.with(JSON.Feature.USE_FIELDS)
.beanFrom(XY.class, aposToQuotes("{'x':3,'y':4}"));
.beanFrom(XY.class, a2q("{'x':3,'y':4}"));
assertEquals(4, result.getY());
assertEquals(3, result.x);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void testMethodsFromSuperclass() throws Exception
}

BaseImpl result = JSON.std.beanFrom(BaseImpl.class,
aposToQuotes("{ 'extra':5, 'value':-245 }"));
a2q("{ 'extra':5, 'value':-245 }"));
assertEquals(5, result.getExtra());
assertEquals(-245, result.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public void testSimpleBooleanArray() throws Exception {
}

public void testSimpleStringArray() throws Exception {
assertEquals(aposToQuotes("['abc','def']"), JSON.std.asString(new String[] { "abc", "def" }));
assertEquals(a2q("['abc','def']"), JSON.std.asString(new String[] { "abc", "def" }));
}

public void testNest() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public void testCustomBeanReader() throws Exception

// similarly with wrapper
CustomValueBean bean = json.beanFrom(CustomValueBean.class,
aposToQuotes("{ 'custom' : 137 }"));
a2q("{ 'custom' : 137 }"));
assertEquals(138, bean.custom.value);

// but also ensure we can change registered handler(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static class NoOpModifier extends ReaderWriterModifier { }
public void testReadIgnoreProperty() throws Exception
{
// verify default read first
final String INPUT = aposToQuotes("{'first':'Bob','last':'Burger'}");
final String INPUT = a2q("{'first':'Bob','last':'Burger'}");
NameBean bean = JSON.std.beanFrom(NameBean.class, INPUT);
assertEquals("Bob", bean.getFirst());
assertEquals("Burger", bean.getLast());
Expand All @@ -67,7 +67,7 @@ public void testReadIgnoreProperty() throws Exception

public void testModifierPairForReading() throws Exception
{
final String INPUT = aposToQuotes("{'first':'Bob','last':'Burger'}");
final String INPUT = a2q("{'first':'Bob','last':'Burger'}");
NameBean bean = jsonWithModifiers(new NoOpModifier(), new MyPropertyModifier("last"))
.beanFrom(NameBean.class, INPUT);
assertEquals("Bob", bean.getFirst());
Expand All @@ -84,14 +84,14 @@ public void testWriteInReverseOrder() throws Exception
{
// verify default write first
final NameBean input = new NameBean("Bob", "Burger");
final String EXP_DEFAULT = aposToQuotes("{'first':'Bob','last':'Burger'}");
final String EXP_DEFAULT = a2q("{'first':'Bob','last':'Burger'}");

assertEquals(EXP_DEFAULT, JSON.std.asString(input));

// but then use customized POJO introspection
String json = jsonWithModifier(new MyPropertyModifier("xxx"))
.asString(input);
assertEquals(aposToQuotes("{'last':'Burger','first':'Bob'}"), json);
assertEquals(a2q("{'last':'Burger','first':'Bob'}"), json);

// and last, to ensure no leakage of customizations
assertEquals(EXP_DEFAULT, JSON.std.asString(input));
Expand All @@ -103,11 +103,11 @@ public void testModifierPairForWriting() throws Exception

String json = jsonWithModifiers(new NoOpModifier(), new MyPropertyModifier("xxx"))
.asString(input);
assertEquals(aposToQuotes("{'last':'Burger','first':'Bill'}"), json);
assertEquals(a2q("{'last':'Burger','first':'Bill'}"), json);

// and nulls fine too wrt chaining
json = jsonWithModifiers(null, new MyPropertyModifier("xxx"))
.asString(input);
assertEquals(aposToQuotes("{'last':'Burger','first':'Bill'}"), json);
assertEquals(a2q("{'last':'Burger','first':'Bill'}"), json);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public Object read(JSONReader reader, JsonParser p) {
String.valueOf(map.get("last")).toUpperCase());
};
});
final String input = aposToQuotes("{'first':'foo', 'last':'bar'}");
final String input = a2q("{'first':'foo', 'last':'bar'}");
NameBean result = jsonWithModifier(mod).beanFrom(NameBean.class, input);
assertEquals("FOO", result.getFirst());
assertEquals("BAR", result.getLast());
Expand All @@ -110,7 +110,7 @@ public Object read(JSONReader reader, JsonParser p) {

public void testPOJOReaderDelegation() throws Exception
{
final String input = aposToQuotes("{'first':'Foo', 'last':'Bar'}");
final String input = a2q("{'first':'Foo', 'last':'Bar'}");
NameBean result = jsonWithModifier(new LowerCasingReaderModifier())
.beanFrom(NameBean.class, input);
assertEquals("foo", result.getFirst());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import okhttp3.RequestBody;

import retrofit2.Converter;

import tools.jackson.jr.ob.JSON;

public class JacksonJrRequestBodyConverter<T> implements Converter<T, RequestBody>
Expand Down

0 comments on commit e9cf682

Please sign in to comment.