-
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.
minor tweaking of #30 fix to future-proof wr jackson 3.x
- Loading branch information
1 parent
efc8118
commit 485730c
Showing
2 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...rc/test/java/com/fasterxml/jackson/module/afterburner/deser/java8/DefaultMethodsTest.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,67 @@ | ||
package com.fasterxml.jackson.module.afterburner.deser.java8; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.module.afterburner.AfterburnerTestBase; | ||
|
||
// for [modules-base#30] | ||
public class DefaultMethodsTest extends AfterburnerTestBase | ||
{ | ||
// NOTE: can only be enabled for Jackson 3.x | ||
/* | ||
public interface Typed { | ||
default String getType() { | ||
return "bogus"; | ||
} | ||
default void setType(String type) { internalSet(type); } | ||
void internalSet(String s); | ||
} | ||
static class Model implements Typed { | ||
String x; | ||
@Override | ||
public void internalSet(String value) { | ||
x = value; | ||
} | ||
} | ||
*/ | ||
|
||
// for Jackson 2.x: | ||
public interface Typed { | ||
public String getType(); | ||
public void setType(String t); | ||
} | ||
|
||
static class Model implements Typed { | ||
String x; | ||
|
||
@Override | ||
public String getType() { return "bogus"; } | ||
@Override | ||
public void setType(String t) { x = t; } | ||
} | ||
|
||
/* | ||
/********************************************************************** | ||
/* Test methods | ||
/********************************************************************** | ||
*/ | ||
|
||
private final ObjectMapper MAPPER = newObjectMapper(); | ||
|
||
public void testSerializeViaDefault() throws Exception | ||
{ | ||
assertEquals(aposToQuotes("{'type':'bogus'}"), | ||
MAPPER.writeValueAsString(new Model())); | ||
} | ||
|
||
public void testDeserializeViaDefault() throws Exception | ||
{ | ||
// Would throws `java.lang.IncompatibleClassChangeError` | ||
Model m = MAPPER.readValue(aposToQuotes("{'type':'stuff'}"), | ||
Model.class); | ||
assertNotNull(m); | ||
assertEquals("stuff", m.x); | ||
} | ||
} |
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