Merge "BUG-973: fixed (de)serialization of union type."
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / 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.parser.impl;
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
17 import org.junit.Test;
18 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
19 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
20 import org.opendaylight.yangtools.yang.model.api.Module;
21 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
22
23 /**
24  * Test antlr grammar capability to parse nested unknown nodes.
25  */
26 public class Bug394Test {
27
28     @Test
29     public void testParseList() throws Exception {
30         Set<Module> modules = TestUtils.loadModules(getClass().getResource("/bugs/bug394").toURI());
31         Module bug394 = TestUtils.findModule(modules, "bug394");
32         assertNotNull(bug394);
33         Module bug394_ext = TestUtils.findModule(modules, "bug394-ext");
34         assertNotNull(bug394_ext);
35
36         ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName("logrecords");
37         assertNotNull(logrecords);
38
39         List<UnknownSchemaNode> nodes = logrecords.getUnknownSchemaNodes();
40         assertEquals(2, nodes.size());
41
42         List<ExtensionDefinition> extensions = bug394_ext.getExtensionSchemaNodes();
43         assertEquals(2, extensions.size());
44
45         assertTrue(extensions.contains(nodes.get(0).getExtensionDefinition()));
46         assertTrue(extensions.contains(nodes.get(1).getExtensionDefinition()));
47     }
48
49 }