[ONOS-3892,3895,3882,3883,3896]Unit test of yang container, list, leaf, leaf-list parser
Change-Id: Iae040d9d354e012584db8adc0aa7ff1ea4c099a0
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
new file mode 100644
index 0000000..c234fee
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ConfigListenerTest.java
@@ -0,0 +1,244 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for config listener.
+ */
+public class ConfigListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid config statement.
+ */
+ @Test
+ public void processConfigTrue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ConfigTrue.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the Config value is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.isConfig(), is(true));
+ }
+
+ /**
+ * Checks valid config statement.
+ */
+ @Test
+ public void processConfigFalse() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ConfigFalse.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the Config value is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.isConfig(), is(false));
+ }
+
+ /**
+ * Checks invalid config statement and expects parser exception.
+ */
+ @Test
+ public void processConfigWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at '}'");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks invalid config statement and expects parser exception.
+ */
+ @Test
+ public void processConfigInvalidValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'invalid' expecting {'false', 'true'}");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigInvalidValue.yang");
+ }
+
+ /**
+ * Checks invalid config statement and expects parser exception.
+ */
+ @Test
+ public void processConfigEmptyValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing {'false', 'true'} at ';'");
+ YangNode node = manager.getDataModel("src/test/resources/ConfigEmptyValue.yang");
+ }
+
+ /**
+ * Checks config statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementConfig() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'config' expecting {'augment', 'choice', 'contact', 'container'," +
+ " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include', " +
+ "'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
+ " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementConfig.yang");
+ }
+
+ /**
+ * Checks config statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementConfig() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementConfig.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"));
+
+ // Check whether the config value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.isConfig(), is(true));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks config statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementConfig() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementConfig.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and config value is set.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid config statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementConfig() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementConfig.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether config value is set correctly.
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.isConfig(), is(true));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
new file mode 100644
index 0000000..25f64d6
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ContainerListenerTest.java
@@ -0,0 +1,197 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing container listener.
+ */
+public class ContainerListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks container statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementContainer.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("valid"));
+ }
+
+ /**
+ * Checks container statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementContainer.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("ospf"));
+
+ // Check whether the container is child of container
+ YangContainer yangContainer1 = (YangContainer) yangContainer.getChild();
+ assertThat(yangContainer1.getName(), is("valid"));
+ }
+
+ /**
+ * Checks container statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementContainer() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementContainer.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList1 = (YangList) yangNode.getChild();
+ assertThat(yangList1.getName(), is("ospf"));
+
+ ListIterator<String> keyList = yangList1.getKeyList().listIterator();
+ assertThat(keyList.next(), is("process-id"));
+
+ // Check whether the list is child of list
+ YangContainer yangContainer = (YangContainer) yangList1.getChild();
+ assertThat(yangContainer.getName(), is("interface"));
+ }
+
+ /**
+ * Checks container with all its sub-statements.
+ */
+ @Test
+ public void processContainerSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatements.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+
+ // Check whether container properties as set correctly.
+ assertThat(yangContainer.getName(), is("ospf"));
+
+ assertThat(yangContainer.isConfig(), is(true));
+ assertThat(yangContainer.getPresence(), is("\"ospf logs\""));
+ assertThat(yangContainer.getDescription(), is("\"container description\""));
+ assertThat(yangContainer.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(yangContainer.getReference(), is("\"container reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks cardinality of sub-statements of container.
+ */
+ @Test
+ public void processContainerSubStatementCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementCardinality.yang");
+ }
+
+ /**
+ * Checks container as root node.
+ */
+ @Test
+ public void processContainerRootNode() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("no viable alternative at input 'container'");
+ YangNode node = manager.getDataModel("src/test/resources/ContainerRootNode.yang");
+ }
+
+ /**
+ * Checks invalid identifier for container statement.
+ */
+ @Test
+ public void processContainerInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER");
+ YangNode node = manager.getDataModel("src/test/resources/ContainerInvalidIdentifier.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java
new file mode 100644
index 0000000..9655b25
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/DescriptionListenerTest.java
@@ -0,0 +1,253 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for description listener.
+ */
+public class DescriptionListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid description statement.
+ */
+ @Test
+ public void processDescriptionValidStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DescriptionValidStatement.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the description is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid description statement.
+ */
+ @Test
+ public void processDescriptionWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("extraneous input '}' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/DescriptionWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementDescription.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"));
+
+ // Check whether the description is set correctly.
+ assertThat(yangNode.getDescription(), is("\"Interval before a route is declared invalid\""));
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of module.
+ */
+ @Test
+ public void processDescriptionEmptyStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DescriptionEmptyStatement.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"));
+
+ // Check whether the description is set correctly.
+ assertThat(yangNode.getDescription(), is("\"\""));
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of revision.
+ */
+ @Test
+ public void processRevisionSubStatementRevision() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionSubStatementRevision.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"));
+
+ // Check whether the description is set correctly.
+ assertThat(yangNode.getDescription(), is("\"module description\""));
+ assertThat(yangNode.getRevision().getDescription(), is("\"revision description\""));
+ }
+
+ /**
+ * Checks description statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementDescription.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"));
+
+ // Check whether the description value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.getDescription(), is("\"container description\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks description statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementDescription.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and description value is set correctly.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getDescription(), is("\"list description\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid description statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementDescription() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementDescription.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether description value is set correctly.
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java
new file mode 100644
index 0000000..727c1d2
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/KeyListenerTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for key listener.
+ */
+public class KeyListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks key statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementKey() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementKey.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid-interval"));
+ }
+
+ /**
+ * Check multiple key values.
+ */
+ @Test
+ public void processMultipleKeyValues() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MultipleKeyValues.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ List<String> keyList = yangList.getKeyList();
+ assertThat(keyList.contains("ospf"), is(true));
+ assertThat(keyList.contains("isis"), is(true));
+ }
+
+ /**
+ * Checks key statement without statement end.
+ */
+ @Test
+ public void processKeyWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaf' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/KeyWithoutStatementEnd.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
new file mode 100644
index 0000000..94f0157
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListListenerTest.java
@@ -0,0 +1,214 @@
+/*
+ * 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.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing leaf-list listener.
+ */
+public class LeafListListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks all the values of leaf-list sub-statements are set
+ * correctly.
+ */
+ @Test
+ public void processLeafListSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatements.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafListInfo.isConfig(), is(true));
+ assertThat(leafListInfo.getMaxElelements(), is(3));
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf-list identifier
+ * starts with digit.
+ */
+ @Test
+ public void processLeafListInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '1invalid-interval' expecting IDENTIFIER");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidIdentifier.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf-list keyword
+ * is incorrect.
+ */
+ @Test
+ public void processLeafListInvalidStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaflist' expecting {'augment', 'choice', 'contact', 'container'," +
+ " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
+ " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
+ " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf-list keyword
+ * without Left brace as per grammar.
+ */
+ @Test
+ public void processLeafListWithoutLeftBrace() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing '{' at 'type'");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListWithoutLeftBrace.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when config statement
+ * cardinality is not as per grammar.
+ */
+ @Test
+ public void processLeafListConfigInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListConfigInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when units statement
+ * cardinality is not as per grammar.
+ */
+ @Test
+ public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/LeafListUnitsInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks leaf-list statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementLeafList.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"));
+
+ //Check whether the container is child of module.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+
+ // Check whether leaf-list properties as set correctly.
+ ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafListInfo.isConfig(), is(true));
+ assertThat(leafListInfo.getMinElements(), is(1));
+ assertThat(leafListInfo.getMaxElelements(), is(2147483647));
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks leaf-list statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementLeafList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementLeafList.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ // Check whether leaf-list properties as set correctly.
+ ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafListInfo.isConfig(), is(true));
+
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
new file mode 100644
index 0000000..519f605
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/LeafListenerTest.java
@@ -0,0 +1,213 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing leaf listener.
+ */
+public class LeafListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks all the values of leaf sub-statements are set
+ * correctly.
+ */
+ @Test
+ public void processLeafSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafSubStatements.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf identifier
+ * starts with digit.
+ */
+ @Test
+ public void processLeafInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '1invalid-interval' expecting IDENTIFIER");
+ YangNode node = manager.getDataModel("src/test/resources/LeafInvalidIdentifier.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf keyword
+ * is incorrect.
+ */
+ @Test
+ public void processLeafInvalidStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leafs' expecting {'augment', 'choice', 'contact', 'container'," +
+ " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
+ " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
+ " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/LeafInvalidStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when leaf keyword
+ * without Left brace as per grammar.
+ */
+ @Test
+ public void processLeafWithoutLeftBrace() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing '{' at 'type'");
+ YangNode node = manager.getDataModel("src/test/resources/LeafWithoutLeftBrace.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when config statement
+ * cardinality is not as per grammar.
+ */
+ @Test
+ public void processLeafConfigInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/LeafConfigInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when mandatory statement
+ * cardinality is not as per grammar.
+ */
+ @Test
+ public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in mandatory before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/LeafMandatoryInvalidCardinality.yang");
+ }
+
+ /**
+ * Checks leaf statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementLeaf.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"));
+
+ //Check whether the container is child of module.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks leaf statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementLeaf() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementLeaf.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
new file mode 100644
index 0000000..6664c5e
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ListListenerTest.java
@@ -0,0 +1,212 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing list listener.
+ */
+public class ListListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks list statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementList.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+
+ ListIterator<String> keyList = yangList.getKeyList().listIterator();
+ assertThat(keyList.next(), is("invalid"));
+ }
+
+ /**
+ * Checks list statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementList.yang");
+
+ 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"));
+
+ // Check whether the container is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("ospf"));
+
+ // Check whether the list is child of container
+ YangList yangList = (YangList) yangContainer.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getKeyList().contains("invalid"), is(true));
+ }
+
+ /**
+ * Checks list statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementList() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementList.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList1 = (YangList) yangNode.getChild();
+ assertThat(yangList1.getName(), is("ospf"));
+ assertThat(yangList1.getKeyList().contains("process-id"), is(true));
+
+ // Check whether the list is child of list
+ YangList yangList = (YangList) yangList1.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getKeyList().contains("invalid"), is(true));
+ }
+
+ /**
+ * Checks list with all its sub-statements.
+ */
+ @Test
+ public void processListSubStatements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatements.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+
+ // Check whether list properties as set correctly.
+ assertThat(yangList.getName(), is("ospf"));
+ assertThat(yangList.getKeyList().contains("process-id"), is(true));
+
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getMaxElelements(), is(10));
+ assertThat(yangList.getMinElements(), is(3));
+ assertThat(yangList.getDescription(), is("\"list description\""));
+ assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(yangList.getReference(), is("\"list reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks cardinality of sub-statements of list.
+ */
+ @Test
+ public void processListSubStatementsCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementsCardinality.yang");
+ }
+
+ /**
+ * Checks list statement without child.
+ */
+ @Test
+ public void processListStatementWithoutChild() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in list before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/ListStatementWithoutChild.yang");
+ }
+
+ /**
+ * Checks list as root node.
+ */
+ @Test
+ public void processListAsRootNode() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("no viable alternative at input 'list'");
+ YangNode node = manager.getDataModel("src/test/resources/ListAsRootNode.yang");
+ }
+
+ /**
+ * Checks invalid identifier for list statement.
+ */
+ @Test
+ public void processListInvalidIdentifier() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER");
+ YangNode node = manager.getDataModel("src/test/resources/ListInvalidIdentifier.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java
new file mode 100644
index 0000000..001e5a9
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MandatoryListenerTest.java
@@ -0,0 +1,155 @@
+/*
+ * 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.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test case for mandatory listener.
+ */
+public class MandatoryListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid mandatory with value true statement.
+ */
+ @Test
+ public void processMandatoryTrue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryTrue.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the mandatory value is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.isMandatory(), is(true));
+ }
+
+ /**
+ * Checks valid mandatory with value false statement.
+ */
+ @Test
+ public void processMandatoryFalse() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryFalse.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the mandatory value is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.isMandatory(), is(false));
+ }
+
+ /**
+ * Checks default value of mandatory statement.
+ */
+ @Test
+ public void processMandatoryDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryDefaultValue.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the mandatory value is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.isMandatory(), is(false));
+ }
+
+ /**
+ * Checks invalid of mandatory statement and expects exception.
+ */
+ @Test
+ public void processMandatoryEmptyStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing {'false', 'true'} at ';'");
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryEmptyStatement.yang");
+ }
+
+ /**
+ * Checks invalid mandatory statement(without statement end) and expects exception.
+ */
+ @Test
+ public void processMandatoryWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at '}'");
+ YangNode node = manager.getDataModel("src/test/resources/MandatoryWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks mandatory statement as sub-statement of module and expects exception.
+ */
+ @Test
+ public void processModuleSubStatementMandatory() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'mandatory' expecting {'augment', 'choice', 'contact', 'container'," +
+ " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
+ " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
+ " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementMandatory.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
new file mode 100644
index 0000000..f03ab75
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MaxElementsListenerTest.java
@@ -0,0 +1,154 @@
+/*
+ * 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.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing max-elements listener.
+ */
+public class MaxElementsListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks max-elements as sub-statements of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementMaxElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementMaxElements.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMaxElelements(), is(3));
+ }
+
+ /**
+ * Checks max-elements as sub-statements of list.
+ */
+ @Test
+ public void processListSubStatementMaxElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementMaxElements.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getMaxElelements(), is(3));
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid max-elements keyword
+ * is given as input.
+ */
+ @Test
+ public void processMaxElementsInvalidStatement() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("extraneous input 'max-element' expecting {'config', 'description', 'if-feature'," +
+ " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units', " +
+ "'when', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsInvalidStatement.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when max-elements statement without statement
+ * end is given as input.
+ */
+ @Test
+ public void processMaxElementsWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at 'description'");
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when max-elements cardinality is not
+ * as per the grammar.
+ */
+ @Test
+ public void processMaxElementsCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in max-elements before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsCardinality.yang");
+ }
+
+ /**
+ * Checks unbounded value of max-elements statement.
+ */
+ @Test
+ public void processMaxElementsUnbounded() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/MaxElementsUnbounded.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMaxElelements(), is(2147483647));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
new file mode 100644
index 0000000..9ee71bd
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/MinElementsListenerTest.java
@@ -0,0 +1,141 @@
+/*
+ * 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.YangLeafList;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for testing min-elements listener.
+ */
+public class MinElementsListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks min-elements as sub-statements of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementMinElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementMinElements.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getMinElements(), is(3));
+ }
+
+ /**
+ * Checks min-elements as sub-statements of list.
+ */
+ @Test
+ public void processListSubStatementMinElements() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementMinElements.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.getMinElements(), is(3));
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid min-elements keyword
+ * is given as input.
+ */
+ @Test
+ public void processMinElementsInvalidKeyword() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("extraneous input 'min-element' expecting {'config', 'description', 'if-feature'," +
+ " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units'," +
+ " 'when', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidKeyword.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when invalid min-elements value
+ * is given as input.
+ */
+ @Test
+ public void processMinElementsInvalidValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'asd' expecting INTEGER");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidValue.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when min-elements statement without statement
+ * end is given as input.
+ */
+ @Test
+ public void processMinElementsWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at 'description'");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown when min-elements cardinality is not
+ * as per the grammar.
+ */
+ @Test
+ public void processMinElementsInvalidCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in" +
+ " min-elements before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListenerTest.java
new file mode 100644
index 0000000..ea5c6e6
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/PresenceListenerTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.nullValue;
+
+/**
+ * Test cases for presence listener.
+ */
+public class PresenceListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks presence statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementPresence() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementPresence.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("valid"));
+ assertThat(yangContainer.getPresence(), is("\"invalid\""));
+ }
+
+ /**
+ * checks default value of presence statement.
+ */
+ @Test
+ public void processPresenceDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/PresenceDefaultValue.yang");
+
+ 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"));
+
+ // Check whether the list is child of module
+ YangContainer yangContainer = (YangContainer) yangNode.getChild();
+ assertThat(yangContainer.getName(), is("valid"));
+ assertThat(yangContainer.getPresence(), is(nullValue()));
+ }
+
+ /**
+ * Checks presence statement without statement end.
+ */
+ @Test
+ public void processPresenceWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'leaf' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/PresenceWithoutStatementEnd.yang");
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java
new file mode 100644
index 0000000..4e17177
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/ReferenceListenerTest.java
@@ -0,0 +1,252 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test case for reference listener.
+ */
+public class ReferenceListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid reference statement.
+ */
+ @Test
+ public void processReferenceStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ReferenceStatement.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the reference is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid reference statement.
+ */
+ @Test
+ public void processReferenceWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/ReferenceWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks valid reference statement under module.
+ */
+ @Test
+ public void processModuleSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementReference.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"));
+
+ // Check whether the reference is set correctly.
+ assertThat(yangNode.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid reference statement under module.
+ */
+ @Test
+ public void processReferenceEmptyStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ReferenceEmptyStatement.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"));
+
+ // Check whether the reference is set correctly.
+ assertThat(yangNode.getReference(), is("\"\""));
+ }
+
+ /**
+ * Checks valid reference statement as sub-statement of revision.
+ */
+ @Test
+ public void processRevisionSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/RevisionSubStatementReference.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"));
+
+ // Check whether the reference is set correctly.
+ assertThat(yangNode.getRevision().getReference(), is("\"revision reference\""));
+ }
+
+ /**
+ * Checks reference statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementReference.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"));
+
+ // Check whether the reference value is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.getReference(), is("\"container reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks reference statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementReference.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and description value is set correctly.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getReference(), is("\"list reference\""));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid reference statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementReference() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementReference.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether description value is set correctly.
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
new file mode 100644
index 0000000..9cfacf9
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/StatusListenerTest.java
@@ -0,0 +1,263 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangContainer;
+import org.onosproject.yangutils.datamodel.YangList;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test cases for status listener.
+ */
+public class StatusListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid status statement.
+ */
+ @Test
+ public void processStatusStatementCurrent() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/StatusStatementCurrent.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the status is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ }
+
+ /**
+ * Checks valid status statement.
+ */
+ @Test
+ public void processStatusStatementDeprecated() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/StatusStatementDeprecated.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the status is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.DEPRECATED));
+ }
+
+ /**
+ * Checks valid status statement.
+ */
+ @Test
+ public void processStatusStatementObsolete() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/StatusStatementObsolete.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether the status is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.OBSOLETE));
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid status statement.
+ */
+ @Test
+ public void processStatusWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("missing ';' at '}'");
+ YangNode node = manager.getDataModel("src/test/resources/StatusWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks whether exception is thrown for invalid status statement.
+ */
+ @Test
+ public void processStatusInvalidValue() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'invalid' expecting {'current', 'deprecated', 'obsolete'}");
+ YangNode node = manager.getDataModel("src/test/resources/StatusInvalidValue.yang");
+ }
+
+ /**
+ * Checks status statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementStatus() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'status' expecting {'augment', 'choice', 'contact', 'container', " +
+ "'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
+ " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference', " +
+ "'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementStatus.yang");
+ }
+
+ /**
+ * Checks status statement as sub-statement of container.
+ */
+ @Test
+ public void processContainerSubStatementStatus() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementStatus.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"));
+
+ // Check whether status is set correctly.
+ YangContainer container = (YangContainer) yangNode.getChild();
+ assertThat(container.getName(), is("valid"));
+ assertThat(container.isConfig(), is(true));
+ assertThat(container.getStatus(), is(YangStatusType.OBSOLETE));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks status statement as sub-statement of list.
+ */
+ @Test
+ public void processListSubStatementStatus() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/ListSubStatementStatus.yang");
+
+ 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"));
+
+ // Check whether the list is child of module and status is set.
+ YangList yangList = (YangList) yangNode.getChild();
+ assertThat(yangList.getName(), is("valid"));
+ assertThat(yangList.isConfig(), is(true));
+ assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
+
+ // Check whether leaf properties as set correctly.
+ ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks valid status statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementStatus() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementStatus.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether status is set correctly.
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.isConfig(), is(true));
+ assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
new file mode 100644
index 0000000..0a056a7
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/TypeListenerTest.java
@@ -0,0 +1,103 @@
+package org.onosproject.yangutils.parser.impl.listeners;
+
+import org.junit.Test;
+import org.onosproject.yangutils.datamodel.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangDataTypes;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+/**
+ * Test case for type listener.
+ */
+public class TypeListenerTest {
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks derived statement without contraints.
+ */
+ @Test
+ public void processDerivedTypeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/DerivedTypeStatement.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"hello\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
+ }
+
+ /**
+ * Checks valid yang data type.
+ */
+ @Test
+ public void processIntegerTypeStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/IntegerTypeStatement.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ }
+
+ /**
+ * Checks type for leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementType() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementType.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
new file mode 100644
index 0000000..c1fccba
--- /dev/null
+++ b/utils/yangutils/src/test/java/org/onosproject/yangutils/parser/impl/listeners/UnitsListenerTest.java
@@ -0,0 +1,190 @@
+/*
+ * 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.YangLeaf;
+import org.onosproject.yangutils.datamodel.YangModule;
+import org.onosproject.yangutils.datamodel.YangNode;
+import org.onosproject.yangutils.datamodel.YangNodeType;
+import org.onosproject.yangutils.datamodel.YangStatusType;
+import org.onosproject.yangutils.datamodel.YangLeafList;
+import org.onosproject.yangutils.parser.exceptions.ParserException;
+import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
+
+import java.io.IOException;
+import java.util.ListIterator;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.hamcrest.Matchers.nullValue;
+
+/**
+ * Test cases for units listener.
+ */
+public class UnitsListenerTest {
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ private final YangUtilsParserManager manager = new YangUtilsParserManager();
+
+ /**
+ * Checks valid units statement.
+ */
+ @Test
+ public void processUnitsStatement() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnitsStatement.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether units value is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ }
+
+ /**
+ * Checks invalid units statement as sub-statement of module.
+ */
+ @Test
+ public void processModuleSubStatementUnits() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input 'type' expecting {'augment', 'choice', 'contact', 'container', " +
+ "'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', " +
+ "'include', 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', " +
+ "'prefix', 'reference', 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
+ YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementUnits.yang");
+ }
+
+ /**
+ * Checks invalid units statement(without statement end).
+ */
+ @Test
+ public void processUnitsWithoutStatementEnd() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("mismatched input '}' expecting {';', '+'}");
+ YangNode node = manager.getDataModel("src/test/resources/UnitsWithoutStatementEnd.yang");
+ }
+
+ /**
+ * Checks order of units statement in leaf.
+ */
+ @Test
+ public void processUnitsStatementOrder() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnitsStatementOrder.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ // Check whether leaf properties is set correctly.
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
+ assertThat(leafInfo.getUnits(), is("\"seconds\""));
+ assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
+ assertThat(leafInfo.isConfig(), is(true));
+ assertThat(leafInfo.isMandatory(), is(true));
+ assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
+ assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
+ }
+
+ /**
+ * Checks the default value of unit statement.
+ */
+ @Test
+ public void processUnitsDefaultValue() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/UnitsDefaultValue.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"));
+
+ ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
+ YangLeaf leafInfo = leafIterator.next();
+
+ assertThat(leafInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafInfo.getUnits(), is(nullValue()));
+ }
+
+ /**
+ * Checks invalid occurance of units statement as sub-statement of leaf.
+ */
+ @Test
+ public void processUnitsStatementCardinality() throws IOException, ParserException {
+ thrown.expect(ParserException.class);
+ thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing.");
+ YangNode node = manager.getDataModel("src/test/resources/UnitsStatementCardinality.yang");
+ }
+
+ /**
+ * Checks valid units statement as sub-statement of leaf-list.
+ */
+ @Test
+ public void processLeafListSubStatementUnits() throws IOException, ParserException {
+
+ YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementUnits.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"));
+
+ ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
+ YangLeafList leafListInfo = leafListIterator.next();
+
+ // Check whether units value is set correctly.
+ assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
+ assertThat(leafListInfo.getUnits(), is("\"seconds\""));
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigEmptyValue.yang b/utils/yangutils/src/test/resources/ConfigEmptyValue.yang
new file mode 100644
index 0000000..0d62956
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigEmptyValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ config ;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigFalse.yang b/utils/yangutils/src/test/resources/ConfigFalse.yang
new file mode 100644
index 0000000..79dc5ac
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigFalse.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config false;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigInvalidValue.yang b/utils/yangutils/src/test/resources/ConfigInvalidValue.yang
new file mode 100644
index 0000000..b2e7659
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigInvalidValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ config invalid;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigTrue.yang b/utils/yangutils/src/test/resources/ConfigTrue.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigTrue.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ConfigWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/ConfigWithoutStatementEnd.yang
new file mode 100644
index 0000000..0ae02af
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ConfigWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ config false
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerInvalidIdentifier.yang b/utils/yangutils/src/test/resources/ContainerInvalidIdentifier.yang
new file mode 100644
index 0000000..eee1acd
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerInvalidIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container 1valid {
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerRootNode.yang b/utils/yangutils/src/test/resources/ContainerRootNode.yang
new file mode 100644
index 0000000..441d717
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerRootNode.yang
@@ -0,0 +1,9 @@
+container valid {
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementCardinality.yang b/utils/yangutils/src/test/resources/ContainerSubStatementCardinality.yang
new file mode 100644
index 0000000..731e389
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ reference "RFC 6020";
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementConfig.yang b/utils/yangutils/src/test/resources/ContainerSubStatementConfig.yang
new file mode 100644
index 0000000..736dcbc
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementConfig.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementContainer.yang b/utils/yangutils/src/test/resources/ContainerSubStatementContainer.yang
new file mode 100644
index 0000000..1f9f810
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementContainer.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementDescription.yang b/utils/yangutils/src/test/resources/ContainerSubStatementDescription.yang
new file mode 100644
index 0000000..dc75d00
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementDescription.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ description "container description";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
+
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementLeaf.yang b/utils/yangutils/src/test/resources/ContainerSubStatementLeaf.yang
new file mode 100644
index 0000000..c9a64e3
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementLeaf.yang
@@ -0,0 +1,17 @@
+
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementLeafList.yang b/utils/yangutils/src/test/resources/ContainerSubStatementLeafList.yang
new file mode 100644
index 0000000..a1877b6
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementLeafList.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ min-elements 1;
+ max-elements unbounded;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementList.yang b/utils/yangutils/src/test/resources/ContainerSubStatementList.yang
new file mode 100644
index 0000000..4450391
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementList.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ list valid {
+ key "invalid";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementPresence.yang b/utils/yangutils/src/test/resources/ContainerSubStatementPresence.yang
new file mode 100644
index 0000000..d3a30dc
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementPresence.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ presence "invalid";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementReference.yang b/utils/yangutils/src/test/resources/ContainerSubStatementReference.yang
new file mode 100644
index 0000000..33f37fd
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementReference.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ reference "container reference";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatementStatus.yang b/utils/yangutils/src/test/resources/ContainerSubStatementStatus.yang
new file mode 100644
index 0000000..fdf907d
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatementStatus.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ config true;
+ status obsolete;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ContainerSubStatements.yang b/utils/yangutils/src/test/resources/ContainerSubStatements.yang
new file mode 100644
index 0000000..2611f97
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ContainerSubStatements.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container ospf {
+ presence "ospf logs";
+ config true;
+ description "container description";
+ status current;
+ reference "container reference";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/DerivedTypeStatement.yang b/utils/yangutils/src/test/resources/DerivedTypeStatement.yang
new file mode 100644
index 0000000..c678822
--- /dev/null
+++ b/utils/yangutils/src/test/resources/DerivedTypeStatement.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "hello";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/DescriptionEmptyStatement.yang b/utils/yangutils/src/test/resources/DescriptionEmptyStatement.yang
new file mode 100644
index 0000000..f6c1c3d
--- /dev/null
+++ b/utils/yangutils/src/test/resources/DescriptionEmptyStatement.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "";
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/DescriptionStringConcat.yang b/utils/yangutils/src/test/resources/DescriptionStringConcat.yang
new file mode 100644
index 0000000..8bf0519
--- /dev/null
+++ b/utils/yangutils/src/test/resources/DescriptionStringConcat.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ description "Interval before a " + "route is declared invalid";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/DescriptionValidStatement.yang b/utils/yangutils/src/test/resources/DescriptionValidStatement.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/DescriptionValidStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/DescriptionWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/DescriptionWithoutStatementEnd.yang
new file mode 100644
index 0000000..ebd8c24
--- /dev/null
+++ b/utils/yangutils/src/test/resources/DescriptionWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ description "Interval before a " + "route is declared invalid"
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/IntegerTypeStatement.yang b/utils/yangutils/src/test/resources/IntegerTypeStatement.yang
new file mode 100644
index 0000000..ca2be38
--- /dev/null
+++ b/utils/yangutils/src/test/resources/IntegerTypeStatement.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/KeyWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/KeyWithoutStatementEnd.yang
new file mode 100644
index 0000000..f56101a
--- /dev/null
+++ b/utils/yangutils/src/test/resources/KeyWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid"
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafConfigInvalidCardinality.yang b/utils/yangutils/src/test/resources/LeafConfigInvalidCardinality.yang
new file mode 100644
index 0000000..d403a56
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafConfigInvalidCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ config false;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafInvalidIdentifier.yang b/utils/yangutils/src/test/resources/LeafInvalidIdentifier.yang
new file mode 100644
index 0000000..dbfff13
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafInvalidIdentifier.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf 1invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafInvalidStatement.yang b/utils/yangutils/src/test/resources/LeafInvalidStatement.yang
new file mode 100644
index 0000000..4d4f6f6
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafInvalidStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leafs invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListConfigInvalidCardinality.yang b/utils/yangutils/src/test/resources/LeafListConfigInvalidCardinality.yang
new file mode 100644
index 0000000..361a852
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListConfigInvalidCardinality.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ config false;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListInvalidIdentifier.yang b/utils/yangutils/src/test/resources/LeafListInvalidIdentifier.yang
new file mode 100644
index 0000000..77c24d2
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListInvalidIdentifier.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list 1invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListInvalidStatement.yang b/utils/yangutils/src/test/resources/LeafListInvalidStatement.yang
new file mode 100644
index 0000000..13e4b5f
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListInvalidStatement.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaflist invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementConfig.yang b/utils/yangutils/src/test/resources/LeafListSubStatementConfig.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementConfig.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementDescription.yang b/utils/yangutils/src/test/resources/LeafListSubStatementDescription.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementDescription.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementMaxElements.yang b/utils/yangutils/src/test/resources/LeafListSubStatementMaxElements.yang
new file mode 100644
index 0000000..5ab2d0f
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementMaxElements.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ max-elements 3;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementMinElements.yang b/utils/yangutils/src/test/resources/LeafListSubStatementMinElements.yang
new file mode 100644
index 0000000..fd71281
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementMinElements.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ min-elements 3;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementReference.yang b/utils/yangutils/src/test/resources/LeafListSubStatementReference.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementReference.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementStatus.yang b/utils/yangutils/src/test/resources/LeafListSubStatementStatus.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementStatus.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementType.yang b/utils/yangutils/src/test/resources/LeafListSubStatementType.yang
new file mode 100644
index 0000000..0e5ab56
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementType.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatementUnits.yang b/utils/yangutils/src/test/resources/LeafListSubStatementUnits.yang
new file mode 100644
index 0000000..293e4a5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatementUnits.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListSubStatements.yang b/utils/yangutils/src/test/resources/LeafListSubStatements.yang
new file mode 100644
index 0000000..29dfdb2
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListSubStatements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-elements 3;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListUnitsInvalidCardinality.yang b/utils/yangutils/src/test/resources/LeafListUnitsInvalidCardinality.yang
new file mode 100644
index 0000000..996e49e
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListUnitsInvalidCardinality.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ units "minutes";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafListWithoutLeftBrace.yang b/utils/yangutils/src/test/resources/LeafListWithoutLeftBrace.yang
new file mode 100644
index 0000000..1196422
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafListWithoutLeftBrace.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafMandatoryInvalidCardinality.yang b/utils/yangutils/src/test/resources/LeafMandatoryInvalidCardinality.yang
new file mode 100644
index 0000000..c275dd7
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafMandatoryInvalidCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ mandatory false;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafSubStatements.yang b/utils/yangutils/src/test/resources/LeafSubStatements.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafSubStatements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/LeafWithoutLeftBrace.yang b/utils/yangutils/src/test/resources/LeafWithoutLeftBrace.yang
new file mode 100644
index 0000000..c2aa979
--- /dev/null
+++ b/utils/yangutils/src/test/resources/LeafWithoutLeftBrace.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListAsRootNode.yang b/utils/yangutils/src/test/resources/ListAsRootNode.yang
new file mode 100644
index 0000000..289525f
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListAsRootNode.yang
@@ -0,0 +1,9 @@
+list valid {
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListInvalidIdentifier.yang b/utils/yangutils/src/test/resources/ListInvalidIdentifier.yang
new file mode 100644
index 0000000..c5f6a3a
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListInvalidIdentifier.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list 1valid {
+ key "invalid-interval";
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListStatementWithoutChild.yang b/utils/yangutils/src/test/resources/ListStatementWithoutChild.yang
new file mode 100644
index 0000000..5c006d7
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListStatementWithoutChild.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementConfig.yang b/utils/yangutils/src/test/resources/ListSubStatementConfig.yang
new file mode 100644
index 0000000..55432fb
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementConfig.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementContainer.yang b/utils/yangutils/src/test/resources/ListSubStatementContainer.yang
new file mode 100644
index 0000000..a81bda5
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementContainer.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "process-id";
+ container interface {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementDescription.yang b/utils/yangutils/src/test/resources/ListSubStatementDescription.yang
new file mode 100644
index 0000000..a8df3d7
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementDescription.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ description "list description";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementKey.yang b/utils/yangutils/src/test/resources/ListSubStatementKey.yang
new file mode 100644
index 0000000..791013d
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementKey.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ListSubStatementLeaf.yang b/utils/yangutils/src/test/resources/ListSubStatementLeaf.yang
new file mode 100644
index 0000000..59b92cc
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementLeaf.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementLeafList.yang b/utils/yangutils/src/test/resources/ListSubStatementLeafList.yang
new file mode 100644
index 0000000..5235295
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementLeafList.yang
@@ -0,0 +1,17 @@
+
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementList.yang b/utils/yangutils/src/test/resources/ListSubStatementList.yang
new file mode 100644
index 0000000..14cf270
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementList.yang
@@ -0,0 +1,17 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "process-id";
+ list valid {
+ key "invalid";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementMaxElements.yang b/utils/yangutils/src/test/resources/ListSubStatementMaxElements.yang
new file mode 100644
index 0000000..de6139e
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementMaxElements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ max-elements 3;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementMinElements.yang b/utils/yangutils/src/test/resources/ListSubStatementMinElements.yang
new file mode 100644
index 0000000..d6071e8
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementMinElements.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ min-elements 3;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementReference.yang b/utils/yangutils/src/test/resources/ListSubStatementReference.yang
new file mode 100644
index 0000000..8adfa04
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementReference.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ reference "list reference";
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementStatus.yang b/utils/yangutils/src/test/resources/ListSubStatementStatus.yang
new file mode 100644
index 0000000..b88ac74
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementStatus.yang
@@ -0,0 +1,18 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ status current;
+ config true;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ListSubStatements.yang b/utils/yangutils/src/test/resources/ListSubStatements.yang
new file mode 100644
index 0000000..f684780
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatements.yang
@@ -0,0 +1,20 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list ospf {
+ key "process-id";
+ config true;
+ max-elements 10;
+ min-elements 3;
+ description "list description";
+ status current;
+ reference "list reference";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ListSubStatementsCardinality.yang b/utils/yangutils/src/test/resources/ListSubStatementsCardinality.yang
new file mode 100644
index 0000000..9c4077c
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ListSubStatementsCardinality.yang
@@ -0,0 +1,16 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid-interval";
+ reference "RFC 6020";
+ reference "RFC 6020";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/MandatoryDefaultValue.yang b/utils/yangutils/src/test/resources/MandatoryDefaultValue.yang
new file mode 100644
index 0000000..c71d5ea
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MandatoryDefaultValue.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MandatoryEmptyStatement.yang b/utils/yangutils/src/test/resources/MandatoryEmptyStatement.yang
new file mode 100644
index 0000000..e2af869
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MandatoryEmptyStatement.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ mandatory ;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MandatoryFalse.yang b/utils/yangutils/src/test/resources/MandatoryFalse.yang
new file mode 100644
index 0000000..3ae4601
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MandatoryFalse.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ mandatory false;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MandatoryTrue.yang b/utils/yangutils/src/test/resources/MandatoryTrue.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MandatoryTrue.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MandatoryWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/MandatoryWithoutStatementEnd.yang
new file mode 100644
index 0000000..055f556
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MandatoryWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ mandatory false
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MaxElementsCardinality.yang b/utils/yangutils/src/test/resources/MaxElementsCardinality.yang
new file mode 100644
index 0000000..bff2fd7
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MaxElementsCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-elements 4;
+ max-elements 6;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/MaxElementsInvalidStatement.yang b/utils/yangutils/src/test/resources/MaxElementsInvalidStatement.yang
new file mode 100644
index 0000000..67cb358
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MaxElementsInvalidStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-element 3;
+ description "Interval before a route is declared invalid;
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/MaxElementsUnbounded.yang b/utils/yangutils/src/test/resources/MaxElementsUnbounded.yang
new file mode 100644
index 0000000..afaca4f
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MaxElementsUnbounded.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ max-elements unbounded;
+ }
+}
diff --git a/utils/yangutils/src/test/resources/MaxElementsWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/MaxElementsWithoutStatementEnd.yang
new file mode 100644
index 0000000..5973dd0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MaxElementsWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ max-elements 3
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/MinElementsInvalidCardinality.yang b/utils/yangutils/src/test/resources/MinElementsInvalidCardinality.yang
new file mode 100644
index 0000000..18f6019
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MinElementsInvalidCardinality.yang
@@ -0,0 +1,15 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-elements 4;
+ min-elements 6;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/MinElementsInvalidKeyword.yang b/utils/yangutils/src/test/resources/MinElementsInvalidKeyword.yang
new file mode 100644
index 0000000..e634509
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MinElementsInvalidKeyword.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-element 3;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MinElementsInvalidValue.yang b/utils/yangutils/src/test/resources/MinElementsInvalidValue.yang
new file mode 100644
index 0000000..a381184
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MinElementsInvalidValue.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-elements asd;
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MinElementsWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/MinElementsWithoutStatementEnd.yang
new file mode 100644
index 0000000..699a8b8
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MinElementsWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf-list invalid-interval {
+ type "uint16";
+ units "seconds";
+ min-elements 3
+ description "Interval before a route is declared invalid";
+ config true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementConfig.yang b/utils/yangutils/src/test/resources/ModuleSubStatementConfig.yang
new file mode 100644
index 0000000..49deb3e
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementConfig.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ config invalid;
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementContainer.yang b/utils/yangutils/src/test/resources/ModuleSubStatementContainer.yang
new file mode 100644
index 0000000..35a91ad
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementContainer.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementDescription.yang b/utils/yangutils/src/test/resources/ModuleSubStatementDescription.yang
new file mode 100644
index 0000000..02643b1
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementDescription.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "Interval before a route is declared invalid";
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementList.yang b/utils/yangutils/src/test/resources/ModuleSubStatementList.yang
new file mode 100644
index 0000000..baf36e7
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementList.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "invalid";
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementMandatory.yang b/utils/yangutils/src/test/resources/ModuleSubStatementMandatory.yang
new file mode 100644
index 0000000..8f6e1a1
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementMandatory.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ mandatory false;
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementReference.yang b/utils/yangutils/src/test/resources/ModuleSubStatementReference.yang
new file mode 100644
index 0000000..20b2fb6
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementReference.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ reference "RFC 6020";
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementStatus.yang b/utils/yangutils/src/test/resources/ModuleSubStatementStatus.yang
new file mode 100644
index 0000000..3739096
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementStatus.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ status current;
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ModuleSubStatementUnits.yang b/utils/yangutils/src/test/resources/ModuleSubStatementUnits.yang
new file mode 100644
index 0000000..d9381ec
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ModuleSubStatementUnits.yang
@@ -0,0 +1,7 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ type "uint16";
+ units "seconds";
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/MultipleKeyValues.yang b/utils/yangutils/src/test/resources/MultipleKeyValues.yang
new file mode 100644
index 0000000..a9d25a2
--- /dev/null
+++ b/utils/yangutils/src/test/resources/MultipleKeyValues.yang
@@ -0,0 +1,20 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ list valid {
+ key "ospf isis";
+ leaf ospf {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ leaf isis {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/PresenceDefaultValue.yang b/utils/yangutils/src/test/resources/PresenceDefaultValue.yang
new file mode 100644
index 0000000..6418e20
--- /dev/null
+++ b/utils/yangutils/src/test/resources/PresenceDefaultValue.yang
@@ -0,0 +1,13 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ leaf ospf {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/PresenceWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/PresenceWithoutStatementEnd.yang
new file mode 100644
index 0000000..1427c5f
--- /dev/null
+++ b/utils/yangutils/src/test/resources/PresenceWithoutStatementEnd.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ container valid {
+ presence "invalid"
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ status current;
+ reference "RFC 6020";
+ }
+ }
+}
diff --git a/utils/yangutils/src/test/resources/ReferenceEmptyStatement.yang b/utils/yangutils/src/test/resources/ReferenceEmptyStatement.yang
new file mode 100644
index 0000000..ff3525a
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ReferenceEmptyStatement.yang
@@ -0,0 +1,6 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ reference "";
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ReferenceStatement.yang b/utils/yangutils/src/test/resources/ReferenceStatement.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ReferenceStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/ReferenceWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/ReferenceWithoutStatementEnd.yang
new file mode 100644
index 0000000..f2fcf43
--- /dev/null
+++ b/utils/yangutils/src/test/resources/ReferenceWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ reference "RFC 6020"
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/RevisionSubStatementReference.yang b/utils/yangutils/src/test/resources/RevisionSubStatementReference.yang
new file mode 100644
index 0000000..d1ada14
--- /dev/null
+++ b/utils/yangutils/src/test/resources/RevisionSubStatementReference.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "module description";
+ revision 2007-06-09 {
+ reference "revision reference";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/RevisionSubStatementRevision.yang b/utils/yangutils/src/test/resources/RevisionSubStatementRevision.yang
new file mode 100644
index 0000000..3d1daa2
--- /dev/null
+++ b/utils/yangutils/src/test/resources/RevisionSubStatementRevision.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ description "module description";
+ revision 2007-06-09 {
+ description "revision description";
+ }
+}
+
diff --git a/utils/yangutils/src/test/resources/StatusInvalidValue.yang b/utils/yangutils/src/test/resources/StatusInvalidValue.yang
new file mode 100644
index 0000000..253b785
--- /dev/null
+++ b/utils/yangutils/src/test/resources/StatusInvalidValue.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status invalid;
+ }
+}
diff --git a/utils/yangutils/src/test/resources/StatusStatementCurrent.yang b/utils/yangutils/src/test/resources/StatusStatementCurrent.yang
new file mode 100644
index 0000000..dd9a36d
--- /dev/null
+++ b/utils/yangutils/src/test/resources/StatusStatementCurrent.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/StatusStatementDeprecated.yang b/utils/yangutils/src/test/resources/StatusStatementDeprecated.yang
new file mode 100644
index 0000000..9a257b1
--- /dev/null
+++ b/utils/yangutils/src/test/resources/StatusStatementDeprecated.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status deprecated;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/StatusStatementObsolete.yang b/utils/yangutils/src/test/resources/StatusStatementObsolete.yang
new file mode 100644
index 0000000..19325ed
--- /dev/null
+++ b/utils/yangutils/src/test/resources/StatusStatementObsolete.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status obsolete;
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/StatusWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/StatusWithoutStatementEnd.yang
new file mode 100644
index 0000000..27a8cfa
--- /dev/null
+++ b/utils/yangutils/src/test/resources/StatusWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ status current
+ }
+}
diff --git a/utils/yangutils/src/test/resources/UnitsDefaultValue.yang b/utils/yangutils/src/test/resources/UnitsDefaultValue.yang
new file mode 100644
index 0000000..c71d5ea
--- /dev/null
+++ b/utils/yangutils/src/test/resources/UnitsDefaultValue.yang
@@ -0,0 +1,8 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/UnitsStatement.yang b/utils/yangutils/src/test/resources/UnitsStatement.yang
new file mode 100644
index 0000000..70349a0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/UnitsStatement.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
\ No newline at end of file
diff --git a/utils/yangutils/src/test/resources/UnitsStatementCardinality.yang b/utils/yangutils/src/test/resources/UnitsStatementCardinality.yang
new file mode 100644
index 0000000..50a2ba0
--- /dev/null
+++ b/utils/yangutils/src/test/resources/UnitsStatementCardinality.yang
@@ -0,0 +1,10 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds";
+ units "minutes";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/UnitsStatementOrder.yang b/utils/yangutils/src/test/resources/UnitsStatementOrder.yang
new file mode 100644
index 0000000..e41e201
--- /dev/null
+++ b/utils/yangutils/src/test/resources/UnitsStatementOrder.yang
@@ -0,0 +1,14 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ units "seconds";
+ type "uint16";
+ description "Interval before a route is declared invalid";
+ config true;
+ mandatory true;
+ status current;
+ reference "RFC 6020";
+ }
+}
diff --git a/utils/yangutils/src/test/resources/UnitsWithoutStatementEnd.yang b/utils/yangutils/src/test/resources/UnitsWithoutStatementEnd.yang
new file mode 100644
index 0000000..889d7b7
--- /dev/null
+++ b/utils/yangutils/src/test/resources/UnitsWithoutStatementEnd.yang
@@ -0,0 +1,9 @@
+module Test {
+ yang-version 1;
+ namespace http://huawei.com;
+ prefix Ant;
+ leaf invalid-interval {
+ type "uint16";
+ units "seconds"
+ }
+}