Bug 5335: augmenting a mandatory node on a presence container 85/35985/1
authorPeter Kajsa <pkajsa@cisco.com>
Thu, 3 Mar 2016 13:46:34 +0000 (14:46 +0100)
committerPeter Kajsa <pkajsa@cisco.com>
Wed, 9 Mar 2016 12:36:59 +0000 (13:36 +0100)
Yang parser didn't perform cross module augmentation of mandatory
node on a presence container which belongs to the same module.
RFC6020 section 3.1 considers a presence container as not mandatory
node, therefore such augmentation should be allowed.

Change-Id: I61f45519db3536ab377fdf2987b083806a3aa51e
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
20 files changed:
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/Bug5335.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/sub-bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/sub-bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-3/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-3/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-4/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/sub-bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-2/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-2/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/bar.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/sub-bar.yang [new file with mode: 0644]

index c835eb24febd2d5f787dbd73294de9bcb6732515..7c83a5f0281fb72e599ae5c56e8b010b778c7486 100644 (file)
@@ -7,12 +7,14 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
+import com.google.common.base.Verify;
 import com.google.common.collect.ImmutableList.Builder;
 import com.google.common.collect.ImmutableSet;
 import java.util.Collection;
 import java.util.List;
 import java.util.Objects;
 import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
@@ -24,6 +26,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.TypeOfCopy;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.validation.ValidationBundlesNamespace.ValidationBundleType;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.RootStatementContext;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 
 // FIXME: Move this to the AugmentStatementDefinition#ApplyAction
