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
9 package org.opendaylight.yangtools.yang.stmt;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertTrue;
13 import static org.junit.Assert.fail;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
19 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
20 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
22 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
23 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
24 import org.opendaylight.yangtools.yang.stmt.test.StmtTestUtils;
26 public class Bug6410Test {
29 public void testTypedefsInRpc() throws ReactorException {
30 final SchemaContext schemaContext = StmtTestUtils.parseYangSources(
31 new YangStatementSourceImpl("/bugs/bug6410/foo.yang", false));
33 final Set<Module> modules = schemaContext.getModules();
34 assertEquals(1, modules.size());
35 final Module module = modules.iterator().next();
37 final Set<RpcDefinition> rpcs = module.getRpcs();
38 assertEquals(1, rpcs.size());
39 final RpcDefinition rpc = rpcs.iterator().next();
41 final Set<TypeDefinition<?>> typeDefs = rpc.getTypeDefinitions();
42 assertEquals(2, typeDefs.size());
46 public void shouldFailOnDuplicateTypedefs() throws ReactorException {
48 final SchemaContext schemaContext = StmtTestUtils.parseYangSources(
49 new YangStatementSourceImpl("/bugs/bug6410/bar.yang", false));
50 fail("A SourceException should have been thrown.");
51 } catch (SourceException ex) {
52 assertTrue(ex.getMessage().contains("Node name collision"));