Skip to content

Commit 5cece09

Browse files
committed
Test streamlining
1 parent 213f722 commit 5cece09

File tree

2 files changed

+32
-38
lines changed

2 files changed

+32
-38
lines changed

src/test/java/com/fasterxml/jackson/databind/deser/filter/ReadOnlyDeser1890Test.java

+32-9
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,26 @@
11
package com.fasterxml.jackson.databind.deser.filter;
22

33
import java.beans.ConstructorProperties;
4-
import java.io.IOException;
54

5+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
66
import com.fasterxml.jackson.annotation.JsonProperty;
77
import com.fasterxml.jackson.databind.BaseMapTest;
88
import com.fasterxml.jackson.databind.ObjectMapper;
99

1010
public class ReadOnlyDeser1890Test
1111
extends BaseMapTest
1212
{
13-
public static class PersonAnnotations {
13+
// [databind#95]
14+
@JsonIgnoreProperties(value={ "computed" }, allowGetters=true)
15+
static class ReadOnly95Bean
16+
{
17+
public int value = 3;
18+
19+
public int getComputed() { return 32; }
20+
}
21+
22+
// [databind#1890]
23+
static class PersonAnnotations {
1424
public String name;
1525
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
1626
private TestEnum testEnum = TestEnum.DEFAULT;
@@ -30,9 +40,9 @@ public TestEnum getTestEnum() {
3040
public void setTestEnum(TestEnum testEnum) {
3141
this.testEnum = testEnum;
3242
}
33-
}
43+
}
3444

35-
public static class Person {
45+
static class Person {
3646
public String name;
3747
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
3848
private TestEnum testEnum = TestEnum.DEFAULT;
@@ -63,30 +73,43 @@ enum TestEnum{
6373
/**********************************************************
6474
*/
6575

66-
private final ObjectMapper MAPPER = objectMapper();
76+
private final ObjectMapper MAPPER = newJsonMapper();
77+
78+
// [databind#95]
79+
public void testReadOnlyProps95() throws Exception
80+
{
81+
ObjectMapper m = new ObjectMapper();
82+
String json = m.writeValueAsString(new ReadOnly95Bean());
83+
if (json.indexOf("computed") < 0) {
84+
fail("Should have property 'computed', didn't: "+json);
85+
}
86+
ReadOnly95Bean bean = m.readValue(json, ReadOnly95Bean.class);
87+
assertNotNull(bean);
88+
}
6789

68-
public void testDeserializeAnnotationsOneField() throws IOException {
90+
// [databind#1890]
91+
public void testDeserializeAnnotationsOneField() throws Exception {
6992
PersonAnnotations person = MAPPER.readValue("{\"testEnum\":\"\"}", PersonAnnotations.class);
7093
// can not remain as is, so becomes `null`
7194
assertEquals(null, person.getTestEnum());
7295
assertNull(person.name);
7396
}
7497

75-
public void testDeserializeAnnotationsTwoFields() throws IOException {
98+
public void testDeserializeAnnotationsTwoFields() throws Exception {
7699
PersonAnnotations person = MAPPER.readValue("{\"testEnum\":\"\",\"name\":\"changyong\"}",
77100
PersonAnnotations.class);
78101
// can not remain as is, so becomes `null`
79102
assertEquals(null, person.getTestEnum());
80103
assertEquals("changyong", person.name);
81104
}
82105

83-
public void testDeserializeOneField() throws IOException {
106+
public void testDeserializeOneField() throws Exception {
84107
Person person = MAPPER.readValue("{\"testEnum\":\"\"}", Person.class);
85108
assertEquals(TestEnum.DEFAULT, person.getTestEnum());
86109
assertNull(person.name);
87110
}
88111

89-
public void testDeserializeTwoFields() throws IOException {
112+
public void testDeserializeTwoFields() throws Exception {
90113
Person person = MAPPER.readValue("{\"testEnum\":\"\",\"name\":\"changyong\"}",
91114
Person.class);
92115
assertEquals(TestEnum.DEFAULT, person.getTestEnum());

src/test/java/com/fasterxml/jackson/databind/deser/filter/ReadOnlyDeser95Test.java

-29
This file was deleted.

0 commit comments

Comments
 (0)