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.assertNotEquals;
14 import java.io.IOException;
16 import org.junit.Test;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
19 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
23 public class YangParserIdentityTest {
25 // base identity name equals identity name
26 @Test(expected = SomeModifiersUnresolvedException.class)
27 public void testParsingIdentityTestModule() throws IOException, ReactorException, YangSyntaxErrorException {
29 TestUtils.loadModuleResources(getClass(), "/identity/identitytest.yang");
30 } catch (SomeModifiersUnresolvedException e) {
31 StmtTestUtils.log(e, " ");
36 // same module prefixed base identity name equals identity name
37 @Test(expected = SomeModifiersUnresolvedException.class)
38 public void testParsingPrefixIdentityTestModule() throws IOException, ReactorException, YangSyntaxErrorException {
40 TestUtils.loadModuleResources(getClass(), "/identity/prefixidentitytest.yang");
41 } catch (SomeModifiersUnresolvedException e) {
42 StmtTestUtils.log(e, " ");
47 // imported module prefixed base identity name equals identity name, but
50 public void testParsingImportPrefixIdentityTestModule() throws Exception {
51 Module module = TestUtils.findModule(TestUtils.loadModules(getClass().getResource("/identity/import").toURI()),
52 "prefiximportidentitytest").get();
53 Set<ModuleImport> imports = module.getImports();
54 assertEquals(imports.size(), 1);
55 ModuleImport dummy = TestUtils.findImport(imports, "dummy");
56 assertNotEquals(dummy.getPrefix(), module.getPrefix());