diff --git a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
index 38fc6197e4..ca6eefaa30 100644
--- a/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
+++ b/src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java
@@ -1510,7 +1510,7 @@ public ObjectMapper enableDefaultTypingAsProperty(DefaultTyping applicability, S
typer = typer.typeProperty(propertyName);
return setDefaultTyping(typer);
}
-
+
/**
* Method for disabling automatic inclusion of type information; if so, only
* explicitly annotated types (ones with
@@ -1611,7 +1611,7 @@ public ObjectMapper setTypeFactory(TypeFactory f)
_serializationConfig = _serializationConfig.with(f);
return this;
}
-
+
/**
* Convenience method for constructing {@link JavaType} out of given
* type (typically java.lang.Class
), but without explicit
@@ -1620,7 +1620,7 @@ public ObjectMapper setTypeFactory(TypeFactory f)
public JavaType constructType(Type t) {
return _typeFactory.constructType(t);
}
-
+
/*
/**********************************************************
/* Configuration, deserialization
@@ -1640,7 +1640,7 @@ public JavaType constructType(Type t) {
public JsonNodeFactory getNodeFactory() {
return _deserializationConfig.getNodeFactory();
}
-
+
/**
* Method for specifying {@link JsonNodeFactory} to use for
* constructing root level tree nodes (via method
diff --git a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java
index 3f32ae252a..3d78595d80 100644
--- a/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java
+++ b/src/main/java/com/fasterxml/jackson/databind/introspect/POJOPropertyBuilder.java
@@ -1346,8 +1346,8 @@ public Linked trimByVisibility() {
@Override
public String toString() {
- String msg = value.toString()+"[visible="+isVisible+",ignore="+isMarkedIgnored
- +",explicitName="+isNameExplicit+"]";
+ String msg = String.format("%s[visible=%b,ignore=%b,explicitName=%b]",
+ value.toString(), isVisible, isMarkedIgnored, isNameExplicit);
if (next != null) {
msg = msg + ", "+next.toString();
}
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java b/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java
index 351721955d..420f5de10f 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/TestBasicAnnotations.java
@@ -100,6 +100,26 @@ public static class SimpleBean {
public int x, y;
}
+ static class AliasBean {
+ @JsonAlias({ "nm", "Name" })
+ public String name;
+
+ int _xyz;
+
+ int _a;
+
+ @JsonCreator
+ public AliasBean(@JsonProperty("a")
+ @JsonAlias("A") int a) {
+ _a = a;
+ }
+
+ @JsonAlias({ "Xyz" })
+ public void setXyz(int x) {
+ _xyz = x;
+ }
+ }
+
/*
/**********************************************************
/* Other helper classes
@@ -186,17 +206,16 @@ public void testIssue442PrivateUnwrapped() throws Exception
/* Test methods, annotations disabled
/**********************************************************
*/
-
+
public void testAnnotationsDisabled() throws Exception
{
// first: verify that annotation introspection is enabled by default
- ObjectMapper m = new ObjectMapper();
- assertTrue(m.getDeserializationConfig().isEnabled(MapperFeature.USE_ANNOTATIONS));
+ assertTrue(MAPPER.getDeserializationConfig().isEnabled(MapperFeature.USE_ANNOTATIONS));
// with annotations, property is renamed
- AnnoBean bean = m.readValue("{ \"y\" : 0 }", AnnoBean.class);
+ AnnoBean bean = MAPPER.readValue("{ \"y\" : 0 }", AnnoBean.class);
assertEquals(0, bean.value);
- m = new ObjectMapper();
+ ObjectMapper m = new ObjectMapper();
m.configure(MapperFeature.USE_ANNOTATIONS, false);
// without annotations, should default to default bean-based name...
bean = m.readValue("{ \"x\" : 0 }", AnnoBean.class);
@@ -222,4 +241,27 @@ public void testNoAccessOverrides() throws Exception
assertEquals(1, bean.x);
assertEquals(2, bean.y);
}
+
+ /*
+ public void testSimpleAliases() throws Exception
+ {
+ AliasBean bean = MAPPER.readValue(aposToQuotes("{'Name':'Foobar','a':3,'xyz':37}"),
+ AliasBean.class);
+ assertEquals("Foobar", bean.name);
+ assertEquals(3, bean._a);
+ assertEquals(37, bean._xyz);
+
+ bean = MAPPER.readValue(aposToQuotes("{'name':'Foobar','A':3,'xyz':37}"),
+ AliasBean.class);
+ assertEquals("Foobar", bean.name);
+ assertEquals(3, bean._a);
+ assertEquals(37, bean._xyz);
+
+ bean = MAPPER.readValue(aposToQuotes("{'name':'Foobar','a':3,'Xyz':37}"),
+ AliasBean.class);
+ assertEquals("Foobar", bean.name);
+ assertEquals(3, bean._a);
+ assertEquals(37, bean._xyz);
+ }
+ */
}
diff --git a/src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderWithUnwrappedTest.java b/src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderWithUnwrappedTest.java
index f284dbd6ec..6a93cf4a57 100644
--- a/src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderWithUnwrappedTest.java
+++ b/src/test/java/com/fasterxml/jackson/databind/deser/builder/BuilderWithUnwrappedTest.java
@@ -132,7 +132,7 @@ public void testWithUnwrapping() throws Exception
}
// Alas: can't pass, until [databind#265] fixed:
- /*
+ // 23-Feb-2017, tatu: or its follow-up: error message is now more descriptive...
public void testWithCreatorUnwrapping() throws Exception
{
final String json = aposToQuotes("{'loc.x':4,'name':'Foobar','loc.y': 7}}");
@@ -141,13 +141,22 @@ public void testWithCreatorUnwrapping() throws Exception
mapper.setInjectableValues(new InjectableValues.Std()
.addValue(String.class, "stuffValue")
);
-
- UnwrappingCreatorValue result = mapper.readValue(json, UnwrappingCreatorValue.class);
+
+ @SuppressWarnings("unused")
+ UnwrappingCreatorValue result;
+ try {
+ result = mapper.readValue(json, UnwrappingCreatorValue.class);
+ fail("Did not expect to really pass -- should maybe update the test");
+ } catch (InvalidDefinitionException e) {
+ verifyException(e, "combination not yet supported");
+ }
+
+ /*
assertNotNull(result);
assertNotNull(result.location);
assertEquals("Foobar", result.name);
assertEquals(4, result.location.x);
assertEquals(7, result.location.y);
+ */
}
- */
}