File: TestOverloaded.java

package info (click to toggle)
libjackson-json-java 1.9.13-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 9,412 kB
  • sloc: java: 88,999; xml: 1,382; sh: 37; makefile: 26
file content (38 lines) | stat: -rw-r--r-- 919 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package org.codehaus.jackson.map.deser;

import org.codehaus.jackson.map.*;

/**
 * Unit tests related to handling of overloaded methods;
 * and specifically addressing problem [JACKSON-189].
 *
 * @since 1.5
 */
public class TestOverloaded
    extends BaseMapTest
{
    static class OverloadBean
    {
        String a;

        public OverloadBean() { }

        public void setA(int value) { a = String.valueOf(value); }
        public void setA(String value) { a = value; }
    }

    /**
     * Unit test related to [JACKSON-189]
     */
    public void testSimpleOverload() throws Exception
    {
        OverloadBean bean;
        try {
            bean = new ObjectMapper().readValue("{ \"a\" : 13 }", OverloadBean.class);
        } catch (JsonMappingException e) {
            fail("Did not expect an exception, got: "+e.getMessage());
            return;
        }
        assertEquals("13", bean.a);
    }
}