2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.yang.parser.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import java.util.List;
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;
24 * Test antlr grammar capability to parse nested unknown nodes.
26 public class Bug394Test {
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);
36 ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName("logrecords");
37 assertNotNull(logrecords);
39 List<UnknownSchemaNode> nodes = logrecords.getUnknownSchemaNodes();
40 assertEquals(2, nodes.size());
42 List<ExtensionDefinition> extensions = bug394_ext.getExtensionSchemaNodes();
43 assertEquals(2, extensions.size());
45 assertTrue(extensions.contains(nodes.get(0).getExtensionDefinition()));
46 assertTrue(extensions.contains(nodes.get(1).getExtensionDefinition()));