Skip to content

Commit 9cf3e43

Browse files
committed
test refactoring
1 parent 42cdeb1 commit 9cf3e43

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/test/java/com/fasterxml/jackson/databind/filter/IgnorePropsTest.java renamed to src/test/java/com/fasterxml/jackson/databind/filter/IgnorePropsForSerTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import com.fasterxml.jackson.databind.*;
88

9-
public class IgnorePropsTest
9+
public class IgnorePropsForSerTest
1010
extends BaseMapTest
1111
{
1212
@JsonIgnoreProperties({"b", "c"})
@@ -23,7 +23,7 @@ static class IgnoreSome
2323
@JsonIgnoreProperties({"@class"})
2424
static class MyMap extends HashMap<String,String> { }
2525

26-
// [JACKSON-787]: allow use of @JsonIgnoreProperties for properties
26+
//allow use of @JsonIgnoreProperties for properties
2727
static class WrapperWithPropIgnore
2828
{
2929
@JsonIgnoreProperties("y")

src/test/java/com/fasterxml/jackson/databind/filter/TestSimpleSerializationIgnore.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,21 @@ static class NonIgnoredType
7070
/**********************************************************
7171
*/
7272

73+
private final ObjectMapper MAPPER = new ObjectMapper();
74+
7375
public void testSimpleIgnore() throws Exception
7476
{
75-
ObjectMapper m = new ObjectMapper();
7677
// Should see "x", not "y"
77-
Map<String,Object> result = writeAndMap(m, new SizeClassEnabledIgnore());
78+
Map<String,Object> result = writeAndMap(MAPPER, new SizeClassEnabledIgnore());
7879
assertEquals(1, result.size());
7980
assertEquals(Integer.valueOf(1), result.get("x"));
8081
assertNull(result.get("y"));
8182
}
8283

8384
public void testDisabledIgnore() throws Exception
8485
{
85-
ObjectMapper m = new ObjectMapper();
8686
// Should see "x" and "y"
87-
Map<String,Object> result = writeAndMap(m, new SizeClassDisabledIgnore());
87+
Map<String,Object> result = writeAndMap(MAPPER, new SizeClassDisabledIgnore());
8888
assertEquals(2, result.size());
8989
assertEquals(Integer.valueOf(3), result.get("x"));
9090
assertEquals(Integer.valueOf(4), result.get("y"));
@@ -96,26 +96,20 @@ public void testDisabledIgnore() throws Exception
9696
*/
9797
public void testIgnoreOver() throws Exception
9898
{
99-
ObjectMapper m = new ObjectMapper();
100-
10199
// should only see "y"
102-
Map<String,Object> result = writeAndMap(m, new BaseClassIgnore());
100+
Map<String,Object> result = writeAndMap(MAPPER, new BaseClassIgnore());
103101
assertEquals(1, result.size());
104102
assertEquals(Integer.valueOf(2), result.get("y"));
105103

106104
// Should see "x" and "y"
107-
result = writeAndMap(m, new SubClassNonIgnore());
105+
result = writeAndMap(MAPPER, new SubClassNonIgnore());
108106
assertEquals(2, result.size());
109107
assertEquals(Integer.valueOf(3), result.get("x"));
110108
assertEquals(Integer.valueOf(2), result.get("y"));
111109
}
112110

113-
/**
114-
* @since 1.7
115-
*/
116111
public void testIgnoreType() throws Exception
117112
{
118-
ObjectMapper m = new ObjectMapper();
119-
assertEquals("{\"value\":13}", m.writeValueAsString(new NonIgnoredType()));
113+
assertEquals("{\"value\":13}", MAPPER.writeValueAsString(new NonIgnoredType()));
120114
}
121115
}

0 commit comments

Comments
 (0)