2 * Copyright (c) 2017 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
9 package org.opendaylight.yangtools.yang.stmt;
11 import static org.junit.Assert.assertTrue;
12 import static org.junit.Assert.fail;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
17 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
19 public class Bug7954Test {
22 public void testParsingTheSameModuleTwice() throws Exception {
23 final File yang = new File(getClass().getResource("/bugs/bug7954/foo.yang").toURI());
26 StmtTestUtils.parseYangSources(yang, yang);
27 fail("An exception should have been thrown because of adding the same YANG module twice.");
28 } catch (final ReactorException ex) {
29 final Throwable cause = ex.getCause();
30 assertTrue(cause instanceof SourceException);
31 assertTrue(cause.getMessage().startsWith("Module namespace collision: foo-ns."));
36 public void testParsingTheSameSubmoduleTwice() throws Exception {
37 final File yang = new File(getClass().getResource("/bugs/bug7954/bar.yang").toURI());
38 final File childYang = new File(getClass().getResource("/bugs/bug7954/subbar.yang").toURI());
41 StmtTestUtils.parseYangSources(yang, childYang, childYang);
42 fail("An exception should have been thrown because of adding the same YANG submodule twice.");
43 } catch (final ReactorException ex) {
44 final Throwable cause = ex.getCause();
45 assertTrue(cause instanceof SourceException);
46 assertTrue(cause.getMessage().startsWith("Submodule name collision: subbar."));