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