Skip to content

Commit

Permalink
2.4->master of tests for #121
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 6, 2014
1 parent 4067d53 commit 9781fac
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
package com.fasterxml.jackson.dataformat.xml.deser;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
import com.fasterxml.jackson.dataformat.xml.*;

public class TestEnums extends XmlTestBase
{
/*
/**********************************************************
/* Helper types
/**********************************************************
*/

static enum TestEnum { A, B, C; }

static class EnumBean
Expand All @@ -27,11 +20,12 @@ public EnumBean() { }
/**********************************************************
*/

private final XmlMapper MAPPER = new XmlMapper();

public void testEnum() throws Exception
{
XmlMapper mapper = new XmlMapper();
String str = mapper.writeValueAsString(new EnumBean(TestEnum.B));
EnumBean result = mapper.readValue(str, EnumBean.class);
String xml = MAPPER.writeValueAsString(new EnumBean(TestEnum.B));
EnumBean result = MAPPER.readValue(xml, EnumBean.class);
assertNotNull(result);
assertEquals(TestEnum.B, result.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import com.fasterxml.jackson.databind.ObjectMapper;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;

Expand All @@ -27,6 +28,8 @@ public UntypedEnumBean() { }
/**********************************************************
*/

private final XmlMapper MAPPER = new XmlMapper();

public void testUntypedEnum() throws Exception
{
ObjectMapper mapper = new XmlMapper();
Expand All @@ -43,4 +46,13 @@ public void testUntypedEnum() throws Exception

assertEquals(TestEnum.B, result.value);
}

// [dataformat-xml#121]
public void testRootEnumIssue121() throws Exception
{
String xml = MAPPER.writeValueAsString(TestEnum.B);
TestEnum result = MAPPER.readValue(xml, TestEnum.class);
assertNotNull(result);
assertEquals(TestEnum.B, result);
}
}

0 comments on commit 9781fac

Please sign in to comment.