BUG-3793 71/22871/1
authorShaleen Saxena <ssaxena@brocade.com>
Wed, 17 Jun 2015 22:16:22 +0000 (15:16 -0700)
committerTony Tkacik <ttkacik@cisco.com>
Thu, 18 Jun 2015 10:56:36 +0000 (10:56 +0000)
Manually patching in changes from Bug 2291 as it does not cherry-pick cleanly.

Change-Id: I17f1c2347d7aa3a120fac0171253e88c46e99fae
Signed-off-by: Shaleen Saxena <ssaxena@brocade.com>
(cherry picked from commit 9e4ce88404e59aed92fdf8d4242587720d8650ab)

yang/yang-parser-impl/src/main/antlr/YangParser.g4
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang [new file with mode: 0644]

index 38a05711ec143f9abf1487dd1302d17f72e6a1d4..3e5ca54da0e315379fbb50eb2efea1f603d3e620 100644 (file)
@@ -182,7 +182,7 @@ extension_stmt : EXTENSION_KEYWORD string (SEMICOLON | (LEFT_BRACE  (argument_st
 // string validated in YangModelBasicValidationListener.enterRevision_date_stmt()
 revision_date_stmt : REVISION_DATE_KEYWORD string stmtend;
 // string validated in YangModelBasicValidationListener.enterRevision_stmt()
-revision_stmt : REVISION_KEYWORD string (SEMICOLON | (LEFT_BRACE stmtsep* (description_stmt )? (reference_stmt )? RIGHT_BRACE));
+revision_stmt : REVISION_KEYWORD string (SEMICOLON | (LEFT_BRACE stmtsep* (description_stmt )? (reference_stmt )? (unknown_statement)? RIGHT_BRACE));
 // string not validated
 units_stmt : UNITS_KEYWORD string stmtend;
 // string not validated
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java
new file mode 100644 (file)
index 0000000..50c94f9
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.math.BigInteger;
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
+import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
+import org.opendaylight.yangtools.yang.model.util.BitsType;
+import org.opendaylight.yangtools.yang.model.util.EnumerationType;
+import org.opendaylight.yangtools.yang.model.util.ExtendedType;
+import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
+import org.opendaylight.yangtools.yang.model.util.InstanceIdentifierType;
+import org.opendaylight.yangtools.yang.model.util.UnionType;
+
+public class Bug2291Test {
+
+    @Test
+    public void testRevisionWithExt() throws Exception {
+        File extdef = new File(getClass().getResource("/bugs/bug2291/bug2291-ext.yang").toURI());
+        File bug = new File(getClass().getResource("/bugs/bug2291/bug2291.yang").toURI());
+        File inet = new File(getClass().getResource("/ietf/ietf-inet-types@2010-09-24.yang").toURI());
+        YangContextParser parser = new YangParserImpl();
+        parser.parseFiles(Arrays.asList(extdef, bug, inet));
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang
new file mode 100644 (file)
index 0000000..f059a8d
--- /dev/null
@@ -0,0 +1,13 @@
+module "bug2291-ext" {
+    yang-version 1;
+    namespace "urn:test:bug:bug2291-ext";
+    prefix "bug2291-ext";
+
+    revision 2012-04-16 {
+    }
+
+    extension migration {
+        argument level;
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang b/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang
new file mode 100644 (file)
index 0000000..90962b4
--- /dev/null
@@ -0,0 +1,22 @@
+module bug2291 {
+    yang-version 1;
+    namespace "urn:test:bug:bug2291";
+    prefix "bug2291";
+
+    import bug2291-ext {
+        prefix bug2291-ext;
+    }
+
+    import ietf-inet-types {
+        prefix "inet";
+    }
+
+    revision 2012-04-16 {
+        description "Initial revision";
+        bug2291-ext:migration 1;
+    }
+
+    leaf test {
+        type string;
+    }
+}