Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test for #223: passes for Blackbird, fails for Afterburner #224

Merged
merged 1 commit into from
Oct 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ syntax: glob
# building
target
.mvn/wrapper/maven-wrapper.jar
dependency-reduced-pom.xml

# Eclipse
.classpath
Expand Down
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());
}
}
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());
}
}