-
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.
Add test for #223: passes for Blackbird, fails for Afterburner
- Loading branch information
1 parent
af6f4c0
commit 9a51cb9
Showing
3 changed files
with
122 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
60 changes: 60 additions & 0 deletions
60
...src/test/java/com/fasterxml/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,60 @@ | ||
package com.fasterxml.jackson.module.afterburner.failing; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.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
...c/test/java/com/fasterxml/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 com.fasterxml.jackson.module.blackbird.deser.java8; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.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()); | ||
} | ||
} |