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
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.datamodel.YangLeafList;
32 +import org.onosproject.yangutils.parser.exceptions.ParserException;
33 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
34 +
35 +import java.io.IOException;
36 +import java.util.ListIterator;
37 +
38 +import static org.hamcrest.MatcherAssert.assertThat;
39 +import static org.hamcrest.core.Is.is;
40 +
41 +/**
42 + * Test cases for config listener.
43 + */
44 +public class ConfigListenerTest {
45 +
46 + @Rule
47 + public ExpectedException thrown = ExpectedException.none();
48 +
49 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
50 +
51 + /**
52 + * Checks valid config statement.
53 + */
54 + @Test
55 + public void processConfigTrue() throws IOException, ParserException {
56 +
57 + YangNode node = manager.getDataModel("src/test/resources/ConfigTrue.yang");
58 +
59 + // Check whether the data model tree returned is of type module.
60 + assertThat((node instanceof YangModule), is(true));
61 +
62 + // Check whether the node type is set properly to module.
63 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
64 +
65 + // Check whether the module name is set correctly.
66 + YangModule yangNode = (YangModule) node;
67 + assertThat(yangNode.getName(), is("Test"));
68 +
69 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
70 + YangLeaf leafInfo = leafIterator.next();
71 +
72 + // Check whether the Config value is set correctly.
73 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
74 + assertThat(leafInfo.isConfig(), is(true));
75 + }
76 +
77 + /**
78 + * Checks valid config statement.
79 + */
80 + @Test
81 + public void processConfigFalse() throws IOException, ParserException {
82 +
83 + YangNode node = manager.getDataModel("src/test/resources/ConfigFalse.yang");
84 +
85 + // Check whether the data model tree returned is of type module.
86 + assertThat((node instanceof YangModule), is(true));
87 +
88 + // Check whether the node type is set properly to module.
89 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
90 +
91 + // Check whether the module name is set correctly.
92 + YangModule yangNode = (YangModule) node;
93 + assertThat(yangNode.getName(), is("Test"));
94 +
95 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
96 + YangLeaf leafInfo = leafIterator.next();
97 +
98 + // Check whether the Config value is set correctly.
99 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
100 + assertThat(leafInfo.isConfig(), is(false));
101 + }
102 +
103 + /**
104 + * Checks invalid config statement and expects parser exception.
105 + */
106 + @Test
107 + public void processConfigWithoutStatementEnd() throws IOException, ParserException {
108 + thrown.expect(ParserException.class);
109 + thrown.expectMessage("missing ';' at '}'");
110 + YangNode node = manager.getDataModel("src/test/resources/ConfigWithoutStatementEnd.yang");
111 + }
112 +
113 + /**
114 + * Checks invalid config statement and expects parser exception.
115 + */
116 + @Test
117 + public void processConfigInvalidValue() throws IOException, ParserException {
118 + thrown.expect(ParserException.class);
119 + thrown.expectMessage("mismatched input 'invalid' expecting {'false', 'true'}");
120 + YangNode node = manager.getDataModel("src/test/resources/ConfigInvalidValue.yang");
121 + }
122 +
123 + /**
124 + * Checks invalid config statement and expects parser exception.
125 + */
126 + @Test
127 + public void processConfigEmptyValue() throws IOException, ParserException {
128 + thrown.expect(ParserException.class);
129 + thrown.expectMessage("missing {'false', 'true'} at ';'");
130 + YangNode node = manager.getDataModel("src/test/resources/ConfigEmptyValue.yang");
131 + }
132 +
133 + /**
134 + * Checks config statement as sub-statement of module.
135 + */
136 + @Test
137 + public void processModuleSubStatementConfig() throws IOException, ParserException {
138 + thrown.expect(ParserException.class);
139 + thrown.expectMessage("mismatched input 'config' expecting {'augment', 'choice', 'contact', 'container'," +
140 + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include', " +
141 + "'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
142 + " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
143 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementConfig.yang");
144 + }
145 +
146 + /**
147 + * Checks config statement as sub-statement of container.
148 + */
149 + @Test
150 + public void processContainerSubStatementConfig() throws IOException, ParserException {
151 +
152 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementConfig.yang");
153 +
154 + // Check whether the data model tree returned is of type module.
155 + assertThat((node instanceof YangModule), is(true));
156 +
157 + // Check whether the node type is set properly to module.
158 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
159 +
160 + // Check whether the module name is set correctly.
161 + YangModule yangNode = (YangModule) node;
162 + assertThat(yangNode.getName(), is("Test"));
163 +
164 + // Check whether the config value is set correctly.
165 + YangContainer container = (YangContainer) yangNode.getChild();
166 + assertThat(container.getName(), is("valid"));
167 + assertThat(container.isConfig(), is(true));
168 +
169 + // Check whether leaf properties as set correctly.
170 + ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
171 + YangLeaf leafInfo = leafIterator.next();
172 +
173 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
174 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
175 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
176 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
177 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
178 + assertThat(leafInfo.isMandatory(), is(true));
179 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
180 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
181 + }
182 +
183 + /**
184 + * Checks config statement as sub-statement of list.
185 + */
186 + @Test
187 + public void processListSubStatementConfig() throws IOException, ParserException {
188 +
189 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementConfig.yang");
190 +
191 + assertThat((node instanceof YangModule), is(true));
192 +
193 + // Check whether the node type is set properly to module.
194 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
195 +
196 + // Check whether the module name is set correctly.
197 + YangModule yangNode = (YangModule) node;
198 + assertThat(yangNode.getName(), is("Test"));
199 +
200 + // Check whether the list is child of module and config value is set.
201 + YangList yangList = (YangList) yangNode.getChild();
202 + assertThat(yangList.getName(), is("valid"));
203 + assertThat(yangList.isConfig(), is(true));
204 +
205 + // Check whether leaf properties as set correctly.
206 + ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
207 + YangLeaf leafInfo = leafIterator.next();
208 +
209 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
210 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
211 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
212 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
213 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
214 + assertThat(leafInfo.isMandatory(), is(true));
215 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
216 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
217 + }
218 +
219 + /**
220 + * Checks valid config statement as sub-statement of leaf-list.
221 + */
222 + @Test
223 + public void processLeafListSubStatementConfig() throws IOException, ParserException {
224 +
225 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementConfig.yang");
226 +
227 + // Check whether the data model tree returned is of type module.
228 + assertThat((node instanceof YangModule), is(true));
229 +
230 + // Check whether the node type is set properly to module.
231 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
232 +
233 + // Check whether the module name is set correctly.
234 + YangModule yangNode = (YangModule) node;
235 + assertThat(yangNode.getName(), is("Test"));
236 +
237 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
238 + YangLeafList leafListInfo = leafListIterator.next();
239 +
240 + // Check whether config value is set correctly.
241 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
242 + assertThat(leafListInfo.isConfig(), is(true));
243 + }
244 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.parser.exceptions.ParserException;
32 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
33 +
34 +import java.io.IOException;
35 +import java.util.ListIterator;
36 +
37 +import static org.hamcrest.MatcherAssert.assertThat;
38 +import static org.hamcrest.core.Is.is;
39 +
40 +/**
41 + * Test cases for testing container listener.
42 + */
43 +public class ContainerListenerTest {
44 +
45 + @Rule
46 + public ExpectedException thrown = ExpectedException.none();
47 +
48 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
49 +
50 + /**
51 + * Checks container statement as sub-statement of module.
52 + */
53 + @Test
54 + public void processModuleSubStatementContainer() throws IOException, ParserException {
55 +
56 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementContainer.yang");
57 +
58 + assertThat((node instanceof YangModule), is(true));
59 +
60 + // Check whether the node type is set properly to module.
61 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
62 +
63 + // Check whether the module name is set correctly.
64 + YangModule yangNode = (YangModule) node;
65 + assertThat(yangNode.getName(), is("Test"));
66 +
67 + // Check whether the container is child of module
68 + YangContainer yangContainer = (YangContainer) yangNode.getChild();
69 + assertThat(yangContainer.getName(), is("valid"));
70 + }
71 +
72 + /**
73 + * Checks container statement as sub-statement of container.
74 + */
75 + @Test
76 + public void processContainerSubStatementContainer() throws IOException, ParserException {
77 +
78 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementContainer.yang");
79 +
80 + assertThat((node instanceof YangModule), is(true));
81 +
82 + // Check whether the node type is set properly to module.
83 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
84 +
85 + // Check whether the module name is set correctly.
86 + YangModule yangNode = (YangModule) node;
87 + assertThat(yangNode.getName(), is("Test"));
88 +
89 + // Check whether the container is child of module
90 + YangContainer yangContainer = (YangContainer) yangNode.getChild();
91 + assertThat(yangContainer.getName(), is("ospf"));
92 +
93 + // Check whether the container is child of container
94 + YangContainer yangContainer1 = (YangContainer) yangContainer.getChild();
95 + assertThat(yangContainer1.getName(), is("valid"));
96 + }
97 +
98 + /**
99 + * Checks container statement as sub-statement of list.
100 + */
101 + @Test
102 + public void processListSubStatementContainer() throws IOException, ParserException {
103 +
104 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementContainer.yang");
105 +
106 + assertThat((node instanceof YangModule), is(true));
107 +
108 + // Check whether the node type is set properly to module.
109 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
110 +
111 + // Check whether the module name is set correctly.
112 + YangModule yangNode = (YangModule) node;
113 + assertThat(yangNode.getName(), is("Test"));
114 +
115 + // Check whether the list is child of module
116 + YangList yangList1 = (YangList) yangNode.getChild();
117 + assertThat(yangList1.getName(), is("ospf"));
118 +
119 + ListIterator<String> keyList = yangList1.getKeyList().listIterator();
120 + assertThat(keyList.next(), is("process-id"));
121 +
122 + // Check whether the list is child of list
123 + YangContainer yangContainer = (YangContainer) yangList1.getChild();
124 + assertThat(yangContainer.getName(), is("interface"));
125 + }
126 +
127 + /**
128 + * Checks container with all its sub-statements.
129 + */
130 + @Test
131 + public void processContainerSubStatements() throws IOException, ParserException {
132 +
133 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatements.yang");
134 +
135 + assertThat((node instanceof YangModule), is(true));
136 +
137 + // Check whether the node type is set properly to module.
138 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
139 +
140 + // Check whether the module name is set correctly.
141 + YangModule yangNode = (YangModule) node;
142 + assertThat(yangNode.getName(), is("Test"));
143 +
144 + // Check whether the container is child of module
145 + YangContainer yangContainer = (YangContainer) yangNode.getChild();
146 +
147 + // Check whether container properties as set correctly.
148 + assertThat(yangContainer.getName(), is("ospf"));
149 +
150 + assertThat(yangContainer.isConfig(), is(true));
151 + assertThat(yangContainer.getPresence(), is("\"ospf logs\""));
152 + assertThat(yangContainer.getDescription(), is("\"container description\""));
153 + assertThat(yangContainer.getStatus(), is(YangStatusType.CURRENT));
154 + assertThat(yangContainer.getReference(), is("\"container reference\""));
155 +
156 + // Check whether leaf properties as set correctly.
157 + ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator();
158 + YangLeaf leafInfo = leafIterator.next();
159 +
160 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
161 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
162 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
163 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
164 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
165 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
166 + }
167 +
168 + /**
169 + * Checks cardinality of sub-statements of container.
170 + */
171 + @Test
172 + public void processContainerSubStatementCardinality() throws IOException, ParserException {
173 + thrown.expect(ParserException.class);
174 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing.");
175 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementCardinality.yang");
176 + }
177 +
178 + /**
179 + * Checks container as root node.
180 + */
181 + @Test
182 + public void processContainerRootNode() throws IOException, ParserException {
183 + thrown.expect(ParserException.class);
184 + thrown.expectMessage("no viable alternative at input 'container'");
185 + YangNode node = manager.getDataModel("src/test/resources/ContainerRootNode.yang");
186 + }
187 +
188 + /**
189 + * Checks invalid identifier for container statement.
190 + */
191 + @Test
192 + public void processContainerInvalidIdentifier() throws IOException, ParserException {
193 + thrown.expect(ParserException.class);
194 + thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER");
195 + YangNode node = manager.getDataModel("src/test/resources/ContainerInvalidIdentifier.yang");
196 + }
197 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.datamodel.YangLeafList;
32 +import org.onosproject.yangutils.parser.exceptions.ParserException;
33 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
34 +
35 +import java.io.IOException;
36 +import java.util.ListIterator;
37 +
38 +import static org.hamcrest.MatcherAssert.assertThat;
39 +import static org.hamcrest.core.Is.is;
40 +
41 +/**
42 + * Test cases for description listener.
43 + */
44 +public class DescriptionListenerTest {
45 +
46 + @Rule
47 + public ExpectedException thrown = ExpectedException.none();
48 +
49 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
50 +
51 + /**
52 + * Checks valid description statement.
53 + */
54 + @Test
55 + public void processDescriptionValidStatement() throws IOException, ParserException {
56 +
57 + YangNode node = manager.getDataModel("src/test/resources/DescriptionValidStatement.yang");
58 +
59 + // Check whether the data model tree returned is of type module.
60 + assertThat((node instanceof YangModule), is(true));
61 +
62 + // Check whether the node type is set properly to module.
63 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
64 +
65 + // Check whether the module name is set correctly.
66 + YangModule yangNode = (YangModule) node;
67 + assertThat(yangNode.getName(), is("Test"));
68 +
69 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
70 + YangLeaf leafInfo = leafIterator.next();
71 +
72 + // Check whether the description is set correctly.
73 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
74 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
75 + }
76 +
77 + /**
78 + * Checks whether exception is thrown for invalid description statement.
79 + */
80 + @Test
81 + public void processDescriptionWithoutStatementEnd() throws IOException, ParserException {
82 + thrown.expect(ParserException.class);
83 + thrown.expectMessage("extraneous input '}' expecting {';', '+'}");
84 + YangNode node = manager.getDataModel("src/test/resources/DescriptionWithoutStatementEnd.yang");
85 + }
86 +
87 + /**
88 + * Checks valid description statement as sub-statement of module.
89 + */
90 + @Test
91 + public void processModuleSubStatementDescription() throws IOException, ParserException {
92 +
93 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementDescription.yang");
94 +
95 + // Check whether the data model tree returned is of type module.
96 + assertThat((node instanceof YangModule), is(true));
97 +
98 + // Check whether the node type is set properly to module.
99 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
100 +
101 + // Check whether the module name is set correctly.
102 + YangModule yangNode = (YangModule) node;
103 + assertThat(yangNode.getName(), is("Test"));
104 +
105 + // Check whether the description is set correctly.
106 + assertThat(yangNode.getDescription(), is("\"Interval before a route is declared invalid\""));
107 + }
108 +
109 + /**
110 + * Checks valid description statement as sub-statement of module.
111 + */
112 + @Test
113 + public void processDescriptionEmptyStatement() throws IOException, ParserException {
114 +
115 + YangNode node = manager.getDataModel("src/test/resources/DescriptionEmptyStatement.yang");
116 +
117 + // Check whether the data model tree returned is of type module.
118 + assertThat((node instanceof YangModule), is(true));
119 +
120 + // Check whether the node type is set properly to module.
121 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
122 +
123 + // Check whether the module name is set correctly.
124 + YangModule yangNode = (YangModule) node;
125 + assertThat(yangNode.getName(), is("Test"));
126 +
127 + // Check whether the description is set correctly.
128 + assertThat(yangNode.getDescription(), is("\"\""));
129 + }
130 +
131 + /**
132 + * Checks valid description statement as sub-statement of revision.
133 + */
134 + @Test
135 + public void processRevisionSubStatementRevision() throws IOException, ParserException {
136 +
137 + YangNode node = manager.getDataModel("src/test/resources/RevisionSubStatementRevision.yang");
138 +
139 + // Check whether the data model tree returned is of type module.
140 + assertThat((node instanceof YangModule), is(true));
141 +
142 + // Check whether the node type is set properly to module.
143 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
144 +
145 + // Check whether the module name is set correctly.
146 + YangModule yangNode = (YangModule) node;
147 + assertThat(yangNode.getName(), is("Test"));
148 +
149 + // Check whether the description is set correctly.
150 + assertThat(yangNode.getDescription(), is("\"module description\""));
151 + assertThat(yangNode.getRevision().getDescription(), is("\"revision description\""));
152 + }
153 +
154 + /**
155 + * Checks description statement as sub-statement of container.
156 + */
157 + @Test
158 + public void processContainerSubStatementDescription() throws IOException, ParserException {
159 +
160 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementDescription.yang");
161 +
162 + // Check whether the data model tree returned is of type module.
163 + assertThat((node instanceof YangModule), is(true));
164 +
165 + // Check whether the node type is set properly to module.
166 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
167 +
168 + // Check whether the module name is set correctly.
169 + YangModule yangNode = (YangModule) node;
170 + assertThat(yangNode.getName(), is("Test"));
171 +
172 + // Check whether the description value is set correctly.
173 + YangContainer container = (YangContainer) yangNode.getChild();
174 + assertThat(container.getName(), is("valid"));
175 + assertThat(container.getDescription(), is("\"container description\""));
176 +
177 + // Check whether leaf properties as set correctly.
178 + ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
179 + YangLeaf leafInfo = leafIterator.next();
180 +
181 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
182 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
183 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
184 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
185 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
186 + assertThat(leafInfo.isMandatory(), is(true));
187 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
188 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
189 + }
190 +
191 + /**
192 + * Checks description statement as sub-statement of list.
193 + */
194 + @Test
195 + public void processListSubStatementDescription() throws IOException, ParserException {
196 +
197 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementDescription.yang");
198 +
199 + assertThat((node instanceof YangModule), is(true));
200 +
201 + // Check whether the node type is set properly to module.
202 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
203 +
204 + // Check whether the module name is set correctly.
205 + YangModule yangNode = (YangModule) node;
206 + assertThat(yangNode.getName(), is("Test"));
207 +
208 + // Check whether the list is child of module and description value is set correctly.
209 + YangList yangList = (YangList) yangNode.getChild();
210 + assertThat(yangList.getName(), is("valid"));
211 + assertThat(yangList.isConfig(), is(true));
212 + assertThat(yangList.getDescription(), is("\"list description\""));
213 +
214 + // Check whether leaf properties as set correctly.
215 + ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
216 + YangLeaf leafInfo = leafIterator.next();
217 +
218 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
219 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
220 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
221 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
222 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
223 + assertThat(leafInfo.isMandatory(), is(true));
224 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
225 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
226 + }
227 +
228 + /**
229 + * Checks valid description statement as sub-statement of leaf-list.
230 + */
231 + @Test
232 + public void processLeafListSubStatementDescription() throws IOException, ParserException {
233 +
234 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementDescription.yang");
235 +
236 + // Check whether the data model tree returned is of type module.
237 + assertThat((node instanceof YangModule), is(true));
238 +
239 + // Check whether the node type is set properly to module.
240 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
241 +
242 + // Check whether the module name is set correctly.
243 + YangModule yangNode = (YangModule) node;
244 + assertThat(yangNode.getName(), is("Test"));
245 +
246 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
247 + YangLeafList leafListInfo = leafListIterator.next();
248 +
249 + // Check whether description value is set correctly.
250 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
251 + assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
252 + }
253 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangModule;
24 +import org.onosproject.yangutils.datamodel.YangNode;
25 +import org.onosproject.yangutils.datamodel.YangNodeType;
26 +import org.onosproject.yangutils.datamodel.YangList;
27 +import org.onosproject.yangutils.parser.exceptions.ParserException;
28 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
29 +
30 +import java.io.IOException;
31 +import java.util.List;
32 +import java.util.ListIterator;
33 +
34 +import static org.hamcrest.MatcherAssert.assertThat;
35 +import static org.hamcrest.core.Is.is;
36 +
37 +/**
38 + * Test cases for key listener.
39 + */
40 +public class KeyListenerTest {
41 +
42 + @Rule
43 + public ExpectedException thrown = ExpectedException.none();
44 +
45 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
46 +
47 + /**
48 + * Checks key statement as sub-statement of list.
49 + */
50 + @Test
51 + public void processListSubStatementKey() throws IOException, ParserException {
52 +
53 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementKey.yang");
54 +
55 + assertThat((node instanceof YangModule), is(true));
56 +
57 + // Check whether the node type is set properly to module.
58 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
59 +
60 + // Check whether the module name is set correctly.
61 + YangModule yangNode = (YangModule) node;
62 + assertThat(yangNode.getName(), is("Test"));
63 +
64 + // Check whether the list is child of module
65 + YangList yangList = (YangList) yangNode.getChild();
66 + assertThat(yangList.getName(), is("valid"));
67 +
68 + ListIterator<String> keyList = yangList.getKeyList().listIterator();
69 + assertThat(keyList.next(), is("invalid-interval"));
70 + }
71 +
72 + /**
73 + * Check multiple key values.
74 + */
75 + @Test
76 + public void processMultipleKeyValues() throws IOException, ParserException {
77 +
78 + YangNode node = manager.getDataModel("src/test/resources/MultipleKeyValues.yang");
79 +
80 + assertThat((node instanceof YangModule), is(true));
81 +
82 + // Check whether the node type is set properly to module.
83 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
84 +
85 + // Check whether the module name is set correctly.
86 + YangModule yangNode = (YangModule) node;
87 + assertThat(yangNode.getName(), is("Test"));
88 +
89 + // Check whether the list is child of module
90 + YangList yangList = (YangList) yangNode.getChild();
91 + assertThat(yangList.getName(), is("valid"));
92 +
93 + List<String> keyList = yangList.getKeyList();
94 + assertThat(keyList.contains("ospf"), is(true));
95 + assertThat(keyList.contains("isis"), is(true));
96 + }
97 +
98 + /**
99 + * Checks key statement without statement end.
100 + */
101 + @Test
102 + public void processKeyWithoutStatementEnd() throws IOException, ParserException {
103 + thrown.expect(ParserException.class);
104 + thrown.expectMessage("mismatched input 'leaf' expecting {';', '+'}");
105 + YangNode node = manager.getDataModel("src/test/resources/KeyWithoutStatementEnd.yang");
106 + }
107 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeafList;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.parser.exceptions.ParserException;
32 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
33 +
34 +import java.io.IOException;
35 +import java.util.ListIterator;
36 +
37 +import static org.hamcrest.MatcherAssert.assertThat;
38 +import static org.hamcrest.core.Is.is;
39 +
40 +/**
41 + * Test cases for testing leaf-list listener.
42 + */
43 +public class LeafListListenerTest {
44 +
45 + @Rule
46 + public ExpectedException thrown = ExpectedException.none();
47 +
48 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
49 +
50 + /**
51 + * Checks all the values of leaf-list sub-statements are set
52 + * correctly.
53 + */
54 + @Test
55 + public void processLeafListSubStatements() throws IOException, ParserException {
56 +
57 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatements.yang");
58 +
59 + // Check whether the data model tree returned is of type module.
60 + assertThat((node instanceof YangModule), is(true));
61 +
62 + // Check whether the node type is set properly to module.
63 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
64 +
65 + // Check whether the module name is set correctly.
66 + YangModule yangNode = (YangModule) node;
67 + assertThat(yangNode.getName(), is("Test"));
68 +
69 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
70 + YangLeafList leafListInfo = leafListIterator.next();
71 +
72 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
73 + assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
74 + assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
75 + assertThat(leafListInfo.getUnits(), is("\"seconds\""));
76 + assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
77 + assertThat(leafListInfo.isConfig(), is(true));
78 + assertThat(leafListInfo.getMaxElelements(), is(3));
79 + assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
80 + assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
81 + }
82 +
83 + /**
84 + * Checks whether exception is thrown when leaf-list identifier
85 + * starts with digit.
86 + */
87 + @Test
88 + public void processLeafListInvalidIdentifier() throws IOException, ParserException {
89 + thrown.expect(ParserException.class);
90 + thrown.expectMessage("mismatched input '1invalid-interval' expecting IDENTIFIER");
91 + YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidIdentifier.yang");
92 + }
93 +
94 + /**
95 + * Checks whether exception is thrown when leaf-list keyword
96 + * is incorrect.
97 + */
98 + @Test
99 + public void processLeafListInvalidStatement() throws IOException, ParserException {
100 + thrown.expect(ParserException.class);
101 + thrown.expectMessage("mismatched input 'leaflist' expecting {'augment', 'choice', 'contact', 'container'," +
102 + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
103 + " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
104 + " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
105 + YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidStatement.yang");
106 + }
107 +
108 + /**
109 + * Checks whether exception is thrown when leaf-list keyword
110 + * without Left brace as per grammar.
111 + */
112 + @Test
113 + public void processLeafListWithoutLeftBrace() throws IOException, ParserException {
114 + thrown.expect(ParserException.class);
115 + thrown.expectMessage("missing '{' at 'type'");
116 + YangNode node = manager.getDataModel("src/test/resources/LeafListWithoutLeftBrace.yang");
117 + }
118 +
119 + /**
120 + * Checks whether exception is thrown when config statement
121 + * cardinality is not as per grammar.
122 + */
123 + @Test
124 + public void processLeafListConfigInvalidCardinality() throws IOException, ParserException {
125 + thrown.expect(ParserException.class);
126 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing.");
127 + YangNode node = manager.getDataModel("src/test/resources/LeafListConfigInvalidCardinality.yang");
128 + }
129 +
130 + /**
131 + * Checks whether exception is thrown when units statement
132 + * cardinality is not as per grammar.
133 + */
134 + @Test
135 + public void processLeafListUnitsInvalidCardinality() throws IOException, ParserException {
136 + thrown.expect(ParserException.class);
137 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing.");
138 + YangNode node = manager.getDataModel("src/test/resources/LeafListUnitsInvalidCardinality.yang");
139 + }
140 +
141 + /**
142 + * Checks leaf-list statement as sub-statement of container.
143 + */
144 + @Test
145 + public void processContainerSubStatementLeafList() throws IOException, ParserException {
146 +
147 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementLeafList.yang");
148 +
149 + // Check whether the data model tree returned is of type module.
150 + assertThat((node instanceof YangModule), is(true));
151 +
152 + // Check whether the node type is set properly to module.
153 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
154 +
155 + // Check whether the module name is set correctly.
156 + YangModule yangNode = (YangModule) node;
157 + assertThat(yangNode.getName(), is("Test"));
158 +
159 + //Check whether the container is child of module.
160 + YangContainer container = (YangContainer) yangNode.getChild();
161 + assertThat(container.getName(), is("valid"));
162 +
163 + // Check whether leaf-list properties as set correctly.
164 + ListIterator<YangLeafList> leafListIterator = container.getListOfLeafList().listIterator();
165 + YangLeafList leafListInfo = leafListIterator.next();
166 +
167 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
168 + assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
169 + assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
170 + assertThat(leafListInfo.getUnits(), is("\"seconds\""));
171 + assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
172 + assertThat(leafListInfo.isConfig(), is(true));
173 + assertThat(leafListInfo.getMinElements(), is(1));
174 + assertThat(leafListInfo.getMaxElelements(), is(2147483647));
175 + assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
176 + assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
177 + }
178 +
179 + /**
180 + * Checks leaf-list statement as sub-statement of list.
181 + */
182 + @Test
183 + public void processListSubStatementLeafList() throws IOException, ParserException {
184 +
185 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementLeafList.yang");
186 +
187 + assertThat((node instanceof YangModule), is(true));
188 +
189 + // Check whether the node type is set properly to module.
190 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
191 +
192 + // Check whether the module name is set correctly.
193 + YangModule yangNode = (YangModule) node;
194 + assertThat(yangNode.getName(), is("Test"));
195 +
196 + // Check whether the list is child of module
197 + YangList yangList = (YangList) yangNode.getChild();
198 + assertThat(yangList.getName(), is("valid"));
199 +
200 + // Check whether leaf-list properties as set correctly.
201 + ListIterator<YangLeafList> leafListIterator = yangList.getListOfLeafList().listIterator();
202 + YangLeafList leafListInfo = leafListIterator.next();
203 +
204 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
205 + assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
206 + assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
207 + assertThat(leafListInfo.getUnits(), is("\"seconds\""));
208 + assertThat(leafListInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
209 + assertThat(leafListInfo.isConfig(), is(true));
210 +
211 + assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
212 + assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
213 + }
214 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.parser.exceptions.ParserException;
32 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
33 +
34 +import java.io.IOException;
35 +import java.util.ListIterator;
36 +
37 +import static org.hamcrest.MatcherAssert.assertThat;
38 +import static org.hamcrest.core.Is.is;
39 +
40 +/**
41 + * Test cases for testing leaf listener.
42 + */
43 +public class LeafListenerTest {
44 +
45 + @Rule
46 + public ExpectedException thrown = ExpectedException.none();
47 +
48 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
49 +
50 + /**
51 + * Checks all the values of leaf sub-statements are set
52 + * correctly.
53 + */
54 + @Test
55 + public void processLeafSubStatements() throws IOException, ParserException {
56 +
57 + YangNode node = manager.getDataModel("src/test/resources/LeafSubStatements.yang");
58 +
59 + // Check whether the data model tree returned is of type module.
60 + assertThat((node instanceof YangModule), is(true));
61 +
62 + // Check whether the node type is set properly to module.
63 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
64 +
65 + // Check whether the module name is set correctly.
66 + YangModule yangNode = (YangModule) node;
67 + assertThat(yangNode.getName(), is("Test"));
68 +
69 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
70 + YangLeaf leafInfo = leafIterator.next();
71 +
72 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
73 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
74 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
75 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
76 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
77 + assertThat(leafInfo.isConfig(), is(true));
78 + assertThat(leafInfo.isMandatory(), is(true));
79 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
80 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
81 + }
82 +
83 + /**
84 + * Checks whether exception is thrown when leaf identifier
85 + * starts with digit.
86 + */
87 + @Test
88 + public void processLeafInvalidIdentifier() throws IOException, ParserException {
89 + thrown.expect(ParserException.class);
90 + thrown.expectMessage("mismatched input '1invalid-interval' expecting IDENTIFIER");
91 + YangNode node = manager.getDataModel("src/test/resources/LeafInvalidIdentifier.yang");
92 + }
93 +
94 + /**
95 + * Checks whether exception is thrown when leaf keyword
96 + * is incorrect.
97 + */
98 + @Test
99 + public void processLeafInvalidStatement() throws IOException, ParserException {
100 + thrown.expect(ParserException.class);
101 + thrown.expectMessage("mismatched input 'leafs' expecting {'augment', 'choice', 'contact', 'container'," +
102 + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
103 + " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
104 + " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
105 + YangNode node = manager.getDataModel("src/test/resources/LeafInvalidStatement.yang");
106 + }
107 +
108 + /**
109 + * Checks whether exception is thrown when leaf keyword
110 + * without Left brace as per grammar.
111 + */
112 + @Test
113 + public void processLeafWithoutLeftBrace() throws IOException, ParserException {
114 + thrown.expect(ParserException.class);
115 + thrown.expectMessage("missing '{' at 'type'");
116 + YangNode node = manager.getDataModel("src/test/resources/LeafWithoutLeftBrace.yang");
117 + }
118 +
119 + /**
120 + * Checks whether exception is thrown when config statement
121 + * cardinality is not as per grammar.
122 + */
123 + @Test
124 + public void processLeafConfigInvalidCardinality() throws IOException, ParserException {
125 + thrown.expect(ParserException.class);
126 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in config before processing.");
127 + YangNode node = manager.getDataModel("src/test/resources/LeafConfigInvalidCardinality.yang");
128 + }
129 +
130 + /**
131 + * Checks whether exception is thrown when mandatory statement
132 + * cardinality is not as per grammar.
133 + */
134 + @Test
135 + public void processLeafMandatoryInvalidCardinality() throws IOException, ParserException {
136 + thrown.expect(ParserException.class);
137 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in mandatory before processing.");
138 + YangNode node = manager.getDataModel("src/test/resources/LeafMandatoryInvalidCardinality.yang");
139 + }
140 +
141 + /**
142 + * Checks leaf statement as sub-statement of container.
143 + */
144 + @Test
145 + public void processContainerSubStatementLeaf() throws IOException, ParserException {
146 +
147 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementLeaf.yang");
148 +
149 + // Check whether the data model tree returned is of type module.
150 + assertThat((node instanceof YangModule), is(true));
151 +
152 + // Check whether the node type is set properly to module.
153 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
154 +
155 + // Check whether the module name is set correctly.
156 + YangModule yangNode = (YangModule) node;
157 + assertThat(yangNode.getName(), is("Test"));
158 +
159 + //Check whether the container is child of module.
160 + YangContainer container = (YangContainer) yangNode.getChild();
161 + assertThat(container.getName(), is("valid"));
162 +
163 + // Check whether leaf properties as set correctly.
164 + ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
165 + YangLeaf leafInfo = leafIterator.next();
166 +
167 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
168 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
169 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
170 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
171 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
172 + assertThat(leafInfo.isConfig(), is(true));
173 + assertThat(leafInfo.isMandatory(), is(true));
174 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
175 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
176 + }
177 +
178 + /**
179 + * Checks leaf statement as sub-statement of list.
180 + */
181 + @Test
182 + public void processListSubStatementLeaf() throws IOException, ParserException {
183 +
184 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementLeaf.yang");
185 +
186 + assertThat((node instanceof YangModule), is(true));
187 +
188 + // Check whether the node type is set properly to module.
189 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
190 +
191 + // Check whether the module name is set correctly.
192 + YangModule yangNode = (YangModule) node;
193 + assertThat(yangNode.getName(), is("Test"));
194 +
195 + // Check whether the list is child of module
196 + YangList yangList = (YangList) yangNode.getChild();
197 + assertThat(yangList.getName(), is("valid"));
198 +
199 + // Check whether leaf properties as set correctly.
200 + ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
201 + YangLeaf leafInfo = leafIterator.next();
202 +
203 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
204 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
205 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
206 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
207 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
208 + assertThat(leafInfo.isConfig(), is(true));
209 + assertThat(leafInfo.isMandatory(), is(true));
210 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
211 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
212 + }
213 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.parser.exceptions.ParserException;
32 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
33 +
34 +import java.io.IOException;
35 +import java.util.ListIterator;
36 +
37 +import static org.hamcrest.MatcherAssert.assertThat;
38 +import static org.hamcrest.core.Is.is;
39 +
40 +/**
41 + * Test cases for testing list listener.
42 + */
43 +public class ListListenerTest {
44 +
45 + @Rule
46 + public ExpectedException thrown = ExpectedException.none();
47 +
48 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
49 +
50 + /**
51 + * Checks list statement as sub-statement of module.
52 + */
53 + @Test
54 + public void processModuleSubStatementList() throws IOException, ParserException {
55 +
56 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementList.yang");
57 +
58 + assertThat((node instanceof YangModule), is(true));
59 +
60 + // Check whether the node type is set properly to module.
61 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
62 +
63 + // Check whether the module name is set correctly.
64 + YangModule yangNode = (YangModule) node;
65 + assertThat(yangNode.getName(), is("Test"));
66 +
67 + // Check whether the list is child of module
68 + YangList yangList = (YangList) yangNode.getChild();
69 + assertThat(yangList.getName(), is("valid"));
70 +
71 + ListIterator<String> keyList = yangList.getKeyList().listIterator();
72 + assertThat(keyList.next(), is("invalid"));
73 + }
74 +
75 + /**
76 + * Checks list statement as sub-statement of container.
77 + */
78 + @Test
79 + public void processContainerSubStatementList() throws IOException, ParserException {
80 +
81 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementList.yang");
82 +
83 + assertThat((node instanceof YangModule), is(true));
84 +
85 + // Check whether the node type is set properly to module.
86 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
87 +
88 + // Check whether the module name is set correctly.
89 + YangModule yangNode = (YangModule) node;
90 + assertThat(yangNode.getName(), is("Test"));
91 +
92 + // Check whether the container is child of module
93 + YangContainer yangContainer = (YangContainer) yangNode.getChild();
94 + assertThat(yangContainer.getName(), is("ospf"));
95 +
96 + // Check whether the list is child of container
97 + YangList yangList = (YangList) yangContainer.getChild();
98 + assertThat(yangList.getName(), is("valid"));
99 + assertThat(yangList.getKeyList().contains("invalid"), is(true));
100 + }
101 +
102 + /**
103 + * Checks list statement as sub-statement of list.
104 + */
105 + @Test
106 + public void processListSubStatementList() throws IOException, ParserException {
107 +
108 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementList.yang");
109 +
110 + assertThat((node instanceof YangModule), is(true));
111 +
112 + // Check whether the node type is set properly to module.
113 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
114 +
115 + // Check whether the module name is set correctly.
116 + YangModule yangNode = (YangModule) node;
117 + assertThat(yangNode.getName(), is("Test"));
118 +
119 + // Check whether the list is child of module
120 + YangList yangList1 = (YangList) yangNode.getChild();
121 + assertThat(yangList1.getName(), is("ospf"));
122 + assertThat(yangList1.getKeyList().contains("process-id"), is(true));
123 +
124 + // Check whether the list is child of list
125 + YangList yangList = (YangList) yangList1.getChild();
126 + assertThat(yangList.getName(), is("valid"));
127 + assertThat(yangList.getKeyList().contains("invalid"), is(true));
128 + }
129 +
130 + /**
131 + * Checks list with all its sub-statements.
132 + */
133 + @Test
134 + public void processListSubStatements() throws IOException, ParserException {
135 +
136 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatements.yang");
137 +
138 + assertThat((node instanceof YangModule), is(true));
139 +
140 + // Check whether the node type is set properly to module.
141 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
142 +
143 + // Check whether the module name is set correctly.
144 + YangModule yangNode = (YangModule) node;
145 + assertThat(yangNode.getName(), is("Test"));
146 +
147 + // Check whether the list is child of module
148 + YangList yangList = (YangList) yangNode.getChild();
149 +
150 + // Check whether list properties as set correctly.
151 + assertThat(yangList.getName(), is("ospf"));
152 + assertThat(yangList.getKeyList().contains("process-id"), is(true));
153 +
154 + assertThat(yangList.isConfig(), is(true));
155 + assertThat(yangList.getMaxElelements(), is(10));
156 + assertThat(yangList.getMinElements(), is(3));
157 + assertThat(yangList.getDescription(), is("\"list description\""));
158 + assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
159 + assertThat(yangList.getReference(), is("\"list reference\""));
160 +
161 + // Check whether leaf properties as set correctly.
162 + ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
163 + YangLeaf leafInfo = leafIterator.next();
164 +
165 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
166 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
167 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
168 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
169 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
170 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
171 + }
172 +
173 + /**
174 + * Checks cardinality of sub-statements of list.
175 + */
176 + @Test
177 + public void processListSubStatementsCardinality() throws IOException, ParserException {
178 + thrown.expect(ParserException.class);
179 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in reference before processing.");
180 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementsCardinality.yang");
181 + }
182 +
183 + /**
184 + * Checks list statement without child.
185 + */
186 + @Test
187 + public void processListStatementWithoutChild() throws IOException, ParserException {
188 + thrown.expect(ParserException.class);
189 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in list before processing.");
190 + YangNode node = manager.getDataModel("src/test/resources/ListStatementWithoutChild.yang");
191 + }
192 +
193 + /**
194 + * Checks list as root node.
195 + */
196 + @Test
197 + public void processListAsRootNode() throws IOException, ParserException {
198 + thrown.expect(ParserException.class);
199 + thrown.expectMessage("no viable alternative at input 'list'");
200 + YangNode node = manager.getDataModel("src/test/resources/ListAsRootNode.yang");
201 + }
202 +
203 + /**
204 + * Checks invalid identifier for list statement.
205 + */
206 + @Test
207 + public void processListInvalidIdentifier() throws IOException, ParserException {
208 + thrown.expect(ParserException.class);
209 + thrown.expectMessage("mismatched input '1valid' expecting IDENTIFIER");
210 + YangNode node = manager.getDataModel("src/test/resources/ListInvalidIdentifier.yang");
211 + }
212 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +import org.junit.rules.ExpectedException;
22 +import org.onosproject.yangutils.datamodel.YangNode;
23 +import org.onosproject.yangutils.datamodel.YangNodeType;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangLeaf;
26 +import org.onosproject.yangutils.parser.exceptions.ParserException;
27 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
28 +
29 +import java.io.IOException;
30 +import java.util.ListIterator;
31 +
32 +import static org.hamcrest.MatcherAssert.assertThat;
33 +import static org.hamcrest.core.Is.is;
34 +
35 +/**
36 + * Test case for mandatory listener.
37 + */
38 +public class MandatoryListenerTest {
39 +
40 + @Rule
41 + public ExpectedException thrown = ExpectedException.none();
42 +
43 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
44 +
45 + /**
46 + * Checks valid mandatory with value true statement.
47 + */
48 + @Test
49 + public void processMandatoryTrue() throws IOException, ParserException {
50 +
51 + YangNode node = manager.getDataModel("src/test/resources/MandatoryTrue.yang");
52 +
53 + // Check whether the data model tree returned is of type module.
54 + assertThat((node instanceof YangModule), is(true));
55 +
56 + // Check whether the node type is set properly to module.
57 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
58 +
59 + // Check whether the module name is set correctly.
60 + YangModule yangNode = (YangModule) node;
61 + assertThat(yangNode.getName(), is("Test"));
62 +
63 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
64 + YangLeaf leafInfo = leafIterator.next();
65 +
66 + // Check whether the mandatory value is set correctly.
67 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
68 + assertThat(leafInfo.isMandatory(), is(true));
69 + }
70 +
71 + /**
72 + * Checks valid mandatory with value false statement.
73 + */
74 + @Test
75 + public void processMandatoryFalse() throws IOException, ParserException {
76 +
77 + YangNode node = manager.getDataModel("src/test/resources/MandatoryFalse.yang");
78 +
79 + // Check whether the data model tree returned is of type module.
80 + assertThat((node instanceof YangModule), is(true));
81 +
82 + // Check whether the node type is set properly to module.
83 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
84 +
85 + // Check whether the module name is set correctly.
86 + YangModule yangNode = (YangModule) node;
87 + assertThat(yangNode.getName(), is("Test"));
88 +
89 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
90 + YangLeaf leafInfo = leafIterator.next();
91 +
92 + // Check whether the mandatory value is set correctly.
93 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
94 + assertThat(leafInfo.isMandatory(), is(false));
95 + }
96 +
97 + /**
98 + * Checks default value of mandatory statement.
99 + */
100 + @Test
101 + public void processMandatoryDefaultValue() throws IOException, ParserException {
102 +
103 + YangNode node = manager.getDataModel("src/test/resources/MandatoryDefaultValue.yang");
104 +
105 + // Check whether the data model tree returned is of type module.
106 + assertThat((node instanceof YangModule), is(true));
107 +
108 + // Check whether the node type is set properly to module.
109 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
110 +
111 + // Check whether the module name is set correctly.
112 + YangModule yangNode = (YangModule) node;
113 + assertThat(yangNode.getName(), is("Test"));
114 +
115 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
116 + YangLeaf leafInfo = leafIterator.next();
117 +
118 + // Check whether the mandatory value is set correctly.
119 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
120 + assertThat(leafInfo.isMandatory(), is(false));
121 + }
122 +
123 + /**
124 + * Checks invalid of mandatory statement and expects exception.
125 + */
126 + @Test
127 + public void processMandatoryEmptyStatement() throws IOException, ParserException {
128 + thrown.expect(ParserException.class);
129 + thrown.expectMessage("missing {'false', 'true'} at ';'");
130 + YangNode node = manager.getDataModel("src/test/resources/MandatoryEmptyStatement.yang");
131 + }
132 +
133 + /**
134 + * Checks invalid mandatory statement(without statement end) and expects exception.
135 + */
136 + @Test
137 + public void processMandatoryWithoutStatementEnd() throws IOException, ParserException {
138 + thrown.expect(ParserException.class);
139 + thrown.expectMessage("missing ';' at '}'");
140 + YangNode node = manager.getDataModel("src/test/resources/MandatoryWithoutStatementEnd.yang");
141 + }
142 +
143 + /**
144 + * Checks mandatory statement as sub-statement of module and expects exception.
145 + */
146 + @Test
147 + public void processModuleSubStatementMandatory() throws IOException, ParserException {
148 + thrown.expect(ParserException.class);
149 + thrown.expectMessage("mismatched input 'mandatory' expecting {'augment', 'choice', 'contact', 'container'," +
150 + " 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
151 + " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference'," +
152 + " 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
153 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementMandatory.yang");
154 + }
155 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeafList;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangList;
28 +import org.onosproject.yangutils.parser.exceptions.ParserException;
29 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
30 +
31 +import java.io.IOException;
32 +import java.util.ListIterator;
33 +
34 +import static org.hamcrest.MatcherAssert.assertThat;
35 +import static org.hamcrest.core.Is.is;
36 +
37 +/**
38 + * Test cases for testing max-elements listener.
39 + */
40 +public class MaxElementsListenerTest {
41 +
42 + @Rule
43 + public ExpectedException thrown = ExpectedException.none();
44 +
45 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
46 +
47 + /**
48 + * Checks max-elements as sub-statements of leaf-list.
49 + */
50 + @Test
51 + public void processLeafListSubStatementMaxElements() throws IOException, ParserException {
52 +
53 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementMaxElements.yang");
54 +
55 + // Check whether the data model tree returned is of type module.
56 + assertThat((node instanceof YangModule), is(true));
57 +
58 + // Check whether the node type is set properly to module.
59 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
60 +
61 + // Check whether the module name is set correctly.
62 + YangModule yangNode = (YangModule) node;
63 + assertThat(yangNode.getName(), is("Test"));
64 +
65 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
66 + YangLeafList leafListInfo = leafListIterator.next();
67 +
68 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
69 + assertThat(leafListInfo.getMaxElelements(), is(3));
70 + }
71 +
72 + /**
73 + * Checks max-elements as sub-statements of list.
74 + */
75 + @Test
76 + public void processListSubStatementMaxElements() throws IOException, ParserException {
77 +
78 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementMaxElements.yang");
79 +
80 + assertThat((node instanceof YangModule), is(true));
81 +
82 + // Check whether the node type is set properly to module.
83 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
84 +
85 + // Check whether the module name is set correctly.
86 + YangModule yangNode = (YangModule) node;
87 + assertThat(yangNode.getName(), is("Test"));
88 +
89 + // Check whether the list is child of module
90 + YangList yangList = (YangList) yangNode.getChild();
91 + assertThat(yangList.getName(), is("valid"));
92 + assertThat(yangList.getMaxElelements(), is(3));
93 + }
94 +
95 + /**
96 + * Checks whether exception is thrown when invalid max-elements keyword
97 + * is given as input.
98 + */
99 + @Test
100 + public void processMaxElementsInvalidStatement() throws IOException, ParserException {
101 + thrown.expect(ParserException.class);
102 + thrown.expectMessage("extraneous input 'max-element' expecting {'config', 'description', 'if-feature'," +
103 + " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units', " +
104 + "'when', '}'}");
105 + YangNode node = manager.getDataModel("src/test/resources/MaxElementsInvalidStatement.yang");
106 + }
107 +
108 + /**
109 + * Checks whether exception is thrown when max-elements statement without statement
110 + * end is given as input.
111 + */
112 + @Test
113 + public void processMaxElementsWithoutStatementEnd() throws IOException, ParserException {
114 + thrown.expect(ParserException.class);
115 + thrown.expectMessage("missing ';' at 'description'");
116 + YangNode node = manager.getDataModel("src/test/resources/MaxElementsWithoutStatementEnd.yang");
117 + }
118 +
119 + /**
120 + * Checks whether exception is thrown when max-elements cardinality is not
121 + * as per the grammar.
122 + */
123 + @Test
124 + public void processMaxElementsCardinality() throws IOException, ParserException {
125 + thrown.expect(ParserException.class);
126 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in max-elements before processing.");
127 + YangNode node = manager.getDataModel("src/test/resources/MaxElementsCardinality.yang");
128 + }
129 +
130 + /**
131 + * Checks unbounded value of max-elements statement.
132 + */
133 + @Test
134 + public void processMaxElementsUnbounded() throws IOException, ParserException {
135 +
136 + YangNode node = manager.getDataModel("src/test/resources/MaxElementsUnbounded.yang");
137 +
138 + // Check whether the data model tree returned is of type module.
139 + assertThat((node instanceof YangModule), is(true));
140 +
141 + // Check whether the node type is set properly to module.
142 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
143 +
144 + // Check whether the module name is set correctly.
145 + YangModule yangNode = (YangModule) node;
146 + assertThat(yangNode.getName(), is("Test"));
147 +
148 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
149 + YangLeafList leafListInfo = leafListIterator.next();
150 +
151 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
152 + assertThat(leafListInfo.getMaxElelements(), is(2147483647));
153 + }
154 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeafList;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangList;
28 +import org.onosproject.yangutils.parser.exceptions.ParserException;
29 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
30 +
31 +import java.io.IOException;
32 +import java.util.ListIterator;
33 +
34 +import static org.hamcrest.MatcherAssert.assertThat;
35 +import static org.hamcrest.core.Is.is;
36 +
37 +/**
38 + * Test cases for testing min-elements listener.
39 + */
40 +public class MinElementsListenerTest {
41 +
42 + @Rule
43 + public ExpectedException thrown = ExpectedException.none();
44 +
45 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
46 +
47 + /**
48 + * Checks min-elements as sub-statements of leaf-list.
49 + */
50 + @Test
51 + public void processLeafListSubStatementMinElements() throws IOException, ParserException {
52 +
53 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementMinElements.yang");
54 +
55 + // Check whether the data model tree returned is of type module.
56 + assertThat((node instanceof YangModule), is(true));
57 +
58 + // Check whether the node type is set properly to module.
59 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
60 +
61 + // Check whether the module name is set correctly.
62 + YangModule yangNode = (YangModule) node;
63 + assertThat(yangNode.getName(), is("Test"));
64 +
65 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
66 + YangLeafList leafListInfo = leafListIterator.next();
67 +
68 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
69 + assertThat(leafListInfo.getMinElements(), is(3));
70 + }
71 +
72 + /**
73 + * Checks min-elements as sub-statements of list.
74 + */
75 + @Test
76 + public void processListSubStatementMinElements() throws IOException, ParserException {
77 +
78 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementMinElements.yang");
79 +
80 + assertThat((node instanceof YangModule), is(true));
81 +
82 + // Check whether the node type is set properly to module.
83 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
84 +
85 + // Check whether the module name is set correctly.
86 + YangModule yangNode = (YangModule) node;
87 + assertThat(yangNode.getName(), is("Test"));
88 +
89 + // Check whether the list is child of module
90 + YangList yangList = (YangList) yangNode.getChild();
91 + assertThat(yangList.getName(), is("valid"));
92 + assertThat(yangList.getMinElements(), is(3));
93 + }
94 +
95 + /**
96 + * Checks whether exception is thrown when invalid min-elements keyword
97 + * is given as input.
98 + */
99 + @Test
100 + public void processMinElementsInvalidKeyword() throws IOException, ParserException {
101 + thrown.expect(ParserException.class);
102 + thrown.expectMessage("extraneous input 'min-element' expecting {'config', 'description', 'if-feature'," +
103 + " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units'," +
104 + " 'when', '}'}");
105 + YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidKeyword.yang");
106 + }
107 +
108 + /**
109 + * Checks whether exception is thrown when invalid min-elements value
110 + * is given as input.
111 + */
112 + @Test
113 + public void processMinElementsInvalidValue() throws IOException, ParserException {
114 + thrown.expect(ParserException.class);
115 + thrown.expectMessage("mismatched input 'asd' expecting INTEGER");
116 + YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidValue.yang");
117 + }
118 +
119 + /**
120 + * Checks whether exception is thrown when min-elements statement without statement
121 + * end is given as input.
122 + */
123 + @Test
124 + public void processMinElementsWithoutStatementEnd() throws IOException, ParserException {
125 + thrown.expect(ParserException.class);
126 + thrown.expectMessage("missing ';' at 'description'");
127 + YangNode node = manager.getDataModel("src/test/resources/MinElementsWithoutStatementEnd.yang");
128 + }
129 +
130 + /**
131 + * Checks whether exception is thrown when min-elements cardinality is not
132 + * as per the grammar.
133 + */
134 + @Test
135 + public void processMinElementsInvalidCardinality() throws IOException, ParserException {
136 + thrown.expect(ParserException.class);
137 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in" +
138 + " min-elements before processing.");
139 + YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidCardinality.yang");
140 + }
141 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangModule;
24 +import org.onosproject.yangutils.datamodel.YangNode;
25 +import org.onosproject.yangutils.datamodel.YangNodeType;
26 +import org.onosproject.yangutils.datamodel.YangContainer;
27 +import org.onosproject.yangutils.parser.exceptions.ParserException;
28 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
29 +
30 +import java.io.IOException;
31 +
32 +import static org.hamcrest.MatcherAssert.assertThat;
33 +import static org.hamcrest.Matchers.is;
34 +import static org.hamcrest.Matchers.nullValue;
35 +
36 +/**
37 + * Test cases for presence listener.
38 + */
39 +public class PresenceListenerTest {
40 +
41 + @Rule
42 + public ExpectedException thrown = ExpectedException.none();
43 +
44 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
45 +
46 + /**
47 + * Checks presence statement as sub-statement of container.
48 + */
49 + @Test
50 + public void processContainerSubStatementPresence() throws IOException, ParserException {
51 +
52 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementPresence.yang");
53 +
54 + assertThat((node instanceof YangModule), is(true));
55 +
56 + // Check whether the node type is set properly to module.
57 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
58 +
59 + // Check whether the module name is set correctly.
60 + YangModule yangNode = (YangModule) node;
61 + assertThat(yangNode.getName(), is("Test"));
62 +
63 + // Check whether the list is child of module
64 + YangContainer yangContainer = (YangContainer) yangNode.getChild();
65 + assertThat(yangContainer.getName(), is("valid"));
66 + assertThat(yangContainer.getPresence(), is("\"invalid\""));
67 + }
68 +
69 + /**
70 + * checks default value of presence statement.
71 + */
72 + @Test
73 + public void processPresenceDefaultValue() throws IOException, ParserException {
74 +
75 + YangNode node = manager.getDataModel("src/test/resources/PresenceDefaultValue.yang");
76 +
77 + assertThat((node instanceof YangModule), is(true));
78 +
79 + // Check whether the node type is set properly to module.
80 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
81 +
82 + // Check whether the module name is set correctly.
83 + YangModule yangNode = (YangModule) node;
84 + assertThat(yangNode.getName(), is("Test"));
85 +
86 + // Check whether the list is child of module
87 + YangContainer yangContainer = (YangContainer) yangNode.getChild();
88 + assertThat(yangContainer.getName(), is("valid"));
89 + assertThat(yangContainer.getPresence(), is(nullValue()));
90 + }
91 +
92 + /**
93 + * Checks presence statement without statement end.
94 + */
95 + @Test
96 + public void processPresenceWithoutStatementEnd() throws IOException, ParserException {
97 + thrown.expect(ParserException.class);
98 + thrown.expectMessage("mismatched input 'leaf' expecting {';', '+'}");
99 + YangNode node = manager.getDataModel("src/test/resources/PresenceWithoutStatementEnd.yang");
100 + }
101 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.datamodel.YangLeafList;
32 +import org.onosproject.yangutils.parser.exceptions.ParserException;
33 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
34 +
35 +import java.io.IOException;
36 +import java.util.ListIterator;
37 +
38 +import static org.hamcrest.MatcherAssert.assertThat;
39 +import static org.hamcrest.core.Is.is;
40 +
41 +/**
42 + * Test case for reference listener.
43 + */
44 +public class ReferenceListenerTest {
45 +
46 + @Rule
47 + public ExpectedException thrown = ExpectedException.none();
48 +
49 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
50 +
51 + /**
52 + * Checks valid reference statement.
53 + */
54 + @Test
55 + public void processReferenceStatement() throws IOException, ParserException {
56 +
57 + YangNode node = manager.getDataModel("src/test/resources/ReferenceStatement.yang");
58 +
59 + // Check whether the data model tree returned is of type module.
60 + assertThat((node instanceof YangModule), is(true));
61 +
62 + // Check whether the node type is set properly to module.
63 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
64 +
65 + // Check whether the module name is set correctly.
66 + YangModule yangNode = (YangModule) node;
67 + assertThat(yangNode.getName(), is("Test"));
68 +
69 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
70 + YangLeaf leafInfo = leafIterator.next();
71 +
72 + // Check whether the reference is set correctly.
73 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
74 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
75 + }
76 +
77 + /**
78 + * Checks whether exception is thrown for invalid reference statement.
79 + */
80 + @Test
81 + public void processReferenceWithoutStatementEnd() throws IOException, ParserException {
82 + thrown.expect(ParserException.class);
83 + thrown.expectMessage("mismatched input '}' expecting {';', '+'}");
84 + YangNode node = manager.getDataModel("src/test/resources/ReferenceWithoutStatementEnd.yang");
85 + }
86 +
87 + /**
88 + * Checks valid reference statement under module.
89 + */
90 + @Test
91 + public void processModuleSubStatementReference() throws IOException, ParserException {
92 +
93 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementReference.yang");
94 +
95 + // Check whether the data model tree returned is of type module.
96 + assertThat((node instanceof YangModule), is(true));
97 +
98 + // Check whether the node type is set properly to module.
99 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
100 +
101 + // Check whether the module name is set correctly.
102 + YangModule yangNode = (YangModule) node;
103 + assertThat(yangNode.getName(), is("Test"));
104 +
105 + // Check whether the reference is set correctly.
106 + assertThat(yangNode.getReference(), is("\"RFC 6020\""));
107 + }
108 +
109 + /**
110 + * Checks valid reference statement under module.
111 + */
112 + @Test
113 + public void processReferenceEmptyStatement() throws IOException, ParserException {
114 +
115 + YangNode node = manager.getDataModel("src/test/resources/ReferenceEmptyStatement.yang");
116 +
117 + // Check whether the data model tree returned is of type module.
118 + assertThat((node instanceof YangModule), is(true));
119 +
120 + // Check whether the node type is set properly to module.
121 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
122 +
123 + // Check whether the module name is set correctly.
124 + YangModule yangNode = (YangModule) node;
125 + assertThat(yangNode.getName(), is("Test"));
126 +
127 + // Check whether the reference is set correctly.
128 + assertThat(yangNode.getReference(), is("\"\""));
129 + }
130 +
131 + /**
132 + * Checks valid reference statement as sub-statement of revision.
133 + */
134 + @Test
135 + public void processRevisionSubStatementReference() throws IOException, ParserException {
136 +
137 + YangNode node = manager.getDataModel("src/test/resources/RevisionSubStatementReference.yang");
138 +
139 + // Check whether the data model tree returned is of type module.
140 + assertThat((node instanceof YangModule), is(true));
141 +
142 + // Check whether the node type is set properly to module.
143 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
144 +
145 + // Check whether the module name is set correctly.
146 + YangModule yangNode = (YangModule) node;
147 + assertThat(yangNode.getName(), is("Test"));
148 +
149 + // Check whether the reference is set correctly.
150 + assertThat(yangNode.getRevision().getReference(), is("\"revision reference\""));
151 + }
152 +
153 + /**
154 + * Checks reference statement as sub-statement of container.
155 + */
156 + @Test
157 + public void processContainerSubStatementReference() throws IOException, ParserException {
158 +
159 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementReference.yang");
160 +
161 + // Check whether the data model tree returned is of type module.
162 + assertThat((node instanceof YangModule), is(true));
163 +
164 + // Check whether the node type is set properly to module.
165 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
166 +
167 + // Check whether the module name is set correctly.
168 + YangModule yangNode = (YangModule) node;
169 + assertThat(yangNode.getName(), is("Test"));
170 +
171 + // Check whether the reference value is set correctly.
172 + YangContainer container = (YangContainer) yangNode.getChild();
173 + assertThat(container.getName(), is("valid"));
174 + assertThat(container.getReference(), is("\"container reference\""));
175 +
176 + // Check whether leaf properties as set correctly.
177 + ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
178 + YangLeaf leafInfo = leafIterator.next();
179 +
180 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
181 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
182 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
183 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
184 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
185 + assertThat(leafInfo.isMandatory(), is(true));
186 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
187 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
188 + }
189 +
190 + /**
191 + * Checks reference statement as sub-statement of list.
192 + */
193 + @Test
194 + public void processListSubStatementReference() throws IOException, ParserException {
195 +
196 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementReference.yang");
197 +
198 + assertThat((node instanceof YangModule), is(true));
199 +
200 + // Check whether the node type is set properly to module.
201 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
202 +
203 + // Check whether the module name is set correctly.
204 + YangModule yangNode = (YangModule) node;
205 + assertThat(yangNode.getName(), is("Test"));
206 +
207 + // Check whether the list is child of module and description value is set correctly.
208 + YangList yangList = (YangList) yangNode.getChild();
209 + assertThat(yangList.getName(), is("valid"));
210 + assertThat(yangList.isConfig(), is(true));
211 + assertThat(yangList.getReference(), is("\"list reference\""));
212 +
213 + // Check whether leaf properties as set correctly.
214 + ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
215 + YangLeaf leafInfo = leafIterator.next();
216 +
217 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
218 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
219 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
220 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
221 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
222 + assertThat(leafInfo.isMandatory(), is(true));
223 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
224 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
225 + }
226 +
227 + /**
228 + * Checks valid reference statement as sub-statement of leaf-list.
229 + */
230 + @Test
231 + public void processLeafListSubStatementReference() throws IOException, ParserException {
232 +
233 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementReference.yang");
234 +
235 + // Check whether the data model tree returned is of type module.
236 + assertThat((node instanceof YangModule), is(true));
237 +
238 + // Check whether the node type is set properly to module.
239 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
240 +
241 + // Check whether the module name is set correctly.
242 + YangModule yangNode = (YangModule) node;
243 + assertThat(yangNode.getName(), is("Test"));
244 +
245 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
246 + YangLeafList leafListInfo = leafListIterator.next();
247 +
248 + // Check whether description value is set correctly.
249 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
250 + assertThat(leafListInfo.getReference(), is("\"RFC 6020\""));
251 + }
252 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangDataTypes;
28 +import org.onosproject.yangutils.datamodel.YangStatusType;
29 +import org.onosproject.yangutils.datamodel.YangContainer;
30 +import org.onosproject.yangutils.datamodel.YangList;
31 +import org.onosproject.yangutils.datamodel.YangLeafList;
32 +import org.onosproject.yangutils.parser.exceptions.ParserException;
33 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
34 +
35 +import java.io.IOException;
36 +import java.util.ListIterator;
37 +
38 +import static org.hamcrest.MatcherAssert.assertThat;
39 +import static org.hamcrest.core.Is.is;
40 +
41 +/**
42 + * Test cases for status listener.
43 + */
44 +public class StatusListenerTest {
45 +
46 + @Rule
47 + public ExpectedException thrown = ExpectedException.none();
48 +
49 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
50 +
51 + /**
52 + * Checks valid status statement.
53 + */
54 + @Test
55 + public void processStatusStatementCurrent() throws IOException, ParserException {
56 +
57 + YangNode node = manager.getDataModel("src/test/resources/StatusStatementCurrent.yang");
58 +
59 + // Check whether the data model tree returned is of type module.
60 + assertThat((node instanceof YangModule), is(true));
61 +
62 + // Check whether the node type is set properly to module.
63 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
64 +
65 + // Check whether the module name is set correctly.
66 + YangModule yangNode = (YangModule) node;
67 + assertThat(yangNode.getName(), is("Test"));
68 +
69 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
70 + YangLeaf leafInfo = leafIterator.next();
71 +
72 + // Check whether the status is set correctly.
73 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
74 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
75 + }
76 +
77 + /**
78 + * Checks valid status statement.
79 + */
80 + @Test
81 + public void processStatusStatementDeprecated() throws IOException, ParserException {
82 +
83 + YangNode node = manager.getDataModel("src/test/resources/StatusStatementDeprecated.yang");
84 +
85 + // Check whether the data model tree returned is of type module.
86 + assertThat((node instanceof YangModule), is(true));
87 +
88 + // Check whether the node type is set properly to module.
89 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
90 +
91 + // Check whether the module name is set correctly.
92 + YangModule yangNode = (YangModule) node;
93 + assertThat(yangNode.getName(), is("Test"));
94 +
95 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
96 + YangLeaf leafInfo = leafIterator.next();
97 +
98 + // Check whether the status is set correctly.
99 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
100 + assertThat(leafInfo.getStatus(), is(YangStatusType.DEPRECATED));
101 + }
102 +
103 + /**
104 + * Checks valid status statement.
105 + */
106 + @Test
107 + public void processStatusStatementObsolete() throws IOException, ParserException {
108 +
109 + YangNode node = manager.getDataModel("src/test/resources/StatusStatementObsolete.yang");
110 +
111 + // Check whether the data model tree returned is of type module.
112 + assertThat((node instanceof YangModule), is(true));
113 +
114 + // Check whether the node type is set properly to module.
115 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
116 +
117 + // Check whether the module name is set correctly.
118 + YangModule yangNode = (YangModule) node;
119 + assertThat(yangNode.getName(), is("Test"));
120 +
121 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
122 + YangLeaf leafInfo = leafIterator.next();
123 +
124 + // Check whether the status is set correctly.
125 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
126 + assertThat(leafInfo.getStatus(), is(YangStatusType.OBSOLETE));
127 + }
128 +
129 + /**
130 + * Checks whether exception is thrown for invalid status statement.
131 + */
132 + @Test
133 + public void processStatusWithoutStatementEnd() throws IOException, ParserException {
134 + thrown.expect(ParserException.class);
135 + thrown.expectMessage("missing ';' at '}'");
136 + YangNode node = manager.getDataModel("src/test/resources/StatusWithoutStatementEnd.yang");
137 + }
138 +
139 + /**
140 + * Checks whether exception is thrown for invalid status statement.
141 + */
142 + @Test
143 + public void processStatusInvalidValue() throws IOException, ParserException {
144 + thrown.expect(ParserException.class);
145 + thrown.expectMessage("mismatched input 'invalid' expecting {'current', 'deprecated', 'obsolete'}");
146 + YangNode node = manager.getDataModel("src/test/resources/StatusInvalidValue.yang");
147 + }
148 +
149 + /**
150 + * Checks status statement as sub-statement of module.
151 + */
152 + @Test
153 + public void processModuleSubStatementStatus() throws IOException, ParserException {
154 + thrown.expect(ParserException.class);
155 + thrown.expectMessage("mismatched input 'status' expecting {'augment', 'choice', 'contact', 'container', " +
156 + "'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', 'include'," +
157 + " 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', 'prefix', 'reference', " +
158 + "'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
159 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementStatus.yang");
160 + }
161 +
162 + /**
163 + * Checks status statement as sub-statement of container.
164 + */
165 + @Test
166 + public void processContainerSubStatementStatus() throws IOException, ParserException {
167 +
168 + YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatementStatus.yang");
169 +
170 + // Check whether the data model tree returned is of type module.
171 + assertThat((node instanceof YangModule), is(true));
172 +
173 + // Check whether the node type is set properly to module.
174 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
175 +
176 + // Check whether the module name is set correctly.
177 + YangModule yangNode = (YangModule) node;
178 + assertThat(yangNode.getName(), is("Test"));
179 +
180 + // Check whether status is set correctly.
181 + YangContainer container = (YangContainer) yangNode.getChild();
182 + assertThat(container.getName(), is("valid"));
183 + assertThat(container.isConfig(), is(true));
184 + assertThat(container.getStatus(), is(YangStatusType.OBSOLETE));
185 +
186 + // Check whether leaf properties as set correctly.
187 + ListIterator<YangLeaf> leafIterator = container.getListOfLeaf().listIterator();
188 + YangLeaf leafInfo = leafIterator.next();
189 +
190 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
191 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
192 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
193 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
194 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
195 + assertThat(leafInfo.isMandatory(), is(true));
196 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
197 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
198 + }
199 +
200 + /**
201 + * Checks status statement as sub-statement of list.
202 + */
203 + @Test
204 + public void processListSubStatementStatus() throws IOException, ParserException {
205 +
206 + YangNode node = manager.getDataModel("src/test/resources/ListSubStatementStatus.yang");
207 +
208 + assertThat((node instanceof YangModule), is(true));
209 +
210 + // Check whether the node type is set properly to module.
211 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
212 +
213 + // Check whether the module name is set correctly.
214 + YangModule yangNode = (YangModule) node;
215 + assertThat(yangNode.getName(), is("Test"));
216 +
217 + // Check whether the list is child of module and status is set.
218 + YangList yangList = (YangList) yangNode.getChild();
219 + assertThat(yangList.getName(), is("valid"));
220 + assertThat(yangList.isConfig(), is(true));
221 + assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
222 +
223 + // Check whether leaf properties as set correctly.
224 + ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
225 + YangLeaf leafInfo = leafIterator.next();
226 +
227 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
228 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
229 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
230 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
231 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
232 + assertThat(leafInfo.isMandatory(), is(true));
233 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
234 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
235 + }
236 +
237 + /**
238 + * Checks valid status statement as sub-statement of leaf-list.
239 + */
240 + @Test
241 + public void processLeafListSubStatementStatus() throws IOException, ParserException {
242 +
243 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementStatus.yang");
244 +
245 + // Check whether the data model tree returned is of type module.
246 + assertThat((node instanceof YangModule), is(true));
247 +
248 + // Check whether the node type is set properly to module.
249 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
250 +
251 + // Check whether the module name is set correctly.
252 + YangModule yangNode = (YangModule) node;
253 + assertThat(yangNode.getName(), is("Test"));
254 +
255 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
256 + YangLeafList leafListInfo = leafListIterator.next();
257 +
258 + // Check whether status is set correctly.
259 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
260 + assertThat(leafListInfo.isConfig(), is(true));
261 + assertThat(leafListInfo.getStatus(), is(YangStatusType.CURRENT));
262 + }
263 +}
...\ No newline at end of file ...\ No newline at end of file
1 +package org.onosproject.yangutils.parser.impl.listeners;
2 +
3 +import org.junit.Test;
4 +import org.onosproject.yangutils.datamodel.YangLeaf;
5 +import org.onosproject.yangutils.datamodel.YangModule;
6 +import org.onosproject.yangutils.datamodel.YangNode;
7 +import org.onosproject.yangutils.datamodel.YangNodeType;
8 +import org.onosproject.yangutils.datamodel.YangDataTypes;
9 +import org.onosproject.yangutils.datamodel.YangLeafList;
10 +import org.onosproject.yangutils.parser.exceptions.ParserException;
11 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
12 +
13 +import java.io.IOException;
14 +import java.util.ListIterator;
15 +
16 +import static org.hamcrest.MatcherAssert.assertThat;
17 +import static org.hamcrest.core.Is.is;
18 +
19 +/**
20 + * Test case for type listener.
21 + */
22 +public class TypeListenerTest {
23 +
24 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
25 +
26 + /**
27 + * Checks derived statement without contraints.
28 + */
29 + @Test
30 + public void processDerivedTypeStatement() throws IOException, ParserException {
31 +
32 + YangNode node = manager.getDataModel("src/test/resources/DerivedTypeStatement.yang");
33 +
34 + // Check whether the data model tree returned is of type module.
35 + assertThat((node instanceof YangModule), is(true));
36 +
37 + // Check whether the node type is set properly to module.
38 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
39 +
40 + // Check whether the module name is set correctly.
41 + YangModule yangNode = (YangModule) node;
42 + assertThat(yangNode.getName(), is("Test"));
43 +
44 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
45 + YangLeaf leafInfo = leafIterator.next();
46 +
47 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
48 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"hello\""));
49 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
50 + }
51 +
52 + /**
53 + * Checks valid yang data type.
54 + */
55 + @Test
56 + public void processIntegerTypeStatement() throws IOException, ParserException {
57 +
58 + YangNode node = manager.getDataModel("src/test/resources/IntegerTypeStatement.yang");
59 +
60 + // Check whether the data model tree returned is of type module.
61 + assertThat((node instanceof YangModule), is(true));
62 +
63 + // Check whether the node type is set properly to module.
64 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
65 +
66 + // Check whether the module name is set correctly.
67 + YangModule yangNode = (YangModule) node;
68 + assertThat(yangNode.getName(), is("Test"));
69 +
70 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
71 + YangLeaf leafInfo = leafIterator.next();
72 +
73 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
74 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
75 + assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
76 + }
77 +
78 + /**
79 + * Checks type for leaf-list.
80 + */
81 + @Test
82 + public void processLeafListSubStatementType() throws IOException, ParserException {
83 +
84 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementType.yang");
85 +
86 + // Check whether the data model tree returned is of type module.
87 + assertThat((node instanceof YangModule), is(true));
88 +
89 + // Check whether the node type is set properly to module.
90 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
91 +
92 + // Check whether the module name is set correctly.
93 + YangModule yangNode = (YangModule) node;
94 + assertThat(yangNode.getName(), is("Test"));
95 +
96 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
97 + YangLeafList leafListInfo = leafListIterator.next();
98 +
99 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
100 + assertThat(leafListInfo.getDataType().getDataTypeName(), is("\"uint16\""));
101 + assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
102 + }
103 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.parser.impl.listeners;
18 +
19 +import org.junit.Rule;
20 +import org.junit.Test;
21 +
22 +import org.junit.rules.ExpectedException;
23 +import org.onosproject.yangutils.datamodel.YangLeaf;
24 +import org.onosproject.yangutils.datamodel.YangModule;
25 +import org.onosproject.yangutils.datamodel.YangNode;
26 +import org.onosproject.yangutils.datamodel.YangNodeType;
27 +import org.onosproject.yangutils.datamodel.YangStatusType;
28 +import org.onosproject.yangutils.datamodel.YangLeafList;
29 +import org.onosproject.yangutils.parser.exceptions.ParserException;
30 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
31 +
32 +import java.io.IOException;
33 +import java.util.ListIterator;
34 +
35 +import static org.hamcrest.MatcherAssert.assertThat;
36 +import static org.hamcrest.core.Is.is;
37 +import static org.hamcrest.Matchers.nullValue;
38 +
39 +/**
40 + * Test cases for units listener.
41 + */
42 +public class UnitsListenerTest {
43 +
44 + @Rule
45 + public ExpectedException thrown = ExpectedException.none();
46 +
47 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
48 +
49 + /**
50 + * Checks valid units statement.
51 + */
52 + @Test
53 + public void processUnitsStatement() throws IOException, ParserException {
54 +
55 + YangNode node = manager.getDataModel("src/test/resources/UnitsStatement.yang");
56 +
57 + // Check whether the data model tree returned is of type module.
58 + assertThat((node instanceof YangModule), is(true));
59 +
60 + // Check whether the node type is set properly to module.
61 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
62 +
63 + // Check whether the module name is set correctly.
64 + YangModule yangNode = (YangModule) node;
65 + assertThat(yangNode.getName(), is("Test"));
66 +
67 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
68 + YangLeaf leafInfo = leafIterator.next();
69 +
70 + // Check whether units value is set correctly.
71 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
72 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
73 + }
74 +
75 + /**
76 + * Checks invalid units statement as sub-statement of module.
77 + */
78 + @Test
79 + public void processModuleSubStatementUnits() throws IOException, ParserException {
80 + thrown.expect(ParserException.class);
81 + thrown.expectMessage("mismatched input 'type' expecting {'augment', 'choice', 'contact', 'container', " +
82 + "'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import', " +
83 + "'include', 'leaf', 'leaf-list', 'list', 'namespace', 'notification', 'organization', " +
84 + "'prefix', 'reference', 'revision', 'rpc', 'typedef', 'uses', 'yang-version', '}'}");
85 + YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementUnits.yang");
86 + }
87 +
88 + /**
89 + * Checks invalid units statement(without statement end).
90 + */
91 + @Test
92 + public void processUnitsWithoutStatementEnd() throws IOException, ParserException {
93 + thrown.expect(ParserException.class);
94 + thrown.expectMessage("mismatched input '}' expecting {';', '+'}");
95 + YangNode node = manager.getDataModel("src/test/resources/UnitsWithoutStatementEnd.yang");
96 + }
97 +
98 + /**
99 + * Checks order of units statement in leaf.
100 + */
101 + @Test
102 + public void processUnitsStatementOrder() throws IOException, ParserException {
103 +
104 + YangNode node = manager.getDataModel("src/test/resources/UnitsStatementOrder.yang");
105 +
106 + // Check whether the data model tree returned is of type module.
107 + assertThat((node instanceof YangModule), is(true));
108 +
109 + // Check whether the node type is set properly to module.
110 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
111 +
112 + // Check whether the module name is set correctly.
113 + YangModule yangNode = (YangModule) node;
114 + assertThat(yangNode.getName(), is("Test"));
115 +
116 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
117 + YangLeaf leafInfo = leafIterator.next();
118 +
119 + // Check whether leaf properties is set correctly.
120 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
121 + assertThat(leafInfo.getDataType().getDataTypeName(), is("\"uint16\""));
122 + assertThat(leafInfo.getUnits(), is("\"seconds\""));
123 + assertThat(leafInfo.getDescription(), is("\"Interval before a route is declared invalid\""));
124 + assertThat(leafInfo.isConfig(), is(true));
125 + assertThat(leafInfo.isMandatory(), is(true));
126 + assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
127 + assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
128 + }
129 +
130 + /**
131 + * Checks the default value of unit statement.
132 + */
133 + @Test
134 + public void processUnitsDefaultValue() throws IOException, ParserException {
135 +
136 + YangNode node = manager.getDataModel("src/test/resources/UnitsDefaultValue.yang");
137 +
138 + // Check whether the data model tree returned is of type module.
139 + assertThat((node instanceof YangModule), is(true));
140 +
141 + // Check whether the node type is set properly to module.
142 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
143 +
144 + // Check whether the module name is set correctly.
145 + YangModule yangNode = (YangModule) node;
146 + assertThat(yangNode.getName(), is("Test"));
147 +
148 + ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
149 + YangLeaf leafInfo = leafIterator.next();
150 +
151 + assertThat(leafInfo.getLeafName(), is("invalid-interval"));
152 + assertThat(leafInfo.getUnits(), is(nullValue()));
153 + }
154 +
155 + /**
156 + * Checks invalid occurance of units statement as sub-statement of leaf.
157 + */
158 + @Test
159 + public void processUnitsStatementCardinality() throws IOException, ParserException {
160 + thrown.expect(ParserException.class);
161 + thrown.expectMessage("Internal parser error detected: Invalid cardinality in units before processing.");
162 + YangNode node = manager.getDataModel("src/test/resources/UnitsStatementCardinality.yang");
163 + }
164 +
165 + /**
166 + * Checks valid units statement as sub-statement of leaf-list.
167 + */
168 + @Test
169 + public void processLeafListSubStatementUnits() throws IOException, ParserException {
170 +
171 + YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementUnits.yang");
172 +
173 + // Check whether the data model tree returned is of type module.
174 + assertThat((node instanceof YangModule), is(true));
175 +
176 + // Check whether the node type is set properly to module.
177 + assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
178 +
179 + // Check whether the module name is set correctly.
180 + YangModule yangNode = (YangModule) node;
181 + assertThat(yangNode.getName(), is("Test"));
182 +
183 + ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
184 + YangLeafList leafListInfo = leafListIterator.next();
185 +
186 + // Check whether units value is set correctly.
187 + assertThat(leafListInfo.getLeafName(), is("invalid-interval"));
188 + assertThat(leafListInfo.getUnits(), is("\"seconds\""));
189 + }
190 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + config ;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config false;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + config invalid;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + config false
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container 1valid {
6 + reference "RFC 6020";
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +container valid {
2 + reference "RFC 6020";
3 + leaf invalid-interval {
4 + type "uint16";
5 + units "seconds";
6 + status current;
7 + reference "RFC 6020";
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + reference "RFC 6020";
7 + reference "RFC 6020";
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + status current;
12 + reference "RFC 6020";
13 + }
14 + }
15 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + config true;
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + description "Interval before a route is declared invalid";
11 + mandatory true;
12 + status current;
13 + reference "RFC 6020";
14 + }
15 + }
16 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container ospf {
6 + container valid {
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + }
14 + }
15 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + description "container description";
7 + config true;
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + description "Interval before a route is declared invalid";
12 + mandatory true;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
18 +
1 +
2 +module Test {
3 + yang-version 1;
4 + namespace http://huawei.com;
5 + prefix Ant;
6 + container valid {
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + description "Interval before a route is declared invalid";
11 + config true;
12 + mandatory true;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + leaf-list invalid-interval {
7 + type "uint16";
8 + units "seconds";
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + min-elements 1;
12 + max-elements unbounded;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container ospf {
6 + list valid {
7 + key "invalid";
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + status current;
12 + reference "RFC 6020";
13 + }
14 + }
15 + }
16 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + presence "invalid";
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + reference "container reference";
7 + config true;
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + description "Interval before a route is declared invalid";
12 + mandatory true;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + config true;
7 + status obsolete;
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + description "Interval before a route is declared invalid";
12 + mandatory true;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container ospf {
6 + presence "ospf logs";
7 + config true;
8 + description "container description";
9 + status current;
10 + reference "container reference";
11 + leaf invalid-interval {
12 + type "uint16";
13 + units "seconds";
14 + status current;
15 + reference "RFC 6020";
16 + }
17 + }
18 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "hello";
7 + }
8 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + description "";
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + description "Interval before a " + "route is declared invalid";
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + description "Interval before a " + "route is declared invalid"
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + }
8 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid"
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + config false;
11 + mandatory true;
12 + status current;
13 + reference "RFC 6020";
14 + }
15 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf 1invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leafs invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + config false;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list 1invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaflist invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + max-elements 3;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + min-elements 3;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + }
8 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + max-elements 3;
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + units "minutes";
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + status current;
11 + reference "RFC 6020";
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + mandatory false;
12 + status current;
13 + reference "RFC 6020";
14 + }
15 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +list valid {
2 + reference "RFC 6020";
3 + leaf invalid-interval {
4 + type "uint16";
5 + units "seconds";
6 + status current;
7 + reference "RFC 6020";
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list 1valid {
6 + key "invalid-interval";
7 + reference "RFC 6020";
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + status current;
12 + reference "RFC 6020";
13 + }
14 + }
15 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + reference "RFC 6020";
7 + }
8 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + config true;
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + description "Interval before a route is declared invalid";
12 + mandatory true;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list ospf {
6 + key "process-id";
7 + container interface {
8 + leaf invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + status current;
12 + reference "RFC 6020";
13 + }
14 + }
15 + }
16 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + description "list description";
8 + config true;
9 + leaf invalid-interval {
10 + type "uint16";
11 + units "seconds";
12 + description "Interval before a route is declared invalid";
13 + mandatory true;
14 + status current;
15 + reference "RFC 6020";
16 + }
17 + }
18 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + }
14 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + description "Interval before a route is declared invalid";
11 + config true;
12 + mandatory true;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +
2 +module Test {
3 + yang-version 1;
4 + namespace http://huawei.com;
5 + prefix Ant;
6 + list valid {
7 + key "invalid-interval";
8 + leaf-list invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + description "Interval before a route is declared invalid";
12 + config true;
13 + status current;
14 + reference "RFC 6020";
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list ospf {
6 + key "process-id";
7 + list valid {
8 + key "invalid";
9 + leaf invalid-interval {
10 + type "uint16";
11 + units "seconds";
12 + status current;
13 + reference "RFC 6020";
14 + }
15 + }
16 + }
17 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + max-elements 3;
8 + leaf-list invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + description "Interval before a route is declared invalid";
12 + }
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + min-elements 3;
8 + leaf-list invalid-interval {
9 + type "uint16";
10 + units "seconds";
11 + description "Interval before a route is declared invalid";
12 + }
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + reference "list reference";
8 + config true;
9 + leaf invalid-interval {
10 + type "uint16";
11 + units "seconds";
12 + description "Interval before a route is declared invalid";
13 + mandatory true;
14 + status current;
15 + reference "RFC 6020";
16 + }
17 + }
18 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + status current;
8 + config true;
9 + leaf invalid-interval {
10 + type "uint16";
11 + units "seconds";
12 + description "Interval before a route is declared invalid";
13 + mandatory true;
14 + status current;
15 + reference "RFC 6020";
16 + }
17 + }
18 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list ospf {
6 + key "process-id";
7 + config true;
8 + max-elements 10;
9 + min-elements 3;
10 + description "list description";
11 + status current;
12 + reference "list reference";
13 + leaf invalid-interval {
14 + type "uint16";
15 + units "seconds";
16 + status current;
17 + reference "RFC 6020";
18 + }
19 + }
20 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid-interval";
7 + reference "RFC 6020";
8 + reference "RFC 6020";
9 + leaf invalid-interval {
10 + type "uint16";
11 + units "seconds";
12 + status current;
13 + reference "RFC 6020";
14 + }
15 + }
16 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + }
8 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + mandatory ;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + mandatory false;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + mandatory false
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + max-elements 4;
9 + max-elements 6;
10 + description "Interval before a route is declared invalid";
11 + config true;
12 + status current;
13 + reference "RFC 6020";
14 + }
15 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + max-element 3;
9 + description "Interval before a route is declared invalid;
10 + config true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + max-elements unbounded;
8 + }
9 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + max-elements 3
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + min-elements 4;
9 + min-elements 6;
10 + description "Interval before a route is declared invalid";
11 + config true;
12 + status current;
13 + reference "RFC 6020";
14 + }
15 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + min-element 3;
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + min-elements asd;
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf-list invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + min-elements 3
9 + description "Interval before a route is declared invalid";
10 + config true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + config invalid;
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + leaf invalid-interval {
7 + type "uint16";
8 + units "seconds";
9 + status current;
10 + reference "RFC 6020";
11 + }
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + description "Interval before a route is declared invalid";
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "invalid";
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + mandatory false;
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + reference "RFC 6020";
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + status current;
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + type "uint16";
6 + units "seconds";
7 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + list valid {
6 + key "ospf isis";
7 + leaf ospf {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + leaf isis {
14 + type "uint16";
15 + units "seconds";
16 + status current;
17 + reference "RFC 6020";
18 + }
19 + }
20 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + leaf ospf {
7 + type "uint16";
8 + units "seconds";
9 + status current;
10 + reference "RFC 6020";
11 + }
12 + }
13 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + container valid {
6 + presence "invalid"
7 + leaf invalid-interval {
8 + type "uint16";
9 + units "seconds";
10 + status current;
11 + reference "RFC 6020";
12 + }
13 + }
14 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + reference "";
6 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + reference "RFC 6020"
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + description "module description";
6 + revision 2007-06-09 {
7 + reference "revision reference";
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + description "module description";
6 + revision 2007-06-09 {
7 + description "revision description";
8 + }
9 +}
10 +
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + status invalid;
8 + }
9 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + status deprecated;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + status obsolete;
8 + }
9 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + status current
8 + }
9 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + }
8 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
...\ No newline at end of file ...\ No newline at end of file
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds";
8 + units "minutes";
9 + }
10 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + units "seconds";
7 + type "uint16";
8 + description "Interval before a route is declared invalid";
9 + config true;
10 + mandatory true;
11 + status current;
12 + reference "RFC 6020";
13 + }
14 +}
1 +module Test {
2 + yang-version 1;
3 + namespace http://huawei.com;
4 + prefix Ant;
5 + leaf invalid-interval {
6 + type "uint16";
7 + units "seconds"
8 + }
9 +}