-
Notifications
You must be signed in to change notification settings - Fork 79
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
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
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
62 changes: 62 additions & 0 deletions
62
...rburner/src/test/java/tools/jackson/module/afterburner/failing/DefaultMethods223Test.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package tools.jackson.module.afterburner.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
import tools.jackson.databind.ObjectMapper; | ||
|
||
import tools.jackson.module.afterburner.AfterburnerTestBase; | ||
|
||
// for [modules-base#223] | ||
public class DefaultMethods223Test extends AfterburnerTestBase | ||
{ | ||
interface Animal223 { | ||
public String getName(); | ||
|
||
public void setName(String name); | ||
default public String getInfo() { | ||
return ""; | ||
} | ||
|
||
// Problematic case: | ||
default public void setInfo(String info) { } | ||
} | ||
|
||
@JsonPropertyOrder({ "name", "info" }) | ||
static class Cat223 implements Animal223 { | ||
String name; | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = newObjectMapper(); | ||
|
||
public void testSerializeViaDefault223() throws Exception | ||
{ | ||
Cat223 cat = new Cat223(); | ||
cat.setName("Molly"); | ||
assertEquals(a2q("{'name':'Molly','info':''}"), | ||
MAPPER.writeValueAsString(cat)); | ||
} | ||
|
||
public void testDeserializeViaDefault223() throws Exception | ||
{ | ||
String json = a2q("{'name':'Emma','info':'xyz'}"); | ||
Cat223 cat = MAPPER.readValue(json, Cat223.class); | ||
assertEquals("Emma", cat.getName()); | ||
assertEquals("", cat.getInfo()); | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...kbird/src/test/java/tools/jackson/module/blackbird/deser/java8/DefaultMethods223Test.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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package tools.jackson.module.blackbird.deser.java8; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
import tools.jackson.databind.ObjectMapper; | ||
import tools.jackson.module.blackbird.BlackbirdTestBase; | ||
|
||
// for [modules-base#223] | ||
public class DefaultMethods223Test extends BlackbirdTestBase | ||
{ | ||
interface Animal223 { | ||
public String getName(); | ||
|
||
public void setName(String name); | ||
default public String getInfo() { | ||
return ""; | ||
} | ||
|
||
// Problematic case: | ||
default public void setInfo(String info) { } | ||
} | ||
|
||
@JsonPropertyOrder({ "name", "info" }) | ||
static class Cat223 implements Animal223 { | ||
String name; | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = newObjectMapper(); | ||
|
||
public void testSerializeViaDefault223() throws Exception | ||
{ | ||
Cat223 cat = new Cat223(); | ||
cat.setName("Molly"); | ||
assertEquals(a2q("{'name':'Molly','info':''}"), | ||
MAPPER.writeValueAsString(cat)); | ||
} | ||
|
||
public void testDeserializeViaDefault223() throws Exception | ||
{ | ||
String json = a2q("{'name':'Emma','info':'xyz'}"); | ||
Cat223 cat = MAPPER.readValue(json, Cat223.class); | ||
assertEquals("Emma", cat.getName()); | ||
assertEquals("", cat.getInfo()); | ||
} | ||
} |