Skip to content

Commit 6875566

Browse files
committed
minor refactoring of tests
1 parent df523d6 commit 6875566

File tree

3 files changed

+42
-28
lines changed

3 files changed

+42
-28
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.fasterxml.jackson.databind.creators;
2+
3+
import java.beans.ConstructorProperties;
4+
5+
import com.fasterxml.jackson.databind.*;
6+
7+
public class CreatorPropertiesTest extends BaseMapTest
8+
{
9+
static class Issue905Bean {
10+
// 08-Nov-2015, tatu: Note that in real code we would most likely use same
11+
// names for properties; but here we use different name on purpose to
12+
// ensure that Jackson has no way of binding JSON properties "x" and "y"
13+
// using any other mechanism than via `@ConstructorProperties` annotation
14+
public int _x, _y;
15+
16+
@ConstructorProperties({"x", "y"})
17+
// Same as above; use differing local parameter names so that parameter name
18+
// introspection can not be used as the source of property names.
19+
public Issue905Bean(int a, int b) {
20+
_x = a;
21+
_y = b;
22+
}
23+
}
24+
25+
/*
26+
/**********************************************************
27+
/* Test methods
28+
/**********************************************************
29+
*/
30+
31+
private final ObjectMapper MAPPER = new ObjectMapper();
32+
33+
// [databind#905]
34+
public void testCreatorPropertiesAnnotation() throws Exception
35+
{
36+
Issue905Bean b = MAPPER.readValue(aposToQuotes("{'y':3,'x':2}"),
37+
Issue905Bean.class);
38+
assertEquals(2, b._x);
39+
assertEquals(3, b._y);
40+
}
41+
}

src/test/java/com/fasterxml/jackson/databind/creators/TestCreators2.java

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ public BeanFor438(@JsonProperty("name") String s) {
8080
}
8181
}
8282

83-
// For [JACKSON-465]
8483
static class MapBean
8584
{
8685
protected Map<String,Long> map;
@@ -122,7 +121,6 @@ static class BustedCtor {
122121
}
123122
}
124123

125-
// As per [JACKSON-575]
126124
static class IgnoredCtor
127125
{
128126
@JsonIgnore
@@ -162,22 +160,6 @@ public Issue700Bean(@JsonProperty("item") String item) { }
162160
public String getItem() { return null; }
163161
}
164162

165-
static class Issue905Bean {
166-
// 08-Nov-2015, tatu: Note that in real code we would most likely use same
167-
// names for properties; but here we use different name on purpose to
168-
// ensure that Jackson has no way of binding JSON properties "x" and "y"
169-
// using any other mechanism than via `@ConstructorProperties` annotation
170-
public int _x, _y;
171-
172-
@ConstructorProperties({"x", "y"})
173-
// Same as above; use differing local parameter names so that parameter name
174-
// introspection can not be used as the source of property names.
175-
public Issue905Bean(int a, int b) {
176-
_x = a;
177-
_y = b;
178-
}
179-
}
180-
181163
/*
182164
/**********************************************************
183165
/* Test methods
@@ -313,13 +295,4 @@ public void testCreatorProperties() throws Exception
313295
Issue700Bean value = MAPPER.readValue("{ \"item\" : \"foo\" }", Issue700Bean.class);
314296
assertNotNull(value);
315297
}
316-
317-
// [databind#905]
318-
public void testCreatorPropertiesAnnotation() throws Exception
319-
{
320-
Issue905Bean b = MAPPER.readValue(aposToQuotes("{'y':3,'x':2}"),
321-
Issue905Bean.class);
322-
assertEquals(2, b._x);
323-
assertEquals(3, b._y);
324-
}
325298
}

src/test/java/com/fasterxml/jackson/failing/AnyGetter1124Test.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static class Bean1124
1818

1919
public void addAdditionalProperty(String key, String value) {
2020
if (additionalProperties == null) {
21-
additionalProperties = new HashMap<>();
21+
additionalProperties = new HashMap<String,String>();
2222
}
2323
additionalProperties.put(key,value);
2424
}

0 commit comments

Comments
 (0)