View Javadoc

1   /**
2    * Copyright (c) 2008-2012, http://www.snakeyaml.org
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.yaml.snakeyaml.nodes;
17  
18  import junit.framework.TestCase;
19  
20  import org.yaml.snakeyaml.error.Mark;
21  
22  public class NodeTest extends TestCase {
23  
24      public void testNode() {
25          try {
26              new ScalarNode(new Tag("!foo"), null, null, null, '"');
27              fail("Value must be required.");
28          } catch (Exception e) {
29              assertEquals("value in a Node is required.", e.getMessage());
30          }
31      }
32  
33      public void testSetTag() {
34          try {
35              ScalarNode node = new ScalarNode(new Tag("!foo"), "Value1", null, null, '"');
36              node.setTag((Tag) null);
37              fail("Value must be required.");
38          } catch (Exception e) {
39              assertEquals("tag in a Node is required.", e.getMessage());
40          }
41      }
42  
43      public void testGetEndMark() {
44          Mark mark1 = new Mark("name", 5, 2, 12, "afd asd asd", 7);
45          Mark mark2 = new Mark("name", 6, 3, 13, "afd asd asd", 8);
46          Node node = new ScalarNode(new Tag("!foo"), "bla-bla", mark1, mark2, '"');
47          assertEquals(mark1, node.getStartMark());
48          assertEquals(mark2, node.getEndMark());
49      }
50  
51  }