-
Notifications
You must be signed in to change notification settings - Fork 77
/
TestAbstractClasses.java
48 lines (39 loc) · 1.37 KB
/
TestAbstractClasses.java
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
39
40
41
42
43
44
45
46
47
48
package com.fasterxml.jackson.module.mrbean;
import com.fasterxml.jackson.databind.ObjectMapper;
public class TestAbstractClasses
extends BaseTest
{
/*
/**********************************************************
/* Test classes, enums
/**********************************************************
*/
public abstract static class Bean
{
int y;
protected Bean() { }
public abstract String getX();
public String getFoo() { return "Foo!"; }
public void setY(int value) { y = value; }
// also verify non-public methods
protected abstract String getZ();
private String customMethod() { return "Private methods rock!"; }
}
/*
/**********************************************************
/* Unit tests
/**********************************************************
*/
@SuppressWarnings("synthetic-access")
public void testSimpleInteface() throws Exception
{
ObjectMapper mapper = newMrBeanMapper();
Bean bean = mapper.readValue("{ \"x\" : \"abc\", \"y\" : 13, \"z\" : \"def\" }", Bean.class);
assertNotNull(bean);
assertEquals("abc", bean.getX());
assertEquals(13, bean.y);
assertEquals("Foo!", bean.getFoo());
assertEquals("def", bean.getZ());
assertEquals("Private methods rock!", bean.customMethod());
}
}