1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.yaml.snakeyaml.nodes;
17
18 import junit.framework.TestCase;
19
20 import org.yaml.snakeyaml.DumperOptions;
21 import org.yaml.snakeyaml.Yaml;
22
23 public class TagsTest extends TestCase {
24
25 public void testGetGlobalTagForClass() {
26 assertEquals(new Tag("tag:yaml.org,2002:java.lang.String"), new Tag(String.class));
27 assertEquals(new Tag("tag:yaml.org,2002:org.yaml.snakeyaml.nodes.TagsTest"), new Tag(
28 TagsTest.class));
29 }
30
31
32
33
34
35 public void testLong() {
36 DumperOptions options = new DumperOptions();
37 options.setDefaultScalarStyle(DumperOptions.ScalarStyle.DOUBLE_QUOTED);
38 Yaml yaml = new Yaml(options);
39 Foo foo = new Foo();
40 String output = yaml.dump(foo);
41
42 Foo foo2 = (Foo) yaml.load(output);
43 assertEquals(new Long(42L), foo2.getBar());
44 }
45
46 public static class Foo {
47 private Long bar = Long.valueOf(42L);
48
49 public Long getBar() {
50 return bar;
51 }
52
53 public void setBar(Long bar) {
54 this.bar = bar;
55 }
56 }
57 }