2 * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.assertTrue;
11 import static org.junit.Assert.fail;
13 import org.junit.Test;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
15 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
17 public class NameCollisionWithinCaseTest {
19 public void testChildNameCollisionOfAugmentCase() throws Exception {
21 StmtTestUtils.parseYangSource("/bugs/name-collision-within-case/foo.yang");
22 fail("Expected failure due to node name collision");
23 } catch (ReactorException e) {
24 final Throwable cause = e.getCause();
25 assertTrue(cause instanceof SourceException);
26 assertTrue(cause.getMessage().startsWith(
27 "Cannot add data tree child with name (foo?revision=2018-02-11)bar, a conflicting child already exists "
33 public void testChildNameCollisionOfAugmentChoice() throws Exception {
35 StmtTestUtils.parseYangSource("/bugs/name-collision-within-case/bar.yang");
36 fail("Expected failure due to node name collision");
37 } catch (ReactorException e) {
38 final Throwable cause = e.getCause();
39 assertTrue(cause instanceof SourceException);
40 assertTrue(cause.getMessage().startsWith(
41 "Cannot add data tree child with name (bar?revision=2018-02-11)bar, a conflicting child already exists "
47 public void testChildNameCollisionNormal() throws Exception {
49 StmtTestUtils.parseYangSource("/bugs/name-collision-within-case/baz.yang");
50 fail("Expected failure due to node name collision");
51 } catch (ReactorException e) {
52 final Throwable cause = e.getCause();
53 assertTrue(cause instanceof SourceException);
54 assertTrue(cause.getMessage().startsWith(
55 "Error in module 'baz': cannot add '(baz?revision=2018-02-28)bar'. Node name collision: "));