Begin to fix issue 149 - identify the problem
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue149/ComponentBean.java b/src/test/java/org/yaml/snakeyaml/issues/issue149/ComponentBean.java
new file mode 100644
index 0000000..68e995f
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue149/ComponentBean.java
@@ -0,0 +1,37 @@
+/**
+ * Copyright (c) 2008-2012, http://www.snakeyaml.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.yaml.snakeyaml.issues.issue149;
+
+public class ComponentBean {
+ private int property1;
+ private String property2;
+
+ public int getProperty1() {
+ return property1;
+ }
+
+ public void setProperty1(int property1) {
+ this.property1 = property1;
+ }
+
+ public String getProperty2() {
+ return property2;
+ }
+
+ public void setProperty2(String property2) {
+ this.property2 = property2;
+ }
+}
diff --git a/src/test/java/org/yaml/snakeyaml/issues/issue149/GlobalDirectivesTest.java b/src/test/java/org/yaml/snakeyaml/issues/issue149/GlobalDirectivesTest.java
new file mode 100644
index 0000000..8211795
--- /dev/null
+++ b/src/test/java/org/yaml/snakeyaml/issues/issue149/GlobalDirectivesTest.java
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2008-2012, http://www.snakeyaml.org
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.yaml.snakeyaml.issues.issue149;
+
+import junit.framework.TestCase;
+
+import org.yaml.snakeyaml.TypeDescription;
+import org.yaml.snakeyaml.Util;
+import org.yaml.snakeyaml.Yaml;
+import org.yaml.snakeyaml.constructor.Constructor;
+import org.yaml.snakeyaml.nodes.Tag;
+
+public class GlobalDirectivesTest extends TestCase {
+ public void testOneDocument() {
+ String input = Util.getLocalResource("issues/issue149-one-document.yaml");
+ // System.out.println(input);
+ Constructor constr = new Constructor();
+ TypeDescription description = new TypeDescription(ComponentBean.class, new Tag(
+ "tag:ualberta.ca,2012:" + 29));
+ constr.addTypeDescription(description);
+ Yaml yaml = new Yaml(constr);
+ Iterable<Object> parsed = yaml.loadAll(input);
+ for (Object obj : parsed) {
+ System.out.println(obj);
+ }
+ }
+
+ public void testDirectives() {
+ String input = Util.getLocalResource("issues/issue149-losing-directives.yaml");
+ // System.out.println(input);
+ Constructor constr = new Constructor();
+ TypeDescription description = new TypeDescription(ComponentBean.class, new Tag(
+ "tag:ualberta.ca,2012:" + 29));
+ constr.addTypeDescription(description);
+ Yaml yaml = new Yaml(constr);
+ // Iterable<Object> parsed = yaml.loadAll(input);
+ // for (Object obj : parsed) {
+ // System.out.println(obj);
+ // }
+ }
+}
\ No newline at end of file
diff --git a/src/test/resources/issues/issue149-losing-directives.yaml b/src/test/resources/issues/issue149-losing-directives.yaml
new file mode 100644
index 0000000..649eac5
--- /dev/null
+++ b/src/test/resources/issues/issue149-losing-directives.yaml
@@ -0,0 +1,9 @@
+%YAML 1.1
+%TAG !u! tag:ualberta.ca,2012:
+--- !u!29 &1
+property1: 0
+property2: aaa
+
+--- !u!29 &2
+property1: 3
+property2: bbb
diff --git a/src/test/resources/issues/issue149-one-document.yaml b/src/test/resources/issues/issue149-one-document.yaml
new file mode 100644
index 0000000..2c4d172
--- /dev/null
+++ b/src/test/resources/issues/issue149-one-document.yaml
@@ -0,0 +1,7 @@
+%YAML 1.1
+%TAG !u! tag:ualberta.ca,2012:
+--- !u!29 &1
+property1: 0
+property2: aaa
+
+