Skip to content

Commit

Permalink
Add failing test for #273
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 11, 2018
1 parent 25485b8 commit 7ac573b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.fasterxml.jackson</groupId>
<artifactId>jackson-base</artifactId>
<version>2.9.3</version>
<version>2.9.4-SNAPSHOT</version>
</parent>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-xml</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;

public class CaseInsensitiveDeserTest extends XmlTestBase
{
// [databind#1036]
static class BaseResponse {
public int errorCode;
public String debugMessage;
}

// [databind#1438]
static class InsensitiveCreator
{
int v;
Expand All @@ -35,13 +32,9 @@ public InsensitiveCreator(@JsonProperty("value") int v0) {

private final ObjectMapper MAPPER = newObjectMapper();

private final ObjectMapper INSENSITIVE_MAPPER = newObjectMapper();
{
INSENSITIVE_MAPPER.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);

}
private final ObjectMapper INSENSITIVE_MAPPER = newObjectMapper()
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);

// [databind#1036]
public void testCaseInsensitive1036() throws Exception
{
final String DOC =
Expand All @@ -60,12 +53,4 @@ public void testCaseInsensitive1036() throws Exception
verifyException(e, "ErrorCode");
}
}

// [databind#1438]
public void testCreatorWithInsensitive() throws Exception
{
final String DOC = aposToQuotes("<root><VALUE>3</VALUE></root>");
InsensitiveCreator bean = INSENSITIVE_MAPPER.readValue(DOC, InsensitiveCreator.class);
assertEquals(3, bean.v);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.fasterxml.jackson.dataformat.xml.failing;

import java.util.ArrayList;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.dataformat.xml.XmlTestBase;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;

public class CaseInsensitiveDeser273Test extends XmlTestBase
{
// [dataformat-xml#273]
static class Depots273
{
public String command;
public String taskId;

@JacksonXmlElementWrapper(useWrapping = false)
public ArrayList<Depot273> element;
}

@JsonIgnoreProperties(ignoreUnknown = true)
static class Depot273
{
@JacksonXmlProperty(isAttribute = true)
public String number;
@JacksonXmlProperty(isAttribute = true)
public String name;
}

/*
/********************************************************
/* Test methods
/********************************************************
*/

private final ObjectMapper INSENSITIVE_MAPPER = newObjectMapper()
.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES);

// [dataformat-xml#273]
public void testCaseInsensitiveComplex() throws Exception
{
final String DOC =
"<AcResponse Command='show depots' TaskId='1260'>\n"+
" <Element Number='1' Name='accurev' Slice='1'\n"+
"exclusiveLocking='false' case='insensitive' locWidth='128'"+
"></Element>\n"+
" <Element Number='2' Name='second accurev' Slice='2'\n"+
"exclusiveLocking='false' case='insensitive' locWidth='128'\n"+
"></Element>\n"+
"</AcResponse>"
;

Depots273 result = INSENSITIVE_MAPPER.readValue(DOC, Depots273.class);
assertNotNull(result);
}
}

0 comments on commit 7ac573b

Please sign in to comment.