@@ -41,17 +44,12 @@ public final class AugmentUtils {
     private static void copyDeclaredStmts(final StatementContextBase<?, ?, ?> sourceCtx,
             final StatementContextBase<?, ?, ?> targetCtx) throws SourceException {
 
-        final List<StatementContextBase<?, ?, ?>> subStatements = new Builder<StatementContextBase<?, ?, ?>>()
-                .addAll(targetCtx.declaredSubstatements()).addAll(targetCtx.effectiveSubstatements()).build();
-        boolean sourceAndTargetInSameModule = Utils.getRootModuleQName(sourceCtx).equals(
-                Utils.getRootModuleQName(targetCtx));
-
         TypeOfCopy typeOfCopy = sourceCtx.getParentContext().getPublicDefinition().getDeclaredRepresentationClass()
                 .equals(UsesStatement.class) ? TypeOfCopy.ADDED_BY_USES_AUGMENTATION : TypeOfCopy.ADDED_BY_AUGMENTATION;
 
         for (StatementContextBase<?, ?, ?> originalStmtCtx : sourceCtx.declaredSubstatements()) {
             if (needToCopyByAugment(originalStmtCtx)) {
-                validateNodeCanBeCopiedByAugment(originalStmtCtx, subStatements, sourceAndTargetInSameModule);
+                validateNodeCanBeCopiedByAugment(originalStmtCtx, targetCtx);
 
                 StatementContextBase<?, ?, ?> copy = originalStmtCtx.createCopy(targetCtx, typeOfCopy);
                 targetCtx.addEffectiveSubstatement(copy);
@@ -63,18 +61,12 @@ public final class AugmentUtils {
 
     private static void copyEffectiveStmts(final StatementContextBase<?, ?, ?> sourceCtx,
             final StatementContextBase<?, ?, ?> targetCtx) throws SourceException {
-
-        final List<StatementContextBase<?, ?, ?>> subStatements = new Builder<StatementContextBase<?, ?, ?>>()
-                .addAll(targetCtx.declaredSubstatements()).addAll(targetCtx.effectiveSubstatements()).build();
-        boolean sourceAndTargetInSameModule = Utils.getRootModuleQName(sourceCtx).equals(
-                Utils.getRootModuleQName(targetCtx));
-
         TypeOfCopy typeOfCopy = sourceCtx.getParentContext().getPublicDefinition().getDeclaredRepresentationClass()
                 .equals(UsesStatement.class) ? TypeOfCopy.ADDED_BY_USES_AUGMENTATION : TypeOfCopy.ADDED_BY_AUGMENTATION;
 
         for (StatementContextBase<?, ?, ?> originalStmtCtx : sourceCtx.effectiveSubstatements()) {
             if (needToCopyByAugment(originalStmtCtx)) {
-                validateNodeCanBeCopiedByAugment(originalStmtCtx, subStatements, sourceAndTargetInSameModule);
+                validateNodeCanBeCopiedByAugment(originalStmtCtx, targetCtx);
 
                 StatementContextBase<?, ?, ?> copy = originalStmtCtx.createCopy(targetCtx, typeOfCopy);
                 targetCtx.addEffectiveSubstatement(copy);
@@ -85,13 +77,13 @@ public final class AugmentUtils {
     }
 
     private static void validateNodeCanBeCopiedByAugment(final StatementContextBase<?, ?, ?> sourceCtx,
-            final List<StatementContextBase<?, ?, ?>> targetSubStatements, final boolean sourceAndTargetInSameModule) {
+            final StatementContextBase<?, ?, ?> targetCtx) {
 
         if (sourceCtx.getPublicDefinition().getDeclaredRepresentationClass().equals(WhenStatement.class)) {
             return;
         }
 
-        if (!sourceAndTargetInSameModule) {
+        if (reguiredCheckOfMandatoryNodes(sourceCtx, targetCtx)) {
             final List<StatementContextBase<?, ?, ?>> sourceSubStatements = new Builder<StatementContextBase<?, ?, ?>>()
                     .addAll(sourceCtx.declaredSubstatements()).addAll(sourceCtx.effectiveSubstatements()).build();
 
@@ -104,6 +96,9 @@ public final class AugmentUtils {
             }
         }
 
+        final List<StatementContextBase<?, ?, ?>> targetSubStatements = new Builder<StatementContextBase<?, ?, ?>>()
+                .addAll(targetCtx.declaredSubstatements()).addAll(targetCtx.effectiveSubstatements()).build();
+
         for (final StatementContextBase<?, ?, ?> subStatement : targetSubStatements) {
 
             final boolean sourceIsDataNode = DataDefinitionStatement.class.isAssignableFrom(sourceCtx
@@ -119,6 +114,47 @@ public final class AugmentUtils {
         }
     }
 
+    private static boolean reguiredCheckOfMandatoryNodes(StatementContextBase<?, ?, ?> sourceCtx,
+            StatementContextBase<?, ?, ?> targetCtx) {
+        /*
+         * If the statement argument is not QName, it cannot be mandatory statement,
+         * therefore return false and skip mandatory nodes validation
+         */
+        if(!(sourceCtx.getStatementArgument() instanceof QName)) {
+            return false;
+        }
+        QName sourceStmtQName = (QName) sourceCtx.getStatementArgument();
+
+        RootStatementContext<?, ?, ?> root = targetCtx.getRoot();
+        do {
+            Verify.verify(targetCtx.getStatementArgument() instanceof QName,
+                    "Argument of augment target statement must be QName.");
+            QName targetStmtQName = (QName) targetCtx.getStatementArgument();
+            /*
+             * If target is from another module, return true and perform
+             * mandatory nodes validation
+             */
+            if (!Utils.belongsToTheSameModule(targetStmtQName, sourceStmtQName)) {
+                return true;
+            } else {
+                /*
+                 * If target or one of its parent is a presence container from
+                 * the same module, return false and skip mandatory nodes
+                 * validation
+                 */
+                if (Utils.isPresenceContainer(targetCtx)) {
+                    return false;
+                }
+            }
+        } while ((targetCtx = targetCtx.getParentContext()) != root);
+
+        /*
+         * All target node's parents belong to the same module as source node,
+         * therefore return false and skip mandatory nodes validation.
+         */
+        return false;
+    }
+
     private static final Set<Rfc6020Mapping> NOCOPY_DEV_SET = ImmutableSet.of(Rfc6020Mapping.USES);
 
     public static boolean needToCopyByAugment(final StmtContext<?, ?, ?> stmtContext) {
@@ -134,7 +170,7 @@ public final class AugmentUtils {
     static boolean isSupportedAugmentTarget(final StatementContextBase<?, ?, ?> substatementCtx) {
 
         /*
-         * :TODO Substatement must be allowed augment target type e.g. Container, etc... and must be not for example
+         * :TODO Substatement must be allowed augment target type e.g. Container, etc... and must not be for example
          * grouping, identity etc. It is problem in case when more than one substatements have the same QName, for
          * example Grouping and Container are siblings and they have the same QName. We must find the Container and the
          * Grouping must be ignored as disallowed augment target.
index 71ae3700a38b3e075a6bbb384b8adffe934de40c..c4b01e1f7a42a32c4b53f2d5dddb8c5dffb76f0c 100644 (file)
@@ -8,10 +8,12 @@
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
+
 import com.google.common.base.CharMatcher;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
 import com.google.common.collect.ImmutableSet;
@@ -40,6 +42,7 @@ import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
@@ -624,4 +627,27 @@ public final class Utils {
         }
         return result.toString();
     }
+
+    public static boolean belongsToTheSameModule(QName targetStmtQName, QName sourceStmtQName) {
+        if (targetStmtQName.getModule().equals(sourceStmtQName.getModule())) {
+            return true;
+        }
+        return false;
+    }
+
+    public static boolean isPresenceContainer(StatementContextBase<?, ?, ?> targetCtx) {
+        if (!targetCtx.getPublicDefinition().equals(Rfc6020Mapping.CONTAINER)) {
+            return false;
+        }
+
+        final List<StatementContextBase<?, ?, ?>> targetSubStatements = new ImmutableList.Builder<StatementContextBase<?, ?, ?>>()
+                .addAll(targetCtx.declaredSubstatements()).addAll(targetCtx.effectiveSubstatements()).build();
+        for (final StatementContextBase<?, ?, ?> subStatement : targetSubStatements) {
+            if (subStatement.getPublicDefinition().equals(Rfc6020Mapping.PRESENCE)) {
+                return true;
+            }
+        }
+
+        return false;
+    }
 }
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/Bug5335.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/Bug5335.java
new file mode 100644 (file)
index 0000000..7946612
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
+import java.net.URISyntaxException;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+public class Bug5335 {
+    private static final String FOO = "foo";
+    private static final String BAR = "bar";
+    private static final String REV = "2016-03-04";
+
+    private static final QName ROOT = QName.create(FOO, REV, "root");
+    private static final QName PRESENCE_CONTAINER_F = QName.create(FOO, REV, "presence-container");
+    private static final QName NON_PRESENCE_CONTAINER_F = QName.create(FOO, REV, "non-presence-container");
+    private static final QName MANDATORY_LEAF_F = QName.create(FOO, REV, "mandatory-leaf");
+    private static final QName PRESENCE_CONTAINER_B = QName.create(BAR, REV, "presence-container");
+    private static final QName NON_PRESENCE_CONTAINER_B = QName.create(BAR, REV, "non-presence-container");
+    private static final QName MANDATORY_LEAF_B = QName.create(BAR, REV, "mandatory-leaf");
+
+    private final ByteArrayOutputStream output = new ByteArrayOutputStream();
+
+    @Before
+    public void setUp() throws UnsupportedEncodingException {
+        System.setOut(new PrintStream(output, true, "UTF-8"));
+    }
+
+    @After
+    public void cleanUp() {
+        System.setOut(System.out);
+    }
+
+    @Test
+    public void incorrectTest1() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-1");
+        assertNotNull(context);
+
+        SchemaPath schemaPath = SchemaPath.create(true, ROOT, NON_PRESENCE_CONTAINER_B, MANDATORY_LEAF_B);
+        SchemaNode mandatoryLeaf = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
+        assertNull(mandatoryLeaf);
+
+        String testLog = output.toString();
+        assertTrue(testLog
+                .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different from target"));
+    }
+
+    @Test
+    public void incorrectTest2() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-2");
+        assertNotNull(context);
+
+        SchemaPath schemaPath = SchemaPath.create(true, ROOT, PRESENCE_CONTAINER_F, MANDATORY_LEAF_B);
+        SchemaNode mandatoryLeaf = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
+        assertNull(mandatoryLeaf);
+
+        String testLog = output.toString();
+        assertTrue(testLog
+                .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different from target"));
+    }
+
+    @Test
+    public void incorrectTest3() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/incorrect/case-2");
+        assertNotNull(context);
+
+        SchemaPath schemaPath = SchemaPath.create(true, ROOT, PRESENCE_CONTAINER_F, NON_PRESENCE_CONTAINER_B,
+                MANDATORY_LEAF_B);
+        SchemaNode mandatoryLeaf = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
+        assertNull(mandatoryLeaf);
+
+        String testLog = output.toString();
+        assertTrue(testLog
+                .contains("An augment cannot add node 'mandatory-leaf' because it is mandatory and in module different from target"));
+    }
+
+    @Test
+    public void correctTest1() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-1");
+        assertNotNull(context);
+
+        SchemaPath schemaPath = SchemaPath.create(true, ROOT, PRESENCE_CONTAINER_B, MANDATORY_LEAF_B);
+        SchemaNode mandatoryLeaf = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
+        assertTrue(mandatoryLeaf instanceof LeafSchemaNode);
+    }
+
+    @Test
+    public void correctTest2() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-2");
+        assertNotNull(context);
+
+        SchemaPath schemaPath = SchemaPath.create(true, ROOT, PRESENCE_CONTAINER_B, NON_PRESENCE_CONTAINER_B,
+                MANDATORY_LEAF_B);
+        SchemaNode mandatoryLeaf = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
+        assertTrue(mandatoryLeaf instanceof LeafSchemaNode);
+    }
+
+    @Test
+    public void correctTest3() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-3");
+        assertNotNull(context);
+
+        SchemaPath schemaPath = SchemaPath.create(true, ROOT, PRESENCE_CONTAINER_B, NON_PRESENCE_CONTAINER_B,
+                MANDATORY_LEAF_B);
+        SchemaNode mandatoryLeaf = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
+        assertTrue(mandatoryLeaf instanceof LeafSchemaNode);
+    }
+
+    @Test
+    public void correctTest4() throws SourceException, FileNotFoundException, ReactorException, URISyntaxException {
+        SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5335/correct/case-4");
+        assertNotNull(context);
+
+        SchemaPath schemaPath = SchemaPath.create(true, ROOT, NON_PRESENCE_CONTAINER_F, MANDATORY_LEAF_F);
+        SchemaNode mandatoryLeaf = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
+        assertTrue(mandatoryLeaf instanceof LeafSchemaNode);
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/bar.yang
new file mode 100644 (file)
index 0000000..998063a
--- /dev/null
@@ -0,0 +1,17 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    augment "/foo:root" {
+        container presence-container {
+            presence "presence-container";
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/foo.yang
new file mode 100644 (file)
index 0000000..793790d
--- /dev/null
@@ -0,0 +1,12 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/sub-bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-1/sub-bar.yang
new file mode 100644 (file)
index 0000000..4ffccd0
--- /dev/null
@@ -0,0 +1,14 @@
+submodule sub-bar {
+    belongs-to bar {
+        prefix bar;
+    }
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    augment "/foo:root/bar:presence-container" {
+        leaf mandatory-leaf {
+            type string;
+            mandatory true;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/bar.yang
new file mode 100644 (file)
index 0000000..32b8d38
--- /dev/null
@@ -0,0 +1,22 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    augment "/foo:root" {
+        container presence-container {
+            presence "presence-container";
+        }
+    }
+
+    augment "/foo:root/bar:presence-container" {
+        container non-presence-container {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/foo.yang
new file mode 100644 (file)
index 0000000..793790d
--- /dev/null
@@ -0,0 +1,12 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/sub-bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-2/sub-bar.yang
new file mode 100644 (file)
index 0000000..4e6b7b6
--- /dev/null
@@ -0,0 +1,14 @@
+submodule sub-bar {
+    belongs-to bar {
+        prefix bar;
+    }
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    augment "/foo:root/bar:presence-container/bar:non-presence-container" {
+        leaf mandatory-leaf {
+            type string;
+            mandatory true;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-3/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-3/bar.yang
new file mode 100644 (file)
index 0000000..ba83b97
--- /dev/null
@@ -0,0 +1,29 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    augment "/foo:root" {
+        container presence-container {
+            presence "presence-container";
+        }
+    }
+
+    augment "/foo:root/bar:presence-container" {
+        container non-presence-container {
+        }
+    }
+
+    augment "/foo:root/bar:presence-container/bar:non-presence-container" {
+        leaf mandatory-leaf {
+            type string;
+            mandatory true;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-3/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-3/foo.yang
new file mode 100644 (file)
index 0000000..793790d
--- /dev/null
@@ -0,0 +1,12 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-4/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/correct/case-4/foo.yang
new file mode 100644 (file)
index 0000000..848b47f
--- /dev/null
@@ -0,0 +1,24 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    container root {
+    }
+
+    augment "/root" {
+        container non-presence-container {
+        }
+    }
+
+    augment "/root/non-presence-container" {
+        leaf mandatory-leaf {
+            type string;
+            mandatory true;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/bar.yang
new file mode 100644 (file)
index 0000000..756c59f
--- /dev/null
@@ -0,0 +1,16 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    augment "/foo:root" {
+        container non-presence-container {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/foo.yang
new file mode 100644 (file)
index 0000000..793790d
--- /dev/null
@@ -0,0 +1,12 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    container root {
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/sub-bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-1/sub-bar.yang
new file mode 100644 (file)
index 0000000..caf317f
--- /dev/null
@@ -0,0 +1,14 @@
+submodule sub-bar {
+    belongs-to bar {
+        prefix bar;
+    }
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    augment "/foo:root/bar:non-presence-container" {
+        leaf mandatory-leaf {
+            type string;
+            mandatory true;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-2/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-2/bar.yang
new file mode 100644 (file)
index 0000000..a47749c
--- /dev/null
@@ -0,0 +1,18 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    augment "/foo:root/foo:presence-container" {
+        leaf mandatory-leaf {
+            type string;
+            mandatory true;
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-2/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-2/foo.yang
new file mode 100644 (file)
index 0000000..fd2ce12
--- /dev/null
@@ -0,0 +1,18 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    container root {
+    }
+
+    augment "/root" {
+        container presence-container {
+            presence "presence-container";
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/bar.yang
new file mode 100644 (file)
index 0000000..c14830c
--- /dev/null
@@ -0,0 +1,16 @@
+module bar {
+    namespace "bar";
+    prefix bar;
+    yang-version 1;
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    augment "/foo:root/foo:presence-container" {
+        container non-presence-container {
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/foo.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/foo.yang
new file mode 100644 (file)
index 0000000..fd2ce12
--- /dev/null
@@ -0,0 +1,18 @@
+module foo {
+    namespace "foo";
+    prefix foo;
+    yang-version 1;
+
+    revision "2016-03-04" {
+        description "test";
+    }
+
+    container root {
+    }
+
+    augment "/root" {
+        container presence-container {
+            presence "presence-container";
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/sub-bar.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug5335/incorrect/case-3/sub-bar.yang
new file mode 100644 (file)
index 0000000..ce22474
--- /dev/null
@@ -0,0 +1,14 @@
+submodule sub-bar {
+    belongs-to bar {
+        prefix bar;
+    }
+
+    import foo { prefix foo; revision-date 2016-03-04; }
+
+    augment "/foo:root/foo:presence-container/bar:non-presence-container" {
+        leaf mandatory-leaf {
+            type string;
+            mandatory true;
+        }
+    }
+}