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
8 package org.opendaylight.yangtools.yang.stmt;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
13 import java.io.IOException;
14 import java.util.Collection;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.Module;
17 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
18 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
22 public class YangParserIdentityTest {
24 // base identity name equals identity name
25 @Test(expected = SomeModifiersUnresolvedException.class)
26 public void testParsingIdentityTestModule() throws IOException, ReactorException, YangSyntaxErrorException {
28 TestUtils.loadModuleResources(getClass(), "/identity/identitytest.yang");
29 } catch (SomeModifiersUnresolvedException e) {
30 StmtTestUtils.log(e, " ");
35 // same module prefixed base identity name equals identity name
36 @Test(expected = SomeModifiersUnresolvedException.class)
37 public void testParsingPrefixIdentityTestModule() throws IOException, ReactorException, YangSyntaxErrorException {
39 TestUtils.loadModuleResources(getClass(), "/identity/prefixidentitytest.yang");
40 } catch (SomeModifiersUnresolvedException e) {
41 StmtTestUtils.log(e, " ");
46 // imported module prefixed base identity name equals identity name, but
49 public void testParsingImportPrefixIdentityTestModule() throws Exception {
50 Module module = TestUtils.findModule(TestUtils.loadModules(getClass().getResource("/identity/import").toURI()),
51 "prefiximportidentitytest").get();
52 Collection<? extends ModuleImport> imports = module.getImports();
53 assertEquals(imports.size(), 1);
54 ModuleImport dummy = TestUtils.findImport(imports, "dummy");
55 assertNotEquals(dummy.getPrefix(), module.getPrefix());