• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package com.fasterxml.jackson.databind.introspect;
2 
3 import com.fasterxml.jackson.databind.*;
4 
5 // Tests for [databind#653]
6 public class BeanNamingTest extends BaseMapTest
7 {
8     static class URLBean {
getURL()9         public String getURL() {
10             return "http://foo";
11         }
12     }
13 
14     static class ABean {
getA()15         public int getA() {
16             return 3;
17         }
18     }
19 
testSimple()20     public void testSimple() throws Exception
21     {
22         ObjectMapper mapper = new ObjectMapper();
23         assertFalse(mapper.isEnabled(MapperFeature.USE_STD_BEAN_NAMING));
24         assertEquals(aposToQuotes("{'url':'http://foo'}"),
25                 mapper.writeValueAsString(new URLBean()));
26         assertEquals(aposToQuotes("{'a':3}"),
27                 mapper.writeValueAsString(new ABean()));
28 
29         mapper = jsonMapperBuilder()
30                 .enable(MapperFeature.USE_STD_BEAN_NAMING)
31                 .build();
32         assertEquals(aposToQuotes("{'URL':'http://foo'}"),
33                 mapper.writeValueAsString(new URLBean()));
34         assertEquals(aposToQuotes("{'a':3}"),
35                 mapper.writeValueAsString(new ABean()));
36     }
37 }
38