@@ -168,8 +168,10 @@ protected FirstNameBean() { }
168
168
// [databind#1026]
169
169
{"usId" , "us_id" },
170
170
{"uId" , "u_id" },
171
+ // [databind#2267]
172
+ {"xCoordinate" , "x_coordinate" },
171
173
});
172
-
174
+
173
175
private ObjectMapper _lcWithUndescoreMapper ;
174
176
175
177
@ Override
@@ -396,32 +398,32 @@ public void testNamingWithObjectNode() throws Exception
396
398
397
399
public void testExplicitRename () throws Exception
398
400
{
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 );
425
427
}
426
428
427
429
// Also verify that "no naming strategy" should be ok
0 commit comments