Added support for parsing submodules & added dependency utility parser
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / impl / YangParserTest.java
index bb2fea413b75cdd096ec4b56d5830fa7cf713e79..e29cc9a07eab3b6905789182fb575a42790da4f0 100644 (file)
@@ -44,6 +44,8 @@ import org.opendaylight.yangtools.yang.model.util.Uint32;
 import org.opendaylight.yangtools.yang.model.util.UnionType;
 
 public class YangParserTest {
+    public static final String FS = File.separator;
+
     private final URI fooNS = URI.create("urn:opendaylight.foo");
     private final URI barNS = URI.create("urn:opendaylight.bar");
     private final URI bazNS = URI.create("urn:opendaylight.baz");
@@ -910,4 +912,28 @@ public class YangParserTest {
         }
     }
 
+    @Test
+    public void testSubmodules() {
+        String yangFilePath = getClass().getResource(FS + "submodule-test" + FS + "subfoo.yang").getPath();
+        String directoryPath = getClass().getResource(FS + "model").getPath();
+
+        File directory = new File(directoryPath);
+        File yangFile = new File(yangFilePath);
+
+        Set<Module> modules = new YangParserImpl().parseYangModels(yangFile, directory);
+        assertEquals(3, modules.size());
+
+        Module foo = TestUtils.findModule(modules, "foo");
+
+        DataSchemaNode id = foo.getDataChildByName("id");
+        assertNotNull(id);
+        DataSchemaNode subExt = foo.getDataChildByName("sub-ext");
+        assertNotNull(subExt);
+        DataSchemaNode subTransfer = foo.getDataChildByName("sub-transfer");
+        assertNotNull(subTransfer);
+
+        assertEquals(2, foo.getExtensionSchemaNodes().size());
+        assertEquals(2, foo.getAugmentations().size());
+    }
+
 }