Skip to content

Commit

Permalink
Add failing test for #1291
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 13, 2016
1 parent 07569c7 commit 9c2e89b
Showing 1 changed file with 45 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.fasterxml.jackson.failing;

import com.fasterxml.jackson.databind.BaseMapTest;
import com.fasterxml.jackson.databind.ObjectMapper;

public class EnumCreator1291Test extends BaseMapTest
{
static enum Enum1291 {

V1("val1"),
V2("val2"),
V3("val3"),
V4("val4"),
V5("val5"),
V6("val6");

private final String name;

Enum1291(String name) {
this.name = name;
}

public static Enum1291 fromString(String name) {
for (Enum1291 type : Enum1291.values()) {
if (type.name.equals(name)) {
return type;
}
}
return Enum1291.valueOf(name.toUpperCase());
}

@Override
public String toString() {
return name;
}
}

public void testEnumCreators1291() throws Exception
{
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(Enum1291.V2);
Enum1291 result = mapper.readValue(json, Enum1291.class);
assertSame(Enum1291.V2, result);
}
}

0 comments on commit 9c2e89b

Please sign in to comment.