Bug 4662: Introduce a SemanticVersion concept - import processing 77/36877/28
authorPeter Kajsa <pkajsa@cisco.com>
Wed, 30 Mar 2016 11:27:34 +0000 (13:27 +0200)
committerRobert Varga <nite@hq.sk>
Fri, 3 Jun 2016 08:35:30 +0000 (08:35 +0000)
Added new semantic version processing mode to yang statement parser.
If the mode is enabled, each module import is processed based on the specified
semantic version and revision date of import statement is ignored.

- fix of SemVer's compareTo method
- fix of Yin statements argument parsing
- added Yang unit tests
- added Yin unit tests
- fix of module imports resolving and module dependency sort
  for cases when semantic versioning is enabled
- added StatementParserMode
- unit test fix

Change-Id: Ibf0519c3ec8fec85763e0a13059c1b8af91276ba
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
194 files changed:
common/concepts/src/main/java/org/opendaylight/yangtools/concepts/SemVer.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Module.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleIdentifier.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/ModuleImport.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Rfc6020Mapping.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/StatementDefinition.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/StatementParserMode.java [new file with mode: 0644]
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/ExtensionStatement.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/ModuleImportImpl.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/ModuleImportImplTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleIdentifierImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YinStatementParserImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangModelDependencyInfo.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/repo/DependencyResolver.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/AbstractStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SemanticVersionModuleNamespace.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SemanticVersionNamespace.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToModuleIdentifier.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToSemVerModuleIdentifier.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleCtxToModuleIdentifier.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleCtxToModuleQName.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ModelDefinedStatementDefinition.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ImportStatementDefinition.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SemanticVersionStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SupportedExtensionsMapping.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangInferencePipeline.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YinStatementSourceImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveModule.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ImportEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SemanticVersionEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionBorderCaseTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionComplexTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionDefaultsTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionIgnoringRevisionTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionImportTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionMultipleImportTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionPositionTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/yin/YinSemanticVersionTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-3/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-3/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/bar@2016-01-31.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/bar@2016-01-31.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/basic/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/bar@2016-01-04.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foobar@2016-01-31.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foobar@2016-02-28.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/bar@2016-01-04.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-01-31.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-02-27.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-02-28.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/defaults/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/defaults/defaults/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/bar@2016-01-31.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-1/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-1/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-2/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-1/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-1/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-2/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-valid/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/import/import-valid/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-03.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-04.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-31.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-02-28.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-02-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-02-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-02-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-02-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-02-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-02-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-01-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-01-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-02-01.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-02-02.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160404.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160405.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160406.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20170406.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/node-test/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/node-test/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/semantic-version.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/bar@2016-01-01.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/bar@2016-01-31.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/foo@2016-02-01.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/semantic-version@2016-02-02.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/bar@2016-01-01.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/bar@2016-01-31.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/foo@2016-02-01.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/semantic-version@2016-02-02.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/bar@2016-01-31.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/foo@2016-02-01.xml [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/semantic-version@2016-02-02.xml [new file with mode: 0644]

index 65d55f2776d7f9f6ae580756c31063e65f09a66b..d7520d47c9ced14f028dc9f850c8809426dbdf03 100644 (file)
@@ -89,7 +89,7 @@ public final class SemVer implements Comparable<SemVer>, Serializable {
         if (i == 0) {
             i = Integer.compare(minor, o.minor);
             if (i == 0) {
-                return Integer.compare(patch, patch);
+                return Integer.compare(patch, o.patch);
             }
         }
 
index 8af290e522eb88486143e071b44da7c9f794f701..9e0311a5ffd98957b52015f7a6d29f78237a6f7b 100644 (file)
@@ -11,6 +11,7 @@ import java.util.List;
 import java.util.Set;
 import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
+import org.opendaylight.yangtools.concepts.SemVer;
 
 /**
  * This interface contains the methods for getting the data from the YANG
@@ -58,6 +59,11 @@ import javax.annotation.concurrent.Immutable;
  */
 @Immutable
 public interface Module extends DataNodeContainer, SourceStreamAware, ModuleIdentifier {
+    /**
+     * Default semantic version of Module.
+     */
+    SemVer DEFAULT_SEMANTIC_VERSION = SemVer.create(0, 0, 0);
+
     /**
      * Returns the prefix of the module
      *
index 8858b51d618237a59cf53e0d94e95232edaea9f8..0ca6e4d25cdd2f397d969b1a0a0b3aaaae543b7c 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.yangtools.yang.model.api;
 
 import java.net.URI;
 import java.util.Date;
-
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 
 
@@ -50,4 +50,19 @@ public interface ModuleIdentifier {
      *         keyword
      */
     Date getRevision();
+
+    /**
+     * Returns the semantic version of yang module.
+     *
+     * If the semantic version is not specified, default semantic version of
+     * module is returned.
+     *
+     * @return SemVer semantic version of yang module which is specified as
+     *         argument of
+     *         (urn:opendaylight:yang:extension:semantic-version?revision
+     *         =2016-02-02)semantic-version statement
+     */
+    default SemVer getSemanticVersion() {
+        return Module.DEFAULT_SEMANTIC_VERSION;
+    }
 }
index 28d934fc07ec8593b8317059d9e978d8d67ccbbd..0ef81046e37c56eb033e9e3435b9abfcb7ad2bc4 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.yangtools.yang.model.api;
 
 import java.util.Date;
+import org.opendaylight.yangtools.concepts.SemVer;
 
 /**
  * Interface describing YANG 'import' statement.
@@ -28,6 +29,13 @@ public interface ModuleImport {
      */
     Date getRevision();
 
+    /**
+     * @return Semantic version of module to import
+     */
+    default SemVer getSemanticVersion() {
+        return Module.DEFAULT_SEMANTIC_VERSION;
+    }
+
     /**
      * @return Prefix used to point to imported module
      */
index d791ab960e1cdfb331696362c6927a92ee7aba0a..7371fbae2fd031860ea683182b47b46b83a148a9 100644 (file)
@@ -11,7 +11,6 @@ import com.google.common.annotations.Beta;
 import com.google.common.base.Preconditions;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
@@ -210,6 +209,7 @@ public enum Rfc6020Mapping implements StatementDefinition {
         return effectiveType;
     }
 
+    @Override
     public boolean isArgumentYinElement() {
         return yinElement;
     }
index cfb8488848b0e7ced7899a26ece96f2659d0a985..ac2293d165b9dbb0b588a665adb8f228b417a613 100644 (file)
@@ -13,13 +13,12 @@ import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
 
 /**
- * Definition / model of YANG {@link DeclaredStatement} and {@link EffectiveStatement}.
+ * Definition / model of YANG {@link DeclaredStatement} and
+ * {@link EffectiveStatement}.
  *
- * Statement concept is defined in RFC6020 section 6.3:
- * <blockquote> A YANG
+ * Statement concept is defined in RFC6020 section 6.3: <blockquote> A YANG
  * module contains a sequence of statements. Each statement starts with a
- * keyword, followed by zero or one argument
- * </blockquote>
+ * keyword, followed by zero or one argument </blockquote>
  *
  * Source: <a href="https://tools.ietf.org/html/rfc6020#section-6.3"> </a>
  */
@@ -64,5 +63,16 @@ public interface StatementDefinition extends Immutable {
      *         with this definition
      */
     @Nonnull
-    Class<? extends EffectiveStatement<?,?>> getEffectiveRepresentationClass();
+    Class<? extends EffectiveStatement<?, ?>> getEffectiveRepresentationClass();
+
+    /**
+     * Returns true, if argument of statement is represented as value of yin
+     * element. If argument of statement is represented as argument of yin
+     * element, returns false.
+     *
+     *
+     * @return returns true, if statement argument is represented as value of
+     *         yin element, otherwise returns false.
+     */
+    boolean isArgumentYinElement();
 }
diff --git a/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/StatementParserMode.java b/yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/repo/api/StatementParserMode.java
new file mode 100644 (file)
index 0000000..e2e71a2
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.repo.api;
+
+import com.google.common.annotations.Beta;
+
+@Beta
+public enum StatementParserMode {
+    /**
+     * Default mode of statement parser.
+     */
+    DEFAULT_MODE,
+    /**
+     * Semantic version mode of statement parser. If it is enabled, module
+     * imports are processed on the basis of semantic versions.
+     */
+    SEMVER_MODE
+}
\ No newline at end of file
index eeb6137e25fd6fd76a0ee813411ef34253d64754..291c56bf09a2325b054253d4fff19b032146e1fe 100644 (file)
@@ -51,6 +51,7 @@ final class ExtensionStatement implements StatementDefinition {
         return statementName;
     }
 
+    @Override
     public boolean isArgumentYinElement() {
         return yinElement;
     }
index 376511663e411b8a66114dacc1bae68661ba191f..f6ec3488bba2a47dfc1d1e4b6172a3e01665b139 100644 (file)
@@ -7,19 +7,28 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
+import com.google.common.base.Preconditions;
 import java.util.Date;
 import java.util.Objects;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
 public final class ModuleImportImpl implements ModuleImport {
     private final String moduleName;
     private final Date revision;
+    private final SemVer semVer;
     private final String prefix;
 
     public ModuleImportImpl(final String moduleName, final Date revision, final String prefix) {
-        this.moduleName = moduleName;
+        this(moduleName, revision, prefix, Module.DEFAULT_SEMANTIC_VERSION);
+    }
+
+    public ModuleImportImpl(final String moduleName, final Date revision, final String prefix, final SemVer semVer) {
+        this.moduleName = Preconditions.checkNotNull(moduleName, "Module name must not be null.");
         this.revision = revision;
-        this.prefix = prefix;
+        this.prefix = Preconditions.checkNotNull(prefix, "Import prefix must not be null.");
+        this.semVer = Preconditions.checkNotNull(semVer, "Semantic version of module must not be null.");
     }
 
     @Override
@@ -32,6 +41,11 @@ public final class ModuleImportImpl implements ModuleImport {
         return revision;
     }
 
+    @Override
+    public SemVer getSemanticVersion() {
+        return semVer;
+    }
+
     @Override
     public String getPrefix() {
         return prefix;
@@ -44,6 +58,7 @@ public final class ModuleImportImpl implements ModuleImport {
         result = prime * result + Objects.hashCode(moduleName);
         result = prime * result + Objects.hashCode(revision);
         result = prime * result + Objects.hashCode(prefix);
+        result = prime * result + Objects.hashCode(semVer);
         return result;
     }
 
@@ -68,6 +83,9 @@ public final class ModuleImportImpl implements ModuleImport {
         if (!Objects.equals(getPrefix(), other.getPrefix())) {
             return false;
         }
+        if (!Objects.equals(getSemanticVersion(), other.getSemanticVersion())) {
+            return false;
+        }
         return true;
     }
 
index 62f127ef5f381e9184ea808c8a64ee623d4c4b4d..21a6cd0a9e83a878d473b466625b11c18a6cfddc 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.util.Date;
-
-import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.junit.Before;
 import org.junit.Test;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 
 public class ModuleImportImplTest {
 
@@ -25,9 +26,9 @@ public class ModuleImportImplTest {
     public void setup() {
         now = new Date();
         module1 = new ModuleImportImpl("myModule", now, "myPrefix");
-        module2 = new ModuleImportImpl(null, null, null);
+        module2 = new ModuleImportImpl("foo", null, "prefix-foo");
         module3 = new ModuleImportImpl("myModule", null, "customPrefix");
-        module4 = new ModuleImportImpl("myModule", now, null);
+        module4 = new ModuleImportImpl("myModule", now, "prefix");
         module5 = new ModuleImportImpl("myModule", now, "myPrefix");
         hash1 = module1.hashCode();
         hash2 = module2.hashCode();
index c4f7f1acb4e5195ddbb68a94153b70b5acc00b2f..59bbfd93c63fe66634bae9b0241fac6f5659478e 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
+
 import com.google.common.collect.Sets;
 import java.net.URI;
 import java.net.URISyntaxException;
@@ -22,6 +23,7 @@ import java.util.HashSet;
 import java.util.Set;
 import org.junit.BeforeClass;
 import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.Module;
@@ -498,6 +500,11 @@ public class SchemaContextProxyTest {
                     return module.getName();
                 }
 
+                @Override
+                public SemVer getSemanticVersion() {
+                    return module.getSemanticVersion();
+                }
+
                 @Override
                 public String toString() {
 
index 63608b3e7a71d6d41aa40468fb8e56f623ead4d9..dd42fec14e3e4f0c4fcd1bc4506edfbd4ae67a16 100644 (file)
@@ -8,10 +8,14 @@
 package org.opendaylight.yangtools.yang.parser.builder.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+
 import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Date;
+import java.util.Objects;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 
 /**
@@ -19,16 +23,23 @@ import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
  * Name is only non-null attribute.
  * Equality check on namespace and revision is only triggered if they are non-null
  *
- * @deprecated Pre-Beryllium implementation, scheduled for removal.
  */
-@Deprecated
+
+// FIXME: This class is used widely by yang statement parser. This class should be moved to one of yang statement
+// parser packages after removal of deprecated pre-beryllium implementation.
 public class ModuleIdentifierImpl implements ModuleIdentifier {
     private final QNameModule qnameModule;
     private final String name;
+    private final SemVer semVer;
 
     public ModuleIdentifierImpl(final String name, final Optional<URI> namespace, final Optional<Date> revision) {
+        this(name, namespace, revision, Module.DEFAULT_SEMANTIC_VERSION);
+    }
+
+    public ModuleIdentifierImpl(final String name, final Optional<URI> namespace, final Optional<Date> revision, final SemVer semVer) {
         this.name = checkNotNull(name);
         this.qnameModule = QNameModule.create(namespace.orNull(), revision.orNull());
+        this.semVer = (semVer == null ? Module.DEFAULT_SEMANTIC_VERSION : semVer);
     }
 
     @Override
@@ -41,6 +52,11 @@ public class ModuleIdentifierImpl implements ModuleIdentifier {
         return qnameModule.getRevision();
     }
 
+    @Override
+    public SemVer getSemanticVersion() {
+        return semVer;
+    }
+
     @Override
     public String getName() {
         return name;
@@ -57,6 +73,7 @@ public class ModuleIdentifierImpl implements ModuleIdentifier {
                 "name='" + name + '\'' +
                 ", namespace=" + getNamespace() +
                 ", revision=" + qnameModule.getFormattedRevision() +
+                ", semantic version=" + semVer +
                 '}';
     }
 
@@ -69,18 +86,22 @@ public class ModuleIdentifierImpl implements ModuleIdentifier {
             return false;
         }
 
-        ModuleIdentifier that = (ModuleIdentifier) o;
+        ModuleIdentifier other = (ModuleIdentifier) o;
 
-        if (!name.equals(that.getName())) {
+        if (!name.equals(other.getName())) {
             return false;
         }
 
         // only fail if this namespace is non-null
-        if (getNamespace() != null && !getNamespace().equals(that.getNamespace())) {
+        if (getNamespace() != null && !getNamespace().equals(other.getNamespace())) {
             return false;
         }
         // only fail if this revision is non-null
-        if (getRevision() != null && !getRevision().equals(that.getRevision())) {
+        if (getRevision() != null && !getRevision().equals(other.getRevision())) {
+            return false;
+        }
+
+        if (!Objects.equals(getSemanticVersion(), other.getSemanticVersion())) {
             return false;
         }
 
index e6abb121b3fa5c26be6e6087e3a5a215f928a5e5..7b5255d2bb24bc2427581f89e895b70a1f945255 100644 (file)
@@ -9,6 +9,7 @@
 package org.opendaylight.yangtools.yang.parser.builder.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
+
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
 import java.net.URI;
@@ -20,6 +21,7 @@ import java.util.Objects;
 import java.util.Set;
 import java.util.TreeSet;
 import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.Deviation;
@@ -253,4 +255,9 @@ public final class ModuleImpl extends AbstractDocumentedDataNodeContainer implem
     public QNameModule getQNameModule() {
         return qnameModule;
     }
+
+    @Override
+    public SemVer getSemanticVersion() {
+        return DEFAULT_SEMANTIC_VERSION;
+    }
 }
index 5128185a229fd704e0b54494d29617d3c7958a0e..d2631f6474693cc1338e4df6809e5d70a329d6fa 100644 (file)
@@ -53,7 +53,7 @@ public class YinStatementParserImpl {
 
     /**
      *
-     * This method is supposed to be called in linkage phase, when YinStatementParserImpl instance has already been
+     * This method is supposed to be called in pre-linkage phase, when YinStatementParserImpl instance has already been
      * created.
      * When done, start walking through YIN source
      *
@@ -67,7 +67,7 @@ public class YinStatementParserImpl {
     }
 
     /**
-     * This method is supposed to be called in any phase but linkage, when YinStatementParserImpl instance has already
+     * This method is supposed to be called in any phase but pre-linkage, when YinStatementParserImpl instance has already
      * been created.
      * When done, start walking through YIN source
      *
@@ -226,28 +226,34 @@ public class YinStatementParserImpl {
         }
     }
 
-    private static boolean isStatementWithArgument(final QName identifier, final QNameToStatementDefinition stmtDef) {
-        if (stmtDef != null && stmtDef.get(Utils.trimPrefix(identifier)) == null) {
+    private boolean isStatementWithArgument(final QName identifier, final QNameToStatementDefinition stmtDef) {
+        StatementDefinition statementDefinition = getStatementDefinition(identifier, stmtDef);
+        if (statementDefinition == null) {
             return false;
-        } else if (((StatementSupport<?, ?, ?>) stmtDef.get(Utils.trimPrefix(identifier))).getPublicView().getArgumentName() == null) {
+        } else if (((StatementSupport<?, ?, ?>) statementDefinition).getPublicView().getArgumentName() == null) {
             return false;
         }
         return true;
     }
 
-    private static boolean isStatementWithYinElement(final QName identifier, final QNameToStatementDefinition stmtDef) {
-        final StatementDefinition statementDefinition = stmtDef.get(Utils.trimPrefix(identifier));
+    private boolean isStatementWithYinElement(final QName identifier, final QNameToStatementDefinition stmtDef) {
+        StatementDefinition statementDefinition = getStatementDefinition(identifier, stmtDef);
         if (statementDefinition == null) {
             return false;
         }
-
-        return ((Rfc6020Mapping) ((StatementSupport<?, ?, ?>) statementDefinition).getPublicView()).isArgumentYinElement();
+        return statementDefinition.isArgumentYinElement();
     }
 
-    private static String getAttributeValue(final XMLStreamReader inputReader, final QName identifier, final QNameToStatementDefinition
+    private String getAttributeValue(final XMLStreamReader inputReader, final QName identifier, final QNameToStatementDefinition
             stmtDef) {
         String namespace = null;
-        return inputReader.getAttributeValue(namespace, (((StatementSupport<?, ?, ?>) stmtDef.get(Utils.trimPrefix(identifier)))
+        return inputReader.getAttributeValue(namespace, (((StatementSupport<?, ?, ?>) getStatementDefinition(identifier, stmtDef))
                 .getPublicView()).getArgumentName().getLocalName());
     }
+
+    private StatementDefinition getStatementDefinition(final QName identifier, final QNameToStatementDefinition stmtDef) {
+        final QName trimPrefixIdentifier = Utils.trimPrefix(identifier);
+        return stmtDef.getByNamespaceAndLocalName(trimPrefixIdentifier.getNamespace(),
+                trimPrefixIdentifier.getLocalName());
+    }
 }
\ No newline at end of file
index cbe259f1fd9fc1abedb2b0ee7aca82bd6b57a540..e7125bf4ad5d210d884ec60b6d66e1dfb080251e 100644 (file)
@@ -9,21 +9,15 @@ package org.opendaylight.yangtools.yang.parser.impl.util;
 
 import static org.opendaylight.yangtools.yang.parser.impl.ParserListenerUtils.getArgumentString;
 
-import org.opendaylight.yangtools.yang.parser.impl.ParserListenerUtils;
-
 import com.google.common.base.Optional;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
-import java.util.HashSet;
-import java.util.Set;
-import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
-import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
-import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableSet;
 import java.io.InputStream;
 import java.util.Date;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Objects;
+import java.util.Set;
 import org.antlr.v4.runtime.ParserRuleContext;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.Belongs_to_stmtContext;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.Import_stmtContext;
@@ -33,9 +27,17 @@ import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.Revision_date_stmt
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.Revision_stmtContext;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.Revision_stmtsContext;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.Submodule_stmtContext;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser.StatementContext;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.parser.impl.ParserListenerUtils;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
 
 /**
  * Helper transfer object which holds basic and dependency information for YANG
@@ -484,11 +486,17 @@ public abstract class YangModelDependencyInfo {
     private static final class ModuleImportImpl implements ModuleImport {
 
         private final Date revision;
+        private final SemVer semVer;
         private final String name;
 
         public ModuleImportImpl(final String moduleName, final Date revision) {
-            this.name = moduleName;
+            this(moduleName, revision, Module.DEFAULT_SEMANTIC_VERSION);
+        }
+
+        public ModuleImportImpl(final String moduleName, final Date revision, final SemVer semVer) {
+            this.name = Preconditions.checkNotNull(moduleName, "Module name must not be null.");
             this.revision = revision;
+            this.semVer = Preconditions.checkNotNull(semVer, "Semantic version of module must not be null.");
         }
 
         @Override
@@ -501,6 +509,11 @@ public abstract class YangModelDependencyInfo {
             return this.revision;
         }
 
+        @Override
+        public SemVer getSemanticVersion() {
+            return this.semVer;
+        }
+
         @Override
         public String getPrefix() {
             return null;
@@ -512,6 +525,7 @@ public abstract class YangModelDependencyInfo {
             int result = 1;
             result = prime * result + Objects.hashCode(name);
             result = prime * result + Objects.hashCode(revision);
+            result = prime * result + Objects.hashCode(semVer);
             return result;
         }
 
@@ -541,6 +555,10 @@ public abstract class YangModelDependencyInfo {
             } else if (!revision.equals(other.revision)) {
                 return false;
             }
+
+            if (!Objects.equals(getSemanticVersion(), other.getSemanticVersion())) {
+                return false;
+            }
             return true;
         }
 
index f2180a3b2ec0706ad7ee021260252437ea4c7c87..d24e8ae116d6efb9b76a5ed5b8cf22ae2d917b85 100644 (file)
@@ -22,6 +22,7 @@ import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -208,6 +209,11 @@ final class DependencyResolver {
             return null;
         }
 
+        @Override
+        public SemVer getSemanticVersion() {
+            return null;
+        }
+
         @Override
         public String toString() {
             return MoreObjects.toStringHelper(this)
index ffc1249a75c77b3ea4cfff4066bf407c69ee5216..ab974ea2555e4ec3db4c38018b078067253a01ac 100644 (file)
@@ -127,4 +127,8 @@ public abstract class AbstractStatementSupport<A, D extends DeclaredStatement<A>
         // NOOP for most implementations
     }
 
+    @Override
+    public boolean isArgumentYinElement() {
+        return getPublicView().isArgumentYinElement();
+    }
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SemanticVersionModuleNamespace.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SemanticVersionModuleNamespace.java
new file mode 100644 (file)
index 0000000..4f5f83e
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.meta;
+
+import com.google.common.annotations.Beta;
+import java.util.NavigableMap;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ * Namespace class for storing Maps of all modules with the same name. This namespace is
+ * used only in case the semantic versioning is enabled, otherwise it is empty.
+ */
+@Beta
+public interface SemanticVersionModuleNamespace extends IdentifierNamespace<String, NavigableMap<SemVer, StmtContext<?, ?, ?>>> {
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SemanticVersionNamespace.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/SemanticVersionNamespace.java
new file mode 100644 (file)
index 0000000..40a7dbb
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.meta;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ * namespace class for storing semantic version of yang modules
+ */
+@Beta
+public interface SemanticVersionNamespace extends IdentifierNamespace<StmtContext<?, ?, ?>, SemVer> {
+}
index 78d1ef44207c6fa0deff013487e1261fe8f001ab..de95986d476a35ab93c79113c40c693f3c383d6b 100644 (file)
@@ -54,6 +54,8 @@ public interface StmtContext<A, D extends DeclaredStatement<A>, E extends Effect
 
     boolean isConfiguration();
 
+    boolean isEnabledSemanticVersioning();
+
     @Nonnull
     <K, V, KT extends K, N extends IdentifierNamespace<K, V>> V getFromNamespace(
             Class<N> type, KT key) throws NamespaceNotAvailableException;
index a60e7dfb94e9caf78ecf8674cdbbb8bcbe59a78d..843ed6adc524ddde01cfe28e756992220a09c33a 100644 (file)
@@ -8,15 +8,12 @@
 package org.opendaylight.yangtools.yang.parser.spi.source;
 
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
-
 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
 
 /**
  *
- * Source-specific mapping of prefixes to namespaces
+ * Source-specific mapping of prefixes to module identifiers
  *
  */
 public interface ImpPrefixToModuleIdentifier extends IdentifierNamespace<String, ModuleIdentifier> {
-
-
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToSemVerModuleIdentifier.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToSemVerModuleIdentifier.java
new file mode 100644 (file)
index 0000000..d167832
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ *
+ * Source-specific mapping of prefixes to module identifier with specified semantic version
+ */
+@Beta
+public interface ImpPrefixToSemVerModuleIdentifier extends IdentifierNamespace<String, ModuleIdentifier> {
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleCtxToModuleIdentifier.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleCtxToModuleIdentifier.java
new file mode 100644 (file)
index 0000000..29e2d9a
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+/**
+ *
+ * Global mapping of modules to module identifier
+ *
+ */
+public interface ModuleCtxToModuleIdentifier extends IdentifierNamespace<StmtContext<?,?,?>, ModuleIdentifier> {
+
+}
index 2487afd3cbd0c32c6fb79f5528ad1f15573d0338..5e118b3de40a9fe9924372fe4abef4f17306ff0c 100644 (file)
@@ -7,14 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.source;
 
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 /**
  *
- * Source-specific mapping of prefixes to namespaces
+ * Global mapping of modules to QNameModules
  *
  */
 public interface ModuleCtxToModuleQName extends IdentifierNamespace<StmtContext<?,?,?>, QNameModule> {
index a4c0b4446b40dbc596e114a3ce6329b983133310..9752834623a7fed2fe4490db67ea79a552c6e83d 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedNamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
@@ -52,42 +53,51 @@ import org.slf4j.LoggerFactory;
 class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBehaviour.Registry {
     private static final Logger LOG = LoggerFactory.getLogger(BuildGlobalContext.class);
 
-    private static final List<ModelProcessingPhase> PHASE_EXECUTION_ORDER = ImmutableList.<ModelProcessingPhase>builder()
-            .add(ModelProcessingPhase.SOURCE_PRE_LINKAGE)
-            .add(ModelProcessingPhase.SOURCE_LINKAGE)
-            .add(ModelProcessingPhase.STATEMENT_DEFINITION)
-            .add(ModelProcessingPhase.FULL_DECLARATION)
-            .add(ModelProcessingPhase.EFFECTIVE_MODEL)
-            .build();
+    private static final List<ModelProcessingPhase> PHASE_EXECUTION_ORDER = ImmutableList
+            .<ModelProcessingPhase> builder().add(ModelProcessingPhase.SOURCE_PRE_LINKAGE)
+            .add(ModelProcessingPhase.SOURCE_LINKAGE).add(ModelProcessingPhase.STATEMENT_DEFINITION)
+            .add(ModelProcessingPhase.FULL_DECLARATION).add(ModelProcessingPhase.EFFECTIVE_MODEL).build();
 
-    private final Map<QName,StatementDefinitionContext<?,?,?>> definitions = new HashMap<>();
-    private final Map<Class<?>,NamespaceBehaviourWithListeners<?, ?, ?>> supportedNamespaces = new HashMap<>();
+    private final Map<QName, StatementDefinitionContext<?, ?, ?>> definitions = new HashMap<>();
+    private final Map<Class<?>, NamespaceBehaviourWithListeners<?, ?, ?>> supportedNamespaces = new HashMap<>();
 
-    private final Map<ModelProcessingPhase,StatementSupportBundle> supports;
+    private final Map<ModelProcessingPhase, StatementSupportBundle> supports;
     private final Set<SourceSpecificContext> sources = new HashSet<>();
 
     private ModelProcessingPhase currentPhase = ModelProcessingPhase.INIT;
     private ModelProcessingPhase finishedPhase = ModelProcessingPhase.INIT;
 
+    private final boolean enabledSemanticVersions;
+
     public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
-                              final Predicate<QName> isFeatureSupported) {
+            StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
         super();
         this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
+        Preconditions.checkNotNull(statementParserMode, "Statement parser mode must not be null.");
+        this.enabledSemanticVersions = statementParserMode == StatementParserMode.SEMVER_MODE;
 
-        addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES, isFeatureSupported);
+        addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
+                Preconditions.checkNotNull(isFeatureSupported, "Supported feature predicate must not be null."));
     }
 
     public BuildGlobalContext(final Map<ModelProcessingPhase, StatementSupportBundle> supports,
-                              final Map<ValidationBundleType,Collection<?>> supportedValidation,
-                              final Predicate<QName> isFeatureSupported) {
+            final Map<ValidationBundleType, Collection<?>> supportedValidation,
+            StatementParserMode statementParserMode, final Predicate<QName> isFeatureSupported) {
         super();
         this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null");
+        Preconditions.checkNotNull(statementParserMode, "Statement parser mode must not be null.");
+        this.enabledSemanticVersions = statementParserMode == StatementParserMode.SEMVER_MODE;
 
         for (Entry<ValidationBundleType, Collection<?>> validationBundle : supportedValidation.entrySet()) {
             addToNs(ValidationBundlesNamespace.class, validationBundle.getKey(), validationBundle.getValue());
         }
 
-        addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES, isFeatureSupported);
+        addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES,
+                Preconditions.checkNotNull(isFeatureSupported, "Supported feature predicate must not be null."));
+    }
+
+    public boolean isEnabledSemanticVersioning() {
+        return enabledSemanticVersions;
     }
 
     public StatementSupportBundle getSupportsForPhase(final ModelProcessingPhase currentPhase) {
@@ -95,7 +105,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
     }
 
     public void addSource(@Nonnull final StatementStreamSource source) {
-        sources.add(new SourceSpecificContext(this,source));
+        sources.add(new SourceSpecificContext(this, source));
     }
 
     @Override
@@ -114,7 +124,8 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
     }
 
     @Override
-    public <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> getNamespaceBehaviour(final Class<N> type) {
+    public <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> getNamespaceBehaviour(
+            final Class<N> type) {
         NamespaceBehaviourWithListeners<?, ?, ?> potential = supportedNamespaces.get(type);
         if (potential == null) {
             NamespaceBehaviour<K, V, N> potentialRaw = supports.get(currentPhase).getNamespaceBehaviour(type);
@@ -122,27 +133,27 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
                 potential = createNamespaceContext(potentialRaw);
                 supportedNamespaces.put(type, potential);
             } else {
-                throw new NamespaceNotAvailableException(
-                        "Namespace " + type + " is not available in phase " + currentPhase);
+                throw new NamespaceNotAvailableException("Namespace " + type + " is not available in phase "
+                        + currentPhase);
             }
         }
 
         Verify.verify(type.equals(potential.getIdentifier()));
         /*
-         * Safe cast, previous checkState checks equivalence of key from which type argument are
-         * derived
+         * Safe cast, previous checkState checks equivalence of key from which
+         * type argument are derived
          */
         return (NamespaceBehaviourWithListeners<K, V, N>) potential;
     }
 
-    @SuppressWarnings({"unchecked", "rawtypes"})
+    @SuppressWarnings({ "unchecked", "rawtypes" })
     private <K, V, N extends IdentifierNamespace<K, V>> NamespaceBehaviourWithListeners<K, V, N> createNamespaceContext(
             final NamespaceBehaviour<K, V, N> potentialRaw) {
         if (potentialRaw instanceof DerivedNamespaceBehaviour) {
-            VirtualNamespaceContext derivedContext =
-                    new VirtualNamespaceContext((DerivedNamespaceBehaviour) potentialRaw);
-            getNamespaceBehaviour(((DerivedNamespaceBehaviour) potentialRaw).getDerivedFrom())
-                    .addDerivedNamespace(derivedContext);
+            VirtualNamespaceContext derivedContext = new VirtualNamespaceContext(
+                    (DerivedNamespaceBehaviour) potentialRaw);
+            getNamespaceBehaviour(((DerivedNamespaceBehaviour) potentialRaw).getDerivedFrom()).addDerivedNamespace(
+                    derivedContext);
             return derivedContext;
         }
         return new SimpleNamespaceContext<>(potentialRaw);
@@ -192,7 +203,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
     private EffectiveSchemaContext transformEffective() {
         Preconditions.checkState(finishedPhase == ModelProcessingPhase.EFFECTIVE_MODEL);
         List<DeclaredStatement<?>> rootStatements = new ArrayList<>(sources.size());
-        List<EffectiveStatement<?,?>> rootEffectiveStatements = new ArrayList<>(sources.size());
+        List<EffectiveStatement<?, ?>> rootEffectiveStatements = new ArrayList<>(sources.size());
 
         for (SourceSpecificContext source : sources) {
             final RootStatementContext<?, ?, ?> root = source.getRoot();
@@ -211,7 +222,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
         currentPhase = phase;
     }
 
-    private  void loadPhaseStatements() throws SourceException {
+    private void loadPhaseStatements() throws SourceException {
         Preconditions.checkState(currentPhase != null);
         for (SourceSpecificContext source : sources) {
             source.loadStatements();
@@ -224,7 +235,8 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
         for (SourceSpecificContext failedSource : sourcesToProgress) {
             final SourceException sourceEx = failedSource.failModifiers(currentPhase);
 
-            // Workaround for broken logging implementations which ignore suppressed exceptions
+            // Workaround for broken logging implementations which ignore
+            // suppressed exceptions
             Throwable cause = sourceEx.getCause() != null ? sourceEx.getCause() : sourceEx;
             if (LOG.isDebugEnabled()) {
                 LOG.error("Failed to parse YANG from source {}", failedSource, sourceEx);
@@ -259,7 +271,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
         return buildFailure;
     }
 
-    private  void completePhaseActions() throws ReactorException {
+    private void completePhaseActions() throws ReactorException {
         Preconditions.checkState(currentPhase != null);
         List<SourceSpecificContext> sourcesToProgress = Lists.newArrayList(sources);
         try {
@@ -272,17 +284,18 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
                     SourceSpecificContext nextSourceCtx = currentSource.next();
                     PhaseCompletionProgress sourceProgress = nextSourceCtx.tryToCompletePhase(currentPhase);
                     switch (sourceProgress) {
-                        case FINISHED:
-                            currentSource.remove();
-                            // Fallback to progress, since we were able to make progress in computation
-                        case PROGRESS:
-                            progressing = true;
-                            break;
-                        case NO_PROGRESS:
-                            // Noop
-                            break;
-                        default:
-                           throw new IllegalStateException("Unsupported phase progress " + sourceProgress);
+                    case FINISHED:
+                        currentSource.remove();
+                        // Fallback to progress, since we were able to make
+                        // progress in computation
+                    case PROGRESS:
+                        progressing = true;
+                        break;
+                    case NO_PROGRESS:
+                        // Noop
+                        break;
+                    default:
+                        throw new IllegalStateException("Unsupported phase progress " + sourceProgress);
                     }
                 }
             }
@@ -296,7 +309,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
         }
     }
 
-    private  void endPhase(final ModelProcessingPhase phase) {
+    private void endPhase(final ModelProcessingPhase phase) {
         Preconditions.checkState(currentPhase == phase);
         finishedPhase = currentPhase;
     }
index 9873466b3040976c6fc0350f61939aaab7e01b00..fac33f5e1da30793fdd10483de5dfbf70a489729 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
-import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.io.ByteSource;
 import java.io.File;
@@ -25,6 +24,7 @@ import java.util.function.Predicate;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
@@ -36,15 +36,16 @@ import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
 
 public class CrossSourceStatementReactor {
 
-    private final Map<ModelProcessingPhase,StatementSupportBundle> supportedTerminology;
-    private final Map<ValidationBundleType,Collection<?>> supportedValidation;
+    private final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology;
+    private final Map<ValidationBundleType, Collection<?>> supportedValidation;
 
     CrossSourceStatementReactor(final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology) {
         this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
         this.supportedValidation = ImmutableMap.of();
     }
 
-    CrossSourceStatementReactor(final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology, final Map<ValidationBundleType,Collection<?>> supportedValidation) {
+    CrossSourceStatementReactor(final Map<ModelProcessingPhase, StatementSupportBundle> supportedTerminology,
+            final Map<ValidationBundleType, Collection<?>> supportedValidation) {
         this.supportedTerminology = ImmutableMap.copyOf(supportedTerminology);
         this.supportedValidation = ImmutableMap.copyOf(supportedValidation);
     }
@@ -54,26 +55,34 @@ public class CrossSourceStatementReactor {
     }
 
     public final BuildAction newBuild() {
-        return newBuild(t -> true);
+        return newBuild(StatementParserMode.DEFAULT_MODE, t -> true);
     }
 
     public final BuildAction newBuild(final Predicate<QName> isFeatureSupported) {
-        return new BuildAction(isFeatureSupported);
+        return new BuildAction(StatementParserMode.DEFAULT_MODE, isFeatureSupported);
     }
 
-    public static class Builder implements org.opendaylight.yangtools.concepts.Builder<CrossSourceStatementReactor>{
+    public final BuildAction newBuild(final StatementParserMode statementParserMode) {
+        return new BuildAction(statementParserMode, t -> true);
+    }
+
+    public final BuildAction newBuild(final StatementParserMode statementParserMode,
+            final Predicate<QName> isFeatureSupported) {
+        return new BuildAction(statementParserMode, isFeatureSupported);
+    }
 
-        final Map<ModelProcessingPhase,StatementSupportBundle> bundles = new EnumMap<>(ModelProcessingPhase.class);
-        final Map<ValidationBundleType,Collection<?>> validationBundles = new EnumMap<>(ValidationBundleType.class);
+    public static class Builder implements org.opendaylight.yangtools.concepts.Builder<CrossSourceStatementReactor> {
 
-        public Builder setBundle(final ModelProcessingPhase phase,final StatementSupportBundle bundle) {
+        final Map<ModelProcessingPhase, StatementSupportBundle> bundles = new EnumMap<>(ModelProcessingPhase.class);
+        final Map<ValidationBundleType, Collection<?>> validationBundles = new EnumMap<>(ValidationBundleType.class);
+
+        public Builder setBundle(final ModelProcessingPhase phase, final StatementSupportBundle bundle) {
             bundles.put(phase, bundle);
             return this;
         }
 
-
         public Builder setValidationBundle(final ValidationBundleType type, final Collection<?> validationBundle) {
-            validationBundles.put(type,validationBundle);
+            validationBundles.put(type, validationBundle);
             return this;
         }
 
@@ -87,12 +96,20 @@ public class CrossSourceStatementReactor {
         private final BuildGlobalContext context;
 
         public BuildAction() {
-            this(t -> true);
+            this(StatementParserMode.DEFAULT_MODE, t -> true);
+        }
+
+        public BuildAction(StatementParserMode statementParserMode) {
+            this(statementParserMode, t -> true);
         }
 
         public BuildAction(Predicate<QName> isFeatureSupported) {
-            Preconditions.checkNotNull(isFeatureSupported);
-            this.context = new BuildGlobalContext(supportedTerminology, supportedValidation, isFeatureSupported);
+            this(StatementParserMode.DEFAULT_MODE, isFeatureSupported);
+        }
+
+        public BuildAction(StatementParserMode statementParserMode, Predicate<QName> isFeatureSupported) {
+            this.context = new BuildGlobalContext(supportedTerminology, supportedValidation, statementParserMode,
+                    isFeatureSupported);
         }
 
         public void addSource(final StatementStreamSource source) {
@@ -117,8 +134,8 @@ public class CrossSourceStatementReactor {
             return context.buildEffective();
         }
 
-        public SchemaContext buildEffective(final Collection<ByteSource> yangByteSources) throws
-                ReactorException, IOException {
+        public SchemaContext buildEffective(final Collection<ByteSource> yangByteSources) throws ReactorException,
+                IOException {
             for (ByteSource yangByteSource : yangByteSources) {
                 addSource(new YangStatementSourceImpl(yangByteSource.openStream()));
             }
@@ -126,8 +143,7 @@ public class CrossSourceStatementReactor {
             return buildEffective();
         }
 
-        public SchemaContext buildEffective(final List<InputStream> yangInputStreams) throws
-                ReactorException {
+        public SchemaContext buildEffective(final List<InputStream> yangInputStreams) throws ReactorException {
             for (InputStream yangInputStream : yangInputStreams) {
                 addSource(new YangStatementSourceImpl(yangInputStream));
             }
@@ -136,11 +152,12 @@ public class CrossSourceStatementReactor {
         }
 
         /**
-         * @deprecated This method was never used and relies on deprecated module methods.
+         * @deprecated This method was never used and relies on deprecated
+         *             module methods.
          */
         @Deprecated
-        public Map<File, Module> buildEffectiveMappedToSource(final List<File> yangFiles) throws
-                ReactorException, FileNotFoundException {
+        public Map<File, Module> buildEffectiveMappedToSource(final List<File> yangFiles) throws ReactorException,
+                FileNotFoundException {
             if (yangFiles == null || yangFiles.isEmpty()) {
                 return Collections.emptyMap();
             }
@@ -162,4 +179,4 @@ public class CrossSourceStatementReactor {
             return sourceFileToModule;
         }
     }
-}
+}
\ No newline at end of file
index 26f4a3e57e8f04a5229058a5343546d0b7d8f381..a6df7138836947f17d5a7efe7e0987b58763746d 100644 (file)
@@ -20,9 +20,15 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UnknownEffe
 // FIXME: Provide real argument name
 final class ModelDefinedStatementDefinition implements StatementDefinition {
     private final QName qName;
+    private final boolean yinElement;
 
     ModelDefinedStatementDefinition(QName qName) {
+        this(qName, false);
+    }
+
+    ModelDefinedStatementDefinition(QName qName, final boolean yinElement) {
         this.qName = qName;
+        this.yinElement = yinElement;
     }
 
     @Nonnull
@@ -48,4 +54,9 @@ final class ModelDefinedStatementDefinition implements StatementDefinition {
     public Class<? extends EffectiveStatement<?, ?>> getEffectiveRepresentationClass() {
         return UnknownEffectiveStatementImpl.class;
     }
+
+    @Override
+    public boolean isArgumentYinElement() {
+        return yinElement;
+    }
 }
\ No newline at end of file
index b24f6e3e04e4db27124921098e92991886ef7961..4fc299a573a86b26d5ad850b02c3118db1b4d5e9 100644 (file)
@@ -171,4 +171,9 @@ public class RootStatementContext<A, D extends DeclaredStatement<A>, E extends E
     public boolean isConfiguration() {
         return true;
     }
+
+    @Override
+    public boolean isEnabledSemanticVersioning() {
+        return sourceContext.isEnabledSemanticVersioning();
+    }
 }
index ead4acb8aad1afb194781dea09562afc97bbf3b0..c2d06d6035517b5cc9c44f518ee0775d04e031f9 100644 (file)
@@ -88,6 +88,10 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
         this.currentContext = currentContext;
     }
 
+    public boolean isEnabledSemanticVersioning(){
+        return currentContext.isEnabledSemanticVersioning();
+    }
+
     ModelProcessingPhase getInProgressPhase() {
         return inProgressPhase;
     }
@@ -382,7 +386,7 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
     }
 
     private QNameToStatementDefinition stmtDef() {
-        // regular YANG statements added
+        // regular YANG statements and extension supports added
         ImmutableMap<QName, StatementSupport<?, ?, ?>> definitions = currentContext.getSupportsForPhase(
                 inProgressPhase).getDefinitions();
         for (Entry<QName, StatementSupport<?, ?, ?>> entry : definitions.entrySet()) {
@@ -396,12 +400,15 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
             if (extensions != null) {
                 for (Entry<QName, StmtContext<?, ExtensionStatement, EffectiveStatement<QName, ExtensionStatement>>> extension :
                     extensions.entrySet()) {
-                    qNameToStmtDefMap.put((extension.getKey()),
+                    if(qNameToStmtDefMap.get(extension.getKey()) == null) {
+                        qNameToStmtDefMap.put((extension.getKey()),
                         (StatementDefinition) ((StatementContextBase<?, ?, ?>) extension.getValue()).definition()
                         .getFactory());
+                    }
                 }
             }
         }
+
         return qNameToStmtDefMap;
     }
 }
index c7e1c1a8de51adbefaf17b27088ba6adf1aceeee..5f47b015adb7344ad1140d3390a2a76344ba7fde 100644 (file)
@@ -257,4 +257,9 @@ final class SubstatementContext<A, D extends DeclaredStatement<A>, E extends Eff
                 "Parent node has config statement set to false, therefore no node underneath it can have config set to true",
                 getStatementSourceReference());
     }
+
+    @Override
+    public boolean isEnabledSemanticVersioning() {
+        return parent.isEnabledSemanticVersioning();
+    }
 }
index 6fc637b59d024581f6f6ee80ca0f54a50988ce51..336b85cb1a0cacb977cf762674fcb9eadc92f9bb 100644 (file)
@@ -18,7 +18,10 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.NavigableMap;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -36,18 +39,22 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionModuleNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToSemVerModuleIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToNamespace;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ImportEffectiveStatementImpl;
 
-public class ImportStatementDefinition
-        extends AbstractStatementSupport<String, ImportStatement, EffectiveStatement<String, ImportStatement>> {
-    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
-            SubstatementValidator.builder(Rfc6020Mapping.IMPORT)
-            .add(Rfc6020Mapping.PREFIX, 1, 1).add(Rfc6020Mapping.REVISION_DATE, 0, 1).build();
+public class ImportStatementDefinition extends
+        AbstractStatementSupport<String, ImportStatement, EffectiveStatement<String, ImportStatement>> {
+    private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator
+            .builder(Rfc6020Mapping.IMPORT).add(Rfc6020Mapping.PREFIX, 1, 1).add(Rfc6020Mapping.REVISION_DATE, 0, 1)
+            .add(SupportedExtensionsMapping.SEMANTIC_VERSION, 0, 1).build();
 
     public ImportStatementDefinition() {
         super(Rfc6020Mapping.IMPORT);
@@ -109,79 +116,186 @@ public class ImportStatementDefinition
     @Override
     public void onLinkageDeclared(
             final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> stmt) {
-        final ModuleIdentifier impIdentifier = getImportedModuleIdentifier(stmt);
-        final ModelActionBuilder importAction = stmt.newInferenceAction(SOURCE_LINKAGE);
-        final Prerequisite<StmtContext<?, ?, ?>> imported = importAction.requiresCtx(stmt, ModuleNamespace.class,
-            impIdentifier, SOURCE_LINKAGE);
-        final Prerequisite<Mutable<?, ?, ?>> linkageTarget = importAction.mutatesCtx(stmt.getRoot(), SOURCE_LINKAGE);
+        if (stmt.isEnabledSemanticVersioning()) {
+            SemanticVersionImport.onLinkageDeclared(stmt);
+        } else {
+            RevisionImport.onLinkageDeclared(stmt);
+        }
+    }
 
-        importAction.apply(new InferenceAction() {
-            @Override
-            public void apply() {
-                StmtContext<?, ?, ?> importedModule = null;
-                ModuleIdentifier importedModuleIdentifier = null;
-                if (impIdentifier.getRevision() == SimpleDateFormatUtil.DEFAULT_DATE_IMP) {
-                    Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> recentModuleEntry =
-                            findRecentModule(impIdentifier, stmt.getAllFromNamespace(ModuleNamespace.class));
-                    if (recentModuleEntry != null) {
-                        importedModuleIdentifier = recentModuleEntry.getKey();
-                        importedModule = recentModuleEntry.getValue();
+    private static class RevisionImport {
+
+        private RevisionImport() {
+            throw new UnsupportedOperationException("Utility class");
+        }
+
+        private static void onLinkageDeclared(
+                final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> stmt) {
+            final ModuleIdentifier impIdentifier = getImportedModuleIdentifier(stmt);
+            final ModelActionBuilder importAction = stmt.newInferenceAction(SOURCE_LINKAGE);
+            final Prerequisite<StmtContext<?, ?, ?>> imported = importAction.requiresCtx(stmt, ModuleNamespace.class,
+                    impIdentifier, SOURCE_LINKAGE);
+            final Prerequisite<Mutable<?, ?, ?>> linkageTarget = importAction
+                    .mutatesCtx(stmt.getRoot(), SOURCE_LINKAGE);
+
+            importAction.apply(new InferenceAction() {
+                @Override
+                public void apply() {
+                    StmtContext<?, ?, ?> importedModule = null;
+                    ModuleIdentifier importedModuleIdentifier = null;
+                    if (impIdentifier.getRevision() == SimpleDateFormatUtil.DEFAULT_DATE_IMP) {
+                        Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> recentModuleEntry = findRecentModule(
+                                impIdentifier, stmt.getAllFromNamespace(ModuleNamespace.class));
+                        if (recentModuleEntry != null) {
+                            importedModuleIdentifier = recentModuleEntry.getKey();
+                            importedModule = recentModuleEntry.getValue();
+                        }
+                    }
+
+                    if (importedModule == null || importedModuleIdentifier == null) {
+                        importedModule = imported.get();
+                        importedModuleIdentifier = impIdentifier;
+                    }
+
+                    linkageTarget.get().addToNs(ImportedModuleContext.class, importedModuleIdentifier, importedModule);
+                    String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
+                    stmt.addToNs(ImpPrefixToModuleIdentifier.class, impPrefix, importedModuleIdentifier);
+
+                    final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(), NamespaceStatement.class);
+                    stmt.addToNs(URIStringToImpPrefix.class, modNs.toString(), impPrefix);
+                }
+
+                @Override
+                public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
+                    if (failed.contains(imported)) {
+                        throw new InferenceException(stmt.getStatementSourceReference(),
+                                "Imported module [%s] was not found.", impIdentifier);
                     }
                 }
+            });
+
+        }
+
+        private static Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> findRecentModule(
+                final ModuleIdentifier impIdentifier,
+                final Map<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> allModules) {
+
+            ModuleIdentifier recentModuleIdentifier = impIdentifier;
+            Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> recentModuleEntry = null;
+
+            for (Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> moduleEntry : allModules
+                    .entrySet()) {
+                final ModuleIdentifier id = moduleEntry.getKey();
 
-                if (importedModule == null || importedModuleIdentifier == null) {
-                    importedModule = imported.get();
-                    importedModuleIdentifier = impIdentifier;
+                if (id.getName().equals(impIdentifier.getName())
+                        && id.getRevision().compareTo(recentModuleIdentifier.getRevision()) > 0) {
+                    recentModuleIdentifier = id;
+                    recentModuleEntry = moduleEntry;
                 }
+            }
 
-                linkageTarget.get().addToNs(ImportedModuleContext.class, importedModuleIdentifier, importedModule);
-                String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
-                stmt.addToNs(ImpPrefixToModuleIdentifier.class, impPrefix, importedModuleIdentifier);
+            return recentModuleEntry;
+        }
 
-                final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(), NamespaceStatement.class);
-                stmt.addToNs(URIStringToImpPrefix.class, modNs.toString(), impPrefix);
+        private static ModuleIdentifier getImportedModuleIdentifier(final Mutable<String, ImportStatement, ?> stmt) {
+            Date revision = firstAttributeOf(stmt.declaredSubstatements(), RevisionDateStatement.class);
+            if (revision == null) {
+                revision = SimpleDateFormatUtil.DEFAULT_DATE_IMP;
             }
 
-            private Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> findRecentModule(
-                    final ModuleIdentifier impIdentifier,
-                    final Map<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> allModules) {
+            return new ModuleIdentifierImpl(stmt.getStatementArgument(), Optional.absent(),
+                    Optional.of(revision));
+        }
+    }
+
+    private static class SemanticVersionImport {
+        private SemanticVersionImport() {
+            throw new UnsupportedOperationException("Utility class");
+        }
 
-                ModuleIdentifier recentModuleIdentifier = impIdentifier;
-                Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> recentModuleEntry = null;
+        private static void onLinkageDeclared(
+                final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> stmt) {
+            final ModuleIdentifier impIdentifier = getImportedModuleIdentifier(stmt);
+            final ModelActionBuilder importAction = stmt.newInferenceAction(SOURCE_LINKAGE);
+            final Prerequisite<StmtContext<?, ?, ?>> imported = importAction.requiresCtx(stmt, ModuleNamespace.class,
+                    impIdentifier, SOURCE_LINKAGE);
+            final Prerequisite<Mutable<?, ?, ?>> linkageTarget = importAction
+                    .mutatesCtx(stmt.getRoot(), SOURCE_LINKAGE);
 
-                for (Entry<ModuleIdentifier, StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>>> moduleEntry : allModules.entrySet()) {
-                    final ModuleIdentifier id = moduleEntry.getKey();
+            importAction.apply(new InferenceAction() {
+                @Override
+                public void apply() {
+                    Entry<SemVer, StmtContext<?, ?, ?>> importedModuleEntry= findRecentCompatibleModuleEntry(
+                            impIdentifier.getName(), stmt);
 
-                    if (id.getName().equals(impIdentifier.getName())
-                            && id.getRevision().compareTo(recentModuleIdentifier.getRevision()) > 0) {
-                        recentModuleIdentifier = id;
-                        recentModuleEntry = moduleEntry;
+                    StmtContext<?, ?, ?> importedModule = null;
+                    ModuleIdentifier importedModuleIdentifier = null;
+                    ModuleIdentifier semVerModuleIdentifier = null;
+                    if (importedModuleEntry != null) {
+                        importedModule = importedModuleEntry.getValue();
+                        importedModuleIdentifier = importedModule.getFromNamespace(ModuleCtxToModuleIdentifier.class, importedModule);
+                        semVerModuleIdentifier = createSemVerModuleIdentifier(importedModuleIdentifier, importedModuleEntry.getKey());
+                    } else {
+                        throw new InferenceException(stmt.getStatementSourceReference(),
+                                "Unable to find module compatible with requested import [%s(%s)].", impIdentifier
+                                        .getName(), getRequestedImportVersion(stmt));
                     }
+
+                    linkageTarget.get().addToNs(ImportedModuleContext.class, importedModuleIdentifier, importedModule);
+                    String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
+                    stmt.addToNs(ImpPrefixToModuleIdentifier.class, impPrefix, importedModuleIdentifier);
+                    stmt.addToNs(ImpPrefixToSemVerModuleIdentifier.class, impPrefix, semVerModuleIdentifier);
+
+                    final URI modNs = firstAttributeOf(importedModule.declaredSubstatements(), NamespaceStatement.class);
+                    stmt.addToNs(URIStringToImpPrefix.class, modNs.toString(), impPrefix);
                 }
 
-                return recentModuleEntry;
+                @Override
+                public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed) {
+                    if (failed.contains(imported)) {
+                        throw new InferenceException(stmt.getStatementSourceReference(),
+                                "Unable to find module compatible with requested import [%s(%s)].", impIdentifier
+                                        .getName(), getRequestedImportVersion(stmt));
+                    }
+                }
+            });
+        }
+
+        private static SemVer getRequestedImportVersion(Mutable<?, ?, ?> impStmt) {
+            SemVer requestedImportVersion = impStmt.getFromNamespace(SemanticVersionNamespace.class, impStmt);
+            if (requestedImportVersion == null) {
+                requestedImportVersion = Module.DEFAULT_SEMANTIC_VERSION;
             }
+            return requestedImportVersion;
+        }
 
-            @Override
-            public void prerequisiteFailed(final Collection<? extends Prerequisite<?>> failed)  {
-                if (failed.contains(imported)) {
-                    throw new InferenceException(stmt.getStatementSourceReference(),
-                        "Imported module [%s] was not found.", impIdentifier);
-                }
+        private static Entry<SemVer, StmtContext<?, ?, ?>> findRecentCompatibleModuleEntry(final String moduleName,
+                final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> impStmt) {
+            NavigableMap<SemVer, StmtContext<?, ?, ?>> allRelevantModulesMap = impStmt.getFromNamespace(
+                    SemanticVersionModuleNamespace.class, moduleName);
+            if (allRelevantModulesMap == null) {
+                return null;
             }
-        });
 
+            final SemVer requestedImportVersion = getRequestedImportVersion(impStmt);
+            allRelevantModulesMap = allRelevantModulesMap.subMap(requestedImportVersion, true,
+                    SemVer.create(requestedImportVersion.getMajor() + 1), false);
+            if (!allRelevantModulesMap.isEmpty()) {
+                return allRelevantModulesMap.lastEntry();
+            }
 
-    }
+            return null;
+        }
 
-    private static ModuleIdentifier getImportedModuleIdentifier(final Mutable<String, ImportStatement, ?> stmt) {
-        Date revision = firstAttributeOf(stmt.declaredSubstatements(), RevisionDateStatement.class);
-        if (revision == null) {
-            revision = SimpleDateFormatUtil.DEFAULT_DATE_IMP;
+        private static ModuleIdentifier getImportedModuleIdentifier(final Mutable<String, ImportStatement, ?> impStmt) {
+            return new ModuleIdentifierImpl(impStmt.getStatementArgument(), Optional.absent(),
+                    Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_IMP));
         }
 
-        return new ModuleIdentifierImpl(stmt.getStatementArgument(), Optional.absent(),
-                Optional.of(revision));
+        private static ModuleIdentifier createSemVerModuleIdentifier(final ModuleIdentifier importedModuleIdentifier,
+                final SemVer semVer) {
+            return new ModuleIdentifierImpl(importedModuleIdentifier.getName(), Optional.fromNullable(importedModuleIdentifier
+                    .getNamespace()), Optional.of(importedModuleIdentifier.getRevision()), semVer);
+        }
     }
-
-}
\ No newline at end of file
+}
index 44c4194cf233f59ab7623cda62d686cd14057bdc..2f0e06ba1da14889f8fd41f99a21469dbdaa0244 100644 (file)
@@ -13,8 +13,12 @@ import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.f
 import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Date;
+import java.util.NavigableMap;
+import java.util.TreeMap;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -27,10 +31,13 @@ import org.opendaylight.yangtools.yang.parser.spi.NamespaceToModule;
 import org.opendaylight.yangtools.yang.parser.spi.PreLinkageModuleNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionModuleNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
@@ -71,6 +78,7 @@ public class ModuleStatementSupport extends
             .add(Rfc6020Mapping.TYPEDEF, 0, MAX)
             .add(Rfc6020Mapping.USES, 0, MAX)
             .add(Rfc6020Mapping.YANG_VERSION, 0, 1)
+            .add(SupportedExtensionsMapping.SEMANTIC_VERSION, 0, 1)
             .build();
 
     public ModuleStatementSupport() {
@@ -139,9 +147,30 @@ public class ModuleStatementSupport extends
         stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
         stmt.addToNs(ModuleNameToModuleQName.class, stmt.getStatementArgument(), qNameModule);
         stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
+        stmt.addToNs(ModuleCtxToModuleIdentifier.class, stmt, moduleIdentifier);
         stmt.addToNs(ModuleQNameToModuleName.class, qNameModule, stmt.getStatementArgument());
         stmt.addToNs(ModuleIdentifierToModuleQName.class, moduleIdentifier, qNameModule);
         stmt.addToNs(ImpPrefixToModuleIdentifier.class, modulePrefix, moduleIdentifier);
+
+        if (stmt.isEnabledSemanticVersioning()) {
+            addToSemVerModuleNamespace(stmt);
+        }
+    }
+
+    private void addToSemVerModuleNamespace(
+            final Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt) {
+        final String moduleName = stmt.getStatementArgument();
+        NavigableMap<SemVer, StmtContext<?, ?, ?>> modulesMap = stmt.getFromNamespace(
+                SemanticVersionModuleNamespace.class, moduleName);
+        if (modulesMap == null) {
+            modulesMap = new TreeMap<SemVer, StmtContext<?, ?, ?>>();
+        }
+        SemVer moduleSemVer = stmt.getFromNamespace(SemanticVersionNamespace.class, stmt);
+        if(moduleSemVer == null) {
+            moduleSemVer = Module.DEFAULT_SEMANTIC_VERSION;
+        }
+        modulesMap.put(moduleSemVer, stmt);
+        stmt.addToNs(SemanticVersionModuleNamespace.class, moduleName, modulesMap);
     }
 
     @Override
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SemanticVersionStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SemanticVersionStatementImpl.java
new file mode 100644 (file)
index 0000000..aea5d7e
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import com.google.common.annotations.Beta;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.SemanticVersionEffectiveStatementImpl;
+
+@Beta
+public final class SemanticVersionStatementImpl extends AbstractDeclaredStatement<SemVer> implements
+        UnknownStatement<SemVer> {
+
+    SemanticVersionStatementImpl(
+            StmtContext<SemVer, UnknownStatement<SemVer>, ?> context) {
+        super(context);
+    }
+
+    public static class SemanticVersionSupport
+            extends
+            AbstractStatementSupport<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> {
+
+        public SemanticVersionSupport() {
+            super(SupportedExtensionsMapping.SEMANTIC_VERSION);
+        }
+
+        @Override
+        public SemVer parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return SemVer.valueOf(value) ;
+        }
+
+        @Override
+        public void onLinkageDeclared(StmtContext.Mutable<SemVer,UnknownStatement<SemVer>,EffectiveStatement<SemVer,UnknownStatement<SemVer>>> stmt) {
+            stmt.addToNs(SemanticVersionNamespace.class, stmt.getParentContext(), stmt.getStatementArgument());
+        }
+
+        @Override
+        public UnknownStatement<SemVer> createDeclared(
+                StmtContext<SemVer, UnknownStatement<SemVer>, ?> ctx) {
+            return new SemanticVersionStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<SemVer, UnknownStatement<SemVer>> createEffective(
+                final StmtContext<SemVer, UnknownStatement<SemVer>, EffectiveStatement<SemVer, UnknownStatement<SemVer>>> ctx) {
+            return new SemanticVersionEffectiveStatementImpl(ctx);
+        }
+    }
+
+    @Override
+    public SemVer getArgument() {
+        return argument();
+    }
+}
index a62e0b7c5e5015a423e65d71b03a4507257076ae..55390c8d2f70e576ffe4db011ceb66d4d6d3ca47 100644 (file)
@@ -16,26 +16,46 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.AnyxmlSchemaLocationEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.SemanticVersionEffectiveStatementImpl;
 
 @Beta
 public enum SupportedExtensionsMapping implements StatementDefinition {
     ANYXML_SCHEMA_LOCATION("urn:opendaylight:yang:extension:yang-ext", "2013-07-09",
-        AnyxmlSchemaLocationStatementImpl.class, AnyxmlSchemaLocationEffectiveStatementImpl.class,
-        "anyxml-schema-location", "target-node");
+            AnyxmlSchemaLocationStatementImpl.class, AnyxmlSchemaLocationEffectiveStatementImpl.class,
+            "anyxml-schema-location", "target-node", false), SEMANTIC_VERSION(
+            "urn:opendaylight:yang:extension:semantic-version", "2016-02-02", SemanticVersionStatementImpl.class,
+            SemanticVersionEffectiveStatementImpl.class, "semantic-version", "semantic-version", false);
 
     private final Class<? extends DeclaredStatement<?>> type;
     private final Class<? extends EffectiveStatement<?, ?>> effectiveType;
     private final QName name;
     private final QName argument;
+    private final boolean yinElement;
 
     SupportedExtensionsMapping(final String namespace, final String revision,
             final Class<? extends DeclaredStatement<?>> declared,
-                    final Class<? extends EffectiveStatement<?, ?>> effective, final String nameStr,
-                            final String argumentStr) {
+            final Class<? extends EffectiveStatement<?, ?>> effective, final String nameStr, final String argumentStr,
+            final boolean yinElement) {
         type = Preconditions.checkNotNull(declared);
         effectiveType = Preconditions.checkNotNull(effective);
         name = createQName(namespace, revision, nameStr);
         argument = createQName(namespace, revision, argumentStr);
+        this.yinElement = yinElement;
+    }
+
+    private SupportedExtensionsMapping(final String namespace, final Class<? extends DeclaredStatement<?>> declared,
+            final Class<? extends EffectiveStatement<?, ?>> effective, final String nameStr, final String argumentStr,
+            final boolean yinElement) {
+        type = Preconditions.checkNotNull(declared);
+        effectiveType = Preconditions.checkNotNull(effective);
+        name = createQName(namespace, nameStr);
+        argument = createQName(namespace, argumentStr);
+        this.yinElement = yinElement;
+    }
+
+    @Nonnull
+    private static QName createQName(final String namespace, final String localName) {
+        return QName.create(namespace, localName).intern();
     }
 
     @Nonnull
@@ -64,4 +84,9 @@ public enum SupportedExtensionsMapping implements StatementDefinition {
     public Class<? extends EffectiveStatement<?, ?>> getEffectiveRepresentationClass() {
         return effectiveType;
     }
+
+    @Override
+    public boolean isArgumentYinElement() {
+        return yinElement;
+    }
 }
index bbb52f6e9a93d1b1dec0956cc9cc587efa2e9b5b..907c22e58524649796d14348e2b6e2f65fe98121 100644 (file)
@@ -24,6 +24,8 @@ import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.DerivedIdentitiesNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.QNameCacheNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionModuleNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
 import org.opendaylight.yangtools.yang.parser.spi.source.AnyxmlSchemaLocationNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
@@ -31,7 +33,9 @@ import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModule
 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToSemVerModuleIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameToIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
 import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
@@ -82,6 +86,7 @@ public final class YangInferencePipeline {
             .addSupport(global(NamespaceToModule.class))
             .addSupport(global(ModuleNameToModuleQName.class))
             .addSupport(global(ModuleCtxToModuleQName.class))
+            .addSupport(global(ModuleCtxToModuleIdentifier.class))
             .addSupport(global(ModuleQNameToModuleName.class))
             .addSupport(global(PrefixToModule.class))
             .addSupport(global(ModuleIdentifierToModuleQName.class))
@@ -95,6 +100,10 @@ public final class YangInferencePipeline {
             .addSupport(sourceLocal(BelongsToModuleContext.class))
             .addSupport(sourceLocal(QNameToStatementDefinition.class))
             .addSupport(sourceLocal(BelongsToPrefixToModuleName.class))
+            .addSupport(new SemanticVersionStatementImpl.SemanticVersionSupport())
+            .addSupport(global(SemanticVersionNamespace.class))
+            .addSupport(global(SemanticVersionModuleNamespace.class))
+            .addSupport(sourceLocal(ImpPrefixToSemVerModuleIdentifier.class))
             .build();
 
     private static final StatementSupportBundle STMT_DEF_BUNDLE = StatementSupportBundle
index c86b84f4223e6f1807846f8c970e0c270edc2a90..7a4fcdc60a23e4545087d6b42eb107fe970fa206 100644 (file)
@@ -45,6 +45,7 @@ public class YinStatementSourceImpl implements StatementStreamSource {
     private String fileName;
     private boolean isAbsolute;
 
+    // FIXME IO exception: input stream closed when called from StmtTestUtils parserseYinSources method
     public YinStatementSourceImpl(final InputStream inputStream) {
         yinStatementModelParser = new YinStatementParserImpl(inputStream.toString());
         this.inputStream = new BufferedInputStream(inputStream);
index f73b455b4d1d98431e42564f8f3e77327f0cd103..2367db331ad5315107737b31ee1afe794e896f98 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
@@ -74,6 +75,7 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
     private final Set<UsesNode> uses;
     private final Set<TypeDefinition<?>> typeDefinitions;
     private final Set<DataSchemaNode> publicChildNodes;
+    private final SemVer semanticVersion;
 
     AbstractEffectiveModule(final StmtContext<String, D, ? extends EffectiveStatement<String, ?>> ctx) {
         super(ctx);
@@ -86,6 +88,9 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
         YangVersionEffectiveStatementImpl yangVersionStmt = firstEffective(YangVersionEffectiveStatementImpl.class);
         this.yangVersion = (yangVersionStmt == null) ? "1" : yangVersionStmt.argument();
 
+        SemanticVersionEffectiveStatementImpl semanticVersionStmt = firstEffective(SemanticVersionEffectiveStatementImpl.class);
+        this.semanticVersion = (semanticVersionStmt == null) ? DEFAULT_SEMANTIC_VERSION : semanticVersionStmt.argument();
+
         OrganizationEffectiveStatementImpl organizationStmt = firstEffective(OrganizationEffectiveStatementImpl.class);
         this.organization = (organizationStmt == null) ? null : organizationStmt.argument();
 
@@ -215,7 +220,11 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
 
         this.unknownNodes = ImmutableList.copyOf(unknownNodesInit);
         this.augmentations = ImmutableSet.copyOf(augmentationsInit);
-        this.imports = ImmutableSet.copyOf(resolveModuleImports(importsInit, ctx));
+        if (ctx.isEnabledSemanticVersioning()) {
+            this.imports = ImmutableSet.copyOf(importsInit);
+        } else {
+            this.imports = ImmutableSet.copyOf(resolveModuleImports(importsInit, ctx));
+        }
         this.notifications = ImmutableSet.copyOf(notificationsInit);
         this.rpcs = ImmutableSet.copyOf(rpcsInit);
         this.deviations = ImmutableSet.copyOf(deviationsInit);
@@ -381,6 +390,11 @@ abstract class AbstractEffectiveModule<D extends DeclaredStatement<String>> exte
         return uses;
     }
 
+    @Override
+    public SemVer getSemanticVersion() {
+        return semanticVersion;
+    }
+
     @Override
     public String toString() {
         return this.getClass().getSimpleName() + "[" +
index d9f6fb6b2ca9141ca630b97267520513b5532712..12b8eb6cd9d9c08936d9757107aa20c94b84d51a 100644 (file)
@@ -9,27 +9,28 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
 import java.util.Date;
 import java.util.Objects;
+import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.stmt.ImportStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.MissingSubstatementException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToSemVerModuleIdentifier;
 
 public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase<String, ImportStatement> implements
         ModuleImport {
 
     private final String moduleName;
     private final Date revision;
+    private final SemVer semVer;
     private final String prefix;
 
     public ImportEffectiveStatementImpl(final StmtContext<String, ImportStatement, ?> ctx) {
         super(ctx);
 
         moduleName = ctx.getStatementArgument();
-
-        RevisionDateEffectiveStatementImpl revisionDateStmt = firstEffective(RevisionDateEffectiveStatementImpl.class);
-        this.revision = (revisionDateStmt == null) ? SimpleDateFormatUtil.DEFAULT_DATE_IMP : revisionDateStmt.argument();
-
         PrefixEffectiveStatementImpl prefixStmt = firstEffective(PrefixEffectiveStatementImpl.class);
         if (prefixStmt != null) {
             this.prefix = prefixStmt.argument();
@@ -37,6 +38,17 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase
             throw new MissingSubstatementException("Prefix is mandatory substatement of import statement",
                     ctx.getStatementSourceReference());
         }
+
+        if (!ctx.isEnabledSemanticVersioning()) {
+            RevisionDateEffectiveStatementImpl revisionDateStmt = firstEffective(RevisionDateEffectiveStatementImpl.class);
+            this.revision = (revisionDateStmt == null) ? SimpleDateFormatUtil.DEFAULT_DATE_IMP : revisionDateStmt
+                    .argument();
+            this.semVer = Module.DEFAULT_SEMANTIC_VERSION;
+        } else {
+            ModuleIdentifier importedModuleIdentifier = ctx.getFromNamespace(ImpPrefixToSemVerModuleIdentifier.class, prefix);
+            revision = importedModuleIdentifier.getRevision();
+            semVer = importedModuleIdentifier.getSemanticVersion();
+        }
     }
 
     @Override
@@ -49,6 +61,11 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase
         return revision;
     }
 
+    @Override
+    public SemVer getSemanticVersion() {
+        return semVer;
+    }
+
     @Override
     public String getPrefix() {
         return prefix;
@@ -61,6 +78,7 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase
         result = prime * result + Objects.hashCode(moduleName);
         result = prime * result + Objects.hashCode(revision);
         result = prime * result + Objects.hashCode(prefix);
+        result = prime * result + Objects.hashCode(semVer);
         return result;
     }
 
@@ -85,12 +103,15 @@ public class ImportEffectiveStatementImpl extends DeclaredEffectiveStatementBase
         if (!Objects.equals(getPrefix(), other.getPrefix())) {
             return false;
         }
+        if (!Objects.equals(getSemanticVersion(), other.getSemanticVersion())) {
+            return false;
+        }
         return true;
     }
 
     @Override
     public String toString() {
         return ImportEffectiveStatementImpl.class.getSimpleName() + "[moduleName=" + moduleName + ", revision="
-                + revision + ", prefix=" + prefix + "]";
+                + revision + ", semantic version=" + semVer + ", prefix=" + prefix + "]";
     }
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SemanticVersionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SemanticVersionEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..eaf7dcc
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import com.google.common.annotations.Beta;
+import java.util.Objects;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnknownStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+@Beta
+public final class SemanticVersionEffectiveStatementImpl extends
+        UnknownEffectiveStatementBase<SemVer> {
+
+    private final SchemaPath path;
+
+    public SemanticVersionEffectiveStatementImpl(
+            final StmtContext<SemVer, UnknownStatement<SemVer>, ?> ctx) {
+        super(ctx);
+        path = ctx.getParentContext().getSchemaPath().get().createChild(getNodeType());
+    }
+
+    @Override
+    public QName getQName() {
+        return getNodeType();
+    }
+
+    @Override
+    public SchemaPath getPath() {
+        return path;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + Objects.hashCode(path);
+        result = prime * result + Objects.hashCode(getNodeType());
+        result = prime * result + Objects.hashCode(getNodeParameter());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        SemanticVersionEffectiveStatementImpl other = (SemanticVersionEffectiveStatementImpl) obj;
+        if (!Objects.equals(path, other.path)) {
+            return false;
+        }
+        if (!Objects.equals(getNodeType(), other.getNodeType())) {
+            return false;
+        }
+        if (!Objects.equals(getNodeParameter(), other.getNodeParameter())) {
+            return false;
+        }
+        return true;
+    }
+}
index 68550261279b0624044234d50b6eeebbd7f13eb7..87b6176750571187e3417b5f12e7eb536e9070c0 100644 (file)
@@ -8,29 +8,31 @@
 
 package org.opendaylight.yangtools.yang.stmt;
 
+import java.io.File;
 import java.io.FileFilter;
-
-import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
+import java.io.FileNotFoundException;
 import java.net.URISyntaxException;
 import java.net.URL;
-import java.io.File;
-import java.io.FileNotFoundException;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 import java.util.ArrayList;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import java.util.Collection;
+import java.util.List;
 import java.util.Set;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YinStatementSourceImpl;
+import org.opendaylight.yangtools.yang.parser.util.NamedFileInputStream;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class StmtTestUtils {
 
@@ -42,8 +44,15 @@ public class StmtTestUtils {
         }
     };
 
-    private static final Logger LOG = LoggerFactory
-            .getLogger(StmtTestUtils.class);
+    final public static FileFilter YIN_FILE_FILTER = new FileFilter() {
+        @Override
+        public boolean accept(File file) {
+            String name = file.getName().toLowerCase();
+            return name.endsWith(".xml") && file.isFile();
+        }
+    };
+
+    private static final Logger LOG = LoggerFactory.getLogger(StmtTestUtils.class);
 
     private StmtTestUtils() {
 
@@ -58,8 +67,7 @@ public class StmtTestUtils {
         }
     }
 
-    public static List<Module> findModules(final Set<Module> modules,
-            final String moduleName) {
+    public static List<Module> findModules(final Set<Module> modules, final String moduleName) {
         List<Module> result = new ArrayList<>();
         for (Module module : modules) {
             if (module.getName().equals(moduleName)) {
@@ -69,18 +77,14 @@ public class StmtTestUtils {
         return result;
     }
 
-    public static void addSources(
-            CrossSourceStatementReactor.BuildAction reactor,
-            YangStatementSourceImpl... sources) {
+    public static void addSources(CrossSourceStatementReactor.BuildAction reactor, YangStatementSourceImpl... sources) {
         for (YangStatementSourceImpl source : sources) {
             reactor.addSource(source);
         }
     }
 
-    public static void printReferences(Module module, boolean isSubmodule,
-            String indent) {
-        LOG.debug(indent + (isSubmodule ? "Submodule " : "Module ")
-                + module.getName());
+    public static void printReferences(Module module, boolean isSubmodule, String indent) {
+        LOG.debug(indent + (isSubmodule ? "Submodule " : "Module ") + module.getName());
         Set<Module> submodules = module.getSubmodules();
         for (Module submodule : submodules) {
             printReferences(submodule, true, indent + "      ");
@@ -88,31 +92,37 @@ public class StmtTestUtils {
         }
     }
 
-    public static void printChilds(Collection<DataSchemaNode> childNodes,
-            String indent) {
+    public static void printChilds(Collection<DataSchemaNode> childNodes, String indent) {
 
         for (DataSchemaNode child : childNodes) {
             LOG.debug(indent + "Child " + child.getQName().getLocalName());
             if (child instanceof DataNodeContainer) {
-                printChilds(((DataNodeContainer) child).getChildNodes(), indent
-                        + "      ");
+                printChilds(((DataNodeContainer) child).getChildNodes(), indent + "      ");
             }
         }
     }
 
-    public static SchemaContext parseYangSources(
-            StatementStreamSource... sources) throws SourceException,
+    public static SchemaContext parseYangSources(StatementStreamSource... sources) throws SourceException,
             ReactorException {
+        return parseYangSources(StatementParserMode.DEFAULT_MODE, sources);
+    }
 
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
+    public static SchemaContext parseYangSources(StatementParserMode statementParserMode, StatementStreamSource... sources)
+            throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(statementParserMode);
         reactor.addSources(sources);
 
         return reactor.buildEffective();
     }
 
-    public static SchemaContext parseYangSources(File... files)
-            throws SourceException, ReactorException, FileNotFoundException {
+    public static SchemaContext parseYangSources(File... files) throws SourceException, ReactorException,
+            FileNotFoundException {
+        return parseYangSources(StatementParserMode.DEFAULT_MODE, files);
+    }
+
+    public static SchemaContext parseYangSources(StatementParserMode statementParserMode, File... files) throws SourceException,
+            ReactorException, FileNotFoundException {
 
         StatementStreamSource[] sources = new StatementStreamSource[files.length];
 
@@ -120,20 +130,75 @@ public class StmtTestUtils {
             sources[i] = new YangStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
         }
 
-        return parseYangSources(sources);
+        return parseYangSources(statementParserMode, sources);
+    }
+
+    public static SchemaContext parseYangSources(Collection<File> files) throws SourceException, ReactorException,
+            FileNotFoundException {
+        return parseYangSources(files, StatementParserMode.DEFAULT_MODE);
     }
 
-    public static SchemaContext parseYangSources(Collection<File> files)
+    public static SchemaContext parseYangSources(Collection<File> files, StatementParserMode statementParserMode)
             throws SourceException, ReactorException, FileNotFoundException {
-        return parseYangSources(files.toArray(new File[files.size()]));
+        return parseYangSources(statementParserMode, files.toArray(new File[files.size()]));
     }
 
-    public static SchemaContext parseYangSources(String yangSourcesDirectoryPath)
+    public static SchemaContext parseYangSources(String yangSourcesDirectoryPath) throws SourceException,
+            ReactorException, FileNotFoundException, URISyntaxException {
+        return parseYangSources(yangSourcesDirectoryPath, StatementParserMode.DEFAULT_MODE);
+    }
+
+    public static SchemaContext parseYangSources(String yangSourcesDirectoryPath, StatementParserMode statementParserMode)
             throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
 
         URL resourceDir = StmtTestUtils.class.getResource(yangSourcesDirectoryPath);
         File testSourcesDir = new File(resourceDir.toURI());
 
-        return parseYangSources(testSourcesDir.listFiles(YANG_FILE_FILTER));
+        return parseYangSources(statementParserMode, testSourcesDir.listFiles(YANG_FILE_FILTER));
+    }
+
+    public static SchemaContext parseYinSources(String yinSourcesDirectoryPath, StatementParserMode statementParserMode)
+            throws SourceException, ReactorException, FileNotFoundException, URISyntaxException {
+
+        URL resourceDir = StmtTestUtils.class.getResource(yinSourcesDirectoryPath);
+        File testSourcesDir = new File(resourceDir.toURI());
+
+        return parseYinSources(statementParserMode, testSourcesDir.listFiles(YIN_FILE_FILTER));
+    }
+
+    public static SchemaContext parseYinSources(StatementParserMode statementParserMode, File... files) throws SourceException,
+            ReactorException, FileNotFoundException {
+
+        StatementStreamSource[] sources = new StatementStreamSource[files.length];
+
+        for (int i = 0; i < files.length; i++) {
+            sources[i] = new YinStatementSourceImpl(new NamedFileInputStream(files[i], files[i].getPath()));
+        }
+
+        return parseYinSources(statementParserMode, sources);
+    }
+
+    public static SchemaContext parseYinSources(StatementParserMode statementParserMode, StatementStreamSource... sources)
+            throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(statementParserMode);
+        reactor.addSources(sources);
+
+        return reactor.buildEffective();
+    }
+
+    public static Module findImportedModule(SchemaContext context, Module rootModule, String importedModuleName) {
+        ModuleImport requestedModuleImport = null;
+        Set<ModuleImport> rootImports = rootModule.getImports();
+        for (ModuleImport moduleImport : rootImports) {
+            if (moduleImport.getModuleName().equals(importedModuleName)) {
+                requestedModuleImport = moduleImport;
+                break;
+            }
+        }
+
+        Module importedModule = context.findModuleByName(requestedModuleImport.getModuleName(),
+                requestedModuleImport.getRevision());
+        return importedModule;
     }
 }
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionBorderCaseTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionBorderCaseTest.java
new file mode 100644 (file)
index 0000000..028989c
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionBorderCaseTest {
+
+    @Test
+    public void borderCaseValidMajorTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-valid-major",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("5.5.5"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void borderCaseValidMinorTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-valid-minor",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("5.6.5"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void borderCaseValidPatchTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-valid-patch",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("5.5.6"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void borderCaseInvalidMajorTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-invalid-major",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(5.5.5)]."));
+        }
+    }
+
+    @Test
+    public void borderCaseInvalidMinorTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-invalid-minor",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(5.5.5)]."));
+        }
+    }
+
+    @Test
+    public void borderCaseInvalidPatchTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/border-case/border-case-invalid-patch",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(5.5.5)]."));
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionComplexTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionComplexTest.java
new file mode 100644 (file)
index 0000000..4420574
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.text.ParseException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
+import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionComplexTest {
+
+    @Test
+    public void complexTest1() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException,
+            ParseException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/complex/complex-1",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        // check module versions
+        assertEquals(SemVer.valueOf("1.3.95"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("1.50.2"), foo.getSemanticVersion());
+
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("1.2.6"), bar.getSemanticVersion());
+
+        Module foobar = StmtTestUtils.findImportedModule(context, bar, "foobar");
+        assertEquals(SemVer.valueOf("2.26.465"), foobar.getSemanticVersion());
+
+        // check imported components
+        assertNotNull("This component should be present", SchemaContextUtil.findDataSchemaNode(context, foo,
+                new RevisionAwareXPathImpl("/bar:root/bar:test-container/bar:number", true)));
+
+        assertNotNull("This component should be present", SchemaContextUtil.findDataSchemaNode(context, foo,
+                new RevisionAwareXPathImpl("/bar:should-present", true)));
+
+        // check not imported components
+        assertNull("This component should not be present", SchemaContextUtil.findDataSchemaNode(context, foo,
+                new RevisionAwareXPathImpl("/bar:root/bar:test-container/bar:oldnumber", true)));
+
+        assertNull("This component should not be present", SchemaContextUtil.findDataSchemaNode(context, foo,
+                new RevisionAwareXPathImpl("/bar:should-not-be-present", true)));
+    }
+
+    @Test
+    public void complexTest2() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException,
+            ParseException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/complex/complex-2",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        // check module versions
+        assertEquals(SemVer.valueOf("2.5.50"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("2.32.2"), foo.getSemanticVersion());
+
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("4.9.8"), bar.getSemanticVersion());
+
+        Module foobar = StmtTestUtils.findImportedModule(context, bar, "foobar");
+        assertEquals(SemVer.valueOf("7.13.99"), foobar.getSemanticVersion());
+
+        // check used augmentations
+        assertNotNull("This component should be present", SchemaContextUtil.findDataSchemaNode(context, bar,
+                new RevisionAwareXPathImpl("/foobar:root/foobar:test-container/bar:should-present-leaf-1", true)));
+
+        assertNotNull("This component should be present", SchemaContextUtil.findDataSchemaNode(context, bar,
+                new RevisionAwareXPathImpl("/foobar:root/foobar:test-container/bar:should-present-leaf-2", true)));
+
+        // check not used augmentations
+        assertNull("This component should not be present",
+                SchemaContextUtil.findDataSchemaNode(context, bar, new RevisionAwareXPathImpl(
+                        "/foobar:root/foobar:test-container/bar:should-not-be-present-leaf-1", true)));
+
+        assertNull("This component should not be present",
+                SchemaContextUtil.findDataSchemaNode(context, bar, new RevisionAwareXPathImpl(
+                        "/foobar:root/foobar:test-container/bar:should-not-be-present-leaf-2", true)));
+
+        // check if correct foobar module was included
+        assertNotNull("This component should be present", SchemaContextUtil.findDataSchemaNode(context, bar,
+                new RevisionAwareXPathImpl("/foobar:root/foobar:included-correct-mark", true)));
+
+        assertNull("This component should not be present", SchemaContextUtil.findDataSchemaNode(context, bar,
+                new RevisionAwareXPathImpl("/foobar:root/foobar:included-not-correct-mark", true)));
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionDefaultsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionDefaultsTest.java
new file mode 100644 (file)
index 0000000..33cc244
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionDefaultsTest {
+
+    @Test
+    public void defaultsTest() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/defaults/defaults",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.0"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.0.0"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void defaultMajorValidTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/defaults/default-major-valid",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.0"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.99.99"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void defaultMajorInvalidTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/defaults/default-major-invalid", StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(0.0.0)]."));
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionIgnoringRevisionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionIgnoringRevisionTest.java
new file mode 100644 (file)
index 0000000..6d09201
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionIgnoringRevisionTest {
+
+    @Test
+    public void ignoringRevisionTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/ignoring-revision",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void ignoringRevision2Test() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/ignoring-revision-2",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionImportTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionImportTest.java
new file mode 100644 (file)
index 0000000..114fbfe
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionImportTest {
+
+    @Test
+    public void importValidTest() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/import/import-valid",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("1.0.0"), semVer.getSemanticVersion());
+    }
+
+    @Test
+    public void importInvalidDeprecatedTest1() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-deprecated-1",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid import of semantic-version module");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage().startsWith(
+                    "Unable to find module compatible with requested import " + "[semantic-version(1.0.0)]."));
+        }
+    }
+
+    @Test
+    public void importInvalidDeprecatedTest2() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-deprecated-2",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid import of semantic-version module");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage().startsWith(
+                    "Unable to find module compatible with requested import " + "[semantic-version(0.9.9)]."));
+        }
+    }
+
+    @Test
+    public void importInvalidNotsufficientTest1() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-notsufficient-1",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid import of semantic-version module");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage().startsWith(
+                    "Unable to find module compatible with requested import " + "[semantic-version(2.0.0)]."));
+        }
+    }
+
+    @Test
+    public void importInvalidNotsufficientTest2() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/import/import-invalid-notsufficient-2",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid import of semantic-version module");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage().startsWith(
+                    "Unable to find module compatible with requested import " + "[semantic-version(2.0.5)]."));
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionMultipleImportTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionMultipleImportTest.java
new file mode 100644 (file)
index 0000000..7b85f55
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Set;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionMultipleImportTest {
+
+    @Test
+    public void multipleInvalidDeprecatedTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/multiple/multiple-invalid-deprecated",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(1.0.0)]."));
+        }
+    }
+
+    @Test
+    public void multipleInvalidNosufficientTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/multiple/multiple-invalid-nosufficient",
+                    StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(2.5.5)]."));
+        }
+    }
+
+    @Test
+    public void multipleValidDefaultsTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/multiple/multiple-valid-defaults",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("0.9.5"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void multipleValidSpecifiedTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/multiple/multiple-valid-specified",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("5.5.6"), bar.getSemanticVersion());
+    }
+
+    private static Module findImportedModule(SchemaContext context, Module rootModule, String importedModuleName) {
+        ModuleImport requestedModuleImport = null;
+        Set<ModuleImport> rootImports = rootModule.getImports();
+        for (ModuleImport moduleImport : rootImports) {
+            if (moduleImport.getModuleName().equals(importedModuleName)) {
+                requestedModuleImport = moduleImport;
+                break;
+            }
+        }
+
+        Module importedModule = context.findModuleByName(requestedModuleImport.getModuleName(),
+                requestedModuleImport.getRevision());
+        return importedModule;
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionPositionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionPositionTest.java
new file mode 100644 (file)
index 0000000..a869ba5
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionPositionTest {
+
+    @Test
+    public void positionHeadTest() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/position/position-head",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void positionMiddleTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/position/position-middle",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void positiontailTest() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/position/position-tail",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/SemanticVersionTest.java
new file mode 100644 (file)
index 0000000..e0bb3d0
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.semver;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class SemanticVersionTest {
+    @Test
+    public void basicTest() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/basic", StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void basicTest2() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/basic-2", StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void basicTest3() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/basic-3", StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+    }
+
+    @Test
+    public void basicImportTest1() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/basic-import-1",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void multipleModulesTest() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/multiple-modules",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("0.10.4"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void basicImportErrTest1() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/basic-import-invalid-1", StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(0.1.2)]."));
+        }
+    }
+
+    @Test
+    public void basicImportErrTest2() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYangSources("/semantic-version/basic-import-invalid-2", StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(0.1.2)]."));
+        }
+    }
+
+    @Test
+    public void nodeTest() throws Exception {
+        SchemaContext context = StmtTestUtils.parseYangSources("/semantic-version/node-test", StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("2016.1.1"), foo.getSemanticVersion());
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("2016.4.6"), bar.getSemanticVersion());
+
+        QName root = QName.create("foo", "2016-01-01", "foo-root");
+        QName container20160404 = QName.create("foo", "2016-01-01", "con20160404");
+        SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
+                SchemaPath.create(true, root, container20160404));
+        assertTrue(findDataSchemaNode instanceof ContainerSchemaNode);
+
+        QName container20160405 = QName.create("foo", "2016-01-01", "con20160405");
+        findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
+                SchemaPath.create(true, root, container20160405));
+        assertTrue(findDataSchemaNode instanceof ContainerSchemaNode);
+
+        QName container20160406 = QName.create("foo", "2016-01-01", "con20160406");
+        findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
+                SchemaPath.create(true, root, container20160406));
+        assertTrue(findDataSchemaNode instanceof ContainerSchemaNode);
+
+        QName container20170406 = QName.create("foo", "2016-01-01", "con20170406");
+        findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
+                SchemaPath.create(true, root, container20170406));
+        assertNull(findDataSchemaNode);
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/yin/YinSemanticVersionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/semver/yin/YinSemanticVersionTest.java
new file mode 100644 (file)
index 0000000..d27ebf8
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.stmt.semver.yin;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
+
+import java.io.FileNotFoundException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import org.junit.Test;
+import org.opendaylight.yangtools.concepts.SemVer;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
+
+public class YinSemanticVersionTest {
+
+    @Test
+    public void basicTest() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYinSources("/semantic-version/yin-input/basic",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module bar = context.findModuleByNamespace(new URI("bar")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void basicImportTest1() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYinSources("/semantic-version/yin-input/basic-import",
+                StatementParserMode.SEMVER_MODE);
+        assertNotNull(context);
+
+        Module foo = context.findModuleByNamespace(new URI("foo")).iterator().next();
+        Module semVer = context.findModuleByNamespace(new URI("urn:opendaylight:yang:extension:semantic-version"))
+                .iterator().next();
+
+        assertEquals(SemVer.valueOf("0.0.1"), semVer.getSemanticVersion());
+        assertEquals(SemVer.valueOf("0.1.1"), foo.getSemanticVersion());
+        Module bar = StmtTestUtils.findImportedModule(context, foo, "bar");
+        assertEquals(SemVer.valueOf("0.1.2"), bar.getSemanticVersion());
+    }
+
+    @Test
+    public void basicImportErrTest1() throws SourceException, FileNotFoundException, ReactorException,
+            URISyntaxException {
+        try {
+            StmtTestUtils.parseYinSources("/semantic-version/yin-input/basic-import-invalid", StatementParserMode.SEMVER_MODE);
+            fail("Test should fail due to invalid semantic version");
+        } catch (InferenceException e) {
+            assertTrue(e.getMessage()
+                    .startsWith("Unable to find module compatible with requested import [bar(0.1.2)]."));
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/bar.yang
new file mode 100644 (file)
index 0000000..5664e68
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02;}
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/foo.yang
new file mode 100644 (file)
index 0000000..01fe8e8
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02;}
+    import bar { prefix bar; revision-date 2016-01-31;}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-2/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-3/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-3/foo.yang
new file mode 100644 (file)
index 0000000..537f5d7
--- /dev/null
@@ -0,0 +1,15 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-3/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-3/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..54da0db
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/bar@2016-01-31.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/bar@2016-01-31.yang
new file mode 100644 (file)
index 0000000..e61a340
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/foo.yang
new file mode 100644 (file)
index 0000000..220c9cc
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-1/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..2e94728
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/bar@2016-01-31.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/bar@2016-01-31.yang
new file mode 100644 (file)
index 0000000..d3d101b
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.1.3";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/foo.yang
new file mode 100644 (file)
index 0000000..220c9cc
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-1/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/bar.yang
new file mode 100644 (file)
index 0000000..e61a340
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/foo.yang
new file mode 100644 (file)
index 0000000..dda1144
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic-import-invalid-2/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic/bar.yang
new file mode 100644 (file)
index 0000000..2adc136
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic/foo.yang
new file mode 100644 (file)
index 0000000..dda1144
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/basic/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/basic/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..e016dde
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..fa2cc10
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "3.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..8bbaa12
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-03" {
+        description "Initial version";
+    }
+    sv:semantic-version "4.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/foo.yang
new file mode 100644 (file)
index 0000000..c89c60d
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "5.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-major/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..06c3e48
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.2.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..0b59cae
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.3.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..4826af8
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-03" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.4.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/foo.yang
new file mode 100644 (file)
index 0000000..c89c60d
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "5.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-minor/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..f6dd765
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..1398079
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.3";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..714f1de
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-03" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.4";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/foo.yang
new file mode 100644 (file)
index 0000000..c89c60d
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "5.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-invalid-patch/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..c331b9e
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "4.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..920c18a
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..f04a98e
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-03" {
+        description "Initial version";
+    }
+    sv:semantic-version "6.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/foo.yang
new file mode 100644 (file)
index 0000000..c89c60d
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "5.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-major/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..c129995
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.4.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..920c18a
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..da8327c
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-03" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.6.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/foo.yang
new file mode 100644 (file)
index 0000000..c89c60d
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "5.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-minor/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..939c7e8
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.4";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..920c18a
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..5d3f96d
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-03" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.6";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/foo.yang
new file mode 100644 (file)
index 0000000..c89c60d
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "5.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/border-case/border-case-valid-patch/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..a7b14f1
--- /dev/null
@@ -0,0 +1,24 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "1.2.012"; }
+    import foobar { prefix foobar; sv:semantic-version "2.25.3"; }
+
+    revision "2016-01-03" {
+        description "Imported version";
+    }
+    sv:semantic-version "1.2.6";
+
+    container root {
+        container test-container {
+            uses foobar:test-grouping;
+        }
+    }
+
+    leaf-list should-present {
+        type string;
+        description "List of strings";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/bar@2016-01-04.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/bar@2016-01-04.yang
new file mode 100644 (file)
index 0000000..eaff86f
--- /dev/null
@@ -0,0 +1,24 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "1.2.210"; }
+    import foobar { prefix foobar; sv:semantic-version "2.25.3"; }
+
+    revision "2016-01-04" {
+        description "Not-imported version";
+    }
+    sv:semantic-version "2.200.200";
+
+    container root {
+        container test-container {
+            uses foobar:test-grouping;
+        }
+    }
+
+    leaf-list should-not-be-present {
+        type uint32;
+        description "List of integers";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foo.yang
new file mode 100644 (file)
index 0000000..bce4b87
--- /dev/null
@@ -0,0 +1,13 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "1.0.0"; }
+    import bar { prefix bar; sv:semantic-version "1.2.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.50.02";
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foobar@2016-01-31.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foobar@2016-01-31.yang
new file mode 100644 (file)
index 0000000..6efe81d
--- /dev/null
@@ -0,0 +1,23 @@
+module foobar {
+    namespace "foobar";
+    prefix foobar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "1.2.95"; }
+
+    revision "2016-01-31" {
+        description "Not-imported version";
+    }
+    sv:semantic-version "2.25.2";
+
+    grouping test-grouping {
+        leaf name {
+            type string;
+            description "Name";
+        }
+        leaf oldnumber {
+            type uint8;
+            description "Old number";
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foobar@2016-02-28.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/foobar@2016-02-28.yang
new file mode 100644 (file)
index 0000000..867d25e
--- /dev/null
@@ -0,0 +1,23 @@
+module foobar {
+    namespace "foobar";
+    prefix foobar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "1.3.95"; }
+
+    revision "2016-02-28" {
+        description "Imported version";
+    }
+    sv:semantic-version "2.26.465";
+
+    grouping test-grouping {
+        leaf name {
+            type string;
+            description "Name";
+        }
+        leaf number {
+            type uint32;
+            description "Number";
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-1/semantic-version.yang
new file mode 100644 (file)
index 0000000..a8de91c
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "1.3.95";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..f11bdb0
--- /dev/null
@@ -0,0 +1,23 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "2.0.40"; }
+    import foobar { prefix foobar; sv:semantic-version "7.12.54"; }
+
+    revision "2016-01-03" {
+        description "Imported version";
+    }
+    sv:semantic-version "4.9.8";
+
+    augment "/foobar:root/foobar:test-container" {
+        leaf should-present-leaf-1 {
+            type string;
+        }
+        leaf should-present-leaf-2 {
+            type uint8;
+            default 0;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/bar@2016-01-04.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/bar@2016-01-04.yang
new file mode 100644 (file)
index 0000000..1066b8a
--- /dev/null
@@ -0,0 +1,23 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "2.0.50"; }
+    import foobar { prefix foobar; sv:semantic-version "7.12.54"; }
+
+    revision "2016-01-04" {
+        description "Not-imported version";
+    }
+    sv:semantic-version "3.0.5";
+
+    augment "/foobar:root/foobar:test-container" {
+        leaf should-not-be-present-leaf-1 {
+            type string;
+        }
+        leaf should-not-be-present-leaf-2 {
+            type uint8;
+            default 0;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foo.yang
new file mode 100644 (file)
index 0000000..5be60d8
--- /dev/null
@@ -0,0 +1,13 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "2.5.40"; }
+    import bar { prefix bar; sv:semantic-version "4.1.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.32.2";
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-01-31.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-01-31.yang
new file mode 100644 (file)
index 0000000..435bea6
--- /dev/null
@@ -0,0 +1,20 @@
+module foobar {
+    namespace "foobar";
+    prefix foobar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "2.1.950"; }
+
+    revision "2016-01-31" {
+        description "Not-imported version";
+    }
+    sv:semantic-version "8.0.0";
+
+    container root {
+        leaf included-not-correct-mark {
+            type empty;
+        }
+        container test-container {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-02-27.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-02-27.yang
new file mode 100644 (file)
index 0000000..8b8f48e
--- /dev/null
@@ -0,0 +1,20 @@
+module foobar {
+    namespace "foobar";
+    prefix foobar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "2.5.50"; }
+
+    revision "2016-02-27" {
+        description "Not-imported version";
+    }
+    sv:semantic-version "7.13.0";
+
+    container root {
+        leaf included-not-correct-mark {
+            type empty;
+        }
+        container test-container {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-02-28.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/foobar@2016-02-28.yang
new file mode 100644 (file)
index 0000000..c45a020
--- /dev/null
@@ -0,0 +1,20 @@
+module foobar {
+    namespace "foobar";
+    prefix foobar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; sv:semantic-version "2.5.50"; }
+
+    revision "2016-02-28" {
+        description "Imported version";
+    }
+    sv:semantic-version "7.13.99";
+
+    container root {
+        leaf included-correct-mark {
+            type empty;
+        }
+        container test-container {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/complex/complex-2/semantic-version.yang
new file mode 100644 (file)
index 0000000..a7e5ba2
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "2.5.50";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/bar.yang
new file mode 100644 (file)
index 0000000..e7fe609
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.0.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/foo.yang
new file mode 100644 (file)
index 0000000..e81c791
--- /dev/null
@@ -0,0 +1,15 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-invalid/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/bar.yang
new file mode 100644 (file)
index 0000000..678f4f6
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.99.99";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/foo.yang
new file mode 100644 (file)
index 0000000..e81c791
--- /dev/null
@@ -0,0 +1,15 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/default-major-valid/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/defaults/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/defaults/bar.yang
new file mode 100644 (file)
index 0000000..7dedebe
--- /dev/null
@@ -0,0 +1,12 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/defaults/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/defaults/defaults/foo.yang
new file mode 100644 (file)
index 0000000..005e06a
--- /dev/null
@@ -0,0 +1,14 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import bar { prefix bar; revision-date 2016-01-31; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..54da0db
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/bar@2016-01-31.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/bar@2016-01-31.yang
new file mode 100644 (file)
index 0000000..e61a340
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/foo.yang
new file mode 100644 (file)
index 0000000..dda1144
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision-2/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..54da0db
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/foo.yang
new file mode 100644 (file)
index 0000000..dda1144
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/ignoring-revision/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-1/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-1/foo.yang
new file mode 100644 (file)
index 0000000..a6c665b
--- /dev/null
@@ -0,0 +1,14 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "1.0.0"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-1/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-1/semantic-version.yang
new file mode 100644 (file)
index 0000000..ca9b177
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "2.0.0";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-2/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-2/foo.yang
new file mode 100644 (file)
index 0000000..eacb99e
--- /dev/null
@@ -0,0 +1,14 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.9.9"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-2/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-deprecated-2/semantic-version.yang
new file mode 100644 (file)
index 0000000..5b1f616
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "1.0.0";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-1/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-1/foo.yang
new file mode 100644 (file)
index 0000000..74446cc
--- /dev/null
@@ -0,0 +1,14 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "2.0.0"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-1/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-1/semantic-version.yang
new file mode 100644 (file)
index 0000000..5b1f616
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "1.0.0";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-2/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-2/foo.yang
new file mode 100644 (file)
index 0000000..d069eef
--- /dev/null
@@ -0,0 +1,14 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "2.0.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-2/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-invalid-notsufficient-2/semantic-version.yang
new file mode 100644 (file)
index 0000000..ca9b177
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "2.0.0";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-valid/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-valid/foo.yang
new file mode 100644 (file)
index 0000000..a6c665b
--- /dev/null
@@ -0,0 +1,14 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "1.0.0"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-valid/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/import/import-valid/semantic-version.yang
new file mode 100644 (file)
index 0000000..5b1f616
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "1.0.0";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..fdab507
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..388f7f1
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-03.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-03.yang
new file mode 100644 (file)
index 0000000..1b7d0e3
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-03" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.3";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-04.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-04.yang
new file mode 100644 (file)
index 0000000..adb2436
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-04" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.10.4";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-31.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-01-31.yang
new file mode 100644 (file)
index 0000000..e61a340
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-02-28.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/bar@2016-02-28.yang
new file mode 100644 (file)
index 0000000..b4a6511
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-28" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.2.28";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/foo.yang
new file mode 100644 (file)
index 0000000..220c9cc
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple-modules/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..6352253
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..db806e8
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-02-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-02-01.yang
new file mode 100644 (file)
index 0000000..69e3d6c
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "4.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-02-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/bar@2016-02-02.yang
new file mode 100644 (file)
index 0000000..13c579c
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.0.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/foo.yang
new file mode 100644 (file)
index 0000000..3a2ab94
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "1.0.0"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-deprecated/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..4422f6d
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.0.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..9d916f6
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.1.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-02-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-02-01.yang
new file mode 100644 (file)
index 0000000..3036761
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.5.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-02-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/bar@2016-02-02.yang
new file mode 100644 (file)
index 0000000..f27a9ef
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "2.5.4";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/foo.yang
new file mode 100644 (file)
index 0000000..ec773ae
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "2.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-invalid-nosufficient/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..5c6572c
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.0.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..b819db3
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-02-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-02-01.yang
new file mode 100644 (file)
index 0000000..4405fa9
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.9.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-02-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/bar@2016-02-02.yang
new file mode 100644 (file)
index 0000000..5450608
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "1.0.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/foo.yang
new file mode 100644 (file)
index 0000000..3da8de0
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-defaults/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-01-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-01-01.yang
new file mode 100644 (file)
index 0000000..732609a
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "4.4.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-01-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-01-02.yang
new file mode 100644 (file)
index 0000000..82dd7ef
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.0";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-02-01.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-02-01.yang
new file mode 100644 (file)
index 0000000..32edae4
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.5";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-02-02.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/bar@2016-02-02.yang
new file mode 100644 (file)
index 0000000..a4d94b5
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-02" {
+        description "Initial version";
+    }
+    sv:semantic-version "5.5.6";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/foo.yang
new file mode 100644 (file)
index 0000000..c89c60d
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; sv:semantic-version "5.5.5"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/multiple/multiple-valid-specified/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160404.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160404.yang
new file mode 100644 (file)
index 0000000..69270ae
--- /dev/null
@@ -0,0 +1,18 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+    
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision 2016-04-04 {
+        description "test";
+    }
+    
+    sv:semantic-version "2016.4.4";
+
+    grouping grp {
+        container con20160404 {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160405.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160405.yang
new file mode 100644 (file)
index 0000000..f2bc4be
--- /dev/null
@@ -0,0 +1,20 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+    
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision 2016-04-05 {
+        description "test";
+    }
+    
+    sv:semantic-version "2016.4.5";
+
+    grouping grp {
+        container con20160404 {
+        }
+        container con20160405 {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160406.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20160406.yang
new file mode 100644 (file)
index 0000000..46d63f0
--- /dev/null
@@ -0,0 +1,22 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    
+    revision 2016-04-06 {
+        description "test";
+    }
+    
+    sv:semantic-version "2016.4.6";
+
+    grouping grp {
+        container con20160404 {
+        }
+        container con20160405 {
+        }
+        container con20160406 {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20170406.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/bar@20170406.yang
new file mode 100644 (file)
index 0000000..21066d4
--- /dev/null
@@ -0,0 +1,24 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    
+    revision 2017-04-06 {
+        description "test";
+    }
+    
+    sv:semantic-version "2017.4.6";
+
+    grouping grp {
+        container con20160404 {
+        }
+        container con20160405 {
+        }
+        container con20160406 {
+        }
+        container con20170406 {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/foo.yang
new file mode 100644 (file)
index 0000000..b4af346
--- /dev/null
@@ -0,0 +1,18 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2017-04-06; sv:semantic-version "2016.4.5"; }
+
+    revision 2016-01-01 {
+        description "test";
+    }
+    
+    sv:semantic-version "2016.1.1";
+
+    container foo-root {
+        uses bar:grp;
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/node-test/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/bar.yang
new file mode 100644 (file)
index 0000000..868ce01
--- /dev/null
@@ -0,0 +1,16 @@
+module bar {
+    sv:semantic-version "0.1.2";
+
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/foo.yang
new file mode 100644 (file)
index 0000000..4aee60f
--- /dev/null
@@ -0,0 +1,17 @@
+module foo {
+    sv:semantic-version "0.1.1";
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "0.1.2";}
+
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-head/semantic-version.yang
new file mode 100644 (file)
index 0000000..3879c06
--- /dev/null
@@ -0,0 +1,48 @@
+module semantic-version {
+    sv:semantic-version "0.0.1";
+
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/bar.yang
new file mode 100644 (file)
index 0000000..2adc136
--- /dev/null
@@ -0,0 +1,15 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.2";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/foo.yang
new file mode 100644 (file)
index 0000000..dda1144
--- /dev/null
@@ -0,0 +1,16 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "0.1.2";}
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+    sv:semantic-version "0.1.1";
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-middle/semantic-version.yang
new file mode 100644 (file)
index 0000000..dd92de6
--- /dev/null
@@ -0,0 +1,47 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+    sv:semantic-version "0.0.1";
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/bar.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/bar.yang
new file mode 100644 (file)
index 0000000..8ce6838
--- /dev/null
@@ -0,0 +1,16 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-01-31" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+
+    sv:semantic-version "0.1.2";
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/foo.yang
new file mode 100644 (file)
index 0000000..67e9025
--- /dev/null
@@ -0,0 +1,17 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    import semantic-version { prefix sv; revision-date 2016-02-02; sv:semantic-version "0.0.1"; }
+
+    revision "2016-02-01" {
+        description "Initial version";
+    }
+
+    container root {
+    }
+
+    sv:semantic-version "0.1.1";
+    import bar { prefix bar; revision-date 2016-01-31; sv:semantic-version "0.1.2";}
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/semantic-version.yang b/yang/yang-parser-impl/src/test/resources/semantic-version/position/position-tail/semantic-version.yang
new file mode 100644 (file)
index 0000000..ca84e11
--- /dev/null
@@ -0,0 +1,48 @@
+module semantic-version {
+    namespace "urn:opendaylight:yang:extension:semantic-version";
+    prefix sv;
+    yang-version 1;
+
+    revision 2016-02-02 {
+        description "Initial verison";
+    }
+
+    extension semantic-version {
+        argument "semantic-version" {
+            yin-element false;
+        }
+        description
+            "The OpenConfig version number for the module. This is
+            expressed as a semantic version number of the form:
+              x.y.z
+            where:
+              * x corresponds to the major version,
+              * y corresponds to a minor version,
+              * z corresponds to a patch version.
+            This version corresponds to the model file within which it is
+            defined, and does not cover the whole set of OpenConfig models.
+            Where several modules are used to build up a single block of
+            functionality, the same module version is specified across each
+            file that makes up the module.
+
+            A major version number of 0 indicates that this model is still
+            in development (whether within OpenConfig or with industry
+            partners), and is potentially subject to change.
+
+            Following a release of major version 1, all modules will
+            increment major revision number where backwards incompatible
+            changes to the model are made.
+
+            The minor version is changed when features are added to the
+            model that do not impact current clients use of the model.
+
+            The patch-level version is incremented when non-feature changes
+            (such as bugfixes or clarifications to human-readable
+            descriptions that do not impact model functionality) are made
+            that maintain backwards compatibility.
+
+            The version number is stored in the module meta-data.";
+    }
+
+    sv:semantic-version "0.0.1";
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/bar@2016-01-01.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/bar@2016-01-01.xml
new file mode 100644 (file)
index 0000000..6b4cfb5
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="bar">
+    <yang-version value="1"></yang-version>
+    <namespace uri="bar"></namespace>
+    <prefix value="bar"></prefix>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-01-01"></revision>
+    <sv:semantic-version semantic-version="1.1.2"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/bar@2016-01-31.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/bar@2016-01-31.xml
new file mode 100644 (file)
index 0000000..97d3dea
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="bar">
+    <yang-version value="1"></yang-version>
+    <namespace uri="bar"></namespace>
+    <prefix value="bar"></prefix>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-01-31"></revision>
+    <sv:semantic-version semantic-version="1.1.3"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/foo@2016-02-01.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/foo@2016-02-01.xml
new file mode 100644 (file)
index 0000000..19c5ea6
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:foo="foo" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="foo">
+    <yang-version value="1"></yang-version>
+    <namespace uri="foo"></namespace>
+    <prefix value="foo"></prefix>
+    <import module="bar">
+        <prefix value="bar"></prefix>
+        <revision-date date="2016-01-31"></revision-date>
+        <sv:semantic-version semantic-version="0.1.2"></sv:semantic-version>
+    </import>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-02-01"></revision>
+    <sv:semantic-version semantic-version="0.1.1"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/semantic-version@2016-02-02.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import-invalid/semantic-version@2016-02-02.xml
new file mode 100644 (file)
index 0000000..fe7aeb9
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:sv="urn:opendaylight:yang:extension:semantic-version"
+        name="semantic-version">
+    <yang-version value="1"></yang-version>
+    <namespace uri="urn:opendaylight:yang:extension:semantic-version"></namespace>
+    <prefix value="sv"></prefix>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-02-02"></revision>
+    <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    <extension name="semantic-version">
+        <argument name="semantic-version">
+            <yin-element value="false"></yin-element>
+        </argument>
+        <status value="current"></status>
+        <description>
+            <text>The OpenConfig version number for the module. This is
+                expressed as a semantic version number of the form:
+                x.y.z
+                where:
+                * x corresponds to the major version,
+                * y corresponds to a minor version,
+                * z corresponds to a patch version.
+                This version corresponds to the model file within which it is
+                defined, and does not cover the whole set of OpenConfig models.
+                Where several modules are used to build up a single block of
+                functionality, the same module version is specified across each
+                file that makes up the module.
+
+                A major version number of 0 indicates that this model is still
+                in development (whether within OpenConfig or with industry
+                partners), and is potentially subject to change.
+
+                Following a release of major version 1, all modules will
+                increment major revision number where backwards incompatible
+                changes to the model are made.
+
+                The minor version is changed when features are added to the
+                model that do not impact current clients use of the model.
+
+                The patch-level version is incremented when non-feature changes
+                (such as bugfixes or clarifications to human-readable
+                descriptions that do not impact model functionality) are made
+                that maintain backwards compatibility.
+
+                The version number is stored in the module meta-data.
+            </text>
+        </description>
+    </extension>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/bar@2016-01-01.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/bar@2016-01-01.xml
new file mode 100644 (file)
index 0000000..ab75b3a
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="bar">
+    <yang-version value="1"></yang-version>
+    <namespace uri="bar"></namespace>
+    <prefix value="bar"></prefix>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-01-01"></revision>
+    <sv:semantic-version semantic-version="0.1.2"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/bar@2016-01-31.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/bar@2016-01-31.xml
new file mode 100644 (file)
index 0000000..224c767
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="bar">
+    <yang-version value="1"></yang-version>
+    <namespace uri="bar"></namespace>
+    <prefix value="bar"></prefix>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-01-31"></revision>
+    <sv:semantic-version semantic-version="1.1.2"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/foo@2016-02-01.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/foo@2016-02-01.xml
new file mode 100644 (file)
index 0000000..19c5ea6
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:foo="foo" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="foo">
+    <yang-version value="1"></yang-version>
+    <namespace uri="foo"></namespace>
+    <prefix value="foo"></prefix>
+    <import module="bar">
+        <prefix value="bar"></prefix>
+        <revision-date date="2016-01-31"></revision-date>
+        <sv:semantic-version semantic-version="0.1.2"></sv:semantic-version>
+    </import>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-02-01"></revision>
+    <sv:semantic-version semantic-version="0.1.1"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/semantic-version@2016-02-02.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic-import/semantic-version@2016-02-02.xml
new file mode 100644 (file)
index 0000000..fe7aeb9
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:sv="urn:opendaylight:yang:extension:semantic-version"
+        name="semantic-version">
+    <yang-version value="1"></yang-version>
+    <namespace uri="urn:opendaylight:yang:extension:semantic-version"></namespace>
+    <prefix value="sv"></prefix>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-02-02"></revision>
+    <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    <extension name="semantic-version">
+        <argument name="semantic-version">
+            <yin-element value="false"></yin-element>
+        </argument>
+        <status value="current"></status>
+        <description>
+            <text>The OpenConfig version number for the module. This is
+                expressed as a semantic version number of the form:
+                x.y.z
+                where:
+                * x corresponds to the major version,
+                * y corresponds to a minor version,
+                * z corresponds to a patch version.
+                This version corresponds to the model file within which it is
+                defined, and does not cover the whole set of OpenConfig models.
+                Where several modules are used to build up a single block of
+                functionality, the same module version is specified across each
+                file that makes up the module.
+
+                A major version number of 0 indicates that this model is still
+                in development (whether within OpenConfig or with industry
+                partners), and is potentially subject to change.
+
+                Following a release of major version 1, all modules will
+                increment major revision number where backwards incompatible
+                changes to the model are made.
+
+                The minor version is changed when features are added to the
+                model that do not impact current clients use of the model.
+
+                The patch-level version is incremented when non-feature changes
+                (such as bugfixes or clarifications to human-readable
+                descriptions that do not impact model functionality) are made
+                that maintain backwards compatibility.
+
+                The version number is stored in the module meta-data.
+            </text>
+        </description>
+    </extension>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/bar@2016-01-31.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/bar@2016-01-31.xml
new file mode 100644 (file)
index 0000000..b3fe6a2
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="bar">
+    <yang-version value="1"></yang-version>
+    <namespace uri="bar"></namespace>
+    <prefix value="bar"></prefix>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-01-31"></revision>
+    <sv:semantic-version semantic-version="0.1.2"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/foo@2016-02-01.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/foo@2016-02-01.xml
new file mode 100644 (file)
index 0000000..19c5ea6
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:foo="foo" xmlns:bar="bar"
+        xmlns:sv="urn:opendaylight:yang:extension:semantic-version" name="foo">
+    <yang-version value="1"></yang-version>
+    <namespace uri="foo"></namespace>
+    <prefix value="foo"></prefix>
+    <import module="bar">
+        <prefix value="bar"></prefix>
+        <revision-date date="2016-01-31"></revision-date>
+        <sv:semantic-version semantic-version="0.1.2"></sv:semantic-version>
+    </import>
+    <import module="semantic-version">
+        <prefix value="sv"></prefix>
+        <revision-date date="2016-02-02"></revision-date>
+        <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    </import>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-02-01"></revision>
+    <sv:semantic-version semantic-version="0.1.1"></sv:semantic-version>
+    <container name="root">
+        <presence value="false"></presence>
+        <config value="true"></config>
+        <status value="current"></status>
+    </container>
+</module>
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/semantic-version@2016-02-02.xml b/yang/yang-parser-impl/src/test/resources/semantic-version/yin-input/basic/semantic-version@2016-02-02.xml
new file mode 100644 (file)
index 0000000..fe7aeb9
--- /dev/null
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module xmlns="urn:ietf:params:xml:ns:yang:yin:1" xmlns:sv="urn:opendaylight:yang:extension:semantic-version"
+        name="semantic-version">
+    <yang-version value="1"></yang-version>
+    <namespace uri="urn:opendaylight:yang:extension:semantic-version"></namespace>
+    <prefix value="sv"></prefix>
+    <organization>
+        <text></text>
+    </organization>
+    <contact>
+        <text></text>
+    </contact>
+    <revision date="2016-02-02"></revision>
+    <sv:semantic-version semantic-version="0.0.1"></sv:semantic-version>
+    <extension name="semantic-version">
+        <argument name="semantic-version">
+            <yin-element value="false"></yin-element>
+        </argument>
+        <status value="current"></status>
+        <description>
+            <text>The OpenConfig version number for the module. This is
+                expressed as a semantic version number of the form:
+                x.y.z
+                where:
+                * x corresponds to the major version,
+                * y corresponds to a minor version,
+                * z corresponds to a patch version.
+                This version corresponds to the model file within which it is
+                defined, and does not cover the whole set of OpenConfig models.
+                Where several modules are used to build up a single block of
+                functionality, the same module version is specified across each
+                file that makes up the module.
+
+                A major version number of 0 indicates that this model is still
+                in development (whether within OpenConfig or with industry
+                partners), and is potentially subject to change.
+
+                Following a release of major version 1, all modules will
+                increment major revision number where backwards incompatible
+                changes to the model are made.
+
+                The minor version is changed when features are added to the
+                model that do not impact current clients use of the model.
+
+                The patch-level version is incremented when non-feature changes
+                (such as bugfixes or clarifications to human-readable
+                descriptions that do not impact model functionality) are made
+                that maintain backwards compatibility.
+
+                The version number is stored in the module meta-data.
+            </text>
+        </description>
+    </extension>
+</module>
\ No newline at end of file