Skip to content

Commit c5176ab

Browse files
committed
Verify non-public class method behavior
1 parent 286b5d9 commit c5176ab

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

mrbean/src/test/java/com/fasterxml/jackson/module/mrbean/TestAbstractClasses.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ public abstract static class Bean
1616
int y;
1717

1818
protected Bean() { }
19-
19+
2020
public abstract String getX();
2121

2222
public String getFoo() { return "Foo!"; }
2323
public void setY(int value) { y = value; }
24+
25+
// also verify non-public methods
26+
protected abstract String getZ();
27+
private Object customMethod() { return new Object(); }
2428
}
2529

2630
/*
@@ -32,10 +36,12 @@ protected Bean() { }
3236
public void testSimpleInteface() throws Exception
3337
{
3438
ObjectMapper mapper = newMrBeanMapper();
35-
Bean bean = mapper.readValue("{ \"x\" : \"abc\", \"y\" : 13 }", Bean.class);
39+
Bean bean = mapper.readValue("{ \"x\" : \"abc\", \"y\" : 13, \"z\" : \"def\" }", Bean.class);
3640
assertNotNull(bean);
3741
assertEquals("abc", bean.getX());
3842
assertEquals(13, bean.y);
3943
assertEquals("Foo!", bean.getFoo());
44+
assertEquals("def", bean.getZ());
45+
assertNotNull(bean.customMethod());
4046
}
4147
}

mrbean/src/test/java/com/fasterxml/jackson/module/mrbean/TestAbstractClassesWithOverrides.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ public abstract static class Bean
1616
int y;
1717

1818
protected Bean() { }
19-
19+
2020
public abstract String getX();
2121

2222
public abstract String roast(int temperature);
2323

2424
public String getFoo() { return "Foo!"; }
2525
public void setY(int value) { y = value; }
26+
27+
// also verify non-public methods
28+
protected abstract String getZ();
29+
private Object customMethod() { return new Object(); }
2630
}
2731

2832
public abstract static class CoffeeBean extends Bean {
@@ -45,10 +49,10 @@ public void testOverrides() throws Exception
4549
ObjectMapper mapper = new ObjectMapper();
4650
mapper.registerModule(new MrBeanModule());
4751

48-
Bean bean = mapper.readValue("{ \"x\" : \"abc\", \"y\" : 13 }", CoffeeBean.class);
52+
Bean bean = mapper.readValue("{ \"x\" : \"abc\", \"y\" : 13, \"z\" : \"def\" }", CoffeeBean.class);
4953
verifyBean(bean);
5054

51-
Bean bean2 = mapper.readValue("{ \"x\" : \"abc\", \"y\" : 13 }", PeruvianCoffeeBean.class);
55+
Bean bean2 = mapper.readValue("{ \"x\" : \"abc\", \"y\" : 13, \"z\" : \"def\" }", PeruvianCoffeeBean.class);
5256
verifyBean(bean2);
5357
}
5458

@@ -57,6 +61,8 @@ private void verifyBean(Bean bean) {
5761
assertEquals("abc", bean.getX());
5862
assertEquals(13, bean.y);
5963
assertEquals("Foo!", bean.getFoo());
64+
assertEquals("def", bean.getZ());
65+
assertNotNull(bean.customMethod());
6066
assertEquals("The coffee beans are roasting at 123 degrees now, yummy", bean.roast(123));
6167
}
6268
}

0 commit comments

Comments
 (0)