Bug 4540: Yang parser exceptions should follow consistent path
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / retest / Bug394Test.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.stmt.retest;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import java.util.List;
15 import java.util.Set;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
19 import org.opendaylight.yangtools.yang.model.api.Module;
20 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
21
22 /**
23  * Test antlr grammar capability to parse nested unknown nodes.
24  */
25 public class Bug394Test {
26
27     @Test
28     public void testParseList() throws Exception {
29         Set<Module> modules = TestUtils.loadModules(getClass().getResource("/bugs/bug394-retest").toURI());
30         Module bug394 = TestUtils.findModule(modules, "bug394");
31         assertNotNull(bug394);
32         Module bug394_ext = TestUtils.findModule(modules, "bug394-ext");
33         assertNotNull(bug394_ext);
34
35         ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName("logrecords");
36         assertNotNull(logrecords);
37
38         List<UnknownSchemaNode> nodes = logrecords.getUnknownSchemaNodes();
39         assertEquals(2, nodes.size());
40
41         List<ExtensionDefinition> extensions = bug394_ext.getExtensionSchemaNodes();
42         assertEquals(3, extensions.size());
43
44         assertTrue(extensions.contains(nodes.get(0).getExtensionDefinition()));
45         assertTrue(extensions.contains(nodes.get(1).getExtensionDefinition()));
46     }
47
48 }