Skip to content

Commit

Permalink
Move #88 test case out of 'failing' (passes now)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 12, 2014
1 parent 0e1e878 commit d352f0c
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.fasterxml.jackson.failing;
package com.fasterxml.jackson.databind.jsontype;

import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.*;

public class TestNodeTypingIssue88 extends BaseMapTest
public class TestDefaultForTreeNodes extends BaseMapTest
{
public static class Foo {
public String bar;
Expand All @@ -17,26 +17,25 @@ public Foo() { }
/* Unit tests
/**********************************************************
*/

private final ObjectMapper DEFAULT_MAPPER = new ObjectMapper();
{
DEFAULT_MAPPER.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
}

public void testValueAsStringWithDefaultTyping() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);

Foo foo = new Foo("baz");
String json = mapper.writeValueAsString(foo);
String json = DEFAULT_MAPPER.writeValueAsString(foo);

JsonNode jsonNode = mapper.readTree(json);
JsonNode jsonNode = DEFAULT_MAPPER.readTree(json);
assertEquals(jsonNode.get("bar").textValue(), foo.bar);
}

public void testValueToTreeWithDefaultTyping() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
mapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);

Foo foo = new Foo("baz");
JsonNode jsonNode = mapper.valueToTree(foo);
JsonNode jsonNode = DEFAULT_MAPPER.valueToTree(foo);
assertEquals(jsonNode.get("bar").textValue(), foo.bar);
}
}

0 comments on commit d352f0c

Please sign in to comment.