Skip to content

Commit d994b2d

Browse files
committed
Merge branch '2.9' into 2.10
2 parents d7a0ebc + 3e65248 commit d994b2d

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

src/test/java/com/fasterxml/jackson/databind/introspect/TestNamingStrategyStd.java

+29-27
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,10 @@ protected FirstNameBean() { }
168168
// [databind#1026]
169169
{"usId", "us_id" },
170170
{"uId", "u_id" },
171+
// [databind#2267]
172+
{"xCoordinate", "x_coordinate" },
171173
});
172-
174+
173175
private ObjectMapper _lcWithUndescoreMapper;
174176

175177
@Override
@@ -396,32 +398,32 @@ public void testNamingWithObjectNode() throws Exception
396398

397399
public void testExplicitRename() throws Exception
398400
{
399-
ObjectMapper m = objectMapperBuilder()
400-
.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
401-
.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
402-
.build();
403-
// by default, renaming will not take place on explicitly named fields
404-
assertEquals(aposToQuotes("{'firstName':'Peter','lastName':'Venkman','user_age':'35'}"),
405-
m.writeValueAsString(new ExplicitBean()));
406-
407-
m = objectMapperBuilder()
408-
.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
409-
.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
410-
.enable(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING)
411-
.build();
412-
// w/ feature enabled, ALL property names should get re-written
413-
assertEquals(aposToQuotes("{'first_name':'Peter','last_name':'Venkman','user_age':'35'}"),
414-
m.writeValueAsString(new ExplicitBean()));
415-
416-
// test deserialization as well
417-
ExplicitBean bean =
418-
m.readValue(aposToQuotes("{'first_name':'Egon','last_name':'Spengler','user_age':'32'}"),
419-
ExplicitBean.class);
420-
421-
assertNotNull(bean);
422-
assertEquals("Egon", bean.userFirstName);
423-
assertEquals("Spengler", bean.userLastName);
424-
assertEquals("32", bean.userAge);
401+
ObjectMapper m = objectMapperBuilder()
402+
.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
403+
.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
404+
.build();
405+
// by default, renaming will not take place on explicitly named fields
406+
assertEquals(aposToQuotes("{'firstName':'Peter','lastName':'Venkman','user_age':'35'}"),
407+
m.writeValueAsString(new ExplicitBean()));
408+
409+
m = objectMapperBuilder()
410+
.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE)
411+
.enable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)
412+
.enable(MapperFeature.ALLOW_EXPLICIT_PROPERTY_RENAMING)
413+
.build();
414+
// w/ feature enabled, ALL property names should get re-written
415+
assertEquals(aposToQuotes("{'first_name':'Peter','last_name':'Venkman','user_age':'35'}"),
416+
m.writeValueAsString(new ExplicitBean()));
417+
418+
// test deserialization as well
419+
ExplicitBean bean =
420+
m.readValue(aposToQuotes("{'first_name':'Egon','last_name':'Spengler','user_age':'32'}"),
421+
ExplicitBean.class);
422+
423+
assertNotNull(bean);
424+
assertEquals("Egon", bean.userFirstName);
425+
assertEquals("Spengler", bean.userLastName);
426+
assertEquals("32", bean.userAge);
425427
}
426428

427429
// Also verify that "no naming strategy" should be ok

0 commit comments

Comments
 (0)