File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\test\java\jenkins\ResilientJsonObjectTest.java.html

1 package jenkins;
2
3 import net.sf.json.JSONObject;
4 import org.junit.Test;
5 import org.jvnet.hudson.test.Bug;
6
7 /**
8 * @author Kohsuke Kawaguchi
9 */
10 public class ResilientJsonObjectTest {
11 public static class Foo { public int a; }
12
13 /**
14 * {@link JSONObject} databinding should be able to ignore non-existent fields.
15 */
16 @Test
17 @Bug(15105)
18 public void databindingShouldIgnoreUnrecognizedJsonProperty() {
19 JSONObject o = JSONObject.fromObject("{a:1,b:2}");
20 Foo f = (Foo)JSONObject.toBean(o,Foo.class);
21 assert f.a == 1;
22 }
23 }
24