1 package org.opendaylight.yangtools.yang.stmt.retest;
3 import static org.junit.Assert.assertEquals;
4 import static org.junit.Assert.assertNotEquals;
6 import java.io.FileInputStream;
7 import java.io.FileNotFoundException;
8 import java.io.InputStream;
9 import java.net.URISyntaxException;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.model.api.Module;
13 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
16 import org.opendaylight.yangtools.yang.stmt.test.StmtTestUtils;
18 public class YangParserIdentityTest {
20 // base identity name equals identity name
21 @Test(expected = SomeModifiersUnresolvedException.class)
22 public void testParsingIdentityTestModule() throws URISyntaxException,
23 ReactorException, FileNotFoundException {
24 File yang = new File(getClass().getResource("/identity/identitytest.yang").toURI());
25 InputStream stream = new FileInputStream(yang);
27 TestUtils.loadModule(stream);
28 } catch (SomeModifiersUnresolvedException e) {
29 StmtTestUtils.log(e, " ");
34 // same module prefixed base identity name equals identity name
35 @Test(expected = SomeModifiersUnresolvedException.class)
36 public void testParsingPrefixIdentityTestModule() throws URISyntaxException,
37 ReactorException, FileNotFoundException {
38 File yang = new File(getClass().getResource("/identity/prefixidentitytest.yang").toURI());
39 InputStream stream = new FileInputStream(yang);
41 TestUtils.loadModule(stream);
42 } catch (SomeModifiersUnresolvedException e) {
43 StmtTestUtils.log(e, " ");
48 // imported module prefixed base identity name equals identity name, but
51 public void testParsingImportPrefixIdentityTestModule() throws URISyntaxException,
53 Set<Module> modules = TestUtils.loadModules(getClass().getResource("/identity/import").toURI());
54 Module module = TestUtils.findModule(modules, "prefiximportidentitytest");
55 Set<ModuleImport> imports = module.getImports();
56 assertEquals(imports.size(), 1);
57 ModuleImport dummy = TestUtils.findImport(imports, "dummy");
58 assertNotEquals(dummy.getPrefix(), module.getPrefix());