-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df523d6
commit 6875566
Showing
3 changed files
with
42 additions
and
28 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/test/java/com/fasterxml/jackson/databind/creators/CreatorPropertiesTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,41 @@ | |||
package com.fasterxml.jackson.databind.creators; | |||
|
|||
import java.beans.ConstructorProperties; | |||
|
|||
import com.fasterxml.jackson.databind.*; | |||
|
|||
public class CreatorPropertiesTest extends BaseMapTest | |||
{ | |||
static class Issue905Bean { | |||
// 08-Nov-2015, tatu: Note that in real code we would most likely use same | |||
// names for properties; but here we use different name on purpose to | |||
// ensure that Jackson has no way of binding JSON properties "x" and "y" | |||
// using any other mechanism than via `@ConstructorProperties` annotation | |||
public int _x, _y; | |||
|
|||
@ConstructorProperties({"x", "y"}) | |||
// Same as above; use differing local parameter names so that parameter name | |||
// introspection can not be used as the source of property names. | |||
public Issue905Bean(int a, int b) { | |||
_x = a; | |||
_y = b; | |||
} | |||
} | |||
|
|||
/* | |||
/********************************************************** | |||
/* Test methods | |||
/********************************************************** | |||
*/ | |||
|
|||
private final ObjectMapper MAPPER = new ObjectMapper(); | |||
|
|||
// [databind#905] | |||
public void testCreatorPropertiesAnnotation() throws Exception | |||
{ | |||
Issue905Bean b = MAPPER.readValue(aposToQuotes("{'y':3,'x':2}"), | |||
Issue905Bean.class); | |||
assertEquals(2, b._x); | |||
assertEquals(3, b._y); | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters