[ONOS-3880, 3881] Yang Listener for Module and Sub-Module
Change-Id: Iee75c3e04af9b66ebc38acb3396aa4c54af5a268
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/CustomExceptionMatcher.java b/src/test/java/org/onosproject/yangutils/parser/impl/CustomExceptionMatcher.java
new file mode 100644
index 0000000..9908da5
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/CustomExceptionMatcher.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl;
+
+import org.hamcrest.Description;
+import org.hamcrest.TypeSafeMatcher;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+
+/**
+ * ExpectedException framework can use the Hamcrest matcher's to test
+ * custom/extended exceptions. This class extends the type safe matcher to define
+ * the custom exception matcher.
+ */
+public final class CustomExceptionMatcher extends TypeSafeMatcher<ParserException> {
+
+ /**
+ * Customized exception matcher to match error location.
+ *
+ * @param line error line
+ * @param charPosition error character position
+ * @return
+ */
+ public static CustomExceptionMatcher errorLocation(int line, int charPosition) {
+ return new CustomExceptionMatcher(line, charPosition);
+ }
+
+ private int actualLine;
+ private final int expectedLine;
+ private int actualCharPosition;
+ private final int expectedCharPosition;
+
+ private CustomExceptionMatcher(int expectedLine, int expectedCharPosition) {
+ this.expectedLine = expectedLine;
+ this.expectedCharPosition = expectedCharPosition;
+ }
+
+ @Override
+ protected boolean matchesSafely(final ParserException exception) {
+ actualLine = exception.getLineNumber();
+ actualCharPosition = exception.getCharPositionInLine();
+ return ((actualLine == expectedLine) && (actualCharPosition == expectedCharPosition));
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText(" Error reported location ")
+ .appendText("Line " + actualLine + ", " + "CharPosition " + actualCharPosition)
+ .appendText(" instead of expected ")
+ .appendText("Line " + expectedLine + ", " + "CharPosition " + expectedCharPosition);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java
new file mode 100644
index 0000000..f2415b2
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BaseFileListenerTest.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.TreeWalkListener;
+
+/**
+ * Test cases for testing base rule listener functionality.
+ */
+public class BaseFileListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ /**
+ * Checks for exception if stack of parsable data is not empty at the entry
+ * of yang base rule.
+ */
+ @Test
+ public void processYangFileEntryNonEmptyStack() {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid holder for yangbase before processing.");
+
+ YangModule tmpModule = new YangModule();
+ TreeWalkListener listener = new TreeWalkListener();
+ listener.getParsedDataStack().push(tmpModule);
+ GeneratedYangParser.YangfileContext ctx = null;
+ BaseFileListener.processYangFileEntry(listener, ctx);
+ }
+
+ /**
+ * Checks that exception shouldn't be generated if stack of parsable data is
+ * empty at the entry of yang base rule.
+ */
+ @Test
+ public void processYangFileEntryEmptyStack() {
+
+ TreeWalkListener listener = new TreeWalkListener();
+ GeneratedYangParser.YangfileContext ctx = null;
+ BaseFileListener.processYangFileEntry(listener, ctx);
+ }
+
+ /**
+ * Checks that exception should be generated if stack of parsable data is
+ * not empty at the exit of yang base rule.
+ */
+ @Test
+ public void processYangFileExitEmptyStack() {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Missing holder at yangbase after processing.");
+
+ TreeWalkListener listener = new TreeWalkListener();
+ GeneratedYangParser.YangfileContext ctx = null;
+ BaseFileListener.processYangFileExit(listener, ctx);
+ }
+
+ /**
+ * Checks that exception shouldn't be generated if stack of parsable data is
+ * empty at the exit of yang base rule.
+ */
+ @Test
+ public void processYangFileExitNonEmptyStack() {
+
+ TreeWalkListener listener = new TreeWalkListener();
+ GeneratedYangParser.YangfileContext ctx = null;
+ BaseFileListener.processYangFileEntry(listener, ctx);
+ }
+
+ /**
+ * Checks that after popping out the parsable node from stack it should be
+ * empty.
+ */
+ @Test
+ public void processYangFileExitStackErrorExtraEntryTest() {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid holder for yangbase after processing.");
+
+ YangModule tmpModule = new YangModule();
+ YangModule tmpModule2 = new YangModule();
+ TreeWalkListener listener = new TreeWalkListener();
+ listener.getParsedDataStack().push(tmpModule);
+ listener.getParsedDataStack().push(tmpModule2);
+ GeneratedYangParser.YangfileContext ctx = null;
+ BaseFileListener.processYangFileExit(listener, ctx);
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java
new file mode 100644
index 0000000..0bc6586
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/BelongstoListenerTest.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.CustomExceptionMatcher;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing belongsto listener functionality.
+ */
+public class BelongstoListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if mandatory belongsto parameter "prefix" is not present.
+ */
+ @Test
+ public void processBelongsToWithoutPrefix() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting 'prefix'");
+ thrown.expect(CustomExceptionMatcher.errorLocation(4, 0));
+ YangNode node = manager.getDataModel("src/test/resources/BelongsToWithoutPrefix.yang");
+ }
+
+ /**
+ * Checks that prefix must be present only once in belongsto.
+ */
+ @Test
+ public void processBelongsToDualPrefix() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'prefix' expecting '}'");
+ thrown.expect(CustomExceptionMatcher.errorLocation(5, 0));
+ YangNode node = manager.getDataModel("src/test/resources/BelongsToDualPrefix.yang");
+ }
+
+ /**
+ * Checks if belongsto listener updates the date model tree.
+ */
+ @Test
+ public void processBelongsToWithPrefix() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/BelongsToWithPrefix.yang");
+ YangSubModule yangNode = (YangSubModule) node;
+ assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+ }
+
+ /**
+ * Checks if mandatory parameter "belongsto" is present.
+ */
+ @Test
+ public void processSubModuleWithoutBelongsTo() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting 'belongs-to'");
+ thrown.expect(CustomExceptionMatcher.errorLocation(3, 0));
+ YangNode node = manager.getDataModel("src/test/resources/SubModuleWithoutBelongsTo.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java
new file mode 100644
index 0000000..9791ba3
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContactListenerTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing contact listener functionality.
+ */
+public class ContactListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if contact listener updates the data model tree.
+ */
+ @Test
+ public void processContactValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContactValidEntry.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getContact(), is("\"WG List: <mailto:spring@ietf.org>\nEditor: "
+ + "Stephane Litkowski\n " + "<mailto:stephane.litkowski@orange.com>\""));
+ }
+
+ /**
+ * Checks that contact must be present only once.
+ */
+ @Test(expected = ParserException.class)
+ public void processContactDualEntryTest() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContactDualEntryTest.yang");
+
+ }
+
+ /**
+ * Checks if contact is not empty.
+ */
+ @Test(expected = ParserException.class)
+ public void processContactWithEmptyString() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContactWithEmptyString.yang");
+ }
+
+ /**
+ * Checks that contact must be present after namespace.
+ */
+ @Test(expected = ParserException.class)
+ public void processContactIncorrectOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContactIncorrectOrder.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java
new file mode 100644
index 0000000..d003cc2
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ImportListenerTest.java
@@ -0,0 +1,112 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing import listener functionality.
+ */
+public class ImportListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if mandatory parameter prefix is present in import.
+ */
+ @Test(expected = ParserException.class)
+ public void processImportWithoutPrefix() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ImportWithoutPrefix.yang");
+ }
+
+ /**
+ * Checks that prefix must be present only once in import.
+ */
+ @Test(expected = ParserException.class)
+ public void processImportWithDualPrefix() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ImportWithDualPrefix.yang");
+ }
+
+ /**
+ * Checks for the correct order of prefix in import.
+ */
+ @Test(expected = ParserException.class)
+ public void processImportInvalidOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ImportInvalidOrder.yang");
+ }
+
+ /**
+ * Checks if import listener updates the data model tree.
+ */
+ @Test
+ public void processImportValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ImportValidEntry.yang");
+
+ // Checks for the revision value in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getRevision(), is("2015-02-03"));
+ // Checks for the prefix id in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getPrefixId(), is("On2"));
+ // Checks for the module name in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getModuleName(), is("ietf"));
+ }
+
+ /**
+ * Checks if optional parameter revision is not mandatory in import.
+ */
+ @Test
+ public void processImportWithoutRevision() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ImportWithoutRevision.yang");
+
+ // Checks for the prefix id in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getPrefixId(), is("On2"));
+ // Checks for the module name in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getModuleName(), is("ietf"));
+ }
+
+ /**
+ * Checks if multiple imports are allowed.
+ */
+ @Test()
+ public void processImportMultipleInstance() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ImportMultipleInstance.yang");
+
+ // Checks for the prefix id in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getPrefixId(), is("On2"));
+ // Checks for the module name in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getModuleName(), is("ietf"));
+
+ // Checks for the prefix id in data model tree.
+ assertThat(((YangModule) node).getImportList().get(1).getPrefixId(), is("On3"));
+ // Checks for the module name in data model tree.
+ assertThat(((YangModule) node).getImportList().get(1).getModuleName(), is("itut"));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java
new file mode 100644
index 0000000..313f5e9
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/IncludeListenerTest.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing include listener functionality.
+ */
+public class IncludeListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if include listener with ; is valid and updates the data
+ * model tree.
+ */
+ @Test
+ public void processIncludeWithStmtend() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IncludeWithStmtend.yang");
+
+ // Checks for the sub module name in data model tree.
+ assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+ }
+
+ /**
+ * Checks if include listener with braces and without revision date is valid
+ * and updates the data model tree.
+ */
+ @Test
+ public void processIncludeWithEmptyBody() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IncludeWithEmptyBody.yang");
+
+ // Checks for the sub module name in data model tree.
+ assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+ }
+
+ /**
+ * Checks if include listener with braces and with revision date is valid
+ * and updates the data model tree.
+ */
+ @Test
+ public void processIncludeWithDate() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IncludeWithDate.yang");
+
+ // Checks for the sub module name in data model tree.
+ assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+ assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+ }
+
+ /**
+ * Checks if include has more than one occurrence.
+ */
+ @Test
+ public void processIncludeMultiInstance() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IncludeMultiInstance.yang");
+
+ // Checks for the sub module name in data model tree.
+ assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+ assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+ assertThat(((YangModule) node).getIncludeList().get(1).getSubModuleName(), is("sdn"));
+ assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is("2014-02-03"));
+ }
+
+ /**
+ * Checks if include and import can come in any order.
+ */
+ @Test
+ public void processIncludeImportAnyOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IncludeImportAnyOrder.yang");
+
+ // Checks for the sub module name in data model tree.
+ assertThat(((YangModule) node).getIncludeList().get(0).getSubModuleName(), is("itut"));
+ assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+ assertThat(((YangModule) node).getIncludeList().get(1).getSubModuleName(), is("sdn"));
+ assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is("2014-02-03"));
+ }
+
+ /**
+ * Checks if syntax of Include is not correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processIncludeInvalidSyntax() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IncludeInvalidSyntax.yang");
+ }
+
+ /**
+ * Checks if syntax of revision date in Include is not correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processIncludeInvalidDateSyntax() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IncludeInvalidDateSyntax.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
new file mode 100644
index 0000000..ab7242a
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ModuleListenerTest.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing module listener functionality.
+ */
+public class ModuleListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if module listener updates the data model root node.
+ */
+ @Test
+ public void processModuleValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleValidEntry.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
+
+ // Check whether the module name is set correctly.
+ YangModule yangNode = (YangModule) node;
+ assertThat(yangNode.getName(), is("Test"));
+ }
+
+ /**
+ * Checks if module name is set correctly.
+ */
+ @Test(expected = ParserException.class)
+ public void processModuleInvalidEntryTest() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleWithInvalidIdentifier.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java
new file mode 100644
index 0000000..50f8f54
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/NamespaceListenerTest.java
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing namespace listener functionality.
+ */
+public class NamespaceListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks that value of namespace shouldn't have invalid spaces.
+ */
+ @Test(expected = ParserException.class)
+ public void processNamespaceWithInvalidSpaces() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NamespaceWithInvalidSpaces.yang");
+ }
+
+ /**
+ * Checks if namespace with double quotes is allowed.
+ */
+ @Test()
+ public void processNamespaceInDoubleQuotes() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NamespaceInDoubleQuotes.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getNameSpace().getUri(), is("\"urn:ietf:params:xml:ns:yang:ietf-ospf\""));
+ }
+
+ /**
+ * Checks if namespace without double quotes is allowed.
+ */
+ @Test()
+ public void processNamespaceWithoutQuotes() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NamespaceWithoutQuotes.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getNameSpace().getUri(), is("urn:ietf:params:xml:ns:yang:ietf-ospf"));
+ }
+
+ /**
+ * Checks if namespace is present only once.
+ */
+ @Test(expected = ParserException.class)
+ public void processNamespaceDualEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NamespaceDualEntry.yang");
+ }
+
+ /**
+ * Checks if mandatory parameter namespace is present.
+ */
+ @Test(expected = ParserException.class)
+ public void processNamespaceNoEntryTest() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/NamespaceNoEntryTest.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java
new file mode 100644
index 0000000..2c71e17
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/OrganizationListenerTest.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing organization listener functionality.
+ */
+public class OrganizationListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if organization listener updates the data model tree.
+ */
+ @Test
+ public void processOrganizationValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/OrganizationValidEntry.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getOrganization(), is("\"IETF SPRING Working Group\""));
+ }
+
+ /**
+ * Checks that organization must be present only once.
+ */
+ @Test(expected = ParserException.class)
+ public void processOrganizationDualEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/OrganizationDualEntry.yang");
+ }
+
+ /**
+ * Checks if organization entry syntax is correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processOrganizationMissingValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/OrganizationMissingValue.yang");
+ }
+
+ /**
+ * Checks if organization and namespace is present in correct order.
+ */
+ @Test(expected = ParserException.class)
+ public void processOrganizationInvalidOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/OrganizationInvalidOrder.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
new file mode 100644
index 0000000..b090bd0
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PrefixListenerTest.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing prefix listener functionality.
+ */
+public class PrefixListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if value of prefix is correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processPrefixInvalidValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PrefixInvalidValue.yang");
+ }
+
+ /**
+ * Checks if prefix listener updates the data model tree.
+ */
+ @Test
+ public void processPrefixValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PrefixValidEntry.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getPrefix(), is("On"));
+ }
+
+ /**
+ * Checks that prefix should be present just once.
+ */
+ @Test(expected = ParserException.class)
+ public void processPrefixDualEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PrefixDualEntry.yang");
+ }
+
+ /**
+ * Checks if prefix syntax is followed.
+ */
+ @Test(expected = ParserException.class)
+ public void processPrefixMissingValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PrefixMissingValue.yang");
+ }
+
+ /**
+ * Checks that exception should be reported if prefix is missing.
+ */
+ @Test(expected = ParserException.class)
+ public void processPrefixOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PrefixOrder.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
new file mode 100644
index 0000000..df56913
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionDateListenerTest.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing revision date listener functionality.
+ */
+public class RevisionDateListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if revision date syntax is correct in include.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionDateInvalidSyntaxAtInclude() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang");
+ }
+
+ /**
+ * Checks if revision date syntax is correct in import.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionDateInvalidSyntaxAtImport() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalidSyntaxAtImport.yang");
+ }
+
+ /**
+ * Checks revision date should not be in quotes inside include.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionDateInQuotesAtInclude() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtInclude.yang");
+ }
+
+ /**
+ * Checks revision date should not be in quotes inside import.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionDateInQuotesAtImport() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionDateInQuotesAtImport.yang");
+ }
+
+ /**
+ * Checks if revision date follows YYYY-MM-DD format.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionDateInvalidFormat() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionDateInvalidFormat.yang");
+ }
+
+ /**
+ * Checks if revision date listener updates the data model tree.
+ */
+ @Test
+ public void processRevisionDateValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionDateValidEntry.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getImportList().get(0).getRevision(), is("2015-02-03"));
+ assertThat(((YangModule) node).getIncludeList().get(0).getRevision(), is("2016-02-03"));
+ assertThat(((YangModule) node).getIncludeList().get(1).getRevision(), is("2014-02-03"));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
new file mode 100644
index 0000000..8226442
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/RevisionListenerTest.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing revision listener functionality.
+ */
+public class RevisionListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if revision doesn't have optional parameters "revision and
+ * description".
+ */
+ @Test
+ public void processRevisionNoOptionalParameter() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionNoOptionalParameter.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getRevision().getRevDate(), is("2016-02-03"));
+ }
+
+ /**
+ * Checks if the syntax of revision is correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionInValidSyntax() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionInValidSyntax.yang");
+ }
+
+ /**
+ * Checks if the correct order is followed.
+ */
+ @Test(expected = ParserException.class)
+ public void processRevisionInValidOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionInValidOrder.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
new file mode 100644
index 0000000..c3028de
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/SubModuleListenerTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangSubModule;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing submodule listener functionality.
+ */
+public class SubModuleListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if the sub module listeners updates the data model tree.
+ */
+ @Test
+ public void processSubModuleValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SubModuleValidEntry.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangSubModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.SUB_MODULE_NODE));
+
+ YangSubModule yangNode = (YangSubModule) node;
+ // Check whether the module name is set correctly.
+ assertThat(yangNode.getName(), is("Test"));
+ // Checks for the version value in data model tree.
+ assertThat(yangNode.getVersion(), is((byte) 1));
+ // Checks identifier of belongsto in data model tree.
+ assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+ // Checks for the version value in data model tree.
+ assertThat(yangNode.getBelongsTo().getPrefix(), is("On1"));
+ }
+
+ /**
+ * Checks if the yang version and belongs to can come in any order in sub
+ * module.
+ */
+ @Test
+ public void processSubModuleOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SubModuleOrder.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangSubModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.SUB_MODULE_NODE));
+
+ YangSubModule yangNode = (YangSubModule) node;
+ // Check whether the module name is set correctly.
+ assertThat(yangNode.getName(), is("Test"));
+ // Checks for the version value in data model tree.
+ assertThat(yangNode.getVersion(), is((byte) 1));
+ // Checks identifier of belongsto in data model tree.
+ assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+ // Checks for the version value in data model tree.
+ assertThat(yangNode.getBelongsTo().getPrefix(), is("On1"));
+ }
+
+ /**
+ * Checks if yang version is optional.
+ */
+ @Test
+ public void processSubModuleWithoutVersion() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SubModuleWithoutVersion.yang");
+
+ // Check whether the data model tree returned is of type module.
+ assertThat((node instanceof YangSubModule), is(true));
+
+ // Check whether the node type is set properly to module.
+ assertThat(node.getNodeType(), is(YangNodeType.SUB_MODULE_NODE));
+
+ YangSubModule yangNode = (YangSubModule) node;
+ // Check whether the module name is set correctly.
+ assertThat(yangNode.getName(), is("Test"));
+ // Checks identifier of belongsto in data model tree.
+ assertThat(yangNode.getBelongsTo().getBelongsToModuleName(), is("ONOS"));
+ // Checks for the version value in data model tree.
+ assertThat(yangNode.getBelongsTo().getPrefix(), is("On1"));
+ }
+
+ /**
+ * Checks if sub module name is correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processSubModuleInvalidName() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SubModuleInvalidName.yang");
+ }
+
+ /**
+ * Checks if sub module has invalid modules construct eg namespace.
+ */
+ @Test(expected = ParserException.class)
+ public void processSubModuleWithNamespace() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/SubModuleWithNamespace.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
new file mode 100644
index 0000000..2338604
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/impl/listeners/VersionListenerTest.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test cases for testing version listener functionality.
+ */
+public class VersionListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks if value of version is correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processVersionInvalidValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/VersionInvalidValue.yang");
+ }
+
+ /**
+ * Checks if version listener updates the data model tree.
+ */
+ @Test
+ public void processVersionValidEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/VersionValidEntry.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getVersion(), is((byte) 1));
+ }
+
+ /**
+ * Checks if version which is optional paramater is not present.
+ */
+ @Test
+ public void processVersionNotPresent() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/VersionNotPresent.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getVersion(), is((byte) 0));
+ }
+
+ /**
+ * Checks that version should be present only once.
+ */
+ @Test(expected = ParserException.class)
+ public void processVersionDualEntry() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/VersionDualEntry.yang");
+ }
+
+ /**
+ * Checks if version can appear in any order in module header.
+ */
+ @Test
+ public void processVersionOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/VersionOrder.yang");
+
+ // Checks for the version value in data model tree.
+ assertThat(((YangModule) node).getVersion(), is((byte) 1));
+ }
+
+ /**
+ * Checks if sytax of version entry is not correct.
+ */
+ @Test(expected = ParserException.class)
+ public void processVersionInvalidSyntax() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/VersionInvalidSyntax.yang");
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
new file mode 100644
index 0000000..7cbc7f6
--- /dev/null
+++ b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerErrorMessageConstructionTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.onosproject.yangutils.parser.parseutils;
+
+import org.junit.Test;
+import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test case for testing listener error message construction util.
+ */
+public class ListenerErrorMessageConstructionTest {
+
+ /**
+ * Checks for error message construction with parsable data type name.
+ */
+ @Test
+ public void checkErrorMsgConstructionWithName() {
+
+ // Create an test error message
+ String testErrorMessage = ListenerErrorMessageConstruction
+ .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, ParsableDataType.CONTACT_DATA,
+ "Test Instance", ListenerErrorLocation.ENTRY);
+
+ // Check message.
+ assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact "
+ + "\"Test Instance\" before processing."));
+ }
+
+ /**
+ * Checks for error message construction without parsable data type name.
+ */
+ @Test
+ public void checkErrorMsgConstructionWithoutName() {
+
+ // Create an test error message
+ String testErrorMessage = ListenerErrorMessageConstruction
+ .constructListenerErrorMessage(ListenerErrorType.INVALID_HOLDER, ParsableDataType.CONTACT_DATA,
+ "Test Instance", ListenerErrorLocation.ENTRY);
+
+ // Check message.
+ assertThat(testErrorMessage,
+ is("Internal parser error detected: Invalid holder for contact \"Test Instance\""
+ + " before processing."));
+ }
+
+ /**
+ * Checks for extended error message construction with parsable data type name.
+ */
+ @Test
+ public void checkExtendedErrorMsgConstructionWithName() {
+
+ // Create an test error message
+ String testErrorMessage = ListenerErrorMessageConstruction
+ .constructExtendedListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
+ ParsableDataType.CONTACT_DATA, "Test Instance",
+ ListenerErrorLocation.ENTRY, "Extended Information");
+
+ // Check message.
+ assertThat(testErrorMessage,
+ is("Internal parser error detected: Invalid holder for contact \"Test Instance\""
+ + " before processing.\n" + "Error Information: Extended Information"));
+ }
+
+ /**
+ * Checks for extended error message construction without parsable data type name.
+ */
+ @Test
+ public void checkExtendedErrorMsgConstructionWithoutName() {
+
+ // Create an test error message
+ String testErrorMessage = ListenerErrorMessageConstruction
+ .constructExtendedListenerErrorMessage(ListenerErrorType.INVALID_HOLDER,
+ ParsableDataType.CONTACT_DATA, "",
+ ListenerErrorLocation.ENTRY, "Extended Information");
+
+ // Check message.
+ assertThat(testErrorMessage, is("Internal parser error detected: Invalid holder for contact"
+ + " before processing.\n" + "Error Information: Extended Information"));
+ }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
index c047f2b..85eb48d 100644
--- a/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/parseutils/ListenerValidationTest.java
@@ -16,74 +16,54 @@
package org.onosproject.yangutils.parser.parseutils;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.datamodel.YangRevision;
+import org.onosproject.yangutils.parser.ParsableDataType;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.TreeWalkListener;
-import org.onosproject.yangutils.parser.impl.parserutils.ListenerError;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorLocation;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorMessageConstruction;
+import org.onosproject.yangutils.parser.impl.parserutils.ListenerErrorType;
import org.onosproject.yangutils.parser.impl.parserutils.ListenerValidation;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
/**
* Test case for testing listener validation util.
*/
public class ListenerValidationTest {
- /**
- * This test case checks in case error pre-exists, listener validate
- * function returns true.
- */
- @Test
- public void listenerValidationErrorExists() {
-
- // Create an test error.
- ListenerError testError = new ListenerError();
- testError.setErrorFlag(true);
- testError.setErrorMsg("Test Error");
-
- // Create test walker and assign test error to it.
- TreeWalkListener testWalker = new TreeWalkListener();
- testWalker.setErrorInformation(testError);
-
- // Create a temporary node of parsable.
- YangRevision tmpNode = new YangRevision();
- testWalker.getParsedDataStack().push(tmpNode);
-
- boolean errorFlag = ListenerValidation.preValidation(testWalker, "ErrorTest");
-
- /**
- * Check for the values set in syntax error function. If not set properly
- * report an assert.
- */
- assertThat(errorFlag, is(true));
- }
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
/**
- * This test case checks in case parsable stack is empty, listener validate
- * function returns true.
+ * Checks for exception in case parsable stack is empty while validating for
+ * not empty scenario.
*/
@Test
- public void listenerValidationEmptyStack() {
+ public void validateStackIsNotEmptyForEmptyStack() {
+
+ String expectedError = ListenerErrorMessageConstruction
+ .constructListenerErrorMessage(ListenerErrorType.MISSING_HOLDER, ParsableDataType.YANGBASE_DATA, "",
+ ListenerErrorLocation.EXIT);
+
+ // Get the exception occurred during parsing.
+ thrown.expect(ParserException.class);
+ thrown.expectMessage(expectedError);
// Create test walker and assign test error to it.
TreeWalkListener testWalker = new TreeWalkListener();
- boolean errorFlag = ListenerValidation.preValidation(testWalker, "ErrorTest");
-
- /**
- * Check for the values set in syntax error function. If not set properly
- * report an assert.
- */
- assertThat(errorFlag, is(true));
+ ListenerValidation.checkStackIsNotEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
+ ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
}
/**
- * This test case checks in case of error doesn't pre-exists and stack is,
- * non empty, listener validate function returns false.
+ * Checks if there is no exception in case parsable stack is not empty while validating
+ * for not empty scenario.
*/
@Test
- public void listenerValidationNoErrorNotExists() {
+ public void validateStackIsNotEmptyForNonEmptyStack() {
// Create test walker and assign test error to it.
TreeWalkListener testWalker = new TreeWalkListener();
@@ -92,12 +72,47 @@
YangRevision tmpNode = new YangRevision();
testWalker.getParsedDataStack().push(tmpNode);
- boolean errorFlag = ListenerValidation.preValidation(testWalker, "ErrorTest");
+ ListenerValidation.checkStackIsNotEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
+ ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ }
- /**
- * Check for the values set in syntax error function. If not set properly
- * report an assert.
- */
- assertThat(errorFlag, is(false));
+ /**
+ * Checks for exception in case parsable stack is not empty while validating
+ * for empty scenario.
+ */
+ @Test
+ public void validateStackIsEmptyForNonEmptyStack() {
+
+ String expectedError = ListenerErrorMessageConstruction
+ .constructListenerErrorMessage(ListenerErrorType.MISSING_HOLDER, ParsableDataType.YANGBASE_DATA, "",
+ ListenerErrorLocation.EXIT);
+
+ // Get the exception occurred during parsing.
+ thrown.expect(ParserException.class);
+ thrown.expectMessage(expectedError);
+
+ // Create test walker and assign test error to it.
+ TreeWalkListener testWalker = new TreeWalkListener();
+
+ // Create a temporary node of parsable.
+ YangRevision tmpNode = new YangRevision();
+ testWalker.getParsedDataStack().push(tmpNode);
+
+ ListenerValidation.checkStackIsEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
+ ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
+ }
+
+ /**
+ * Checks if there is no exception in case parsable stack is empty while validating
+ * for empty scenario.
+ */
+ @Test
+ public void validateStackIsEmptyForEmptyStack() {
+
+ // Create test walker and assign test error to it.
+ TreeWalkListener testWalker = new TreeWalkListener();
+
+ ListenerValidation.checkStackIsEmpty(testWalker, ListenerErrorType.MISSING_HOLDER,
+ ParsableDataType.YANGBASE_DATA, "", ListenerErrorLocation.EXIT);
}
}
\ No newline at end of file
diff --git a/src/test/java/org/onosproject/yangutils/parser/parseutils/ParseTreeErrorListenerTest.java b/src/test/java/org/onosproject/yangutils/parser/parseutils/ParseTreeErrorListenerTest.java
index f91797e..a45ed72 100644
--- a/src/test/java/org/onosproject/yangutils/parser/parseutils/ParseTreeErrorListenerTest.java
+++ b/src/test/java/org/onosproject/yangutils/parser/parseutils/ParseTreeErrorListenerTest.java
@@ -14,29 +14,26 @@
* limitations under the License.
*/
-package org.onosproject.yangutils.parser.impl.parseutils;
+package org.onosproject.yangutils.parser.parseutils;
import org.antlr.v4.runtime.ANTLRFileStream;
import org.antlr.v4.runtime.ANTLRInputStream;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
-import org.junit.After;
-import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangLexer;
import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser;
import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.CustomExceptionMatcher;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.parser.impl.parserutils.ParseTreeErrorListener;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileWriter;
import java.io.IOException;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertThat;
-
/**
* Test case for testing parse tree error listener.
*/
@@ -46,31 +43,16 @@
File file;
BufferedWriter out;
- @Before
- public void setUp() throws Exception {
- file = new File("demo.yang");
- out = new BufferedWriter(new FileWriter(file));
- }
- @After
- public void tearDown() throws Exception {
- file.delete();
- }
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
/**
- * This test case checks whether the error received from parser is correctly
- * handled.
+ * Checks that no exception is generated for YANG file with valid syntax.
*/
@Test
- public void syntaxErrorValidationTest() throws IOException {
+ public void checkValidYangFileForNoSyntaxError() throws IOException {
- out.write("module ONOS {\n");
- out.write("yang-version 1\n");
- out.write("namespace urn:ietf:params:xml:ns:yang:ietf-ospf;\n");
- out.write("prefix On;\n");
- out.write("}\n");
- out.close();
-
- ANTLRInputStream input = new ANTLRFileStream("demo.yang");
+ ANTLRInputStream input = new ANTLRFileStream("src/test/resources/YangFileWithoutSyntaxError.yang");
// Create a lexer that feeds off of input char stream.
GeneratedYangLexer lexer = new GeneratedYangLexer(input);
@@ -86,15 +68,34 @@
parser.addErrorListener(parseTreeErrorListener);
// Begin parsing YANG file and generate parse tree.
ParseTree tree = parser.yangfile();
- // Get the exception occurred during parsing.
- ParserException parserException = parseTreeErrorListener.getParserException();
+ }
- /**
- * Check for the values set in syntax error function. If not set properly
- * report an assert.
- */
- assertThat(parseTreeErrorListener.isExceptionFlag(), is(true));
- assertThat(parserException.getLineNumber(), is(3));
- assertThat(parserException.getCharPositionInLine(), is(0));
+ /**
+ * Checks that exception is generated for YANG file with invalid syntax.
+ */
+ @Test
+ public void checkInvalidYangFileForSyntaxError() throws IOException {
+
+ // Get the exception occurred during parsing.
+ thrown.expect(ParserException.class);
+ thrown.expect(CustomExceptionMatcher.errorLocation(3, 0));
+ thrown.expectMessage("no viable alternative at input 'yang-version 1\\nnamespace'");
+
+ ANTLRInputStream input = new ANTLRFileStream("src/test/resources/YangFileWithSyntaxError.yang");
+
+ // Create a lexer that feeds off of input char stream.
+ GeneratedYangLexer lexer = new GeneratedYangLexer(input);
+ // Create a buffer of tokens pulled from the lexer.
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+ // Create a parser that feeds off the tokens buffer.
+ GeneratedYangParser parser = new GeneratedYangParser(tokens);
+ // Remove console error listener.
+ parser.removeErrorListeners();
+ // Create instance of customized error listener.
+ ParseTreeErrorListener parseTreeErrorListener = new ParseTreeErrorListener();
+ // Add customized error listener to catch errors during parsing.
+ parser.addErrorListener(parseTreeErrorListener);
+ // Begin parsing YANG file and generate parse tree.
+ ParseTree tree = parser.yangfile();
}
}
\ No newline at end of file
diff --git a/src/test/resources/BelongsToDualPrefix.yang b/src/test/resources/BelongsToDualPrefix.yang
new file mode 100644
index 0000000..37973da
--- /dev/null
+++ b/src/test/resources/BelongsToDualPrefix.yang
@@ -0,0 +1,8 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+prefix On1;
+prefix On2;
+}
+}
+
diff --git a/src/test/resources/BelongsToWithPrefix.yang b/src/test/resources/BelongsToWithPrefix.yang
new file mode 100644
index 0000000..75a13ca
--- /dev/null
+++ b/src/test/resources/BelongsToWithPrefix.yang
@@ -0,0 +1,6 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+prefix On1;
+}
+}
diff --git a/src/test/resources/BelongsToWithoutPrefix.yang b/src/test/resources/BelongsToWithoutPrefix.yang
new file mode 100644
index 0000000..eaf9885
--- /dev/null
+++ b/src/test/resources/BelongsToWithoutPrefix.yang
@@ -0,0 +1,6 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+}
+}
+
diff --git a/src/test/resources/ContactDualEntryTest.yang b/src/test/resources/ContactDualEntryTest.yang
new file mode 100644
index 0000000..2dca10e
--- /dev/null
+++ b/src/test/resources/ContactDualEntryTest.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+contact "WG List";
+contact "Invalid";
+}
+
diff --git a/src/test/resources/ContactIncorrectOrder.yang b/src/test/resources/ContactIncorrectOrder.yang
new file mode 100644
index 0000000..237d003
--- /dev/null
+++ b/src/test/resources/ContactIncorrectOrder.yang
@@ -0,0 +1,7 @@
+module Test {
+yang-version 1;
+contact "Test";
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+}
diff --git a/src/test/resources/ContactValidEntry.yang b/src/test/resources/ContactValidEntry.yang
new file mode 100644
index 0000000..f88e147
--- /dev/null
+++ b/src/test/resources/ContactValidEntry.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+contact "WG List: <mailto:spring@ietf.org>
+Editor: Stephane Litkowski
+ <mailto:stephane.litkowski@orange.com>";
+}
diff --git a/src/test/resources/ContactWithEmptyString.yang b/src/test/resources/ContactWithEmptyString.yang
new file mode 100644
index 0000000..34c6008
--- /dev/null
+++ b/src/test/resources/ContactWithEmptyString.yang
@@ -0,0 +1,7 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+organization "IETF SPRING Working Group";
+contact;
+}
diff --git a/src/test/resources/ImportInvalidOrder.yang b/src/test/resources/ImportInvalidOrder.yang
new file mode 100644
index 0000000..6bfc685
--- /dev/null
+++ b/src/test/resources/ImportInvalidOrder.yang
@@ -0,0 +1,10 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+revision-date 2015-02-03;
+prefix On1;
+}
+contact "Test";
+}
diff --git a/src/test/resources/ImportMultipleInstance.yang b/src/test/resources/ImportMultipleInstance.yang
new file mode 100644
index 0000000..175f2ff
--- /dev/null
+++ b/src/test/resources/ImportMultipleInstance.yang
@@ -0,0 +1,14 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+import itut {
+prefix On3;
+revision-date 2016-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/ImportValidEntry.yang b/src/test/resources/ImportValidEntry.yang
new file mode 100644
index 0000000..b725d39
--- /dev/null
+++ b/src/test/resources/ImportValidEntry.yang
@@ -0,0 +1,10 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/ImportWithDualPrefix.yang b/src/test/resources/ImportWithDualPrefix.yang
new file mode 100644
index 0000000..8b40bb0
--- /dev/null
+++ b/src/test/resources/ImportWithDualPrefix.yang
@@ -0,0 +1,11 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On1;
+prefix On2;
+revision-date 2015-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/ImportWithoutPrefix.yang b/src/test/resources/ImportWithoutPrefix.yang
new file mode 100644
index 0000000..ee68e59
--- /dev/null
+++ b/src/test/resources/ImportWithoutPrefix.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+revision-date 2015-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/ImportWithoutRevision.yang b/src/test/resources/ImportWithoutRevision.yang
new file mode 100644
index 0000000..af47b7a
--- /dev/null
+++ b/src/test/resources/ImportWithoutRevision.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+}
+contact "Test";
+}
diff --git a/src/test/resources/IncludeImportAnyOrder.yang b/src/test/resources/IncludeImportAnyOrder.yang
new file mode 100644
index 0000000..05339a6
--- /dev/null
+++ b/src/test/resources/IncludeImportAnyOrder.yang
@@ -0,0 +1,16 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+include itut {
+revision-date 2016-02-03;
+}
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/IncludeInvalidDateSyntax.yang b/src/test/resources/IncludeInvalidDateSyntax.yang
new file mode 100644
index 0000000..3716209
--- /dev/null
+++ b/src/test/resources/IncludeInvalidDateSyntax.yang
@@ -0,0 +1,16 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 16-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/IncludeInvalidSyntax.yang b/src/test/resources/IncludeInvalidSyntax.yang
new file mode 100644
index 0000000..91ae17b
--- /dev/null
+++ b/src/test/resources/IncludeInvalidSyntax.yang
@@ -0,0 +1,16 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut; {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/IncludeMultiInstance.yang b/src/test/resources/IncludeMultiInstance.yang
new file mode 100644
index 0000000..81a527a
--- /dev/null
+++ b/src/test/resources/IncludeMultiInstance.yang
@@ -0,0 +1,16 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/IncludeWithDate.yang b/src/test/resources/IncludeWithDate.yang
new file mode 100644
index 0000000..9701a2d
--- /dev/null
+++ b/src/test/resources/IncludeWithDate.yang
@@ -0,0 +1,13 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/IncludeWithEmptyBody.yang b/src/test/resources/IncludeWithEmptyBody.yang
new file mode 100644
index 0000000..471fdb3
--- /dev/null
+++ b/src/test/resources/IncludeWithEmptyBody.yang
@@ -0,0 +1,12 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+}
+contact "Test";
+}
diff --git a/src/test/resources/IncludeWithStmtend.yang b/src/test/resources/IncludeWithStmtend.yang
new file mode 100644
index 0000000..e40813b
--- /dev/null
+++ b/src/test/resources/IncludeWithStmtend.yang
@@ -0,0 +1,11 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut;
+contact "Test";
+}
diff --git a/src/test/resources/ModuleValidEntry.yang b/src/test/resources/ModuleValidEntry.yang
new file mode 100644
index 0000000..439ded8
--- /dev/null
+++ b/src/test/resources/ModuleValidEntry.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/src/test/resources/ModuleWithInvalidIdentifier.yang b/src/test/resources/ModuleWithInvalidIdentifier.yang
new file mode 100644
index 0000000..d89340a
--- /dev/null
+++ b/src/test/resources/ModuleWithInvalidIdentifier.yang
@@ -0,0 +1,5 @@
+module Test:Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/src/test/resources/NamespaceDualEntry.yang b/src/test/resources/NamespaceDualEntry.yang
new file mode 100644
index 0000000..09c9b54
--- /dev/null
+++ b/src/test/resources/NamespaceDualEntry.yang
@@ -0,0 +1,6 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+namespace urn:ietf:params:xml:ns:yang:ietf-segment-routing;
+prefix On;
+}
diff --git a/src/test/resources/NamespaceInDoubleQuotes.yang b/src/test/resources/NamespaceInDoubleQuotes.yang
new file mode 100644
index 0000000..aec0042
--- /dev/null
+++ b/src/test/resources/NamespaceInDoubleQuotes.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace "urn:ietf:params:xml:ns:yang:ietf-ospf";
+prefix On;
+}
diff --git a/src/test/resources/NamespaceNoEntryTest.yang b/src/test/resources/NamespaceNoEntryTest.yang
new file mode 100644
index 0000000..ac30ae4
--- /dev/null
+++ b/src/test/resources/NamespaceNoEntryTest.yang
@@ -0,0 +1,4 @@
+module Test {
+yang-version 1;
+prefix On;
+}
diff --git a/src/test/resources/NamespaceWithConcatenationTest.yang b/src/test/resources/NamespaceWithConcatenationTest.yang
new file mode 100644
index 0000000..c9ac4b0
--- /dev/null
+++ b/src/test/resources/NamespaceWithConcatenationTest.yang
@@ -0,0 +1,6 @@
+module Test {
+yang-version 1;
+namespace "urn:ietf:params:xml:ns:"
+ + "yang:ietf-segment-routing";
+prefix On;
+}
diff --git a/src/test/resources/NamespaceWithInvalidSpaces.yang b/src/test/resources/NamespaceWithInvalidSpaces.yang
new file mode 100644
index 0000000..f8f91c5
--- /dev/null
+++ b/src/test/resources/NamespaceWithInvalidSpaces.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace "urn:ietf:params:xml :ns:yang:ietf-ospf";
+prefix On;
+}
diff --git a/src/test/resources/NamespaceWithoutQuotes.yang b/src/test/resources/NamespaceWithoutQuotes.yang
new file mode 100644
index 0000000..439ded8
--- /dev/null
+++ b/src/test/resources/NamespaceWithoutQuotes.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/src/test/resources/OrganizationDualEntry.yang b/src/test/resources/OrganizationDualEntry.yang
new file mode 100644
index 0000000..64bf23d
--- /dev/null
+++ b/src/test/resources/OrganizationDualEntry.yang
@@ -0,0 +1,18 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "IETF SPRING Working Group";
+organization "ITUT SPRING Working Group";
+}
diff --git a/src/test/resources/OrganizationInvalidOrder.yang b/src/test/resources/OrganizationInvalidOrder.yang
new file mode 100644
index 0000000..333f2e5
--- /dev/null
+++ b/src/test/resources/OrganizationInvalidOrder.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+organization "ONOS";
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut; {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+}
diff --git a/src/test/resources/OrganizationMissingValue.yang b/src/test/resources/OrganizationMissingValue.yang
new file mode 100644
index 0000000..e9e3f46
--- /dev/null
+++ b/src/test/resources/OrganizationMissingValue.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization ;
+}
diff --git a/src/test/resources/OrganizationValidEntry.yang b/src/test/resources/OrganizationValidEntry.yang
new file mode 100644
index 0000000..25ae1ec
--- /dev/null
+++ b/src/test/resources/OrganizationValidEntry.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "IETF SPRING Working Group";
+}
diff --git a/src/test/resources/PrefixDualEntry.yang b/src/test/resources/PrefixDualEntry.yang
new file mode 100644
index 0000000..e999774
--- /dev/null
+++ b/src/test/resources/PrefixDualEntry.yang
@@ -0,0 +1,18 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+prefix On3;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/PrefixInvalidValue.yang b/src/test/resources/PrefixInvalidValue.yang
new file mode 100644
index 0000000..40f7617
--- /dev/null
+++ b/src/test/resources/PrefixInvalidValue.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix -On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/PrefixMissingValue.yang b/src/test/resources/PrefixMissingValue.yang
new file mode 100644
index 0000000..4d92ee1
--- /dev/null
+++ b/src/test/resources/PrefixMissingValue.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix ;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/PrefixOrder.yang b/src/test/resources/PrefixOrder.yang
new file mode 100644
index 0000000..d14e8b1
--- /dev/null
+++ b/src/test/resources/PrefixOrder.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+prefix test;
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/PrefixValidEntry.yang b/src/test/resources/PrefixValidEntry.yang
new file mode 100644
index 0000000..826dee4
--- /dev/null
+++ b/src/test/resources/PrefixValidEntry.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/RevisionDateInQuotesAtImport.yang b/src/test/resources/RevisionDateInQuotesAtImport.yang
new file mode 100644
index 0000000..5f8bcb8
--- /dev/null
+++ b/src/test/resources/RevisionDateInQuotesAtImport.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date "2015-02-03";
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/RevisionDateInQuotesAtInclude.yang b/src/test/resources/RevisionDateInQuotesAtInclude.yang
new file mode 100644
index 0000000..de405a3
--- /dev/null
+++ b/src/test/resources/RevisionDateInQuotesAtInclude.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date "2016-02-03";
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/RevisionDateInvalidFormat.yang b/src/test/resources/RevisionDateInvalidFormat.yang
new file mode 100644
index 0000000..8a6c717
--- /dev/null
+++ b/src/test/resources/RevisionDateInvalidFormat.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date 15-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/RevisionDateInvalidSyntaxAtImport.yang b/src/test/resources/RevisionDateInvalidSyntaxAtImport.yang
new file mode 100644
index 0000000..df726bf
--- /dev/null
+++ b/src/test/resources/RevisionDateInvalidSyntaxAtImport.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date 2015/02/03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang b/src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang
new file mode 100644
index 0000000..ea5631e
--- /dev/null
+++ b/src/test/resources/RevisionDateInvalidSyntaxAtInclude.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016/02/03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/RevisionDateValidEntry.yang b/src/test/resources/RevisionDateValidEntry.yang
new file mode 100644
index 0000000..dbf4d3a
--- /dev/null
+++ b/src/test/resources/RevisionDateValidEntry.yang
@@ -0,0 +1,17 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/RevisionInValidOrder.yang b/src/test/resources/RevisionInValidOrder.yang
new file mode 100644
index 0000000..c60d434
--- /dev/null
+++ b/src/test/resources/RevisionInValidOrder.yang
@@ -0,0 +1,9 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+revision 2016-02-03;
+include itut {
+revision-date 2016-02-03;
+}
+}
diff --git a/src/test/resources/RevisionInValidSyntax.yang b/src/test/resources/RevisionInValidSyntax.yang
new file mode 100644
index 0000000..1795b3e
--- /dev/null
+++ b/src/test/resources/RevisionInValidSyntax.yang
@@ -0,0 +1,8 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+contact "Test";
+organization "ONOS";
+revision;
+}
diff --git a/src/test/resources/RevisionNoOptionalParameter.yang b/src/test/resources/RevisionNoOptionalParameter.yang
new file mode 100644
index 0000000..664204e
--- /dev/null
+++ b/src/test/resources/RevisionNoOptionalParameter.yang
@@ -0,0 +1,8 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix test;
+contact "Test";
+organization "ONOS";
+revision 2016-02-03;
+}
diff --git a/src/test/resources/SubModuleInvalidName.yang b/src/test/resources/SubModuleInvalidName.yang
new file mode 100644
index 0000000..7da9397
--- /dev/null
+++ b/src/test/resources/SubModuleInvalidName.yang
@@ -0,0 +1,18 @@
+submodule Test:Test {
+belongs-to ONOS {
+prefix On1;
+}
+yang-version 1;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/SubModuleOrder.yang b/src/test/resources/SubModuleOrder.yang
new file mode 100644
index 0000000..9779bbb
--- /dev/null
+++ b/src/test/resources/SubModuleOrder.yang
@@ -0,0 +1,18 @@
+submodule Test {
+belongs-to ONOS {
+prefix On1;
+}
+yang-version 1;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/SubModuleValidEntry.yang b/src/test/resources/SubModuleValidEntry.yang
new file mode 100644
index 0000000..00ecdca
--- /dev/null
+++ b/src/test/resources/SubModuleValidEntry.yang
@@ -0,0 +1,18 @@
+submodule Test {
+yang-version 1;
+belongs-to ONOS {
+prefix On1;
+}
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/SubModuleWithNamespace.yang b/src/test/resources/SubModuleWithNamespace.yang
new file mode 100644
index 0000000..d7a38f7
--- /dev/null
+++ b/src/test/resources/SubModuleWithNamespace.yang
@@ -0,0 +1,19 @@
+submodule Test {
+belongs-to ONOS {
+prefix On1;
+}
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/SubModuleWithoutBelongsTo.yang b/src/test/resources/SubModuleWithoutBelongsTo.yang
new file mode 100644
index 0000000..4a25209
--- /dev/null
+++ b/src/test/resources/SubModuleWithoutBelongsTo.yang
@@ -0,0 +1,3 @@
+submodule Test {
+yang-version 1;
+}
diff --git a/src/test/resources/SubModuleWithoutVersion.yang b/src/test/resources/SubModuleWithoutVersion.yang
new file mode 100644
index 0000000..f44df8b
--- /dev/null
+++ b/src/test/resources/SubModuleWithoutVersion.yang
@@ -0,0 +1,17 @@
+submodule Test {
+belongs-to ONOS {
+prefix On1;
+}
+import ietf {
+prefix On2;
+revision-date 2015-02-03;
+}
+include itut {
+revision-date 2016-02-03;
+}
+include sdn {
+revision-date 2014-02-03;
+}
+contact "Test";
+organization "ONOS";
+}
diff --git a/src/test/resources/VersionDualEntry.yang b/src/test/resources/VersionDualEntry.yang
new file mode 100644
index 0000000..f8eaddd
--- /dev/null
+++ b/src/test/resources/VersionDualEntry.yang
@@ -0,0 +1,6 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+yang-version 1;
+}
diff --git a/src/test/resources/VersionInvalidSyntax.yang b/src/test/resources/VersionInvalidSyntax.yang
new file mode 100644
index 0000000..26cb0b2
--- /dev/null
+++ b/src/test/resources/VersionInvalidSyntax.yang
@@ -0,0 +1,5 @@
+module Test {
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+yang-version ;
+}
diff --git a/src/test/resources/VersionInvalidValue.yang b/src/test/resources/VersionInvalidValue.yang
new file mode 100644
index 0000000..e8e6107
--- /dev/null
+++ b/src/test/resources/VersionInvalidValue.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 2;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/src/test/resources/VersionNotPresent.yang b/src/test/resources/VersionNotPresent.yang
new file mode 100644
index 0000000..eed9953
--- /dev/null
+++ b/src/test/resources/VersionNotPresent.yang
@@ -0,0 +1,4 @@
+module Test {
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/src/test/resources/VersionOrder.yang b/src/test/resources/VersionOrder.yang
new file mode 100644
index 0000000..92463e9
--- /dev/null
+++ b/src/test/resources/VersionOrder.yang
@@ -0,0 +1,5 @@
+module Test {
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+yang-version 1;
+}
diff --git a/src/test/resources/VersionValidEntry.yang b/src/test/resources/VersionValidEntry.yang
new file mode 100644
index 0000000..439ded8
--- /dev/null
+++ b/src/test/resources/VersionValidEntry.yang
@@ -0,0 +1,5 @@
+module Test {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix On;
+}
diff --git a/src/test/resources/YangFileWithSyntaxError.yang b/src/test/resources/YangFileWithSyntaxError.yang
new file mode 100644
index 0000000..413a181
--- /dev/null
+++ b/src/test/resources/YangFileWithSyntaxError.yang
@@ -0,0 +1,6 @@
+module Antlrtest {
+yang-version 1
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix Ant;
+}
+
diff --git a/src/test/resources/YangFileWithoutSyntaxError.yang b/src/test/resources/YangFileWithoutSyntaxError.yang
new file mode 100644
index 0000000..4f4839f
--- /dev/null
+++ b/src/test/resources/YangFileWithoutSyntaxError.yang
@@ -0,0 +1,6 @@
+module Antlrtest {
+yang-version 1;
+namespace urn:ietf:params:xml:ns:yang:ietf-ospf;
+prefix Ant;
+}
+