Vidyashree Rama
Committed by Gerrit Code Review

[ONOS-3892,3895,3882,3883,3896]Unit test of yang container, list, leaf, leaf-list parser

Change-Id: Iae040d9d354e012584db8adc0aa7ff1ea4c099a0
Showing 115 changed files with 4053 additions and 0 deletions
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
/*
* 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
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
/*
* 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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
config ;
}
}
\ No newline at end of file
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
config invalid;
}
}
\ No newline at end of file
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
config false
}
}
\ No newline at end of file
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
container valid {
reference "RFC 6020";
leaf invalid-interval {
type "uint16";
units "seconds";
status current;
reference "RFC 6020";
}
}
\ No newline at end of file
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
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
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
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";
}
}
}
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
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
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";
}
}
}
}
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
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
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
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "hello";
}
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
description "";
}
\ No newline at end of file
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
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
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
}
}
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
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
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
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
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
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
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
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
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
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
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
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
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf-list invalid-interval {
type "uint16";
}
}
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
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
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
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
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
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
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
list valid {
reference "RFC 6020";
leaf invalid-interval {
type "uint16";
units "seconds";
status current;
reference "RFC 6020";
}
}
\ No newline at end of file
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
list valid {
reference "RFC 6020";
}
}
\ No newline at end of file
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
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
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
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";
}
}
}
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
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
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
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
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
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
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";
}
}
}
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
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";
}
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
}
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
mandatory ;
}
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
mandatory false;
}
}
\ No newline at end of file
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
mandatory false
}
}
\ No newline at end of file
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";
}
}
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";
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf-list invalid-interval {
type "uint16";
max-elements unbounded;
}
}
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";
}
}
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";
}
}
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
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
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
config invalid;
}
\ No newline at end of file
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
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
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
mandatory false;
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
reference "RFC 6020";
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
status current;
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
type "uint16";
units "seconds";
}
\ No newline at end of file
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
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
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";
}
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
reference "";
}
\ No newline at end of file
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
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
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
description "module description";
revision 2007-06-09 {
description "revision description";
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
status invalid;
}
}
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";
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
status deprecated;
}
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
status obsolete;
}
}
\ No newline at end of file
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
status current
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
}
}
\ No newline at end of file
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
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
units "seconds";
units "minutes";
}
}
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";
}
}
module Test {
yang-version 1;
namespace http://huawei.com;
prefix Ant;
leaf invalid-interval {
type "uint16";
units "seconds"
}
}