2 * Copyright (c) 2016 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.stmt;
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;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
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.SchemaContext;
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 final SchemaContext context = TestUtils.loadModules(getClass().getResource("/bugs/bug394-retest").toURI());
31 final Module bug394 = TestUtils.findModule(context, "bug394").get();
32 final Module bug394_ext = TestUtils.findModule(context, "bug394-ext").get();
34 final ContainerSchemaNode logrecords = (ContainerSchemaNode) bug394.getDataChildByName(QName.create(
35 bug394.getQNameModule(), "logrecords"));
36 assertNotNull(logrecords);
38 final List<UnknownSchemaNode> nodes = logrecords.getUnknownSchemaNodes();
39 assertEquals(2, nodes.size());
41 final List<ExtensionDefinition> extensions = bug394_ext.getExtensionSchemaNodes();
42 assertEquals(3, extensions.size());
44 assertTrue(extensions.contains(nodes.get(0).getExtensionDefinition()));
45 assertTrue(extensions.contains(nodes.get(1).getExtensionDefinition()));