2 * Copyright (c) 2014 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.retest;
10 import static org.junit.Assert.assertNotNull;
14 import org.junit.Rule;
15 import org.junit.Test;
16 import org.junit.rules.ExpectedException;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
19 import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
20 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
21 import org.opendaylight.yangtools.yang.parser.util.YangParseException;
23 public class SameQNamesInChoiceTest {
26 public ExpectedException thrown = ExpectedException.none();
29 public void testSameQNameInChoice() throws Exception {
30 thrown.expect(YangParseException.class);
31 thrown.expectMessage("Choice has two nodes case with same qnames");
33 SchemaContext context;
34 File yangFile = new File(getClass().getResource("/bugs/qnameDuplicity/two-same-node-in-choice/two-same-nodes-in-choice-case.yang").toURI());
35 File dependenciesDir = new File(getClass().getResource("/bugs/qnameDuplicity/two-same-node-in-choice").toURI());
36 YangContextParser parser = new YangParserImpl();
37 context = parser.parseFile(yangFile, dependenciesDir);
39 Module testModule = context.findModuleByNamespace(URI.create("urn:test:two:same-nodes-in-choice-case")).iterator().next();
40 assertNotNull(testModule);
45 public void testAugmentedNodeIntoChoiceCase() throws Exception {
46 thrown.expect(YangParseException.class);
47 thrown.expectMessage("Choice has two nodes case with same qnames");
49 SchemaContext context;
50 File yangFile = new File(getClass().getResource("/bugs/qnameDuplicity/augment/two-cases.yang").toURI());
51 File dependenciesDir = new File(getClass().getResource("/bugs/qnameDuplicity/augment").toURI());
52 YangContextParser parser = new YangParserImpl();
53 context = parser.parseFile(yangFile, dependenciesDir);
55 Module testModule = context.findModuleByNamespace(URI.create("urn:test:two:cases")).iterator().next();
56 assertNotNull(testModule);