Bug 5829 - New yang parser allows two choice cases with identical child elements
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / stmt / Bug5550.java
1 /*
2  * Copyright (c) 2016 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;
9
10 import static org.junit.Assert.assertNotNull;
11 import static org.junit.Assert.assertTrue;
12
13 import java.io.FileNotFoundException;
14 import java.net.URISyntaxException;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
20 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
21 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
23 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
24
25 public class Bug5550 {
26     private static final String NS = "foo";
27     private static final String REV = "2016-03-18";
28
29     @Test
30     public void test() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
31         SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5550");
32         assertNotNull(context);
33
34         QName root = QName.create(NS, REV, "root");
35         QName containerInGrouping = QName.create(NS, REV, "container-in-grouping");
36         QName leaf1 = QName.create(NS, REV, "leaf-1");
37
38         SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
39                 SchemaPath.create(true, root, containerInGrouping, leaf1));
40         assertTrue(findDataSchemaNode instanceof LeafSchemaNode);
41     }
42 }