From 5079ec96bfeeb7a6ff66e71a114033c7d6c5c7a3 Mon Sep 17 00:00:00 2001 From: Igor Foltin Date: Tue, 16 May 2017 14:04:38 +0200 Subject: [PATCH] Bug 8307: Add the option for activating deviation statements YANG statement parser currently resolves all deviation statements. Add the option to specify which of the processed YANG modules can be deviated by the specified YANG modules. This information is passed down to the statement parser in the form of Map>. If no deviations should be activated, use an empty Map. In default mode, that is when the Map is not provided at all, all deviations are activated. This patch handles only the statement reactor part. SchemaContextFactory should be fixed in a separate patch. Moreover, change the rules for allowed deviation target path. A deviation statement cannot target nodes in the same module as the one it is defined in. Adjust existing unit tests accordingly. Change-Id: Ica0f8c09218e50fd4c3efeb4dc08acb4fa418798 Signed-off-by: Igor Foltin Signed-off-by: Igor Foltin --- .../spi/source/ModulesDeviatedByModules.java | 28 +++ .../stmt/reactor/BuildGlobalContext.java | 20 +- .../reactor/CrossSourceStatementReactor.java | 99 ++++++++-- .../stmt/rfc6020/DeviateStatementImpl.java | 36 +++- .../stmt/rfc6020/DeviationStatementImpl.java | 16 ++ .../stmt/rfc6020/YangInferencePipeline.java | 2 + .../yangtools/yang/stmt/Bug4933Test.java | 5 +- .../yangtools/yang/stmt/Bug7440Test.java | 8 +- .../yangtools/yang/stmt/Bug8307Test.java | 158 ++++++++++++++++ .../yang/stmt/DeviationResolutionTest.java | 176 ++++++++++-------- .../yang/stmt/DeviationStmtTest.java | 4 +- .../yang/stmt/EffectiveModuleTest.java | 5 +- .../yang/stmt/IfFeatureResolutionTest.java | 9 +- .../yangtools/yang/stmt/StmtTestUtils.java | 11 +- .../resources/bugs/bug4933/correct/bar.yang | 15 ++ .../resources/bugs/bug4933/correct/foo.yang | 19 +- .../resources/bugs/bug4933/incorrect/bar.yang | 15 ++ .../resources/bugs/bug4933/incorrect/foo.yang | 19 +- .../src/test/resources/bugs/bug7440/bar.yang | 10 + .../src/test/resources/bugs/bug7440/foo.yang | 11 +- .../resources/bugs/bug8307/bar-invalid.yang | 19 ++ .../src/test/resources/bugs/bug8307/bar.yang | 19 ++ .../resources/bugs/bug8307/baz-invalid.yang | 8 + .../src/test/resources/bugs/bug8307/baz.yang | 26 +++ .../resources/bugs/bug8307/foo-invalid.yang | 12 ++ .../src/test/resources/bugs/bug8307/foo.yang | 12 ++ .../test/resources/bugs/bug8307/foobar.yang | 24 +++ .../deviation-resolution-test/bar.yang | 10 + .../deviation-add/bar-invalid-2.yang | 11 ++ .../deviation-add/bar-invalid-3.yang | 10 + .../deviation-add/bar-invalid-4.yang | 20 ++ .../deviation-add/bar-invalid.yang | 11 ++ .../deviation-add/bar.yang | 74 ++++++++ .../deviation-add/bar10-invalid.yang | 10 + .../deviation-add/foo-invalid-2.yang | 12 +- .../deviation-add/foo-invalid-3.yang | 11 +- .../deviation-add/foo-invalid-4.yang | 21 +-- .../deviation-add/foo-invalid.yang | 12 +- .../deviation-add/foo.yang | 86 ++------- .../deviation-add/foo10-invalid.yang | 11 +- .../deviation-delete/bar-invalid-2.yang | 11 ++ .../deviation-delete/bar-invalid.yang | 10 + .../deviation-delete/bar.yang | 84 +++++++++ .../deviation-delete/bar10-invalid.yang | 10 + .../deviation-delete/foo-invalid-2.yang | 10 +- .../deviation-delete/foo-invalid.yang | 11 +- .../deviation-delete/foo.yang | 102 ++-------- .../deviation-delete/foo10-invalid.yang | 11 +- .../deviation-not-supported/imported.yang | 28 +++ .../deviation-not-supported/root.yang | 34 +--- .../deviation-replace/bar-invalid-2.yang | 13 ++ .../deviation-replace/bar-invalid-3.yang | 11 ++ .../deviation-replace/bar-invalid.yang | 10 + .../deviation-replace/bar.yang | 65 +++++++ .../deviation-replace/foo-invalid-2.yang | 13 +- .../deviation-replace/foo-invalid-3.yang | 12 +- .../deviation-replace/foo-invalid.yang | 11 +- .../deviation-replace/foo.yang | 79 ++------ .../foo-invalid-deviation-path.yang | 7 +- .../foo-invalid-deviation-target.yang | 11 +- .../deviation-stmt-test/bar-imp.yang | 20 ++ .../resources/deviation-stmt-test/bar.yang | 33 ++-- .../deviation-stmt-test/foo-imp.yang | 50 +++++ .../resources/deviation-stmt-test/foo.yang | 57 +----- .../effective-module/imported.yang | 2 + .../effective-module/root.yang | 2 +- .../parser/system/test/SystemTestUtils.java | 7 +- 67 files changed, 1250 insertions(+), 549 deletions(-) create mode 100644 yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModulesDeviatedByModules.java create mode 100644 yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8307Test.java create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug7440/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug8307/foobar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-2.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-3.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-4.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar10-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid-2.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar10-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-2.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-3.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar-imp.yang create mode 100644 yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo-imp.yang diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModulesDeviatedByModules.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModulesDeviatedByModules.java new file mode 100644 index 0000000000..77caed506b --- /dev/null +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModulesDeviatedByModules.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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 java.util.Map; +import java.util.Set; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace; + +/** + * Namespace used for storing information about modules that support deviation resolution. + * Map key (QNameModule) denotes a module which can be deviated by the modules specified in the Map value. + */ +@Beta +public interface ModulesDeviatedByModules + extends IdentifierNamespace>> { + + enum SupportedModules { + SUPPORTED_MODULES + } +} diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java index 5fc5db2061..322b05ffb6 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java @@ -11,6 +11,7 @@ import com.google.common.base.Preconditions; import com.google.common.base.Verify; import com.google.common.collect.HashBasedTable; import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Lists; import com.google.common.collect.Table; @@ -30,6 +31,7 @@ import java.util.Set; import java.util.SortedMap; import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; import org.opendaylight.yangtools.yang.common.YangVersion; import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier; @@ -49,6 +51,8 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException; import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException; import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport; import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle; +import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules; +import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules.SupportedModules; import org.opendaylight.yangtools.yang.parser.spi.source.SourceException; import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource; import org.opendaylight.yangtools.yang.parser.spi.source.SupportedFeaturesNamespace; @@ -84,7 +88,7 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh BuildGlobalContext(final Map supports, final Map> supportedValidation, - final StatementParserMode statementParserMode, final Set supportedFeatures) { + final StatementParserMode statementParserMode) { this.supports = Preconditions.checkNotNull(supports, "BuildGlobalContext#supports cannot be null"); switch (statementParserMode) { @@ -102,10 +106,6 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh addToNs(ValidationBundlesNamespace.class, validationBundle.getKey(), validationBundle.getValue()); } - if (supportedFeatures != null) { - addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES, - ImmutableSet.copyOf(supportedFeatures)); - } this.supportedVersions = ImmutableSet.copyOf(supports.get(ModelProcessingPhase.INIT).getSupportedVersions()); } @@ -129,6 +129,16 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh libSources.add(new SourceSpecificContext(this, libSource)); } + void setSupportedFeatures(final Set supportedFeatures) { + addToNs(SupportedFeaturesNamespace.class, SupportedFeatures.SUPPORTED_FEATURES, + ImmutableSet.copyOf(supportedFeatures)); + } + + void setModulesDeviatedByModules(final Map> modulesDeviatedByModules) { + addToNs(ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES, + ImmutableMap.copyOf(modulesDeviatedByModules)); + } + @Override public StorageNodeType getStorageNodeType() { return StorageNodeType.GLOBAL; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java index f116991ab7..c44e2463bc 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java @@ -7,6 +7,7 @@ */ 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.IOException; @@ -18,7 +19,9 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; +import javax.annotation.Nonnull; import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.model.api.SchemaContext; import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode; @@ -56,7 +59,7 @@ public final class CrossSourceStatementReactor { } /** - * Start a new reactor build using default statement parser mode and enabling all features. + * Start a new reactor build using the default statement parser mode with all features and deviations enabled. * * @return A new {@link BuildAction}. */ @@ -65,67 +68,99 @@ public final class CrossSourceStatementReactor { } /** - * Start a new reactor build using default statement parser mode and only specified features. + * Start a new reactor build using the default statement parser mode and enabling only the specified features + * and all deviations. * * @param supportedFeatures The set of supported features in the final SchemaContext * @return A new {@link BuildAction}. * - * @deprecated Use {@link #newBuild(Optional)} instead. + * @deprecated Use {@link #newBuild()} and then call setSupportedFeatures() on the created BuildAction instead. */ @Deprecated public BuildAction newBuild(final Set supportedFeatures) { - return new BuildAction(warnOnNull(supportedFeatures), StatementParserMode.DEFAULT_MODE); + final BuildAction buildAction = newBuild(); + if (supportedFeatures != null) { + buildAction.setSupportedFeatures(supportedFeatures); + } + + return buildAction; } /** - * Start a new reactor build using default statement parser mode and only specified features. + * Start a new reactor build using the default statement parser mode and enabling only the specified features + * and all deviations. * * @param supportedFeatures The set of supported features in the final SchemaContext, if present. * @return A new {@link BuildAction}. + * + * @deprecated Use {@link #newBuild()} and then call setSupportedFeatures() on the created BuildAction instead. */ + @Deprecated public BuildAction newBuild(final Optional> supportedFeatures) { - return new BuildAction(supportedFeatures.orElse(null), StatementParserMode.DEFAULT_MODE); + final BuildAction buildAction = newBuild(); + if (supportedFeatures.isPresent()) { + buildAction.setSupportedFeatures(supportedFeatures.get()); + } + + return buildAction; } /** - * Start a new reactor build using specified statement parser mode and enabling all features. + * Start a new reactor build using the specified statement parser mode and enabling all features and deviations. * * @param statementParserMode Parser mode to use * @return A new {@link BuildAction}. * @throws NullPointerException if statementParserMode is null */ public BuildAction newBuild(final StatementParserMode statementParserMode) { - return new BuildAction(null, statementParserMode); + return new BuildAction(statementParserMode); } /** - * Start a new reactor build using default statement parser mode and only specified features. + * Start a new reactor build using the specified statement parser mode and enabling only the specified features + * and all deviations. * * @param statementParserMode Parser mode to use * @param supportedFeatures The set of supported features in the final SchemaContext * @return A new {@link BuildAction}. * @throws NullPointerException if statementParserMode is null * - * @deprecated Use {@link #newBuild(StatementParserMode, Optional)} instead. + * @deprecated Use {@link #newBuild(StatementParserMode)} and then call setSupportedFeatures() + * on the created BuildAction instead. */ @Deprecated public BuildAction newBuild(final StatementParserMode statementParserMode, final Set supportedFeatures) { - return new BuildAction(warnOnNull(supportedFeatures), statementParserMode); + final BuildAction buildAction = new BuildAction(statementParserMode); + if (supportedFeatures != null) { + buildAction.setSupportedFeatures(supportedFeatures); + } + + return buildAction; } /** - * Start a new reactor build using default statement parser mode and only specified features. + * Start a new reactor build using the specified statement parser mode and enabling only the specified features + * and all deviations. * * @param statementParserMode Parser mode to use * @param supportedFeatures The set of supported features in the final SchemaContext, or absent if all features * encountered should be supported. * @return A new {@link BuildAction}. * @throws NullPointerException if statementParserMode is null + * + * @deprecated Use {@link #newBuild(StatementParserMode)} and then call setSupportedFeatures() + * on the created BuildAction instead. */ + @Deprecated public BuildAction newBuild(final StatementParserMode statementParserMode, final Optional> supportedFeatures) { - return new BuildAction(supportedFeatures.orElse(null), statementParserMode); + final BuildAction buildAction = new BuildAction(statementParserMode); + if (supportedFeatures.isPresent()) { + buildAction.setSupportedFeatures(supportedFeatures.get()); + } + + return buildAction; } private static T warnOnNull(final T obj) { @@ -159,10 +194,12 @@ public final class CrossSourceStatementReactor { public class BuildAction { private final BuildGlobalContext context; + private boolean supportedFeaturesSet = false; + private boolean modulesDeviatedByModulesSet = false; - BuildAction(final Set supportedFeatures, final StatementParserMode statementParserMode) { - this.context = new BuildGlobalContext(supportedTerminology, supportedValidation, statementParserMode, - supportedFeatures); + BuildAction(@Nonnull final StatementParserMode statementParserMode) { + this.context = new BuildGlobalContext(supportedTerminology,supportedValidation, + Preconditions.checkNotNull(statementParserMode)); } /** @@ -209,6 +246,36 @@ public final class CrossSourceStatementReactor { } } + /** + * Set supported features based on which all if-feature statements in the + * parsed YANG modules will be resolved. + * + * @param supportedFeatures + * Set of supported features in the final SchemaContext. + * If the set is empty, no features encountered will be supported. + */ + public void setSupportedFeatures(@Nonnull final Set supportedFeatures) { + Preconditions.checkState(!supportedFeaturesSet, "Supported features should be set only once."); + context.setSupportedFeatures(Preconditions.checkNotNull(supportedFeatures)); + supportedFeaturesSet = true; + } + + /** + * Set YANG modules which can be deviated by specified modules during the parsing process. + * Map key (QNameModule) denotes a module which can be deviated by the modules in the Map value. + * + * @param modulesDeviatedByModules + * Map of YANG modules (Map key) which can be deviated by specified modules (Map value) in the final + * SchemaContext. If the map is empty, no deviations encountered will be supported. + */ + public void setModulesWithSupportedDeviations( + @Nonnull final Map> modulesDeviatedByModules) { + Preconditions.checkState(!modulesDeviatedByModulesSet, + "Modules with supported deviations should be set only once."); + context.setModulesDeviatedByModules(Preconditions.checkNotNull(modulesDeviatedByModules)); + modulesDeviatedByModulesSet = true; + } + /** * @throws org.opendaylight.yangtools.yang.parser.spi.source.SourceException * @throws ReactorException diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java index 94f8ac2f90..8377d17205 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java @@ -10,9 +10,11 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; import java.util.Collection; +import java.util.Map; import java.util.Objects; import java.util.Set; import javax.annotation.Nonnull; +import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.common.YangVersion; import org.opendaylight.yangtools.yang.model.api.DeviateKind; import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; @@ -31,6 +33,9 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prereq import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils; +import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName; +import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules; +import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules.SupportedModules; import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviateEffectiveStatementImpl; import org.slf4j.Logger; @@ -108,12 +113,16 @@ public class DeviateStatementImpl extends AbstractDeclaredStatement final DeviateKind deviateKind = deviateStmtCtx.getStatementArgument(); getSubstatementValidatorForDeviate(deviateKind).validate(deviateStmtCtx); - final ModelActionBuilder deviateAction = deviateStmtCtx.newInferenceAction( - ModelProcessingPhase.EFFECTIVE_MODEL); - final SchemaNodeIdentifier deviationTarget = (SchemaNodeIdentifier) deviateStmtCtx.getParentContext().getStatementArgument(); + if (!isDeviationSupported(deviateStmtCtx, deviationTarget)) { + return; + } + + final ModelActionBuilder deviateAction = deviateStmtCtx.newInferenceAction( + ModelProcessingPhase.EFFECTIVE_MODEL); + final Prerequisite>> sourceCtxPrerequisite = deviateAction.requiresCtx(deviateStmtCtx, ModelProcessingPhase.EFFECTIVE_MODEL); @@ -155,6 +164,27 @@ public class DeviateStatementImpl extends AbstractDeclaredStatement }); } + private static boolean isDeviationSupported(final StmtContext.Mutable> deviateStmtCtx, + final SchemaNodeIdentifier deviationTarget) { + final Map> modulesDeviatedByModules = deviateStmtCtx.getFromNamespace( + ModulesDeviatedByModules.class, SupportedModules.SUPPORTED_MODULES); + if (modulesDeviatedByModules == null) { + return true; + } + + final QNameModule currentModule = deviateStmtCtx.getFromNamespace(ModuleCtxToModuleQName.class, + deviateStmtCtx.getRoot()); + final QNameModule targetModule = deviationTarget.getLastComponent().getModule(); + + final Set deviationModulesSupportedByTargetModule = modulesDeviatedByModules.get(targetModule); + if (deviationModulesSupportedByTargetModule != null) { + return deviationModulesSupportedByTargetModule.contains(currentModule); + } + + return false; + } + private static void performDeviateAdd(final StatementContextBase deviateStmtCtx, final StatementContextBase targetCtx) { for (StatementContextBase originalStmtCtx : deviateStmtCtx.declaredSubstatements()) { diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviationStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviationStatementImpl.java index d75e3d6b93..68cb1fb8ae 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviationStatementImpl.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviationStatementImpl.java @@ -8,6 +8,7 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020; import javax.annotation.Nonnull; +import org.opendaylight.yangtools.yang.common.QNameModule; import org.opendaylight.yangtools.yang.model.api.YangStmtMapping; import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement; import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement; @@ -15,7 +16,9 @@ import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier; import org.opendaylight.yangtools.yang.parser.spi.SubstatementValidator; 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.InferenceException; import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext; +import org.opendaylight.yangtools.yang.parser.spi.source.ModuleCtxToModuleQName; import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DeviationEffectiveStatementImpl; public class DeviationStatementImpl extends AbstractDeclaredStatement implements DeviationStatement { @@ -52,6 +55,19 @@ public class DeviationStatementImpl extends AbstractDeclaredStatement> ctx) { + final QNameModule currentModule = ctx.getFromNamespace(ModuleCtxToModuleQName.class, + ctx.getRoot()); + final QNameModule targetModule = ctx.getStatementArgument().getLastComponent().getModule(); + + if (currentModule.equals(targetModule)) { + throw new InferenceException(ctx.getStatementSourceReference(), + "Deviation must not target the same module as the one it is defined in: %s", currentModule); + } + } + @Override protected SubstatementValidator getSubstatementValidator() { return SUBSTATEMENT_VALIDATOR; diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangInferencePipeline.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangInferencePipeline.java index b43e4bc8bf..7b283fcb61 100644 --- a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangInferencePipeline.java +++ b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangInferencePipeline.java @@ -53,6 +53,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToNamespace; import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNamespaceForBelongsTo; import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName; +import org.opendaylight.yangtools.yang.parser.spi.source.ModulesDeviatedByModules; import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule; import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition; import org.opendaylight.yangtools.yang.parser.spi.source.StmtOrderingNamespace; @@ -92,6 +93,7 @@ public final class YangInferencePipeline { public static final StatementSupportBundle INIT_BUNDLE = StatementSupportBundle .builder(SUPPORTED_VERSIONS).addSupport(global(ValidationBundlesNamespace.class)) .addSupport(global(SupportedFeaturesNamespace.class)) + .addSupport(global(ModulesDeviatedByModules.class)) .build(); public static final StatementSupportBundle PRE_LINKAGE_BUNDLE = StatementSupportBundle diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4933Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4933Test.java index 2019d64c05..e22cc13aeb 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4933Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4933Test.java @@ -15,6 +15,7 @@ import static org.junit.Assert.fail; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.model.api.Deviation; +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; @@ -26,7 +27,9 @@ public class Bug4933Test { SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug4933/correct"); assertNotNull(context); - Set deviations = context.getModules().iterator().next().getDeviations(); + final Module foo = context.findModuleByName("foo", null); + + Set deviations = foo.getDeviations(); assertEquals(4, deviations.size()); } diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7440Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7440Test.java index d09a80b9d6..a2bb499dd3 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7440Test.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7440Test.java @@ -28,13 +28,15 @@ public class Bug7440Test { @Test public void testRestrictedTypeParentSchemaPathInDeviate() throws Exception { - final SchemaContext schemaContext = StmtTestUtils.parseYangSource("/bugs/bug7440/foo.yang"); + final SchemaContext schemaContext = StmtTestUtils.parseYangSources("/bugs/bug7440"); assertNotNull(schemaContext); final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2016-12-23"); final Module foo = schemaContext.findModuleByName("foo", revision); assertNotNull(foo); + final Module bar = schemaContext.findModuleByName("bar", revision); + assertNotNull(bar); final Set deviations = foo.getDeviations(); assertEquals(1, deviations.size()); @@ -44,8 +46,8 @@ public class Bug7440Test { assertEquals(1, deviates.size()); final DeviateDefinition deviateReplace = deviates.iterator().next(); - final SchemaPath deviatedTypePath = SchemaPath.create(true, QName.create(foo.getQNameModule(), "test-leaf"), - QName.create(foo.getQNameModule(), "uint32")); + final SchemaPath deviatedTypePath = SchemaPath.create(true, QName.create(bar.getQNameModule(), "test-leaf"), + QName.create(bar.getQNameModule(), "uint32")); final TypeDefinition deviatedType = deviateReplace.getDeviatedType(); assertEquals(deviatedTypePath, deviatedType.getPath()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8307Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8307Test.java new file mode 100644 index 0000000000..471495fc14 --- /dev/null +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8307Test.java @@ -0,0 +1,158 @@ +/* + * Copyright (c) 2017 Pantheon Technologies s.r.o. 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; + +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 static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; + +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import java.net.URI; +import java.text.ParseException; +import java.util.Date; +import java.util.Map; +import java.util.Set; +import org.junit.BeforeClass; +import org.junit.Test; +import org.opendaylight.yangtools.yang.common.QName; +import org.opendaylight.yangtools.yang.common.QNameModule; +import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +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.StatementStreamSource; +import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline; + +public class Bug8307Test { + + private static final StatementStreamSource FOO_MODULE = sourceForResource("/bugs/bug8307/foo.yang"); + private static final StatementStreamSource BAR_MODULE = sourceForResource("/bugs/bug8307/bar.yang"); + private static final StatementStreamSource BAZ_MODULE = sourceForResource("/bugs/bug8307/baz.yang"); + private static final StatementStreamSource FOOBAR_MODULE = sourceForResource("/bugs/bug8307/foobar.yang"); + private static final StatementStreamSource FOO_INVALID_MODULE = sourceForResource("/bugs/bug8307/foo-invalid.yang"); + private static final StatementStreamSource BAR_INVALID_MODULE = sourceForResource("/bugs/bug8307/bar-invalid.yang"); + private static final StatementStreamSource BAZ_INVALID_MODULE = sourceForResource("/bugs/bug8307/baz-invalid.yang"); + + private static final URI FOO_NS = URI.create("foo-ns"); + private static final URI BAR_NS = URI.create("bar-ns"); + private static final URI BAZ_NS = URI.create("baz-ns"); + + private static Date revision; + private static QNameModule foo; + private static QName myFooContA; + private static QName myFooContB; + private static QName myFooContC; + private static QNameModule bar; + private static QName myBarContA; + private static QName myBarContB; + private static QNameModule baz; + private static QName myBazCont; + + @BeforeClass + public static void setup() throws ParseException { + revision = SimpleDateFormatUtil.getRevisionFormat().parse("2017-05-16"); + foo = QNameModule.create(FOO_NS, revision); + myFooContA = QName.create(foo, "my-foo-cont-a"); + myFooContB = QName.create(foo, "my-foo-cont-b"); + myFooContC = QName.create(foo, "my-foo-cont-c"); + bar = QNameModule.create(BAR_NS, revision); + myBarContA = QName.create(bar, "my-bar-cont-a"); + myBarContB = QName.create(bar, "my-bar-cont-b"); + baz = QNameModule.create(BAZ_NS, revision); + myBazCont = QName.create(baz, "my-baz-cont"); + } + + @Test + public void testDeviationsSupportedInSomeModules() throws Exception { + final Map> modulesWithSupportedDeviations = ImmutableMap.of( + foo, ImmutableSet.of(bar, baz), bar, ImmutableSet.of(baz)); + + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); + reactor.addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE); + reactor.setModulesWithSupportedDeviations(modulesWithSupportedDeviations); + + final SchemaContext schemaContext = reactor.buildEffective(); + assertNotNull(schemaContext); + + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA))); + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB))); + assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC))); + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA))); + assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB))); + } + + @Test + public void testDeviationsSupportedInAllModules() throws Exception { + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); + reactor.addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE); + + final SchemaContext schemaContext = reactor.buildEffective(); + assertNotNull(schemaContext); + + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA))); + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB))); + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC))); + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA))); + assertNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB))); + } + + @Test + public void testDeviationsSupportedInNoModule() throws Exception { + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); + reactor.addSources(FOO_MODULE, BAR_MODULE, BAZ_MODULE, FOOBAR_MODULE); + reactor.setModulesWithSupportedDeviations(ImmutableMap.of()); + + final SchemaContext schemaContext = reactor.buildEffective(); + assertNotNull(schemaContext); + + assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContA))); + assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContB))); + assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myFooContC))); + assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContA))); + assertNotNull(SchemaContextUtil.findDataSchemaNode(schemaContext, SchemaPath.create(true, myBarContB))); + } + + @Test + public void shouldFailOnAttemptToDeviateTheSameModule() { + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); + reactor.addSources(FOO_INVALID_MODULE); + + try { + reactor.buildEffective(); + fail("Deviation that targets the same module as the one it is defined is forbidden."); + } catch (final ReactorException ex) { + final Throwable cause = ex.getCause(); + assertTrue(cause instanceof InferenceException); + assertTrue(cause.getMessage().startsWith( + "Deviation must not target the same module as the one it is defined in")); + } + } + + @Test + public void shouldFailOnAttemptToDeviateTheSameModule2() { + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); + reactor.addSources(BAR_INVALID_MODULE, BAZ_INVALID_MODULE); + + try { + reactor.buildEffective(); + fail("Deviation that targets the same module as the one it is defined is forbidden."); + } catch (final ReactorException ex) { + final Throwable cause = ex.getCause(); + assertTrue(cause instanceof InferenceException); + assertTrue(cause.getMessage().startsWith( + "Deviation must not target the same module as the one it is defined in")); + } + } +} diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java index 4f716aa4c0..b31ebaba6c 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationResolutionTest.java @@ -14,8 +14,10 @@ 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 static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; import java.io.ByteArrayOutputStream; +import java.io.File; import java.io.PrintStream; import java.util.Date; import org.junit.Test; @@ -46,23 +48,20 @@ public class DeviationResolutionTest { final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2017-01-20"); - final Module rootModule = schemaContext.findModuleByName("root", revision); - assertNotNull(rootModule); + final Module importedModule = schemaContext.findModuleByName("imported", revision); + assertNotNull(importedModule); - final ContainerSchemaNode myContA = (ContainerSchemaNode) rootModule.getDataChildByName( - QName.create(rootModule.getQNameModule(), "my-cont-a")); + final ContainerSchemaNode myContA = (ContainerSchemaNode) importedModule.getDataChildByName( + QName.create(importedModule.getQNameModule(), "my-cont-a")); assertNotNull(myContA); assertEquals(1, myContA.getChildNodes().size()); - assertNotNull(myContA.getDataChildByName(QName.create(rootModule.getQNameModule(), "my-leaf-a3"))); + assertNotNull(myContA.getDataChildByName(QName.create(importedModule.getQNameModule(), "my-leaf-a3"))); - final ContainerSchemaNode myContB = (ContainerSchemaNode) rootModule.getDataChildByName( - QName.create(rootModule.getQNameModule(), "my-cont-b")); + final ContainerSchemaNode myContB = (ContainerSchemaNode) importedModule.getDataChildByName( + QName.create(importedModule.getQNameModule(), "my-cont-b")); assertNull(myContB); - final Module importedModule = schemaContext.findModuleByName("imported", revision); - assertNotNull(importedModule); - final ContainerSchemaNode myContC = (ContainerSchemaNode) importedModule.getDataChildByName( QName.create(importedModule.getQNameModule(), "my-cont-c")); assertNotNull(myContC); @@ -74,17 +73,18 @@ public class DeviationResolutionTest { @Test public void testDeviateAdd() throws Exception { - final SchemaContext schemaContext = StmtTestUtils.parseYangSource( - "/deviation-resolution-test/deviation-add/foo.yang"); + final SchemaContext schemaContext = StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-add/foo.yang"), + sourceForResource("/deviation-resolution-test/deviation-add/bar.yang")); assertNotNull(schemaContext); final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2017-01-20"); - final Module fooModule = schemaContext.findModuleByName("foo", revision); - assertNotNull(fooModule); + final Module barModule = schemaContext.findModuleByName("bar", revision); + assertNotNull(barModule); - final LeafListSchemaNode myLeafList = (LeafListSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-leaf-list")); + final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-leaf-list")); assertNotNull(myLeafList); assertFalse(myLeafList.isConfiguration()); @@ -93,27 +93,27 @@ public class DeviationResolutionTest { assertEquals(5, myLeafList.getConstraints().getMinElements().intValue()); assertNotNull(myLeafList.getType().getUnits()); - final ListSchemaNode myList = (ListSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-list")); + final ListSchemaNode myList = (ListSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-list")); assertNotNull(myList); assertEquals(2, myList.getUniqueConstraints().size()); - final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-choice")); + final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-choice")); assertNotNull(myChoice); assertEquals("c2", myChoice.getDefaultCase()); - final RpcDefinition myRpc = fooModule.getRpcs().iterator().next(); + final RpcDefinition myRpc = barModule.getRpcs().iterator().next(); final ContainerSchemaNode input = myRpc.getInput(); assertEquals(2, input.getConstraints().getMustConstraints().size()); final ContainerSchemaNode output = myRpc.getOutput(); assertEquals(2, output.getConstraints().getMustConstraints().size()); - final NotificationDefinition myNotification = fooModule.getNotifications().iterator().next(); + final NotificationDefinition myNotification = barModule.getNotifications().iterator().next(); assertEquals(2, myNotification.getConstraints().getMustConstraints().size()); - final AnyXmlSchemaNode myAnyxml = (AnyXmlSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-anyxml")); + final AnyXmlSchemaNode myAnyxml = (AnyXmlSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-anyxml")); assertNotNull(myAnyxml); assertTrue(myAnyxml.getConstraints().isMandatory()); assertEquals(2, myAnyxml.getUnknownSchemaNodes().size()); @@ -121,17 +121,18 @@ public class DeviationResolutionTest { @Test public void testDeviateReplace() throws Exception { - final SchemaContext schemaContext = StmtTestUtils.parseYangSource( - "/deviation-resolution-test/deviation-replace/foo.yang"); + final SchemaContext schemaContext = StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-replace/foo.yang"), + sourceForResource("/deviation-resolution-test/deviation-replace/bar.yang")); assertNotNull(schemaContext); final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2017-01-20"); - final Module fooModule = schemaContext.findModuleByName("foo", revision); - assertNotNull(fooModule); + final Module barModule = schemaContext.findModuleByName("bar", revision); + assertNotNull(barModule); - final LeafSchemaNode myLeaf = (LeafSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-leaf")); + final LeafSchemaNode myLeaf = (LeafSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-leaf")); assertNotNull(myLeaf); assertTrue(myLeaf.getType() instanceof UnsignedIntegerTypeDefinition); @@ -140,28 +141,28 @@ public class DeviationResolutionTest { assertNotNull(myLeaf.getDefault()); assertEquals("10", myLeaf.getDefault()); - final LeafListSchemaNode myLeafList = (LeafListSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-leaf-list-test")); + final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-leaf-list-test")); assertNotNull(myLeafList); assertEquals(6, myLeafList.getConstraints().getMaxElements().intValue()); assertEquals(3, myLeafList.getConstraints().getMinElements().intValue()); assertTrue(myLeafList.isConfiguration()); - final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-choice")); + final ChoiceSchemaNode myChoice = (ChoiceSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-choice")); assertNotNull(myChoice); assertFalse(myChoice.getConstraints().isMandatory()); assertEquals(1, myChoice.getUnknownSchemaNodes().size()); assertEquals("new arg", myChoice.getUnknownSchemaNodes().iterator().next().getNodeParameter()); - final ContainerSchemaNode myCont = (ContainerSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-cont")); + final ContainerSchemaNode myCont = (ContainerSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-cont")); assertNotNull(myCont); final LeafSchemaNode myAugLeaf = (LeafSchemaNode) myCont.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-aug-leaf")); + QName.create(barModule.getQNameModule(), "my-aug-leaf")); assertNotNull(myAugLeaf); assertTrue(myAugLeaf.getType() instanceof UnsignedIntegerTypeDefinition); assertNotNull(myAugLeaf.getUnits()); @@ -172,7 +173,7 @@ public class DeviationResolutionTest { assertEquals("new arg", myAugLeaf.getUnknownSchemaNodes().iterator().next().getNodeParameter()); final LeafSchemaNode myUsedLeaf = (LeafSchemaNode) myCont.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-used-leaf")); + QName.create(barModule.getQNameModule(), "my-used-leaf")); assertNotNull(myUsedLeaf); assertTrue(myUsedLeaf.getType() instanceof UnsignedIntegerTypeDefinition); assertNotNull(myUsedLeaf.getUnits()); @@ -185,43 +186,44 @@ public class DeviationResolutionTest { @Test public void testDeviateDelete() throws Exception { - final SchemaContext schemaContext = StmtTestUtils.parseYangSource( - "/deviation-resolution-test/deviation-delete/foo.yang"); + final SchemaContext schemaContext = StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-delete/foo.yang"), + sourceForResource("/deviation-resolution-test/deviation-delete/bar.yang")); assertNotNull(schemaContext); final Date revision = SimpleDateFormatUtil.getRevisionFormat().parse("2017-01-20"); - final Module fooModule = schemaContext.findModuleByName("foo", revision); - assertNotNull(fooModule); + final Module barModule = schemaContext.findModuleByName("bar", revision); + assertNotNull(barModule); - final LeafSchemaNode myLeaf = (LeafSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-leaf")); + final LeafSchemaNode myLeaf = (LeafSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-leaf")); assertNotNull(myLeaf); assertNull(myLeaf.getDefault()); assertNull(myLeaf.getUnits()); assertEquals(0, myLeaf.getUnknownSchemaNodes().size()); - final LeafListSchemaNode myLeafList = (LeafListSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-leaf-list")); + final LeafListSchemaNode myLeafList = (LeafListSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-leaf-list")); assertNotNull(myLeafList); assertEquals(0, myLeafList.getDefaults().size()); assertEquals(0, myLeafList.getConstraints().getMustConstraints().size()); - final ListSchemaNode myList = (ListSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-list")); + final ListSchemaNode myList = (ListSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-list")); assertNotNull(myList); assertEquals(0, myList.getUniqueConstraints().size()); assertEquals(0, myList.getUnknownSchemaNodes().size()); - final ContainerSchemaNode myCont = (ContainerSchemaNode) fooModule.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-cont")); + final ContainerSchemaNode myCont = (ContainerSchemaNode) barModule.getDataChildByName( + QName.create(barModule.getQNameModule(), "my-cont")); assertNotNull(myCont); final LeafSchemaNode myAugLeaf = (LeafSchemaNode) myCont.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-aug-leaf")); + QName.create(barModule.getQNameModule(), "my-aug-leaf")); assertNotNull(myAugLeaf); assertNull(myAugLeaf.getDefault()); assertNull(myAugLeaf.getUnits()); @@ -229,7 +231,7 @@ public class DeviationResolutionTest { assertEquals(0, myAugLeaf.getUnknownSchemaNodes().size()); final LeafSchemaNode myUsedLeaf = (LeafSchemaNode) myCont.getDataChildByName( - QName.create(fooModule.getQNameModule(), "my-used-leaf")); + QName.create(barModule.getQNameModule(), "my-used-leaf")); assertNotNull(myUsedLeaf); assertNull(myUsedLeaf.getDefault()); assertNull(myUsedLeaf.getUnits()); @@ -240,7 +242,9 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidYang10Model() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-add/foo10-invalid.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-add/foo10-invalid.yang"), + sourceForResource("/deviation-resolution-test/deviation-add/bar10-invalid.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); @@ -252,7 +256,9 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidYang10Model2() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-delete/foo10-invalid.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-delete/foo10-invalid.yang"), + sourceForResource("/deviation-resolution-test/deviation-delete/bar10-invalid.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); @@ -264,12 +270,14 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviationTarget() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/foo-invalid-deviation-target.yang"); + StmtTestUtils.parseYangSources(sourceForResource( + "/deviation-resolution-test/foo-invalid-deviation-target.yang"), + sourceForResource("/deviation-resolution-test/bar.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("(foo?revision=2017-01-20)my-cont is not a valid deviation " + + assertTrue(cause.getMessage().startsWith("(bar?revision=2017-01-20)my-cont is not a valid deviation " + "target for substatement (urn:ietf:params:xml:ns:yang:yin:1)max-elements.")); } } @@ -277,26 +285,30 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviationPath() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/foo-invalid-deviation-path.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/foo-invalid-deviation-path.yang"), + sourceForResource("/deviation-resolution-test/bar.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause().getCause(); assertTrue(cause instanceof InferenceException); - assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(foo?revision=2017-01-20)invalid, " + - "(foo?revision=2017-01-20)path]}' not found")); + assertTrue(cause.getMessage().startsWith("Deviation target 'Absolute{path=[(bar?revision=2017-01-20)" + + "invalid, (bar?revision=2017-01-20)path]}' not found")); } } @Test public void shouldFailOnInvalidDeviateAdd() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-add/foo-invalid.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-add/foo-invalid.yang"), + sourceForResource("/deviation-resolution-test/deviation-add/bar-invalid.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + - ":yin:1)config to target node (foo?revision=2017-01-20)my-leaf because it is already defined in" + + ":yin:1)config to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" + " target and can appear only once.")); } } @@ -304,13 +316,15 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviateAdd2() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-add/foo-invalid-2.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-add/foo-invalid-2.yang"), + sourceForResource("/deviation-resolution-test/deviation-add/bar-invalid-2.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + - ":yin:1)default to target node (foo?revision=2017-01-20)my-leaf because it is already defined in" + + ":yin:1)default to target node (bar?revision=2017-01-20)my-leaf because it is already defined in" + " target and can appear only once.")); } } @@ -318,13 +332,15 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviateAdd3() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-add/foo-invalid-4.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-add/foo-invalid-4.yang"), + sourceForResource("/deviation-resolution-test/deviation-add/bar-invalid-4.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); assertTrue(cause.getMessage().startsWith("Deviation cannot add substatement (urn:ietf:params:xml:ns:yang" + - ":yin:1)default to target node (foo?revision=2017-02-01)my-used-leaf because it is already " + + ":yin:1)default to target node (bar?revision=2017-02-01)my-used-leaf because it is already " + "defined in target and can appear only once.")); } } @@ -332,13 +348,15 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviateReplace() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-replace/foo-invalid.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-replace/foo-invalid.yang"), + sourceForResource("/deviation-resolution-test/deviation-replace/bar-invalid.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); assertTrue(cause instanceof InferenceException); assertTrue(cause.getMessage().startsWith("Deviation cannot replace substatement " + - "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (foo?revision=2017-01-20)my-leaf " + + "(urn:ietf:params:xml:ns:yang:yin:1)units in target node (bar?revision=2017-01-20)my-leaf " + "because it does not exist in target node.")); } } @@ -351,11 +369,13 @@ public class DeviationResolutionTest { System.setOut(new PrintStream(output, true, "UTF-8")); - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-replace/foo-invalid-2.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-replace/foo-invalid-2.yang"), + sourceForResource("/deviation-resolution-test/deviation-replace/bar-invalid-2.yang")); testLog = output.toString(); assertTrue(testLog.contains("Deviation cannot replace substatement (urn:ietf:params:xml:ns:yang:yin:1)default" + - " in target leaf-list (foo?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple " + + " in target leaf-list (bar?revision=2017-01-20)my-leaf-list because a leaf-list can have multiple " + "default statements.")); System.setOut(stdout); } @@ -368,11 +388,13 @@ public class DeviationResolutionTest { System.setOut(new PrintStream(output, true, "UTF-8")); - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-delete/foo-invalid.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-delete/foo-invalid.yang"), + sourceForResource("/deviation-resolution-test/deviation-delete/bar-invalid.yang")); testLog = output.toString(); assertTrue(testLog.contains("Deviation cannot delete substatement (urn:ietf:params:xml:ns:yang:yin:1)units " + - "with argument 'seconds' in target node (foo?revision=2017-01-20)my-leaf because it does not exist " + + "with argument 'seconds' in target node (bar?revision=2017-01-20)my-leaf because it does not exist " + "in the target node.")); System.setOut(stdout); } @@ -380,7 +402,9 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviateAddSubstatement() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-add/foo-invalid-3.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-add/foo-invalid-3.yang"), + sourceForResource("/deviation-resolution-test/deviation-add/bar-invalid-3.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); @@ -392,7 +416,9 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviateReplaceSubstatement() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-replace/foo-invalid-3.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-replace/foo-invalid-3.yang"), + sourceForResource("/deviation-resolution-test/deviation-replace/bar-invalid-3.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); @@ -404,7 +430,9 @@ public class DeviationResolutionTest { @Test public void shouldFailOnInvalidDeviateDeleteSubstatement() throws Exception { try { - StmtTestUtils.parseYangSource("/deviation-resolution-test/deviation-delete/foo-invalid-2.yang"); + StmtTestUtils.parseYangSources( + sourceForResource("/deviation-resolution-test/deviation-delete/foo-invalid-2.yang"), + sourceForResource("/deviation-resolution-test/deviation-delete/bar-invalid-2.yang")); fail("An exception should have been thrown."); } catch (final ReactorException ex) { final Throwable cause = ex.getCause(); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java index a7f9658595..7adc4f9595 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/DeviationStmtTest.java @@ -34,12 +34,14 @@ import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline public class DeviationStmtTest { private static final StatementStreamSource FOO_MODULE = sourceForResource("/deviation-stmt-test/foo.yang"); + private static final StatementStreamSource FOO_IMP_MODULE = sourceForResource("/deviation-stmt-test/foo-imp.yang"); private static final StatementStreamSource BAR_MODULE = sourceForResource("/deviation-stmt-test/bar.yang"); + private static final StatementStreamSource BAR_IMP_MODULE = sourceForResource("/deviation-stmt-test/bar-imp.yang"); @Test public void testDeviationAndDeviate() throws ReactorException, ParseException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); - reactor.addSources(FOO_MODULE, BAR_MODULE); + reactor.addSources(FOO_MODULE, FOO_IMP_MODULE, BAR_MODULE, BAR_IMP_MODULE); final SchemaContext schemaContext = reactor.buildEffective(); assertNotNull(schemaContext); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java index 0a6bcd876d..0891fcc054 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java @@ -119,7 +119,10 @@ public class EffectiveModuleTest { assertEquals(1, deviations.size()); final Deviation deviationStmt = deviations.iterator().next(); assertNotNull(deviationStmt); - assertEquals(contSchemaPath, deviationStmt.getTargetPath()); + final QNameModule importedModuleQName = QNameModule.create(URI.create("imported"), revision); + final QName importedContQName = QName.create(importedModuleQName, "cont"); + final SchemaPath importedContSchemaPath = SchemaPath.create(true, importedContQName); + assertEquals(importedContSchemaPath, deviationStmt.getTargetPath()); assertEquals(DeviateKind.ADD, deviationStmt.getDeviates().iterator().next().getDeviateType()); assertEquals("deviate reference", deviationStmt.getReference()); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IfFeatureResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IfFeatureResolutionTest.java index ea7983c08d..49b3cf6ee1 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IfFeatureResolutionTest.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IfFeatureResolutionTest.java @@ -14,7 +14,6 @@ import static org.junit.Assert.assertNull; import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource; import com.google.common.collect.ImmutableSet; -import java.util.Optional; import java.util.Set; import org.junit.Test; import org.opendaylight.yangtools.yang.common.QName; @@ -41,9 +40,9 @@ public class IfFeatureResolutionTest { QName.create("foo-namespace", "1970-01-01", "test-feature-3"), QName.create("bar-namespace", "1970-01-01", "imp-feature")); - final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild( - Optional.of(supportedFeatures)); + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(FOO_MODULE, BAR_MODULE); + reactor.setSupportedFeatures(supportedFeatures); final SchemaContext schemaContext = reactor.buildEffective(); assertNotNull(schemaContext); @@ -275,9 +274,9 @@ public class IfFeatureResolutionTest { @Test public void testNoFeaturesSupported() throws ReactorException { - final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild( - Optional.of(ImmutableSet.of())); + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(FOO_MODULE, BAR_MODULE); + reactor.setSupportedFeatures(ImmutableSet.of()); final SchemaContext schemaContext = reactor.buildEffective(); assertNotNull(schemaContext); diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java index c9dca5f858..fe86a265d9 100644 --- a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/StmtTestUtils.java @@ -115,8 +115,11 @@ public class StmtTestUtils { final Set supportedFeatures, final Collection sources) throws SourceException, ReactorException { final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild( - statementParserMode, supportedFeatures); + statementParserMode); reactor.addSources(sources); + if (supportedFeatures != null) { + reactor.setSupportedFeatures(supportedFeatures); + } return reactor.buildEffective(); } @@ -265,10 +268,12 @@ public class StmtTestUtils { private static SchemaContext parseYangSources(final StatementStreamSource[] yangSources, final StatementStreamSource[] libSources, final Set supportedFeatures) throws ReactorException { - final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR - .newBuild(supportedFeatures); + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(yangSources); reactor.addLibSources(libSources); + if (supportedFeatures != null) { + reactor.setSupportedFeatures(supportedFeatures); + } return reactor.buildEffective(); } diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/bar.yang new file mode 100644 index 0000000000..19746fc55d --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/bar.yang @@ -0,0 +1,15 @@ +module bar { + namespace bar-ns; + prefix bar; + + container my-container { + leaf-list my-leaf-list { + type string; + max-elements 5; + must "0 != 1"; + } + } + + container my-container2 { + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/foo.yang index 282e242459..0ae8d61452 100644 --- a/yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/foo.yang +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/correct/foo.yang @@ -3,36 +3,29 @@ module foo { namespace "foo"; prefix foo; - container my-container { - leaf-list my-leaf-list { - type string; - max-elements 5; - must "0 != 1"; - } + import bar { + prefix bar; } - deviation /my-container/my-leaf-list { + deviation /bar:my-container/bar:my-leaf-list { deviate add { min-elements 1; } } - deviation /my-container/my-leaf-list { + deviation /bar:my-container/bar:my-leaf-list { deviate replace { max-elements 10; } } - deviation /my-container/my-leaf-list { + deviation /bar:my-container/bar:my-leaf-list { deviate delete { must "0 != 1"; } } - container my-container2 { - } - - deviation /my-container2 { + deviation /bar:my-container2 { deviate not-supported; } } diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/bar.yang new file mode 100644 index 0000000000..19746fc55d --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/bar.yang @@ -0,0 +1,15 @@ +module bar { + namespace bar-ns; + prefix bar; + + container my-container { + leaf-list my-leaf-list { + type string; + max-elements 5; + must "0 != 1"; + } + } + + container my-container2 { + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/foo.yang index 2993abd154..51ff1fe928 100644 --- a/yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/foo.yang +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug4933/incorrect/foo.yang @@ -3,36 +3,29 @@ module foo { namespace "foo"; prefix foo; - container my-container { - leaf-list my-leaf-list { - type string; - max-elements 5; - must "0 != 1"; - } + import bar { + prefix bar; } - deviation /my-container/my-leaf-list { + deviation /bar:my-container/bar:my-leaf-list { deviate add { min-elements 1; } } - deviation /my-container/my-leaf-list { + deviation /bar:my-container/bar:my-leaf-list { deviate replace { max-elements 10; } } - deviation /my-container/my-leaf-list { + deviation /bar:my-container/bar:my-leaf-list { deviate delete { must "0 != 1"; } } - container my-container2 { - } - - deviation /my-container2 { + deviation /bar:my-container2 { deviate not_supported; } } diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug7440/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug7440/bar.yang new file mode 100644 index 0000000000..883b4a7fe7 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug7440/bar.yang @@ -0,0 +1,10 @@ +module bar { + namespace bar-ns; + prefix bar; + + revision 2016-12-23; + + leaf test-leaf { + type int32; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug7440/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug7440/foo.yang index 3afa573d9d..7ca75a1d60 100644 --- a/yang/yang-parser-impl/src/test/resources/bugs/bug7440/foo.yang +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug7440/foo.yang @@ -2,17 +2,18 @@ module foo { namespace foo-ns; prefix foo-prfx; + import bar { + prefix bar; + revision-date 2016-12-23; + } + revision 2016-12-23; - deviation "/test-leaf" { + deviation "/bar:test-leaf" { deviate replace { type uint32 { range "5..50"; } } } - - leaf test-leaf { - type int32; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar-invalid.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar-invalid.yang new file mode 100644 index 0000000000..d49ab16253 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar-invalid.yang @@ -0,0 +1,19 @@ +module bar { + namespace bar-ns; + prefix bar; + + import baz { + prefix baz; + revision-date 2017-05-16; + } + + revision 2017-05-16; + + deviation "/baz:my-baz-cont/bar:my-aug-cont" { + deviate not-supported; + } + + augment "/baz:my-baz-cont" { + container my-aug-cont {} + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar.yang new file mode 100644 index 0000000000..46e15df4d3 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/bar.yang @@ -0,0 +1,19 @@ +module bar { + namespace bar-ns; + prefix bar-prefix; + + import foo { + prefix foo; + revision-date 2017-05-16; + } + + revision 2017-05-16; + + deviation "/foo:my-foo-cont-a" { + deviate not-supported; + } + + container my-bar-cont-a {} + + container my-bar-cont-b {} +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz-invalid.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz-invalid.yang new file mode 100644 index 0000000000..39d1cfee7b --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz-invalid.yang @@ -0,0 +1,8 @@ +module baz { + namespace baz-ns; + prefix baz; + + revision 2017-05-16; + + container my-baz-cont {} +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz.yang new file mode 100644 index 0000000000..05df3ad11a --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/baz.yang @@ -0,0 +1,26 @@ +module baz { + namespace baz-ns; + prefix baz-prefix; + + import foo { + prefix foo; + revision-date 2017-05-16; + } + + import bar { + prefix bar; + revision-date 2017-05-16; + } + + revision 2017-05-16; + + deviation "/foo:my-foo-cont-b" { + deviate not-supported; + } + + deviation "/bar:my-bar-cont-a" { + deviate not-supported; + } + + container my-baz-cont {} +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo-invalid.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo-invalid.yang new file mode 100644 index 0000000000..b1cad5439b --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo-invalid.yang @@ -0,0 +1,12 @@ +module foo { + namespace foo-ns; + prefix foo; + + revision 2017-05-16; + + deviation "/my-foo-cont" { + deviate not-supported; + } + + container my-foo-cont {} +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo.yang new file mode 100644 index 0000000000..4027fee792 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foo.yang @@ -0,0 +1,12 @@ +module foo { + namespace foo-ns; + prefix foo-prefix; + + revision 2017-05-16; + + container my-foo-cont-a {} + + container my-foo-cont-b {} + + container my-foo-cont-c {} +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foobar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foobar.yang new file mode 100644 index 0000000000..97d44786d5 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug8307/foobar.yang @@ -0,0 +1,24 @@ +module foobar { + namespace foobar-ns; + prefix foobar-prefix; + + import foo { + prefix foo; + revision-date 2017-05-16; + } + + import bar { + prefix bar; + revision-date 2017-05-16; + } + + revision 2017-05-16; + + deviation "/foo:my-foo-cont-c" { + deviate not-supported; + } + + deviation "/bar:my-bar-cont-b" { + deviate not-supported; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/bar.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/bar.yang new file mode 100644 index 0000000000..76e70f6acc --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/bar.yang @@ -0,0 +1,10 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + container my-cont { + + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-2.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-2.yang new file mode 100644 index 0000000000..dc93a72db0 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-2.yang @@ -0,0 +1,11 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + default 100; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-3.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-3.yang new file mode 100644 index 0000000000..2b0ec52162 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-3.yang @@ -0,0 +1,10 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-4.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-4.yang new file mode 100644 index 0000000000..98bd9f9ebc --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid-4.yang @@ -0,0 +1,20 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-02-01; + + container my-cont { + uses my-grouping { + refine my-used-leaf { + default "def-val-added-by-refine"; + } + } + } + + grouping my-grouping { + leaf my-used-leaf { + type int32; + } + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid.yang new file mode 100644 index 0000000000..b3a2fa124a --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar-invalid.yang @@ -0,0 +1,11 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + config false; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar.yang new file mode 100644 index 0000000000..d04bc8b9e9 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar.yang @@ -0,0 +1,74 @@ +module bar { + namespace bar; + prefix bar; + yang-version 1.1; + + revision 2017-01-20; + + leaf-list my-leaf-list { + type int32; + default 50; + } + + list my-list { + key key-leaf; + + leaf key-leaf { + type string; + } + + leaf my-leaf-a { + type string; + } + + leaf my-leaf-b { + type string; + } + + leaf my-leaf-c { + type string; + } + + leaf my-leaf-d { + type string; + } + } + + choice my-choice { + case c1 { + leaf c1-leaf { + type string; + default "heaven"; + } + } + + case c2 { + leaf c2-leaf { + type string; + default "hell"; + } + } + } + + rpc my-rpc { + input { + leaf my-rpc-input-leaf { + type string; + } + } + + output { + leaf my-rpc-output-leaf { + type string; + } + } + } + + notification my-notification { + + } + + anyxml my-anyxml { + + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar10-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar10-invalid.yang new file mode 100644 index 0000000000..9892f6a75f --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/bar10-invalid.yang @@ -0,0 +1,10 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf-list my-leaf-list { + type int32; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-2.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-2.yang index 4c04bedf69..2efe0f1840 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-2.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-2.yang @@ -2,16 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate add { default 200; } } - - leaf my-leaf { - type int32; - default 100; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-3.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-3.yang index 325d1393cb..219614ad6f 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-3.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-3.yang @@ -2,15 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate add { type string; } } - - leaf my-leaf { - type int32; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-4.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-4.yang index b48742aa16..2070d7718a 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-4.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid-4.yang @@ -2,25 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-02-01; + } + revision 2017-02-01; - deviation "/my-cont/my-used-leaf" { + deviation "/bar:my-cont/bar:my-used-leaf" { deviate add { default 50; } } - - container my-cont { - uses my-grouping { - refine my-used-leaf { - default "def-val-added-by-refine"; - } - } - } - - grouping my-grouping { - leaf my-used-leaf { - type int32; - } - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid.yang index 771c698d83..1916b6e337 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo-invalid.yang @@ -2,16 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate add { config true; } } - - leaf my-leaf { - type int32; - config false; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo.yang index af0d925629..c1edf965f3 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo.yang @@ -3,9 +3,14 @@ module foo { prefix foo; yang-version 1.1; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf-list" { + deviation "/bar:my-leaf-list" { deviate add { config false; min-elements 5; @@ -16,41 +21,41 @@ module foo { } } - deviation "/my-list" { + deviation "/bar:my-list" { deviate add { unique "my-leaf-a my-leaf-b"; unique "my-leaf-c my-leaf-d"; } } - deviation "/my-choice" { + deviation "/bar:my-choice" { deviate add { default c2; } } - deviation "/my-rpc/input" { + deviation "/bar:my-rpc/bar:input" { deviate add { must "day or night"; must "black and white"; } } - deviation "/my-rpc/output" { + deviation "/bar:my-rpc/bar:output" { deviate add { must "day or night"; must "black and white"; } } - deviation "/my-notification" { + deviation "/bar:my-notification" { deviate add { must "day or night"; must "black and white"; } } - deviation "/my-anyxml" { + deviation "/bar:my-anyxml" { deviate add { mandatory true; foo:custom-property "arg"; @@ -61,71 +66,4 @@ module foo { extension custom-property { argument name; } - - leaf-list my-leaf-list { - type int32; - default 50; - } - - list my-list { - key key-leaf; - - leaf key-leaf { - type string; - } - - leaf my-leaf-a { - type string; - } - - leaf my-leaf-b { - type string; - } - - leaf my-leaf-c { - type string; - } - - leaf my-leaf-d { - type string; - } - } - - choice my-choice { - case c1 { - leaf c1-leaf { - type string; - default "heaven"; - } - } - - case c2 { - leaf c2-leaf { - type string; - default "hell"; - } - } - } - - rpc my-rpc { - input { - leaf my-rpc-input-leaf { - type string; - } - } - - output { - leaf my-rpc-output-leaf { - type string; - } - } - } - - notification my-notification { - - } - - anyxml my-anyxml { - - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo10-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo10-invalid.yang index 6f636a7b3d..410f5b615d 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo10-invalid.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-add/foo10-invalid.yang @@ -2,16 +2,17 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf-list" { + deviation "/bar:my-leaf-list" { deviate add { default 10; default 100; } } - - leaf-list my-leaf-list { - type int32; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid-2.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid-2.yang new file mode 100644 index 0000000000..b3a2fa124a --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid-2.yang @@ -0,0 +1,11 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + config false; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid.yang new file mode 100644 index 0000000000..2b0ec52162 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar-invalid.yang @@ -0,0 +1,10 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar.yang new file mode 100644 index 0000000000..c66768da4a --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar.yang @@ -0,0 +1,84 @@ +module bar { + namespace bar; + prefix bar; + yang-version 1.1; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + units seconds; + default 100; + bar:custom-property-without-arg; + } + + leaf-list my-leaf-list { + type string; + default "def-val-1"; + default "def-val-2"; + must "a = 1 or b = 2"; + must "x != y"; + } + + list my-list { + key key-leaf; + + unique "my-leaf-a my-leaf-b"; + unique "my-leaf-c my-leaf-d"; + bar:custom-property "arg"; + bar:custom-property "another arg"; + + leaf key-leaf { + type string; + } + + leaf my-leaf-a { + type string; + } + + leaf my-leaf-b { + type string; + } + + leaf my-leaf-c { + type string; + } + + leaf my-leaf-d { + type string; + } + } + + container my-cont { + uses my-grouping { + refine my-used-leaf { + default "def-val-added-by-refine"; + bar:custom-property-without-arg; + } + } + } + + augment "/my-cont" { + leaf my-aug-leaf { + type int32; + default "def-val"; + units "minutes"; + must "x = 1"; + bar:custom-property-without-arg; + } + } + + grouping my-grouping { + leaf my-used-leaf { + type int32; + units "days"; + must "y = 5"; + } + } + + extension custom-property { + argument name; + } + + extension custom-property-without-arg; +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar10-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar10-invalid.yang new file mode 100644 index 0000000000..9892f6a75f --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/bar10-invalid.yang @@ -0,0 +1,10 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf-list my-leaf-list { + type int32; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid-2.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid-2.yang index d0d3f95f84..4c4a555327 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid-2.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid-2.yang @@ -2,6 +2,11 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; deviation "/my-leaf" { @@ -9,9 +14,4 @@ module foo { config false; } } - - leaf my-leaf { - type int32; - config false; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid.yang index 8cfbd63200..87b127229f 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo-invalid.yang @@ -2,15 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate delete { units "seconds"; } } - - leaf my-leaf { - type int32; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo.yang index f001ac6b37..57abb1f9cd 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo.yang @@ -3,17 +3,22 @@ module foo { prefix foo; yang-version 1.1; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate delete { units seconds; default 100; - foo:custom-property-without-arg; + bar:custom-property-without-arg; } } - deviation "/my-leaf-list" { + deviation "/bar:my-leaf-list" { deviate delete { default "def-val-1"; default "def-val-2"; @@ -22,105 +27,28 @@ module foo { } } - deviation "/my-list" { + deviation "/bar:my-list" { deviate delete { unique "my-leaf-a my-leaf-b"; unique "my-leaf-c my-leaf-d"; - foo:custom-property "arg"; - foo:custom-property "another arg"; - } - } - - extension custom-property { - argument name; - } - - extension custom-property-without-arg; - - leaf my-leaf { - type int32; - units seconds; - default 100; - foo:custom-property-without-arg; - } - - leaf-list my-leaf-list { - type string; - default "def-val-1"; - default "def-val-2"; - must "a = 1 or b = 2"; - must "x != y"; - } - - list my-list { - key key-leaf; - - unique "my-leaf-a my-leaf-b"; - unique "my-leaf-c my-leaf-d"; - foo:custom-property "arg"; - foo:custom-property "another arg"; - - leaf key-leaf { - type string; - } - - leaf my-leaf-a { - type string; - } - - leaf my-leaf-b { - type string; - } - - leaf my-leaf-c { - type string; - } - - leaf my-leaf-d { - type string; - } - } - - container my-cont { - uses my-grouping { - refine my-used-leaf { - default "def-val-added-by-refine"; - foo:custom-property-without-arg; - } - } - } - - augment "/my-cont" { - leaf my-aug-leaf { - type int32; - default "def-val"; - units "minutes"; - must "x = 1"; - foo:custom-property-without-arg; + bar:custom-property "arg"; + bar:custom-property "another arg"; } } - deviation "/my-cont/my-aug-leaf" { + deviation "/bar:my-cont/bar:my-aug-leaf" { deviate delete { default "def-val"; units "minutes"; must "x = 1"; - foo:custom-property-without-arg; - } - } - - grouping my-grouping { - leaf my-used-leaf { - type int32; - units "days"; - must "y = 5"; + bar:custom-property-without-arg; } } - deviation "/my-cont/my-used-leaf" { + deviation "/bar:my-cont/bar:my-used-leaf" { deviate delete { default "def-val-added-by-refine"; - foo:custom-property-without-arg; + bar:custom-property-without-arg; units "days"; must "y = 5"; } diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo10-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo10-invalid.yang index a54f21c17c..b5f76dcddd 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo10-invalid.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-delete/foo10-invalid.yang @@ -2,16 +2,17 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf-list" { + deviation "/bar:my-leaf-list" { deviate delete { default 10; default 100; } } - - leaf-list my-leaf-list { - type int32; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/imported.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/imported.yang index 162d0002d0..559fec247e 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/imported.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/imported.yang @@ -4,6 +4,34 @@ module imported { revision 2017-01-20; + container my-cont-a { + leaf my-leaf-a1 { + type int8; + } + + leaf my-leaf-a2 { + type int16; + } + + leaf my-leaf-a3 { + type int32; + } + } + + container my-cont-b { + leaf my-leaf-b1 { + type int8; + } + + leaf my-leaf-b2 { + type int16; + } + + leaf my-leaf-b3 { + type int32; + } + } + container my-cont-c { leaf my-leaf-c1 { type int8; diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/root.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/root.yang index 6e448640a0..6a19cbc596 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/root.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-not-supported/root.yang @@ -9,47 +9,19 @@ module root { revision 2017-01-20; - deviation "/my-cont-a/my-leaf-a1" { + deviation "/imp:my-cont-a/imp:my-leaf-a1" { deviate not-supported; } - deviation "/my-cont-a/my-leaf-a2" { + deviation "/imp:my-cont-a/imp:my-leaf-a2" { deviate not-supported; } - deviation "/my-cont-b" { + deviation "/imp:my-cont-b" { deviate not-supported; } deviation "/imp:my-cont-c/imp:my-leaf-c3" { deviate not-supported; } - - container my-cont-a { - leaf my-leaf-a1 { - type int8; - } - - leaf my-leaf-a2 { - type int16; - } - - leaf my-leaf-a3 { - type int32; - } - } - - container my-cont-b { - leaf my-leaf-b1 { - type int8; - } - - leaf my-leaf-b2 { - type int16; - } - - leaf my-leaf-b3 { - type int32; - } - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-2.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-2.yang new file mode 100644 index 0000000000..290267ae87 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-2.yang @@ -0,0 +1,13 @@ +module bar { + namespace bar; + prefix bar; + yang-version 1.1; + + revision 2017-01-20; + + leaf-list my-leaf-list { + type string; + default "default value one"; + default "default value two"; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-3.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-3.yang new file mode 100644 index 0000000000..0e4f1fef64 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid-3.yang @@ -0,0 +1,11 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + must "a != b"; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid.yang new file mode 100644 index 0000000000..2b0ec52162 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar-invalid.yang @@ -0,0 +1,10 @@ +module bar { + namespace bar; + prefix bar; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar.yang new file mode 100644 index 0000000000..24a5e42f51 --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/bar.yang @@ -0,0 +1,65 @@ +module bar { + namespace bar; + prefix bar; + yang-version 1.1; + + revision 2017-01-20; + + leaf my-leaf { + type int32; + default 100; + units kilobytes; + } + + leaf-list my-leaf-list-test { + type string; + min-elements 5; + max-elements 10; + config false; + } + + choice my-choice { + mandatory true; + bar:custom-property "original arg"; + case c1 { + leaf c1-leaf { + type string; + } + } + + case c2 { + leaf c2-leaf { + type string; + } + } + } + + augment "/my-cont" { + leaf my-aug-leaf { + type int32; + default "def-val"; + units "minutes"; + bar:custom-property "arg"; + } + } + + container my-cont { + uses my-grouping { + refine my-used-leaf { + default "def-val-added-by-refine"; + bar:custom-property "arg"; + } + } + } + + grouping my-grouping { + leaf my-used-leaf { + type int32; + units "days"; + } + } + + extension custom-property { + argument name; + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-2.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-2.yang index 98fe768c31..9ebf435350 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-2.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-2.yang @@ -3,17 +3,16 @@ module foo { prefix foo; yang-version 1.1; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf-list" { + deviation "/bar:my-leaf-list" { deviate replace { default "new default value"; } } - - leaf-list my-leaf-list { - type string; - default "default value one"; - default "default value two"; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-3.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-3.yang index 7829568f78..f3a9ab742b 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-3.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid-3.yang @@ -2,16 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate replace { must "a != b"; } } - - leaf my-leaf { - type int32; - must "a != b"; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid.yang index 43004cf105..04f110c861 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo-invalid.yang @@ -2,15 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate replace { units "seconds"; } } - - leaf my-leaf { - type int32; - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo.yang index af866f4563..5375af4d3b 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/deviation-replace/foo.yang @@ -2,9 +2,14 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-leaf" { + deviation "/bar:my-leaf" { deviate replace { type uint32; default 10; @@ -12,7 +17,7 @@ module foo { } } - deviation "/my-leaf-list-test" { + deviation "/bar:my-leaf-list-test" { deviate replace { min-elements 3; max-elements 6; @@ -20,85 +25,27 @@ module foo { } } - deviation "/my-choice" { + deviation "/bar:my-choice" { deviate replace { mandatory false; - foo:custom-property "new arg"; - } - } - - extension custom-property { - argument name; - } - - leaf my-leaf { - type int32; - default 100; - units kilobytes; - } - - leaf-list my-leaf-list-test { - type string; - min-elements 5; - max-elements 10; - config false; - } - - choice my-choice { - mandatory true; - foo:custom-property "original arg"; - case c1 { - leaf c1-leaf { - type string; - } - } - - case c2 { - leaf c2-leaf { - type string; - } - } - } - - container my-cont { - uses my-grouping { - refine my-used-leaf { - default "def-val-added-by-refine"; - foo:custom-property "arg"; - } + bar:custom-property "new arg"; } } - augment "/my-cont" { - leaf my-aug-leaf { - type int32; - default "def-val"; - units "minutes"; - foo:custom-property "arg"; - } - } - - deviation "/my-cont/my-aug-leaf" { + deviation "/bar:my-cont/bar:my-aug-leaf" { deviate replace { type uint32; default "new-def-val"; units "seconds"; - foo:custom-property "new arg"; - } - } - - grouping my-grouping { - leaf my-used-leaf { - type int32; - units "days"; + bar:custom-property "new arg"; } } - deviation "/my-cont/my-used-leaf" { + deviation "/bar:my-cont/bar:my-used-leaf" { deviate replace { type uint32; default "new-def-val"; - foo:custom-property "new arg"; + bar:custom-property "new arg"; units "weeks"; } } diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-path.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-path.yang index c0684413da..21ef959042 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-path.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-path.yang @@ -2,9 +2,14 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/invalid/path" { + deviation "/bar:invalid/bar:path" { deviate not-supported; } diff --git a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-target.yang b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-target.yang index 2cbbab76f4..96180581a3 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-target.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-resolution-test/foo-invalid-deviation-target.yang @@ -2,15 +2,16 @@ module foo { namespace foo; prefix foo; + import bar { + prefix bar; + revision-date 2017-01-20; + } + revision 2017-01-20; - deviation "/my-cont" { + deviation "/bar:my-cont" { deviate add { max-elements 5; } } - - container my-cont { - - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar-imp.yang b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar-imp.yang new file mode 100644 index 0000000000..38652e013c --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar-imp.yang @@ -0,0 +1,20 @@ +module bar-imp { + namespace "bimp-ns"; + prefix "bimp"; + + revision 2016-09-22; + + container bar-container-1 { + leaf bar-leaf-1 { + type string; + } + } + + container bar-container-2 { + must "a = b"; + + leaf bar-leaf-2 { + type string; + } + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar.yang b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar.yang index 831895a78f..6b52bf33fe 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/bar.yang @@ -2,68 +2,59 @@ module bar { namespace bar-namespace; prefix bar-prefix; + import bar-imp { + prefix bimp; + revision-date 2016-09-22; + } + revision "2016-09-22"; - deviation "/bar-container-1" { + deviation "/bimp:bar-container-1" { deviate add { must "a != b"; } bar-prefix:bar-extension; } - deviation "/bar-container-2" { + deviation "/bimp:bar-container-2" { deviate delete { must "a = b"; } } - deviation "/bar-container-2" { + deviation "/bimp:bar-container-2" { deviate add { config false; } } - deviation "/bar-container-1/bar-leaf-1" { + deviation "/bimp:bar-container-1/bimp:bar-leaf-1" { deviate add { default "def-val"; } description "desc"; } - deviation "/bar-container-1/bar-leaf-1" { + deviation "/bimp:bar-container-1/bimp:bar-leaf-1" { deviate add { config false; } description "another desc"; } - deviation "/bar-container-2/bar-leaf-2" { + deviation "/bimp:bar-container-2/bimp:bar-leaf-2" { deviate add { default "def-val"; } reference "ref"; } - deviation "/bar-container-2/bar-leaf-2" { + deviation "/bimp:bar-container-2/bimp:bar-leaf-2" { deviate add { config false; } reference "another ref"; } - container bar-container-1 { - leaf bar-leaf-1 { - type string; - } - } - - container bar-container-2 { - must "a = b"; - - leaf bar-leaf-2 { - type string; - } - } - extension bar-extension {} } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo-imp.yang b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo-imp.yang new file mode 100644 index 0000000000..016467156d --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo-imp.yang @@ -0,0 +1,50 @@ +module foo-imp { + namespace "fimp-ns"; + prefix "fimp"; + + revision 2016-06-23; + + container test-container { + leaf test-leaf { + type string; + } + + leaf test-leaf-2 { + type string; + } + + leaf-list test-leaf-list { + type int32; + min-elements 3; + must "daytime or time"; + must "time or daytime"; + units minutes; + } + + list test-list { + key key-leaf; + unique "list-leaf-1 list-leaf-2"; + unique "list-leaf-3 list-leaf-4"; + + leaf key-leaf { + type string; + } + + leaf list-leaf-1 { + type string; + } + + leaf list-leaf-2 { + type string; + } + + leaf list-leaf-3 { + type string; + } + + leaf list-leaf-4 { + type string; + } + } + } +} \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo.yang b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo.yang index 2102b9e09e..bb456735b4 100644 --- a/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo.yang +++ b/yang/yang-parser-impl/src/test/resources/deviation-stmt-test/foo.yang @@ -2,16 +2,21 @@ module foo { namespace "foo-namespace"; prefix "foo-prefix"; + import foo-imp { + prefix fimp; + revision-date 2016-06-23; + } + revision "2016-06-23" { description "Initial revision"; } - deviation "/test-container/test-leaf" { + deviation "/fimp:test-container/fimp:test-leaf" { description "test-leaf is not supported"; deviate not-supported; } - deviation "/test-container/test-leaf-2" { + deviation "/fimp:test-container/fimp:test-leaf-2" { deviate add { default "added-def-val"; config false; @@ -19,7 +24,7 @@ module foo { } } - deviation "/test-container/test-leaf-list" { + deviation "/fimp:test-container/fimp:test-leaf-list" { deviate add { max-elements 12; } @@ -36,54 +41,10 @@ module foo { } } - deviation "/test-container/test-list" { + deviation "/fimp:test-container/fimp:test-list" { deviate delete { unique "list-leaf-1 list-leaf-2"; unique "list-leaf-3 list-leaf-4"; } } - - container test-container { - leaf test-leaf { - type string; - } - - leaf test-leaf-2 { - type string; - } - - leaf-list test-leaf-list { - type int32; - min-elements 3; - must "daytime or time"; - must "time or daytime"; - units minutes; - } - - list test-list { - key key-leaf; - unique "list-leaf-1 list-leaf-2"; - unique "list-leaf-3 list-leaf-4"; - - leaf key-leaf { - type string; - } - - leaf list-leaf-1 { - type string; - } - - leaf list-leaf-2 { - type string; - } - - leaf list-leaf-3 { - type string; - } - - leaf list-leaf-4 { - type string; - } - } - } } \ No newline at end of file diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/imported.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/imported.yang index 5edb432981..2cd551412b 100644 --- a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/imported.yang +++ b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/imported.yang @@ -3,4 +3,6 @@ module imported { prefix imported; revision "2000-01-01"; + + container cont {} } diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/root.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/root.yang index 51ce0c5e0f..63a76d280d 100644 --- a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/root.yang +++ b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/effective-module/root.yang @@ -36,7 +36,7 @@ module root { rpc rpc1 { } - deviation /cont { + deviation /imp-pref:cont { deviate add { } reference "deviate reference"; diff --git a/yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/SystemTestUtils.java b/yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/SystemTestUtils.java index a3d3d65604..5b1e3b4038 100644 --- a/yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/SystemTestUtils.java +++ b/yang/yang-system-test/src/main/java/org/opendaylight/yangtools/yang/parser/system/test/SystemTestUtils.java @@ -70,11 +70,14 @@ class SystemTestUtils { final StatementStreamSource[] libSources, final Set supportedFeatures) throws ReactorException { Preconditions.checkArgument(testSources != null && testSources.length > 0, "No yang sources"); - final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR - .newBuild(supportedFeatures); + final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild(); reactor.addSources(testSources); reactor.addLibSources(libSources); + if (supportedFeatures != null) { + reactor.setSupportedFeatures(supportedFeatures); + } + return reactor.buildEffective(); } -- 2.36.6