From 9e4ce88404e59aed92fdf8d4242587720d8650ab Mon Sep 17 00:00:00 2001 From: Shaleen Saxena Date: Wed, 17 Jun 2015 15:16:22 -0700 Subject: [PATCH] BUG-3793 Manually patching in changes from Bug 2291 as it does not cherry-pick cleanly. Change-Id: I17f1c2347d7aa3a120fac0171253e88c46e99fae Signed-off-by: Shaleen Saxena --- .../src/main/antlr/YangParser.g4 | 2 +- .../yang/parser/impl/Bug2291Test.java | 54 +++++++++++++++++++ .../resources/bugs/bug2291/bug2291-ext.yang | 13 +++++ .../test/resources/bugs/bug2291/bug2291.yang | 22 ++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang create mode 100644 yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang diff --git a/yang/yang-parser-impl/src/main/antlr/YangParser.g4 b/yang/yang-parser-impl/src/main/antlr/YangParser.g4 index 38a05711ec..3e5ca54da0 100644 --- a/yang/yang-parser-impl/src/main/antlr/YangParser.g4 +++ b/yang/yang-parser-impl/src/main/antlr/YangParser.g4 @@ -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 index 0000000000..50c94f9999 --- /dev/null +++ b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/Bug2291Test.java @@ -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 index 0000000000..f059a8da9e --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291-ext.yang @@ -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 index 0000000000..90962b485b --- /dev/null +++ b/yang/yang-parser-impl/src/test/resources/bugs/bug2291/bug2291.yang @@ -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; + } +} -- 2.36.6