Skip to content

Commit 321562a

Browse files
committed
Add javadocs to indicate why alternate naming used in tests.
1 parent 51a02d0 commit 321562a

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,18 @@ public Issue700Bean(@JsonProperty("item") String item) { }
163163
}
164164

165165
static class Issue905Bean {
166-
public int v1, v2;
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;
167171

168172
@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.
169175
public Issue905Bean(int a, int b) {
170-
v1 = a;
171-
v2 = b;
176+
_x = a;
177+
_y = b;
172178
}
173179
}
174180

@@ -313,7 +319,7 @@ public void testCreatorPropertiesAnnotation() throws Exception
313319
{
314320
Issue905Bean b = MAPPER.readValue(aposToQuotes("{'y':3,'x':2}"),
315321
Issue905Bean.class);
316-
assertEquals(2, b.v1);
317-
assertEquals(3, b.v2);
322+
assertEquals(2, b._x);
323+
assertEquals(3, b._y);
318324
}
319325
}

0 commit comments

Comments
 (0)