Committed by
Gerrit Code Review
[ONOS-4762][ONOS-4601]Grammar for meta data + Union defect fix
Change-Id: I8f78127e5b292cca6a79b32d496c2602c9105acd
Showing
21 changed files
with
156 additions
and
162 deletions
This diff is collapsed. Click to expand it.
| ... | @@ -1376,6 +1376,99 @@ public class TreeWalkListener implements GeneratedYangListener { | ... | @@ -1376,6 +1376,99 @@ public class TreeWalkListener implements GeneratedYangListener { |
| 1376 | } | 1376 | } |
| 1377 | 1377 | ||
| 1378 | @Override | 1378 | @Override |
| 1379 | + public void enterCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext ctx) { | ||
| 1380 | + // TODO: implement the method. | ||
| 1381 | + } | ||
| 1382 | + | ||
| 1383 | + @Override | ||
| 1384 | + public void exitCompilerAnnotationStatement(GeneratedYangParser.CompilerAnnotationStatementContext ctx) { | ||
| 1385 | + // TODO: implement the method. | ||
| 1386 | + } | ||
| 1387 | + | ||
| 1388 | + @Override | ||
| 1389 | + public void enterAnnotationStatement(GeneratedYangParser.AnnotationStatementContext ctx) { | ||
| 1390 | + // TODO: implement the method. | ||
| 1391 | + } | ||
| 1392 | + | ||
| 1393 | + @Override | ||
| 1394 | + public void exitAnnotationStatement(GeneratedYangParser.AnnotationStatementContext ctx) { | ||
| 1395 | + // TODO: implement the method. | ||
| 1396 | + } | ||
| 1397 | + | ||
| 1398 | + @Override | ||
| 1399 | + public void enterAnnotationType(GeneratedYangParser.AnnotationTypeContext ctx) { | ||
| 1400 | + // TODO: implement the method. | ||
| 1401 | + } | ||
| 1402 | + | ||
| 1403 | + @Override | ||
| 1404 | + public void exitAnnotationType(GeneratedYangParser.AnnotationTypeContext ctx) { | ||
| 1405 | + // TODO: implement the method. | ||
| 1406 | + } | ||
| 1407 | + | ||
| 1408 | + @Override | ||
| 1409 | + public void enterAnnotationParameterSpecification(GeneratedYangParser.AnnotationParameterSpecificationContext | ||
| 1410 | + ctx) { | ||
| 1411 | + // TODO: implement the method. | ||
| 1412 | + } | ||
| 1413 | + | ||
| 1414 | + @Override | ||
| 1415 | + public void exitAnnotationParameterSpecification(GeneratedYangParser.AnnotationParameterSpecificationContext ctx) { | ||
| 1416 | + // TODO: implement the method. | ||
| 1417 | + } | ||
| 1418 | + | ||
| 1419 | + @Override | ||
| 1420 | + public void enterAnnotationParameterSpecificationArg(GeneratedYangParser.AnnotationParameterSpecificationArgContext | ||
| 1421 | + ctx) { | ||
| 1422 | + // TODO: implement the method. | ||
| 1423 | + } | ||
| 1424 | + | ||
| 1425 | + @Override | ||
| 1426 | + public void exitAnnotationParameterSpecificationArg(GeneratedYangParser.AnnotationParameterSpecificationArgContext | ||
| 1427 | + ctx) { | ||
| 1428 | + // TODO: implement the method. | ||
| 1429 | + } | ||
| 1430 | + | ||
| 1431 | + @Override | ||
| 1432 | + public void enterAnnotationParaInstance(GeneratedYangParser.AnnotationParaInstanceContext ctx) { | ||
| 1433 | + // TODO: implement the method. | ||
| 1434 | + } | ||
| 1435 | + | ||
| 1436 | + @Override | ||
| 1437 | + public void exitAnnotationParaInstance(GeneratedYangParser.AnnotationParaInstanceContext ctx) { | ||
| 1438 | + // TODO: implement the method. | ||
| 1439 | + } | ||
| 1440 | + | ||
| 1441 | + @Override | ||
| 1442 | + public void enterAnnotationParaTypeIdentifier(GeneratedYangParser.AnnotationParaTypeIdentifierContext ctx) { | ||
| 1443 | + // TODO: implement the method. | ||
| 1444 | + } | ||
| 1445 | + | ||
| 1446 | + @Override | ||
| 1447 | + public void exitAnnotationParaTypeIdentifier(GeneratedYangParser.AnnotationParaTypeIdentifierContext ctx) { | ||
| 1448 | + // TODO: implement the method. | ||
| 1449 | + } | ||
| 1450 | + | ||
| 1451 | + @Override | ||
| 1452 | + public void enterAnnotationParaTypeValue(GeneratedYangParser.AnnotationParaTypeValueContext ctx) { | ||
| 1453 | + // TODO: implement the method. | ||
| 1454 | + } | ||
| 1455 | + | ||
| 1456 | + @Override | ||
| 1457 | + public void exitAnnotationParaTypeValue(GeneratedYangParser.AnnotationParaTypeValueContext ctx) { | ||
| 1458 | + // TODO: implement the method. | ||
| 1459 | + } | ||
| 1460 | + | ||
| 1461 | + @Override | ||
| 1462 | + public void enterAnnotationIdentifier(GeneratedYangParser.AnnotationIdentifierContext ctx) { | ||
| 1463 | + // TODO: implement the method. | ||
| 1464 | + } | ||
| 1465 | + | ||
| 1466 | + @Override | ||
| 1467 | + public void exitAnnotationIdentifier(GeneratedYangParser.AnnotationIdentifierContext ctx) { | ||
| 1468 | + // TODO: implement the method. | ||
| 1469 | + } | ||
| 1470 | + | ||
| 1471 | + @Override | ||
| 1379 | public void enterVersion(GeneratedYangParser.VersionContext ctx) { | 1472 | public void enterVersion(GeneratedYangParser.VersionContext ctx) { |
| 1380 | // do nothing. | 1473 | // do nothing. |
| 1381 | } | 1474 | } | ... | ... |
| ... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
| 16 | 16 | ||
| 17 | package org.onosproject.yangutils.parser.impl.listeners; | 17 | package org.onosproject.yangutils.parser.impl.listeners; |
| 18 | 18 | ||
| 19 | -import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
| 20 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; | 19 | import org.onosproject.yangutils.datamodel.YangDerivedInfo; |
| 21 | import org.onosproject.yangutils.datamodel.YangLeaf; | 20 | import org.onosproject.yangutils.datamodel.YangLeaf; |
| 22 | import org.onosproject.yangutils.datamodel.YangLeafList; | 21 | import org.onosproject.yangutils.datamodel.YangLeafList; |
| ... | @@ -27,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangTypeDef; | ... | @@ -27,6 +26,7 @@ import org.onosproject.yangutils.datamodel.YangTypeDef; |
| 27 | import org.onosproject.yangutils.datamodel.YangUnion; | 26 | import org.onosproject.yangutils.datamodel.YangUnion; |
| 28 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; | 27 | import org.onosproject.yangutils.datamodel.exceptions.DataModelException; |
| 29 | import org.onosproject.yangutils.datamodel.utils.Parsable; | 28 | import org.onosproject.yangutils.datamodel.utils.Parsable; |
| 29 | +import org.onosproject.yangutils.datamodel.utils.builtindatatype.YangDataTypes; | ||
| 30 | import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl; | 30 | import org.onosproject.yangutils.linker.impl.YangResolutionInfoImpl; |
| 31 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; | 31 | import org.onosproject.yangutils.parser.antlrgencode.GeneratedYangParser; |
| 32 | import org.onosproject.yangutils.parser.exceptions.ParserException; | 32 | import org.onosproject.yangutils.parser.exceptions.ParserException; |
| ... | @@ -94,6 +94,8 @@ public final class TypeListener { | ... | @@ -94,6 +94,8 @@ public final class TypeListener { |
| 94 | // Obtain the YANG data type. | 94 | // Obtain the YANG data type. |
| 95 | YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText()); | 95 | YangDataTypes yangDataTypes = YangDataTypes.getType(ctx.string().getText()); |
| 96 | 96 | ||
| 97 | + validateTypeSubStatementCardinality(ctx, yangDataTypes); | ||
| 98 | + | ||
| 97 | // Create YANG type object and fill the values. | 99 | // Create YANG type object and fill the values. |
| 98 | YangType<?> type = getYangType(JAVA_GENERATION); | 100 | YangType<?> type = getYangType(JAVA_GENERATION); |
| 99 | type.setNodeIdentifier(nodeIdentifier); | 101 | type.setNodeIdentifier(nodeIdentifier); |
| ... | @@ -265,4 +267,37 @@ public final class TypeListener { | ... | @@ -265,4 +267,37 @@ public final class TypeListener { |
| 265 | TYPE_DATA, ctx.string().getText(), ENTRY, e.getMessage())); | 267 | TYPE_DATA, ctx.string().getText(), ENTRY, e.getMessage())); |
| 266 | } | 268 | } |
| 267 | } | 269 | } |
| 270 | + | ||
| 271 | + /** | ||
| 272 | + * Validates type body statements cardinality. | ||
| 273 | + * | ||
| 274 | + * @param ctx context object of the grammar rule | ||
| 275 | + * @param yangDataType yang data type | ||
| 276 | + */ | ||
| 277 | + private static void validateTypeSubStatementCardinality(GeneratedYangParser.TypeStatementContext ctx, | ||
| 278 | + YangDataTypes yangDataType) { | ||
| 279 | + if (ctx.typeBodyStatements() == null || ctx.typeBodyStatements().isEmpty()) { | ||
| 280 | + ParserException parserException; | ||
| 281 | + switch (yangDataType) { | ||
| 282 | + case UNION: | ||
| 283 | + parserException = new ParserException("YANG file error : a type union" + | ||
| 284 | + " must have atleast one type statement."); | ||
| 285 | + break; | ||
| 286 | + case ENUMERATION: | ||
| 287 | + parserException = new ParserException("YANG file error : a type enumeration" + | ||
| 288 | + " must have atleast one enum statement."); | ||
| 289 | + break; | ||
| 290 | + case BITS: | ||
| 291 | + parserException = new ParserException("YANG file error : a type bits" + | ||
| 292 | + " must have atleast one bit statement."); | ||
| 293 | + break; | ||
| 294 | + // TODO : decimal64, identity ref, leafref | ||
| 295 | + default: | ||
| 296 | + return; | ||
| 297 | + } | ||
| 298 | + parserException.setLine(ctx.getStart().getLine()); | ||
| 299 | + parserException.setCharPosition(ctx.getStart().getCharPositionInLine()); | ||
| 300 | + throw parserException; | ||
| 301 | + } | ||
| 302 | + } | ||
| 268 | } | 303 | } | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -100,6 +100,7 @@ lexer grammar YangLexer; | ... | @@ -100,6 +100,7 @@ lexer grammar YangLexer; |
| 100 | TRUE_KEYWORD : 'true'; | 100 | TRUE_KEYWORD : 'true'; |
| 101 | UNBOUNDED_KEYWORD : 'unbounded'; | 101 | UNBOUNDED_KEYWORD : 'unbounded'; |
| 102 | USER_KEYWORD : 'user'; | 102 | USER_KEYWORD : 'user'; |
| 103 | + COMPILER_ANNOTATION_KEYWORD : 'compiler-annotation'; | ||
| 103 | 104 | ||
| 104 | // Lexer tokens to be skipped | 105 | // Lexer tokens to be skipped |
| 105 | COMMENT | 106 | COMMENT |
| ... | @@ -116,11 +117,18 @@ lexer grammar YangLexer; | ... | @@ -116,11 +117,18 @@ lexer grammar YangLexer; |
| 116 | DATE_ARG : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; | 117 | DATE_ARG : DIGIT DIGIT DIGIT DIGIT '-' DIGIT DIGIT '-' DIGIT DIGIT; |
| 117 | LEFT_CURLY_BRACE : '{'; | 118 | LEFT_CURLY_BRACE : '{'; |
| 118 | RIGHT_CURLY_BRACE : '}'; | 119 | RIGHT_CURLY_BRACE : '}'; |
| 120 | + LEFT_ROUND_BRACE : '('; | ||
| 121 | + RIGHT_ROUND_BRACE : ')'; | ||
| 122 | + ANNOTATION_START : '@'; | ||
| 123 | + ANNOTATION_IDENTIFIER : ('@')(ALPHA | '_') | ||
| 124 | + (ALPHA | DIGIT | '_' | '-' | '.')*; | ||
| 119 | IDENTIFIER : (ALPHA | '_') | 125 | IDENTIFIER : (ALPHA | '_') |
| 120 | (ALPHA | DIGIT | '_' | '-' | '.')*; | 126 | (ALPHA | DIGIT | '_' | '-' | '.')*; |
| 121 | STMTEND : ';'; | 127 | STMTEND : ';'; |
| 122 | DQUOTE : '"'; | 128 | DQUOTE : '"'; |
| 123 | COLON : ':'; | 129 | COLON : ':'; |
| 130 | + COMMA : ','; | ||
| 131 | + EQUAL : '='; | ||
| 124 | PLUS : '+'; | 132 | PLUS : '+'; |
| 125 | MINUS: '-'; | 133 | MINUS: '-'; |
| 126 | 134 | ... | ... |
| ... | @@ -129,19 +129,6 @@ public class ConfigListenerTest { | ... | @@ -129,19 +129,6 @@ public class ConfigListenerTest { |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | /** | 131 | /** |
| 132 | - * Checks config statement as sub-statement of module. | ||
| 133 | - */ | ||
| 134 | - @Test | ||
| 135 | - public void processModuleSubStatementConfig() throws IOException, ParserException { | ||
| 136 | - thrown.expect(ParserException.class); | ||
| 137 | - thrown.expectMessage("mismatched input 'config' expecting {'anyxml', 'augment', 'choice', 'contact', " | ||
| 138 | - + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import'," | ||
| 139 | - + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," | ||
| 140 | - + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); | ||
| 141 | - YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementConfig.yang"); | ||
| 142 | - } | ||
| 143 | - | ||
| 144 | - /** | ||
| 145 | * Checks config statement as sub-statement of container. | 132 | * Checks config statement as sub-statement of container. |
| 146 | */ | 133 | */ |
| 147 | @Test | 134 | @Test | ... | ... |
| ... | @@ -91,13 +91,8 @@ public class LeafListListenerTest { | ... | @@ -91,13 +91,8 @@ public class LeafListListenerTest { |
| 91 | /** | 91 | /** |
| 92 | * Checks whether exception is thrown when leaf-list keyword is incorrect. | 92 | * Checks whether exception is thrown when leaf-list keyword is incorrect. |
| 93 | */ | 93 | */ |
| 94 | - @Test | 94 | + @Test(expected = ParserException.class) |
| 95 | public void processLeafListInvalidStatement() throws IOException, ParserException { | 95 | public void processLeafListInvalidStatement() throws IOException, ParserException { |
| 96 | - thrown.expect(ParserException.class); | ||
| 97 | - thrown.expectMessage("mismatched input 'leaflist' expecting {'anyxml', 'augment', 'choice', 'contact', " | ||
| 98 | - + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import'," | ||
| 99 | - + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," | ||
| 100 | - + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); | ||
| 101 | YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidStatement.yang"); | 96 | YangNode node = manager.getDataModel("src/test/resources/LeafListInvalidStatement.yang"); |
| 102 | } | 97 | } |
| 103 | 98 | ... | ... |
| ... | @@ -90,19 +90,6 @@ public class LeafListenerTest { | ... | @@ -90,19 +90,6 @@ public class LeafListenerTest { |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | /** | 92 | /** |
| 93 | - * Checks whether exception is thrown when leaf keyword is incorrect. | ||
| 94 | - */ | ||
| 95 | - @Test | ||
| 96 | - public void processLeafInvalidStatement() throws IOException, ParserException { | ||
| 97 | - thrown.expect(ParserException.class); | ||
| 98 | - thrown.expectMessage("mismatched input 'leafs' expecting {'anyxml', 'augment', 'choice', 'contact', " | ||
| 99 | - + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import'," | ||
| 100 | - + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," | ||
| 101 | - + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); | ||
| 102 | - YangNode node = manager.getDataModel("src/test/resources/LeafInvalidStatement.yang"); | ||
| 103 | - } | ||
| 104 | - | ||
| 105 | - /** | ||
| 106 | * Checks whether exception is thrown when leaf keyword without Left brace | 93 | * Checks whether exception is thrown when leaf keyword without Left brace |
| 107 | * as per grammar. | 94 | * as per grammar. |
| 108 | */ | 95 | */ | ... | ... |
| ... | @@ -140,18 +140,4 @@ public class MandatoryListenerTest { | ... | @@ -140,18 +140,4 @@ public class MandatoryListenerTest { |
| 140 | thrown.expectMessage("missing ';' at '}'"); | 140 | thrown.expectMessage("missing ';' at '}'"); |
| 141 | YangNode node = manager.getDataModel("src/test/resources/MandatoryWithoutStatementEnd.yang"); | 141 | YangNode node = manager.getDataModel("src/test/resources/MandatoryWithoutStatementEnd.yang"); |
| 142 | } | 142 | } |
| 143 | - | ||
| 144 | - /** | ||
| 145 | - * Checks mandatory statement as sub-statement of module and expects | ||
| 146 | - * exception. | ||
| 147 | - */ | ||
| 148 | - @Test | ||
| 149 | - public void processModuleSubStatementMandatory() throws IOException, ParserException { | ||
| 150 | - thrown.expect(ParserException.class); | ||
| 151 | - thrown.expectMessage("mismatched input 'mandatory' expecting {'anyxml', 'augment', 'choice', 'contact'," | ||
| 152 | - + " 'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import'," | ||
| 153 | - + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference'," | ||
| 154 | - + " 'revision', 'rpc', 'typedef', 'uses', '}'}"); | ||
| 155 | - YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementMandatory.yang"); | ||
| 156 | - } | ||
| 157 | } | 143 | } | ... | ... |
| ... | @@ -92,19 +92,6 @@ public class MaxElementsListenerTest { | ... | @@ -92,19 +92,6 @@ public class MaxElementsListenerTest { |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | /** | 94 | /** |
| 95 | - * Checks whether exception is thrown when invalid max-elements keyword is | ||
| 96 | - * given as input. | ||
| 97 | - */ | ||
| 98 | - @Test | ||
| 99 | - public void processMaxElementsInvalidStatement() throws IOException, ParserException { | ||
| 100 | - thrown.expect(ParserException.class); | ||
| 101 | - thrown.expectMessage("extraneous input 'max-element' expecting {'config', 'description', 'if-feature'," | ||
| 102 | - + " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units', " | ||
| 103 | - + "'when', '}'}"); | ||
| 104 | - YangNode node = manager.getDataModel("src/test/resources/MaxElementsInvalidStatement.yang"); | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - /** | ||
| 108 | * Checks whether exception is thrown when max-elements statement without | 95 | * Checks whether exception is thrown when max-elements statement without |
| 109 | * statement end is given as input. | 96 | * statement end is given as input. |
| 110 | */ | 97 | */ | ... | ... |
| ... | @@ -92,19 +92,6 @@ public class MinElementsListenerTest { | ... | @@ -92,19 +92,6 @@ public class MinElementsListenerTest { |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | /** | 94 | /** |
| 95 | - * Checks whether exception is thrown when invalid min-elements keyword is | ||
| 96 | - * given as input. | ||
| 97 | - */ | ||
| 98 | - @Test | ||
| 99 | - public void processMinElementsInvalidKeyword() throws IOException, ParserException { | ||
| 100 | - thrown.expect(ParserException.class); | ||
| 101 | - thrown.expectMessage("extraneous input 'min-element' expecting {'config', 'description', 'if-feature'," | ||
| 102 | - + " 'max-elements', 'min-elements', 'must', 'ordered-by', 'reference', 'status', 'type', 'units'," | ||
| 103 | - + " 'when', '}'}"); | ||
| 104 | - YangNode node = manager.getDataModel("src/test/resources/MinElementsInvalidKeyword.yang"); | ||
| 105 | - } | ||
| 106 | - | ||
| 107 | - /** | ||
| 108 | * Checks whether exception is thrown when invalid min-elements value is | 95 | * Checks whether exception is thrown when invalid min-elements value is |
| 109 | * given as input. | 96 | * given as input. |
| 110 | */ | 97 | */ | ... | ... |
| ... | @@ -145,19 +145,6 @@ public class StatusListenerTest { | ... | @@ -145,19 +145,6 @@ public class StatusListenerTest { |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | /** | 147 | /** |
| 148 | - * Checks status statement as sub-statement of module. | ||
| 149 | - */ | ||
| 150 | - @Test | ||
| 151 | - public void processModuleSubStatementStatus() throws IOException, ParserException { | ||
| 152 | - thrown.expect(ParserException.class); | ||
| 153 | - thrown.expectMessage("mismatched input 'status' expecting {'anyxml', 'augment', 'choice', 'contact', " | ||
| 154 | - + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity', 'import'," | ||
| 155 | - + " 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', 'reference', " | ||
| 156 | - + "'revision', 'rpc', 'typedef', 'uses', '}'}"); | ||
| 157 | - YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementStatus.yang"); | ||
| 158 | - } | ||
| 159 | - | ||
| 160 | - /** | ||
| 161 | * Checks status statement as sub-statement of container. | 148 | * Checks status statement as sub-statement of container. |
| 162 | */ | 149 | */ |
| 163 | @Test | 150 | @Test | ... | ... |
| ... | @@ -138,4 +138,12 @@ public class UnionListenerTest { | ... | @@ -138,4 +138,12 @@ public class UnionListenerTest { |
| 138 | 138 | ||
| 139 | YangNode node = manager.getDataModel("src/test/resources/UnionWithEmptyType.yang"); | 139 | YangNode node = manager.getDataModel("src/test/resources/UnionWithEmptyType.yang"); |
| 140 | } | 140 | } |
| 141 | + | ||
| 142 | + /** | ||
| 143 | + * Checks whether type union has atleast one type statement. | ||
| 144 | + */ | ||
| 145 | + @Test (expected = ParserException.class) | ||
| 146 | + public void processUnionWithoutChild() throws IOException, ParserException { | ||
| 147 | + manager.getDataModel("src/test/resources/UnionWithoutChild.yang"); | ||
| 148 | + } | ||
| 141 | } | 149 | } | ... | ... |
| ... | @@ -71,19 +71,6 @@ public class UnitsListenerTest { | ... | @@ -71,19 +71,6 @@ public class UnitsListenerTest { |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | /** | 73 | /** |
| 74 | - * Checks invalid units statement as sub-statement of module. | ||
| 75 | - */ | ||
| 76 | - @Test | ||
| 77 | - public void processModuleSubStatementUnits() throws IOException, ParserException { | ||
| 78 | - thrown.expect(ParserException.class); | ||
| 79 | - thrown.expectMessage("mismatched input 'type' expecting {'anyxml', 'augment', 'choice', 'contact', " | ||
| 80 | - + "'container', 'description', 'extension', 'deviation', 'feature', 'grouping', 'identity'," | ||
| 81 | - + " 'import', 'include', 'leaf', 'leaf-list', 'list', 'notification', 'organization', " | ||
| 82 | - + "'reference', 'revision', 'rpc', 'typedef', 'uses', '}'}"); | ||
| 83 | - YangNode node = manager.getDataModel("src/test/resources/ModuleSubStatementUnits.yang"); | ||
| 84 | - } | ||
| 85 | - | ||
| 86 | - /** | ||
| 87 | * Checks invalid units statement(without statement end). | 74 | * Checks invalid units statement(without statement end). |
| 88 | */ | 75 | */ |
| 89 | @Test | 76 | @Test | ... | ... |
| 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 | - 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 | - 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 |
| ... | @@ -2,5 +2,13 @@ module Test { | ... | @@ -2,5 +2,13 @@ module Test { |
| 2 | yang-version 1; | 2 | yang-version 1; |
| 3 | namespace http://huawei.com; | 3 | namespace http://huawei.com; |
| 4 | prefix Ant; | 4 | prefix Ant; |
| 5 | - config invalid; | ||
| 6 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 5 | + list valid { | ||
| 6 | + key "invalid-interval"; | ||
| 7 | + leaf invalid-interval { | ||
| 8 | + type union { | ||
| 9 | + type "union"; | ||
| 10 | + } | ||
| 11 | + } | ||
| 12 | + } | ||
| 13 | +} | ||
| 14 | + | ... | ... |
-
Please register or login to post a comment