Skip to content

Commit 86c43de

Browse files
committed
Add test for #1595 for 2.7 (does not fail, so this is 2.7->2.8 regression)
1 parent d1e40ca commit 86c43de

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.fasterxml.jackson.databind.filter;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
5+
import com.fasterxml.jackson.databind.*;
6+
7+
public class JsonIgnoreProperties1595Test extends BaseMapTest
8+
{
9+
@JsonIgnoreProperties(value = {"name"}, allowSetters = true)
10+
@JsonPropertyOrder(alphabetic=true)
11+
static class Simple {
12+
private int id;
13+
private String name;
14+
15+
public int getId() {
16+
return id;
17+
}
18+
19+
public void setId(int id) {
20+
this.id = id;
21+
}
22+
23+
public String getName() {
24+
return name;
25+
}
26+
27+
public void setName(String name) {
28+
this.name = name;
29+
}
30+
}
31+
32+
public void testIgnoreGetterNotSetter1595() throws Exception
33+
{
34+
ObjectMapper mapper = new ObjectMapper();
35+
Simple config = new Simple();
36+
config.setId(123);
37+
config.setName("jack");
38+
String json = mapper.writeValueAsString(config);
39+
assertEquals(aposToQuotes("{'id':123}"), json);
40+
Simple des = mapper.readValue(aposToQuotes("{'id':123,'name':'jack'}"), Simple.class);
41+
assertEquals("jack", des.getName());
42+
}
43+
}

0 commit comments

Comments
 (0)