BUG-4688: eliminate SimpleDateFormatUtil.DEFAULT_DATE_REV 73/64673/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 24 Oct 2017 15:49:22 +0000 (17:49 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 24 Oct 2017 19:28:42 +0000 (21:28 +0200)
This is the final push for eliminating DEFAULT_DATE_REV, with all
other issues resolved, this removes the constant, adjusts the code
to correctly interpret non-present revisions and fixes up test
cases, eliminating the leaking 1970-01-01 string.

This actually fixes a few test cases, which relied on import with
revision 1970-01-01 matching modules which do not declare revision.

Change-Id: I59dbe8b06ad2d94e6a677959f29f5c2b52357d0b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
103 files changed:
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/SimpleDateFormatUtil.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug4501Test.java
yang/yang-data-codec-gson/src/test/java/org/opendaylight/yangtools/yang/data/codec/gson/Bug7246Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8745Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/Bug8803Test.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/DOMSourceXMLStreamReaderTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/NormalizedNodesToXmlTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLDeserializationTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/YangModeledAnyXMLSerializationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/codecs/StringPatternCheckingCodecTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/Bug7844Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/SchemaUtilsTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug4295Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug8291Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/OrderedListTest.java
yang/yang-data-impl/src/test/resources/bug7844/bar.yang
yang/yang-data-impl/src/test/resources/bug7844/foo.yang
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/Util.java
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/SchemaContextEmitter.java
yang/yang-model-export/src/main/java/org/opendaylight/yangtools/yang/model/export/YinExportUtils.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/EffectiveSchemaContextEmitterTest.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/Bug2444Test.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/YinExportTestUtils.java
yang/yang-model-export/src/test/resources/bugs/bug2444/yang/import-yang1.yang
yang/yang-model-export/src/test/resources/bugs/bug2444/yang/import.yang
yang/yang-model-export/src/test/resources/bugs/bug2444/yang/include.yang
yang/yang-model-export/src/test/resources/bugs/bug2444/yin-effective-emitter/notification.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin-effective-emitter/notification@1970-01-01.yin with 96% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/action.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/action@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/anydata.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/anydata@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/binary-spec.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/binary-spec@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/default.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/default@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/identities.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/identities@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/import-yang1@1970-01-01.yin
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/import.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/import@1970-01-01.yin with 90% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/include@2017-06-26.yin
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/leafref-yang1.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/leafref-yang1@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/leafref.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/leafref@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/modifier-yang1.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/modifier-yang1@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/modifier.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/modifier@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/must-yang1.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/must-yang1@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/must.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/must@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/notification.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/notification@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/submodule.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/submodule@1970-01-01.yin with 100% similarity]
yang/yang-model-export/src/test/resources/bugs/bug2444/yin/unique.yin [moved from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/unique@1970-01-01.yin with 100% similarity]
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/ModuleDependencySort.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SubmoduleStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/SubmoduleEffectiveStatementImpl.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/MultipleRevImportBug6875Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/repo/SharedSchemaRepositoryWithFeaturesTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Bug5410Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6868Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6869Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6870Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6876Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6880Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6883Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6884Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6897Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/stmt/rfc7950/Bug6901Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/AugmentProcessTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug3874ExtensionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4410Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug4623Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5396Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug5518Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6183Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6316Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6491Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug6771Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7037Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7424Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7865Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug7879Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8126Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8597Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/Bug8922Test.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveBuildTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveIdentityTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModuleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/EffectiveModulesAndSubmodulesTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IfFeatureResolutionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/ImportRevisionsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/IncludeRevisionsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/MoreRevisionsTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangParserNegativeTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/YangTypes2StmtTest.java
yang/yang-parser-impl/src/test/resources/bugs/bug7037/foo.yang
yang/yang-parser-impl/src/test/resources/bugs/bug7038/bar.yang
yang/yang-parser-impl/src/test/resources/bugs/bug8126/bar.yang
yang/yang-parser-impl/src/test/resources/import-revision-date-test/root-with-1970-revision-date.yang [deleted file]
yang/yang-parser-impl/src/test/resources/revisions/mod-1970-rev.yang [deleted file]
yang/yang-parser-impl/src/test/resources/revisions/mod-1970-root.yang [deleted file]
yang/yang-parser-impl/src/test/resources/rfc7950/bug6884/circular-includes/foo.yang
yang/yang-parser-impl/src/test/resources/rfc7950/bug6884/circular-includes/sub-foo.yang
yang/yang-parser-impl/src/test/resources/rfc7950/bug6884/yang1-1/foo.yang
yang/yang-parser-impl/src/test/resources/stmt-test/augments/multiple-augment-root.yang
yang/yang-parser-impl/src/test/resources/stmt-test/submodules/root-module.yang
yang/yang-parser-impl/src/test/resources/stmt-test/submodules/submodule-1.yang
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java

index d98926d4464c59e9eff67b49305d127ea5f8131b..2d8df756c0ad69463c74f63c1c560dd62e7e1f80 100644 (file)
@@ -8,9 +8,7 @@
 
 package org.opendaylight.yangtools.yang.common;
 
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
 
 public final class SimpleDateFormatUtil {
 
@@ -19,26 +17,6 @@ public final class SimpleDateFormatUtil {
      */
     private static final String REVISION_SIMPLE_DATE = "yyyy-MM-dd";
 
-    /**
-     * default Yang date that is used when date is not present.
-     */
-    private static final String DEFAULT_DATE = "1970-01-01";
-
-    /**
-     * {@link SimpleDateFormatUtil#DEFAULT_DATE} for revision statement.
-     */
-    public static final Date DEFAULT_DATE_REV;
-
-    static {
-        final SimpleDateFormat simpleDateFormat = new SimpleDateFormat(REVISION_SIMPLE_DATE);
-
-        try {
-            DEFAULT_DATE_REV = simpleDateFormat.parse(DEFAULT_DATE);
-        } catch (final ParseException e) {
-            throw new ExceptionInInitializerError(e);
-        }
-    }
-
     private SimpleDateFormatUtil() {
         throw new UnsupportedOperationException("Utility class should not be instantiated");
     }
index 20a9536151a4adbd1ed9f1ccdc24edaad9665007..cb05b63a1d618138750c90d436e7abeafaee9f1f 100644 (file)
@@ -53,7 +53,7 @@ public class Bug4501Test {
 
         final UnkeyedListNode hop = (UnkeyedListNode) transformedInput;
         final Optional<DataContainerChild<? extends PathArgument, ?>> lrsBits = hop.getChild(0).getChild(
-                NodeIdentifier.create(QName.create("foo", "1970-01-01", "lrs-bits")));
+                NodeIdentifier.create(QName.create("foo", "lrs-bits")));
 
         final ImmutableSet<String> expectedValue = ImmutableSet.of("lookup", "rloc-probe", "strict");
         assertEquals(expectedValue, lrsBits.get().getValue());
@@ -70,8 +70,7 @@ public class Bug4501Test {
             jsonParser.parse(new JsonReader(new StringReader(inputJson)));
             fail("IllegalArgumentException should be thrown.");
         } catch (IllegalArgumentException e) {
-            assertEquals(e.getMessage(),
-                    "Node '(foo?revision=1970-01-01)lrs-bits' has already set its value to '[lookup]'");
+            assertEquals(e.getMessage(), "Node '(foo)lrs-bits' has already set its value to '[lookup]'");
         }
     }
 }
\ No newline at end of file
index 912b89a334d24fbcdafae6f42d78a8737594dead..d2d1bbbdcb1d3913dd85e6b6be87c430ebd57fcd 100644 (file)
@@ -17,7 +17,6 @@ import java.io.IOException;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.net.URI;
-import java.net.URISyntaxException;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
@@ -34,7 +33,6 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug7246Test {
     private static final String NS = "my-namespace";
-    private static final String REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
@@ -56,15 +54,15 @@ public class Bug7246Test {
     }
 
     private static QName qN(final String localName) {
-        return QName.create(NS, REV, localName);
+        return QName.create(NS, localName);
     }
 
     private static String normalizedNodeToJsonStreamTransformation(final SchemaContext schemaContext,
             final SchemaPath path, final Writer writer, final NormalizedNode<?, ?> inputStructure)
-            throws IOException, URISyntaxException {
+            throws IOException {
 
         final NormalizedNodeStreamWriter jsonStream = JSONNormalizedNodeStreamWriter.createExclusiveWriter(
-                JSONCodecFactory.getShared(schemaContext), path, new URI(NS),
+                JSONCodecFactory.getShared(schemaContext), path, URI.create(NS),
                 JsonWriterFactory.createJsonWriter(writer, 2));
         final NormalizedNodeWriter nodeWriter = NormalizedNodeWriter.forStreamWriter(jsonStream);
         nodeWriter.write(inputStructure);
index 7c651935c0a297bc2da69f05e32f260d94cc848a..6661c09806627e8e07a1cdedf1e6be863c411940 100644 (file)
@@ -45,7 +45,7 @@ public class Bug8745Test {
     @Test
     public void testParsingAttributes() throws Exception {
         final SchemaContext schemaContext = YangParserTestUtils.parseYangResource("/bug8745/foo.yang");
-        final QName contWithAttributes = QName.create("foo", "1970-01-01", "cont-with-attributes");
+        final QName contWithAttributes = QName.create("foo", "cont-with-attributes");
         final ContainerSchemaNode contWithAttr = (ContainerSchemaNode) SchemaContextUtil.findDataSchemaNode(
                 schemaContext, SchemaPath.create(true, contWithAttributes));
 
index c0a9f657cfd4fb192d1cadf409ccea9a2d89f02f..b4a3fd970f73312ef0fc11896e6a97d237f55f65 100644 (file)
@@ -36,7 +36,7 @@ public class Bug8803Test {
     @Test
     public void test() throws Exception {
         final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/bug8803");
-        final SchemaPath topContPath = SchemaPath.create(true, QName.create("foo-ns", "1970-01-01", "top-cont"));
+        final SchemaPath topContPath = SchemaPath.create(true, QName.create("foo-ns", "top-cont"));
         final SchemaNode dataSchemaNode = SchemaContextUtil.findDataSchemaNode(schemaContext, topContPath);
         assertTrue(dataSchemaNode instanceof ContainerSchemaNode);
         final ContainerSchemaNode topContSchema = (ContainerSchemaNode) dataSchemaNode;
index 9992ce1ca37fc1318d4ffbbdaaae46e480b82f65..6606a44e0137cb535c86513b7a25698d3c83b65f 100644 (file)
@@ -48,8 +48,7 @@ public class DOMSourceXMLStreamReaderTest {
     public void test() throws Exception {
         final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/dom-reader-test");
         final ContainerSchemaNode outerContainerSchema = (ContainerSchemaNode) SchemaContextUtil
-                .findNodeInSchemaContext(schemaContext, ImmutableList.of(QName.create("foo-ns", "1970-01-01",
-                        "top-cont")));
+                .findNodeInSchemaContext(schemaContext, ImmutableList.of(QName.create("foo-ns", "top-cont")));
         assertNotNull(outerContainerSchema);
 
         // deserialization
index 60ad09be759cc72466b5ed6d3da14381a906248b..130478f563fa052df866396767d2280ca210369e 100644 (file)
@@ -87,7 +87,7 @@ public class NormalizedNodesToXmlTest {
 
     @Before
     public void setup() {
-        bazModule = QNameModule.create(URI.create("baz-namespace"), QName.parseRevision("1970-01-01"));
+        bazModule = QNameModule.create(URI.create("baz-namespace"), null);
 
         outerContainer = QName.create(bazModule, "outer-container");
 
index 1e072739ac96fde50e713eb41430da0b2aa4ccdb..d7a402c79b8410299a001fd855369098f376b6cc 100644 (file)
@@ -85,11 +85,11 @@ public class XmlToNormalizedNodesTest {
     private static QName myLeafInList3;
 
     @BeforeClass
-    public static void setup() throws Exception {
-        fooModule = QNameModule.create(new URI("foo-namespace"), QName.parseRevision("1970-01-01"));
+    public static void setup() {
+        fooModule = QNameModule.create(URI.create("foo-namespace"), null);
         parentContainer = QName.create(fooModule, "parent-container");
 
-        bazModule = QNameModule.create(new URI("baz-namespace"), QName.parseRevision("1970-01-01"));
+        bazModule = QNameModule.create(URI.create("baz-namespace"), null);
         outerContainer = QName.create(bazModule, "outer-container");
 
         myContainer1 = QName.create(bazModule, "my-container-1");
index 32318e981cf533b1ac7053a420a6d3e98d897635..2922c3875d5c686d380a641d72404ffbd53c7dde 100644 (file)
@@ -59,13 +59,13 @@ public class YangModeledAnyXMLDeserializationTest {
     private SchemaContext schemaContext;
 
     @Before
-    public void setUp() throws Exception {
-        barModuleQName = QNameModule.create(new URI("bar"), QName.parseRevision("1970-01-01"));
+    public void setUp() {
+        barModuleQName = QNameModule.create(URI.create("bar"), null);
         myContainer1 = QName.create(barModuleQName, "my-container-1");
         myLeaf1 = QName.create(barModuleQName, "my-leaf-1");
         myAnyXMLDataBar = QName.create(barModuleQName, "my-anyxml-data");
 
-        fooModuleQName = QNameModule.create(new URI("foo"), QName.parseRevision("1970-01-01"));
+        fooModuleQName = QNameModule.create(URI.create("foo"), null);
         myContainer2 = QName.create(fooModuleQName, "my-container-2");
         innerContainer = QName.create(fooModuleQName, "inner-container");
         myLeaf3 = QName.create(fooModuleQName, "my-leaf-3");
index 27ab3f125958926fbc015de1dc99233f1c3cc737..57e7312a997c4591f7cb4a7603c354b945db42c3 100644 (file)
@@ -57,18 +57,13 @@ import org.xml.sax.SAXException;
 
 public class YangModeledAnyXMLSerializationTest extends XMLTestCase {
 
-    private final QNameModule bazModuleQName;
-    private final QName myAnyXMLDataBaz;
-    private final QName bazQName;
-    private final QName myContainer2QName;
+    private final QNameModule bazModuleQName = QNameModule.create(URI.create("baz"), null);
+    private final QName myAnyXMLDataBaz = QName.create(bazModuleQName, "my-anyxml-data");
+    private final QName bazQName = QName.create(bazModuleQName, "baz");
+    private final QName myContainer2QName = QName.create(bazModuleQName, "my-container-2");
     private final SchemaContext schemaContext;
 
-    public YangModeledAnyXMLSerializationTest() throws Exception {
-        bazModuleQName = QNameModule.create(new URI("baz"), QName.parseRevision("1970-01-01"));
-        bazQName = QName.create(bazModuleQName, "baz");
-        myContainer2QName = QName.create(bazModuleQName, "my-container-2");
-        myAnyXMLDataBaz = QName.create(bazModuleQName, "my-anyxml-data");
-
+    public YangModeledAnyXMLSerializationTest() {
         schemaContext = YangParserTestUtils.parseYangResourceDirectory("/anyxml-support/serialization");
     }
 
index 244d56bc56a00d669ff76e68121b299955f34b53..b0aa31c35717fe69bf08f8431e586a1fd0dca858 100644 (file)
@@ -17,11 +17,9 @@ import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwa
 import java.io.FileNotFoundException;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.text.ParseException;
 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.data.api.codec.StringCodec;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -37,14 +35,13 @@ public class StringPatternCheckingCodecTest {
     private static final Logger LOG = LoggerFactory.getLogger(StringPatternCheckingCodecTest.class);
 
     @Test
-    public void testStringPatternCheckingCodec() throws ReactorException, ParseException, URISyntaxException,
+    public void testStringPatternCheckingCodec() throws ReactorException, URISyntaxException,
             FileNotFoundException {
         final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
             "/string-pattern-checking-codec-test.yang");
         assertNotNull(schemaContext);
 
-        final QNameModule testModuleQName = QNameModule.create(new URI("string-pattern-checking-codec-test"),
-                SimpleDateFormatUtil.DEFAULT_DATE_REV);
+        final QNameModule testModuleQName = QNameModule.create(new URI("string-pattern-checking-codec-test"), null);
 
         final Module testModule = schemaContext.findModules("string-pattern-checking-codec-test").iterator().next();
         final ContainerSchemaNode testContainer = (ContainerSchemaNode) testModule.getDataChildByName(
index 96a8475bd932aa0d7c320c68df5ed999af66ca70..dd2031067224f059dfb92fab9f4e8101ba010fdb 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Map;
 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.test.util.YangParserTestUtils;
 
@@ -26,10 +25,9 @@ public class Bug7844Test {
     private static final String FOO_NS = "foo";
     private static final String BAR_NS = "bar";
     private static final String BAZ_NS = "baz";
-    private static final String REV = "1970-01-01";
 
     @Test
-    public void test() throws Exception {
+    public void test() {
         final SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/bug7844");
         assertNotNull(context);
 
@@ -39,8 +37,7 @@ public class Bug7844Test {
         final Map<QName, LeafRefContext> referencingChilds = leafRefContext.getReferencingChilds();
         assertEquals(7, referencingChilds.size());
 
-        final QNameModule bazQNameModule = QNameModule.create(new URI(BAZ_NS),
-                SimpleDateFormatUtil.getRevisionFormat().parse(REV));
+        final QNameModule bazQNameModule = QNameModule.create(URI.create(BAZ_NS), null);
         final LeafRefPath expectedPathToBazTarget = LeafRefPath.create(true,
                 new QNameWithPredicateImpl(bazQNameModule, "root", ImmutableList.of()),
                 new QNameWithPredicateImpl(bazQNameModule, "target", ImmutableList.of()));
@@ -52,8 +49,7 @@ public class Bug7844Test {
         assertLeafRef(referencingChilds.get(bar("my-leafref-in-bar")), expectedPathToBazTarget);
         assertLeafRef(referencingChilds.get(bar("my-leafref-in-bar-2")), expectedPathToBazTarget);
 
-        final QNameModule barQNameModule = QNameModule.create(new URI(BAR_NS),
-                SimpleDateFormatUtil.getRevisionFormat().parse(REV));
+        final QNameModule barQNameModule = QNameModule.create(URI.create(BAR_NS), null);
         final LeafRefPath expectedPathToBarTarget = LeafRefPath.create(true,
                 new QNameWithPredicateImpl(barQNameModule, "bar-target", ImmutableList.of()));
         assertLeafRef(referencingChilds.get(foo("direct-leafref")), expectedPathToBarTarget);
@@ -89,14 +85,14 @@ public class Bug7844Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 
     private static QName bar(final String localName) {
-        return QName.create(BAR_NS, REV, localName);
+        return QName.create(BAR_NS, localName);
     }
 
     private static QName baz(final String localName) {
-        return QName.create(BAZ_NS, REV, localName);
+        return QName.create(BAZ_NS, localName);
     }
 }
index 28d9a57456625a0c254c6c1593c79b465bfb1fc5..2067575a73bd490ccf33540373cf9c5fa60c5a6d 100644 (file)
@@ -24,7 +24,6 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class SchemaUtilsTest {
     private static final String NS = "my-namespace";
-    private static final String REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
@@ -73,6 +72,6 @@ public class SchemaUtilsTest {
     }
 
     private static QName qN(final String localName) {
-        return QName.create(NS, REV, localName);
+        return QName.create(NS, localName);
     }
 }
index b07d72988d27a785ac18c0d4a09a37e9d3f4cc35..d0e20cd42865d1ff5350fd74e85acca982a9f84f 100644 (file)
@@ -9,13 +9,11 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableMap.Builder;
-import java.io.File;
 import java.net.URI;
 import org.junit.Before;
 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.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -48,11 +46,9 @@ public class Bug4295Test {
     private QNameModule foo;
 
     @Before
-    public void init() throws Exception {
-        final File resourceFile = new File(Bug4295Test.class.getResource("/bug-4295/foo.yang")
-                .toURI());
-        context = YangParserTestUtils.parseYangFiles(resourceFile);
-        foo = QNameModule.create(new URI("foo"), SimpleDateFormatUtil.getRevisionFormat().parse("1970-01-01"));
+    public void init() {
+        context = YangParserTestUtils.parseYangResource("/bug-4295/foo.yang");
+        foo = QNameModule.create(URI.create("foo"), null);
         root = QName.create(foo, "root");
         subRoot = QName.create(foo, "sub-root");
         outerList = QName.create(foo, "outer-list");
index f4952d5d592ad61460c45d8caa8c090807e24927..842c908b7fa540d9ddca4c1d4d9dcf81decb5e0e 100644 (file)
@@ -24,19 +24,17 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class Bug8291Test {
     private static final String NS = "foo";
-    private static final String REV = "1970-01-01";
-    private static final QName ROOT = QName.create(NS, REV, "root");
-    private static final QName OUTER_LIST = QName.create(NS, REV, "outer-list");
-    private static final QName OUTER_LIST_ID = QName.create(NS, REV, "id");
-    private static final QName INNER_LIST = QName.create(NS, REV, "inner-list");
+    private static final QName ROOT = QName.create(NS, "root");
+    private static final QName OUTER_LIST = QName.create(NS, "outer-list");
+    private static final QName OUTER_LIST_ID = QName.create(NS, "id");
+    private static final QName INNER_LIST = QName.create(NS, "inner-list");
     private SchemaContext schemaContext;
 
     @Before
-    public void init() throws ReactorException {
+    public void init() {
         this.schemaContext = TestModel.createTestContext("/bug8291/foo.yang");
         assertNotNull("Schema context must not be null.", this.schemaContext);
     }
index 41dcc93a39c8956625a582361eb206b396d48513..003a1028da7dcc7e208af65cd97eb77125b1be94 100644 (file)
@@ -13,14 +13,12 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import com.google.common.collect.ImmutableMap;
-import java.io.File;
 import java.net.URI;
 import java.util.Optional;
 import org.junit.Before;
 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.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
@@ -57,12 +55,9 @@ public class OrderedListTest {
     private QName childOrdinaryLeaf;
 
     @Before
-    public void setup() throws Exception {
-        final File resourceFile = new File(Bug4295Test.class.getResource("/ordered-list-modification-test.yang")
-                .toURI());
-        context = YangParserTestUtils.parseYangFiles(resourceFile);
-        testModule = QNameModule.create(new URI("ordered-list-modification-test"),
-                SimpleDateFormatUtil.getRevisionFormat().parse("1970-01-01"));
+    public void setup() {
+        context = YangParserTestUtils.parseYangResource("/ordered-list-modification-test.yang");
+        testModule = QNameModule.create(URI.create("ordered-list-modification-test"), null);
         parentContainer = QName.create(testModule, "parent-container");
         childContainer = QName.create(testModule, "child-container");
         parentOrderedList = QName.create(testModule, "parent-ordered-list");
index 8ac871bb50fb9e58f3ba112c1d1fbf5297376fc8..42dab9372cedd2b2950574e37d8e7b0a609652e5 100644 (file)
@@ -2,7 +2,7 @@ module bar {
     namespace bar;
     prefix bar-mod;
 
-    import baz { prefix baz-imp; revision-date 1970-01-01; }
+    import baz { prefix baz-imp; }
 
     typedef bar-leafref {
         type baz-imp:my-leafref;
index b7f19b448907ebba7e01c175eaae98a6589f94db..6a50b73e7f4f98bef87584e37483bfbac908667f 100644 (file)
@@ -2,7 +2,7 @@ module foo {
     namespace foo;
     prefix foo-mod;
 
-    import bar { prefix bar-imp; revision-date 1970-01-01; }
+    import bar { prefix bar-imp; }
 
     leaf my-leaf {
         type foo-leafref;
index f142b6f944516fbe596f679466743c99c2df9199..776c8c78141fb0c725d4142177e637baa8a1e04d 100644 (file)
@@ -18,12 +18,10 @@ import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Optional;
 import java.util.Set;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
@@ -37,7 +35,6 @@ import org.apache.maven.plugin.MojoFailureException;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.repository.RepositorySystem;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
@@ -268,14 +265,8 @@ final class Util {
 
     static SourceIdentifier moduleToIdentifier(final Module module) {
         final QNameModule mod = module.getQNameModule();
-        final Date rev = mod.getRevision();
-        final Optional<String> optRev;
-        if (SimpleDateFormatUtil.DEFAULT_DATE_REV.equals(rev)) {
-            optRev = Optional.empty();
-        } else {
-            optRev = Optional.of(mod.getFormattedRevision());
-        }
-
-        return RevisionSourceIdentifier.create(module.getName(), optRev);
+        final String rev = mod.getFormattedRevision();
+        return rev != null ? RevisionSourceIdentifier.create(module.getName(), rev)
+                : RevisionSourceIdentifier.create(module.getName());
     }
 }
index 1cde06daec0449c01255185d97eca0b76e173865..71555a38f064d2ed68cf5e7af7cb87ca499fe029 100644 (file)
@@ -1350,15 +1350,15 @@ abstract class SchemaContextEmitter {
         }
 
         private void emitRevision(final Date date) {
-            super.writer.startRevisionNode(date);
-
-            //
-            // FIXME: BUG-2444: FIXME: BUG-2444: BUG-2417: descriptionNode
-            // //FIXME: BUG-2444: Optional
-            // FIXME: BUG-2444: FIXME: BUG-2444: BUG-2417: referenceNode
-            // //FIXME: BUG-2444: Optional
-            super.writer.endNode();
+            if (date != null) {
+                super.writer.startRevisionNode(date);
 
+                // FIXME: BUG-2444: FIXME: BUG-2444: BUG-2417: descriptionNode
+                // //FIXME: BUG-2444: Optional
+                // FIXME: BUG-2444: FIXME: BUG-2444: BUG-2417: referenceNode
+                // //FIXME: BUG-2444: Optional
+                super.writer.endNode();
+            }
         }
 
         private void emitRevisionDateNode(@Nullable final Date date) {
index ba7c917151b4a1fc63de892b2c7936158d9fda3a..2a955f56dd3339d370c7c76a6453712978625106 100644 (file)
@@ -18,6 +18,7 @@ import javax.xml.stream.XMLOutputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -39,7 +40,8 @@ public final class YinExportUtils {
      * @return well-formed file name of YIN file as defined in RFC6020.
      */
     public static String wellFormedYinName(final String name, final Date revision) {
-        return wellFormedYinName(name, SimpleDateFormatUtil.getRevisionFormat().format(revision));
+        return revision == null ? wellFormedYinName(name, (String) null) :
+            wellFormedYinName(name, SimpleDateFormatUtil.getRevisionFormat().format(revision));
     }
 
     /**
@@ -53,7 +55,10 @@ public final class YinExportUtils {
      * @return well-formed file name of YIN file as defined in RFC6020.
      */
     public static String wellFormedYinName(final String name, final String revision) {
-        return String.format("%s@%s.yin", Preconditions.checkNotNull(name), Preconditions.checkNotNull(revision));
+        if (revision == null) {
+            return name + YangConstants.RFC6020_YIN_FILE_EXTENSION;
+        }
+        return Preconditions.checkNotNull(name) + '@' + revision +  YangConstants.RFC6020_YIN_FILE_EXTENSION;
     }
 
     /**
index c7d683e7decb368f32431a5e7548744c3d7a519b..4a4e68aa80b579325ad6dc3a9f24eebfa3c1f19a 100644 (file)
@@ -29,7 +29,6 @@ import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -59,9 +58,7 @@ public class EffectiveSchemaContextEmitterTest {
                 assertNotNull(output);
                 assertNotEquals(0, output.length());
 
-                final Document doc = YinExportTestUtils
-                        .loadDocument(String.format("/bugs/bug2444/yin-effective-emitter/%s@%s.yin", module.getName(),
-                                SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision())));
+                final Document doc = YinExportTestUtils.loadDocument("/bugs/bug2444/yin-effective-emitter", module);
                 assertXMLEquals(doc, output);
             } finally {
                 byteArrayOutputStream.close();
index d96f600146ae62dd8c67d8068890b6368825a6a3..cd8776f26a142df7116e7a5fa971b7359a8394db 100644 (file)
@@ -21,7 +21,6 @@ import org.custommonkey.xmlunit.ElementNameAndAttributeQualifier;
 import org.custommonkey.xmlunit.XMLAssert;
 import org.custommonkey.xmlunit.XMLUnit;
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.export.YinExportUtils;
@@ -45,9 +44,8 @@ public class Bug2444Test {
                 assertNotNull(output);
                 assertNotEquals(0, output.length());
 
-                final Document doc = YinExportTestUtils.loadDocument(String.format("/bugs/bug2444/yin/%s@%s.yin",
-                        module.getName(), SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision())));
-                assertXMLEquals(doc, output);
+                final Document doc = YinExportTestUtils.loadDocument("/bugs/bug2444/yin", module);
+                assertXMLEquals(module.getName(), doc, output);
             } finally {
                 byteArrayOutputStream.close();
                 bufferedOutputStream.close();
@@ -64,7 +62,7 @@ public class Bug2444Test {
         return builder.build();
     }
 
-    private static void assertXMLEquals(final Document expectedXMLDoc, final String output)
+    private static void assertXMLEquals(final String fileName, final Document expectedXMLDoc, final String output)
             throws SAXException, IOException {
         final String expected = YinExportTestUtils.toString(expectedXMLDoc.getDocumentElement());
 
@@ -74,6 +72,6 @@ public class Bug2444Test {
 
         final Diff diff = new Diff(expected, output);
         diff.overrideElementQualifier(new ElementNameAndAttributeQualifier());
-        XMLAssert.assertXMLEqual(diff, true);
+        XMLAssert.assertXMLEqual(fileName, diff, true);
     }
 }
index 7cf35e8d798ab17c115abd8c0b2c57a099f609b7..259b8cc8356155c947ec718f64a33416728af05f 100644 (file)
@@ -19,6 +19,9 @@ import javax.xml.transform.TransformerFactoryConfigurationError;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 import org.opendaylight.yangtools.util.xml.UntrustedXML;
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.YangConstants;
+import org.opendaylight.yangtools.yang.model.api.Module;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 import org.xml.sax.SAXException;
@@ -29,6 +32,12 @@ public class YinExportTestUtils {
         throw new UnsupportedOperationException("Utility class");
     }
 
+    public static Document loadDocument(final String prefix, final Module module) throws IOException, SAXException {
+        final String fileName = module.getRevision() == null ? module.getName()
+                : module.getName() + '@' + SimpleDateFormatUtil.getRevisionFormat().format(module.getRevision());
+        return loadDocument(prefix + '/' + fileName + YangConstants.RFC6020_YIN_FILE_EXTENSION);
+    }
+
     public static Document loadDocument(final String xmlPath) throws IOException, SAXException {
         final InputStream resourceAsStream = SchemaContextEmitterTest.class.getResourceAsStream(xmlPath);
         final Document currentConfigElement = readXmlToDocument(resourceAsStream);
index bd716f6a60ebc747699e1dfb5add80cfd992e34f..3e708e2d16e0eae9f71d1f3e40b1c186be34ab98 100644 (file)
@@ -3,7 +3,7 @@ module import-yang1 {
     prefix iy1;
     yang-version 1;
 
-    import action { prefix ac; revision-date 1970-01-01; }
+    import action { prefix ac; }
     
     revision 1970-01-01;
 }
index db1f786db1e4dfb8e166e410b9feff4ea8569772..f8fc24bf4d9aa09704dd68baaff4249fd4c9ebdc 100644 (file)
@@ -3,5 +3,5 @@ module import {
     prefix i;
     yang-version 1.1;
 
-    import action { description "txt"; reference "ref"; prefix ac; revision-date 1970-01-01; }
+    import action { description "txt"; reference "ref"; prefix ac; }
 }
index d04249e34e1045d6688613fe2cf6c8667d16114f..09f7425f6c6ec968057ec89d829a2eadddb46c5d 100644 (file)
@@ -6,7 +6,6 @@ module include {
     import deviation-target { prefix dev-tgt; revision-date 2017-01-20; reference "import ref"; description "import desc"; }
 
     include submodule {
-        revision-date 1970-01-01;
         reference "include ref";
         description "include desc";
     }
similarity index 96%
rename from yang/yang-model-export/src/test/resources/bugs/bug2444/yin-effective-emitter/notification@1970-01-01.yin
rename to yang/yang-model-export/src/test/resources/bugs/bug2444/yin-effective-emitter/notification.yin
index 8b996e194f1f8197b05e295e4120a8f2d56ed265..2d89662d3d5aea6ba00ea270132b2592100d67b4 100644 (file)
@@ -3,7 +3,6 @@
     <yang-version value="1.1"></yang-version>
     <namespace uri="notification"></namespace>
     <prefix value="n"></prefix>
-    <revision date="1970-01-01"></revision>
     <grouping name="grp">
         <status value="current"></status>
         <notification name="n5">
@@ -48,4 +47,4 @@
             <status value="current"></status>
         </container>
     </notification>
-</module>
\ No newline at end of file
+</module>
index 4bfc82419e833cd1a7bf4cf9a78209a8d329a219..3406313942392bb70b9a8e2e6a59aa40eb6d6eeb 100644 (file)
@@ -5,7 +5,6 @@
     <yang-version value="1" />
     <import module="action">
         <prefix value="ac" />
-        <revision-date date="1970-01-01" />
     </import>
     <revision date="1970-01-01" />
 </module>
similarity index 90%
rename from yang/yang-model-export/src/test/resources/bugs/bug2444/yin/import@1970-01-01.yin
rename to yang/yang-model-export/src/test/resources/bugs/bug2444/yin/import.yin
index 3b97daa05c579f44f26f566648c590cea30dac7e..1dc8085f61c44dc90360a82967e45ace2d6c72d3 100644 (file)
@@ -11,6 +11,5 @@
             <text>ref</text>
         </reference>
         <prefix value="ac" />
-        <revision-date date="1970-01-01" />
     </import>
 </module>
index 3e4996b81f40287c7817a7033d21c813b0a7fd24..d94492a47e680ba40e157749ea77b376a4633884 100644 (file)
@@ -14,7 +14,6 @@
         </description>
     </import>
     <include module="submodule">
-        <revision-date date="1970-01-01" />
         <reference>
             <text>include ref</text>
         </reference>
index 6f3cc009fd4942fffad1cbfbd6c5971409b741a4..076d2d0ef877f2f21efa10e758fd152c48df73b1 100644 (file)
@@ -40,11 +40,11 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 
 public abstract class AbstractSchemaContext implements SchemaContext {
     protected static final Comparator<Module> REVISION_COMPARATOR = (o1, o2) -> {
-        if (o2.getRevision() == null) {
-            return -1;
+        if (o1.getRevision() == null) {
+            return o2.getRevision() == null ? 0 : 1;
         }
 
-        return o2.getRevision().compareTo(o1.getRevision());
+        return o2.getRevision() == null ? -1 : o2.getRevision().compareTo(o1.getRevision());
     };
 
     protected static final TreeSet<Module> createModuleSet() {
index 8bdd17c80d80ffe2b10524a187524f9bc70a7c64..f4c6da4c787eedd0314c42336cb2e15c0acc9045 100644 (file)
@@ -7,8 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
-import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.DEFAULT_DATE_REV;
-
 import com.google.common.annotations.Beta;
 import com.google.common.collect.HashBasedTable;
 import com.google.common.collect.Lists;
@@ -21,6 +19,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.Optional;
 import org.opendaylight.yangtools.util.TopologicalSort;
 import org.opendaylight.yangtools.util.TopologicalSort.Node;
 import org.opendaylight.yangtools.util.TopologicalSort.NodeImpl;
@@ -76,12 +75,12 @@ public final class ModuleDependencySort {
     }
 
     private static List<Node> sortInternal(final Iterable<Module> modules) {
-        final Table<String, Date, ModuleNodeImpl> moduleGraph = createModuleGraph(modules);
+        final Table<String, Optional<Date>, ModuleNodeImpl> moduleGraph = createModuleGraph(modules);
         return TopologicalSort.sort(new HashSet<>(moduleGraph.values()));
     }
 
-    private static Table<String, Date, ModuleNodeImpl> createModuleGraph(final Iterable<Module> builders) {
-        final Table<String, Date, ModuleNodeImpl> moduleGraph = HashBasedTable.create();
+    private static Table<String, Optional<Date>, ModuleNodeImpl> createModuleGraph(final Iterable<Module> builders) {
+        final Table<String, Optional<Date>, ModuleNodeImpl> moduleGraph = HashBasedTable.create();
 
         processModules(moduleGraph, builders);
         processDependencies(moduleGraph, builders);
@@ -92,7 +91,7 @@ public final class ModuleDependencySort {
     /**
      * Extract module:revision from modules.
      */
-    private static void processDependencies(final Table<String, Date, ModuleNodeImpl> moduleGraph,
+    private static void processDependencies(final Table<String, Optional<Date>, ModuleNodeImpl> moduleGraph,
             final Iterable<Module> mmbs) {
         final Map<URI, Module> allNS = new HashMap<>();
 
@@ -101,7 +100,7 @@ public final class ModuleDependencySort {
             final Map<String, Date> imported = new HashMap<>();
             final String fromName = module.getName();
             final URI ns = module.getNamespace();
-            Date fromRevision = module.getRevision();
+            final Date fromRevision = module.getRevision();
 
             // check for existence of module with same namespace
             final Module prev = allNS.putIfAbsent(ns, module);
@@ -113,19 +112,12 @@ public final class ModuleDependencySort {
                 }
             }
 
-            // no need to check if other Type of object, check is performed in
-            // process modules
-
-            if (fromRevision == null) {
-                fromRevision = DEFAULT_DATE_REV;
-            }
-
+            // no need to check if other Type of object, check is performed in process modules
             for (final ModuleImport imprt : module.getImports()) {
                 final String toName = imprt.getModuleName();
-                final Date toRevision = imprt.getRevision() == null ? DEFAULT_DATE_REV : imprt.getRevision();
-
-                final ModuleNodeImpl from = moduleGraph.get(fromName, fromRevision);
+                final Date toRevision = imprt.getRevision();
 
+                final ModuleNodeImpl from = moduleGraph.get(fromName, Optional.ofNullable(fromRevision));
                 final ModuleNodeImpl to = getModuleByNameAndRevision(moduleGraph, fromName, fromRevision, toName,
                     toRevision);
 
@@ -135,8 +127,7 @@ public final class ModuleDependencySort {
                  */
                 if (module.getYangVersion() == YangVersion.VERSION_1) {
                     final Date impRevision = imported.get(toName);
-                    if (impRevision != null && !impRevision.equals(toRevision)
-                        && !DEFAULT_DATE_REV.equals(impRevision) && !DEFAULT_DATE_REV.equals(toRevision)) {
+                    if (impRevision != null && !impRevision.equals(toRevision) && toRevision != null) {
                         throw new IllegalArgumentException(String.format(
                             "Module:%s imported twice with different revisions:%s, %s", toName,
                             formatRevDate(impRevision), formatRevDate(toRevision)));
@@ -153,17 +144,18 @@ public final class ModuleDependencySort {
     /**
      * Get imported module by its name and revision from moduleGraph.
      */
-    private static ModuleNodeImpl getModuleByNameAndRevision(final Table<String, Date, ModuleNodeImpl> moduleGraph,
+    private static ModuleNodeImpl getModuleByNameAndRevision(
+            final Table<String, Optional<Date>, ModuleNodeImpl> moduleGraph,
             final String fromName, final Date fromRevision, final String toName, final Date toRevision) {
 
-        final ModuleNodeImpl exact = moduleGraph.get(toName, toRevision);
+        final ModuleNodeImpl exact = moduleGraph.get(toName, Optional.ofNullable(toRevision));
         if (exact != null) {
             return exact;
         }
 
         // If revision is not specified in import, but module exists with different revisions, take first one
-        if (DEFAULT_DATE_REV.equals(toRevision)) {
-            final Map<Date, ModuleNodeImpl> modulerevs = moduleGraph.row(toName);
+        if (toRevision == null) {
+            final Map<Optional<Date>, ModuleNodeImpl> modulerevs = moduleGraph.row(toName);
 
             if (!modulerevs.isEmpty()) {
                 final ModuleNodeImpl first = modulerevs.values().iterator().next();
@@ -186,30 +178,27 @@ public final class ModuleDependencySort {
     /**
      * Extract dependencies from modules to fill dependency graph.
      */
-    private static void processModules(final Table<String, Date, ModuleNodeImpl> moduleGraph,
+    private static void processModules(final Table<String, Optional<Date>, ModuleNodeImpl> moduleGraph,
             final Iterable<Module> modules) {
 
         // Process nodes
         for (final Module momb : modules) {
 
             final String name = momb.getName();
-            Date rev = momb.getRevision();
-            if (rev == null) {
-                rev = DEFAULT_DATE_REV;
-            }
+            final Optional<Date> rev = Optional.ofNullable(momb.getRevision());
 
-            final Map<Date, ModuleNodeImpl> revs = moduleGraph.row(name);
+            final Map<Optional<Date>, ModuleNodeImpl> revs = moduleGraph.row(name);
             if (revs.containsKey(rev)) {
                 throw new IllegalArgumentException(String.format("Module:%s with revision:%s declared twice", name,
-                    formatRevDate(rev)));
+                    formatRevDate(rev.orElse(null))));
             }
 
-            revs.put(rev, new ModuleNodeImpl(name, rev, momb));
+            revs.put(rev, new ModuleNodeImpl(name, rev.orElse(null), momb));
         }
     }
 
     private static String formatRevDate(final Date rev) {
-        return rev.equals(DEFAULT_DATE_REV) ? "default" : SimpleDateFormatUtil.getRevisionFormat().format(rev);
+        return rev == null ? "default" : SimpleDateFormatUtil.getRevisionFormat().format(rev);
     }
 
     private static final class ModuleNodeImpl extends NodeImpl {
index c650e6d729b8a608c52f58f491303b63ca6bd028..c19cfafdb1da18b5f659e1815346a8ff71dbd0ec 100644 (file)
@@ -14,7 +14,6 @@ import java.util.Date;
 import java.util.Optional;
 import org.opendaylight.yangtools.concepts.SemVer;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -115,12 +114,8 @@ public class ModuleStatementSupport extends
 
         stmt.addContext(PreLinkageModuleNamespace.class, moduleName, stmt);
 
-        Optional<Date> revisionDate = Optional.ofNullable(StmtContextUtils.getLatestRevision(
+        final Optional<Date> revisionDate = Optional.ofNullable(StmtContextUtils.getLatestRevision(
             stmt.declaredSubstatements()));
-        if (!revisionDate.isPresent()) {
-            revisionDate = Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_REV);
-        }
-
         final QNameModule qNameModule = QNameModule.create(moduleNs, revisionDate.orElse(null)).intern();
 
         stmt.addToNs(ModuleCtxToModuleQName.class, stmt, qNameModule);
@@ -136,12 +131,8 @@ public class ModuleStatementSupport extends
         SourceException.throwIf(!moduleNs.isPresent(), stmt.getStatementSourceReference(),
             "Namespace of the module [%s] is missing", stmt.getStatementArgument());
 
-        Optional<Date> revisionDate = Optional.ofNullable(StmtContextUtils.getLatestRevision(
+        final Optional<Date> revisionDate = Optional.ofNullable(StmtContextUtils.getLatestRevision(
             stmt.declaredSubstatements()));
-        if (!revisionDate.isPresent()) {
-            revisionDate = Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_REV);
-        }
-
         final QNameModule qNameModule = QNameModule.create(moduleNs.get(), revisionDate.orElse(null)).intern();
         final StmtContext<?, ModuleStatement, EffectiveStatement<String, ModuleStatement>> possibleDuplicateModule =
                 stmt.getFromNamespace(NamespaceToModule.class, qNameModule);
index 4ea6a4d35da58f7417e1cd71cf0df39637a74b58..73ee7dcd338a11ac47957af2a68b061d63181329 100644 (file)
@@ -13,7 +13,6 @@ import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.f
 import java.util.Date;
 import java.util.Optional;
 import javax.annotation.Nonnull;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -61,7 +60,6 @@ public class SubmoduleStatementImpl extends AbstractRootStatement<SubmoduleState
             .addAny(YangStmtMapping.USES)
             .addOptional(YangStmtMapping.YANG_VERSION)
             .build();
-    private static final Optional<Date> DEFAULT_REVISION = Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_REV);
 
     protected SubmoduleStatementImpl(final StmtContext<String, SubmoduleStatement, ?> context) {
         super(context);
@@ -125,10 +123,9 @@ public class SubmoduleStatementImpl extends AbstractRootStatement<SubmoduleState
         private static ModuleIdentifier getSubmoduleIdentifier(
                 final Mutable<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> stmt) {
             final Date maybeDate = StmtContextUtils.getLatestRevision(stmt.declaredSubstatements());
-            final Optional<Date> revisionDate = maybeDate != null ? Optional.of(maybeDate) : DEFAULT_REVISION;
 
             final ModuleIdentifier submoduleIdentifier = ModuleIdentifierImpl.create(stmt.getStatementArgument(),
-                    revisionDate);
+                    Optional.ofNullable(maybeDate));
             return submoduleIdentifier;
         }
 
index c7f7d143d81134831b12a11a258990fbe378bc60..57f4640b1de11dcd159730e12c6c0a82442489d2 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
 
+import com.google.common.base.Verify;
 import java.util.Objects;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
@@ -22,12 +22,7 @@ public final class ModuleEffectiveStatementImpl extends AbstractEffectiveModule<
             final StmtContext<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> ctx) {
         super(ctx);
 
-        final QNameModule module = ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx);
-        if (module.getRevision() == null) {
-            qnameModule = QNameModule.create(module.getNamespace(), SimpleDateFormatUtil.DEFAULT_DATE_REV).intern();
-        } else {
-            qnameModule = module;
-        }
+        qnameModule = Verify.verifyNotNull(ctx.getFromNamespace(ModuleCtxToModuleQName.class, ctx));
     }
 
     @Override
index 848f02bc22abbe754d4fe2d7f7d14e19cc8bee97..099c89adb51e9f4b6ce20929d2afd3c58352d04e 100644 (file)
@@ -11,7 +11,6 @@ import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.f
 
 import java.util.Objects;
 import org.opendaylight.yangtools.yang.common.QNameModule;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
@@ -30,10 +29,8 @@ public final class SubmoduleEffectiveStatementImpl extends AbstractEffectiveModu
         final QNameModule belongsToModuleQName = ctx.getFromNamespace(ModuleNameToModuleQName.class,
                 belongsToModuleName);
         final RevisionEffectiveStatementImpl submoduleRevision = firstEffective(RevisionEffectiveStatementImpl.class);
-        this.qnameModule = (submoduleRevision == null
-                ? QNameModule.create(belongsToModuleQName.getNamespace(), SimpleDateFormatUtil.DEFAULT_DATE_REV)
-                        : QNameModule.create(belongsToModuleQName.getNamespace(), submoduleRevision.argument()))
-                .intern();
+        this.qnameModule = QNameModule.create(belongsToModuleQName.getNamespace(),
+            submoduleRevision == null ? null : submoduleRevision.argument()).intern();
     }
 
     @Override
index 0a1ad9b1b868774e1059ccb027bae297a97510b6..97da30ddc30acafefe1f7b2d9dfebe58cfb97f69 100644 (file)
@@ -35,7 +35,6 @@ public class MultipleRevImportBug6875Test {
     private static final String BAR_REV_2 = "1999-01-01";
     private static final String BAR_REV_3 = "1970-01-01";
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void testYang11() throws Exception {
@@ -132,7 +131,7 @@ public class MultipleRevImportBug6875Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, FOO_REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 
     private static QName bar1(final String localName) {
index 0312047ff8f1abe3558a0bb52a77f1c599073fef..c4ee5d771eaa644fd4d187f7b7519742c5200b2d 100644 (file)
@@ -33,7 +33,7 @@ public class SharedSchemaRepositoryWithFeaturesTest {
 
     @Test
     public void testSharedSchemaRepositoryWithSomeFeaturesSupported() throws Exception {
-        final Set<QName> supportedFeatures = ImmutableSet.of(QName.create("foobar-namespace", "1970-01-01", "test-feature-1"));
+        final Set<QName> supportedFeatures = ImmutableSet.of(QName.create("foobar-namespace", "test-feature-1"));
 
         final SharedSchemaRepository sharedSchemaRepository = new SharedSchemaRepository(
                 "shared-schema-repo-with-features-test");
index 26dae2b255d352c98076649b630ee56ffea6d64c..d81fa6a63732c0d7ee2da5aa46b469f38f86c916 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug5410Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void testJavaRegexFromXSD() {
@@ -226,7 +225,7 @@ public class Bug5410Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, FOO_REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 
     @SuppressWarnings("checkstyle:regexpSinglelineJava")
index 4b9569728290e0d3261406ab9a402292b8719fbd..a10faff04bae3c01132cf9b93edbcdf45858be3e 100644 (file)
@@ -30,7 +30,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6868Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
     private static final String IMP_NS = "imp";
     private static final String IMP_REV = "2017-01-09";
     private static final Set<String> ALL_CONTAINERS = ImmutableSet.of("my-container-1", "my-container-2",
@@ -76,7 +75,7 @@ public class Bug6868Test {
         final Set<QName> supportedFeatures = new HashSet<>();
         for (final String featureName : featureNames) {
             if (featureName.indexOf(':') == -1) {
-                supportedFeatures.add(QName.create(FOO_NS, FOO_REV, featureName));
+                supportedFeatures.add(QName.create(FOO_NS, featureName));
             } else {
                 supportedFeatures
                         .add(QName.create(IMP_NS, IMP_REV, featureName.substring(featureName.indexOf(':') + 1)));
@@ -88,7 +87,7 @@ public class Bug6868Test {
 
     private static SchemaNode findNode(final SchemaContext context, final String localName) {
         return SchemaContextUtil.findDataSchemaNode(context,
-                SchemaPath.create(true, QName.create(FOO_NS, FOO_REV, localName)));
+                SchemaPath.create(true, QName.create(FOO_NS, localName)));
     }
 
     @Test
index da54f7aa6c489b88f65151e28c9b07eac1d8a304..edf4b86aac11b034ea134ff1e4d4e501d458c981 100644 (file)
@@ -33,7 +33,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6869Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void identityNoFeaureTest() throws Exception {
@@ -75,7 +74,7 @@ public class Bug6869Test {
     private static Set<QName> createFeaturesSet(final String... featureNames) {
         final Set<QName> supportedFeatures = new HashSet<>();
         for (final String featureName : featureNames) {
-            supportedFeatures.add(QName.create(FOO_NS, FOO_REV, featureName));
+            supportedFeatures.add(QName.create(FOO_NS, featureName));
         }
 
         return ImmutableSet.copyOf(supportedFeatures);
@@ -83,7 +82,7 @@ public class Bug6869Test {
 
     private static SchemaNode findNode(final SchemaContext context, final Iterable<String> localNamesPath) {
         final Iterable<QName> qNames = Iterables.transform(localNamesPath,
-            localName -> QName.create(FOO_NS, FOO_REV, localName));
+            localName -> QName.create(FOO_NS, localName));
         return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true));
     }
 
index 1b7efb0abfbc430c22b021c91a9c1f294bdab735..0cd20ee37d88b19bfe009de6f7d36adb838284a8 100644 (file)
@@ -32,7 +32,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6870Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void valid11Test() throws Exception {
@@ -62,7 +61,7 @@ public class Bug6870Test {
 
     private static SchemaNode findNode(final SchemaContext context, final Iterable<String> localNamesPath) {
         final Iterable<QName> qNames = Iterables.transform(localNamesPath,
-            localName -> QName.create(FOO_NS, FOO_REV, localName));
+            localName -> QName.create(FOO_NS, localName));
         return SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(qNames, true));
     }
 
index 6717159a6f500d397167bb32534019f0b1fbf31a..b74618d875d52ec2d11e7917a9e3c34ab047d7e3 100644 (file)
@@ -25,7 +25,6 @@ public class Bug6876Test {
     private static final String BAR_NS = "bar";
     private static final String BAR_REV = "2017-01-11";
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void yang11Test() throws Exception {
@@ -53,7 +52,7 @@ public class Bug6876Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, FOO_REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 
     private static QName bar(final String localName) {
index 12897ae68a78f925fd293038c7fbef419add38dd..05ac83409e49a70bae59e89eb1657836955102d8 100644 (file)
@@ -26,7 +26,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6880Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void valid10Test() throws Exception {
@@ -34,7 +33,7 @@ public class Bug6880Test {
         assertNotNull(schemaContext);
 
         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(schemaContext,
-                SchemaPath.create(true, QName.create(FOO_NS, FOO_REV, "my-leaf-list")));
+                SchemaPath.create(true, QName.create(FOO_NS, "my-leaf-list")));
         assertTrue(findDataSchemaNode instanceof LeafListSchemaNode);
         final LeafListSchemaNode myLeafList = (LeafListSchemaNode) findDataSchemaNode;
 
index e7923e80303a0d861c7dd0e0cbb1de95630ac425..00a51c738e6efb87c2ce286b01a8ca8c869a4367 100644 (file)
@@ -26,7 +26,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6883Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
@@ -53,7 +52,7 @@ public class Bug6883Test {
 
     private static AnyDataSchemaNode assertAnyData(final SchemaContext context, final Iterable<String> localNamesPath) {
         final Iterable<QName> qNames = Iterables.transform(localNamesPath,
-            localName -> QName.create(FOO_NS, FOO_REV, localName));
+            localName -> QName.create(FOO_NS, localName));
         final SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context,
                 SchemaPath.create(qNames, true));
         assertTrue(findDataSchemaNode instanceof AnyDataSchemaNode);
index 360b6ad0a6ca966f4f1a11cc6dbb1f7c2d895756..ce98c6d24ba75c79880938b3355126f7aa95dcac 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6884Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void testYang11() throws Exception {
@@ -49,6 +48,6 @@ public class Bug6884Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, FOO_REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 }
index c88851b334479b1a09897a7fb207d465ef836f4e..e1efac262a3e4fa24277a6293e7b3feebd8c5966 100644 (file)
@@ -28,7 +28,6 @@ import org.opendaylight.yangtools.yang.stmt.StmtTestUtils;
 
 public class Bug6897Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void notificationsInDataContainersTest() throws Exception {
@@ -54,8 +53,8 @@ public class Bug6897Test {
 
     private static void assertContainsNotifications(final SchemaContext schemaContext, final String dataContainerName,
             final String... notificationNames) {
-        final DataSchemaNode dataChildByName = schemaContext.getDataChildByName(QName.create(FOO_NS, FOO_REV,
-                dataContainerName));
+        final DataSchemaNode dataChildByName = schemaContext.getDataChildByName(
+            QName.create(FOO_NS, dataContainerName));
         assertTrue(dataChildByName instanceof NotificationNodeContainer);
         assertContainsNotifications((NotificationNodeContainer) dataChildByName, notificationNames);
     }
@@ -69,7 +68,7 @@ public class Bug6897Test {
         notifications.forEach(n -> notificationQNames.add(n.getQName()));
 
         for (final String notificationName : notificationNames) {
-            assertTrue(notificationQNames.contains(QName.create(FOO_NS, FOO_REV, notificationName)));
+            assertTrue(notificationQNames.contains(QName.create(FOO_NS, notificationName)));
         }
     }
 
@@ -90,8 +89,7 @@ public class Bug6897Test {
             fail("Test should fail due to invalid Yang 1.1");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                "Notification (foo?revision=1970-01-01)grp-notification is defined within an rpc, action, or another "
-                        + "notification"));
+                "Notification (foo)grp-notification is defined within an rpc, action, or another notification"));
         }
     }
 
index 80bd9d640947f6e990608957dd3410a40cc4653c..33ad7dbd0e032eba99017b91c8ece78965cc9457 100644 (file)
@@ -32,8 +32,7 @@ public class Bug6901Test {
             fail("Test should fail due to invalid Yang 1.1");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                    "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature "
-                            + "statement."));
+                    "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."));
         }
     }
 
@@ -44,8 +43,7 @@ public class Bug6901Test {
             fail("Test should fail due to invalid Yang 1.1");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                    "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature "
-                            + "statement."));
+                    "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."));
         }
     }
 
@@ -56,8 +54,7 @@ public class Bug6901Test {
             fail("Test should fail due to invalid Yang 1.1");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                    "Leaf '(foo?revision=1970-01-01)enum-leaf' has default value 'two' marked with an if-feature "
-                            + "statement."));
+                    "Leaf '(foo)enum-leaf' has default value 'two' marked with an if-feature statement."));
         }
     }
 
@@ -68,8 +65,7 @@ public class Bug6901Test {
             fail("Test should fail due to invalid Yang 1.1");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                    "Typedef '(foo?revision=1970-01-01)bits-typedef-2' has default value 'two' marked with an "
-                            + "if-feature statement."));
+                    "Typedef '(foo)bits-typedef-2' has default value 'two' marked with an if-feature statement."));
         }
     }
 
@@ -80,8 +76,7 @@ public class Bug6901Test {
             fail("Test should fail due to invalid Yang 1.1");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                    "Leaf '(foo?revision=1970-01-01)union-leaf' has default value 'two' marked with an if-feature "
-                            + "statement."));
+                    "Leaf '(foo)union-leaf' has default value 'two' marked with an if-feature statement."));
         }
     }
 
index 47d19c99742f072098d46ce268a8f80f7bb2f352..4d3f4d79b35969756b79012735e58d6bb97c29f0 100644 (file)
@@ -19,7 +19,6 @@ import java.net.URI;
 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.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.ChoiceSchemaNode;
@@ -30,7 +29,6 @@ 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.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
@@ -40,10 +38,8 @@ public class AugmentProcessTest {
     private static final StatementStreamSource AUGMENTED = sourceForResource("/stmt-test/augments/augmented.yang");
     private static final StatementStreamSource ROOT = sourceForResource("/stmt-test/augments/aug-root.yang");
 
-    private static final QNameModule ROOT_QNAME_MODULE = QNameModule.create(
-            URI.create("root"), SimpleDateFormatUtil.DEFAULT_DATE_REV);
-    private static final QNameModule AUGMENTED_QNAME_MODULE = QNameModule
-            .create(URI.create("aug"), SimpleDateFormatUtil.DEFAULT_DATE_REV);
+    private static final QNameModule ROOT_QNAME_MODULE = QNameModule.create(URI.create("root"), null);
+    private static final QNameModule AUGMENTED_QNAME_MODULE = QNameModule.create(URI.create("aug"), null);
 
     private final QName augParent1 = QName.create(AUGMENTED_QNAME_MODULE,
             "aug-parent1");
@@ -90,7 +86,7 @@ public class AugmentProcessTest {
             "/stmt-test/augments/multiple-augment-incorrect2.yang");
 
     @Test
-    public void multipleAugmentsAndMultipleModulesTest() throws SourceException, ReactorException {
+    public void multipleAugmentsAndMultipleModulesTest() throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
                 .newBuild();
         addSources(reactor, MULTIPLE_AUGMENT_ROOT, MULTIPLE_AUGMENT_IMPORTED,
@@ -101,7 +97,7 @@ public class AugmentProcessTest {
     }
 
     @Test
-    public void multipleAugmentTest() throws SourceException, ReactorException {
+    public void multipleAugmentTest() throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
                 .newBuild();
         addSources(reactor, MULTIPLE_AUGMENT);
@@ -111,7 +107,7 @@ public class AugmentProcessTest {
     }
 
     @Test(expected = SomeModifiersUnresolvedException.class)
-    public void multipleAugmentIncorrectPathTest() throws SourceException, ReactorException {
+    public void multipleAugmentIncorrectPathTest() throws  ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
                 .newBuild();
         addSources(reactor, MULTIPLE_AUGMENT_INCORRECT);
@@ -121,7 +117,7 @@ public class AugmentProcessTest {
     }
 
     @Test(expected = SomeModifiersUnresolvedException.class)
-    public void multipleAugmentIncorrectPathAndGrpTest() throws SourceException, ReactorException {
+    public void multipleAugmentIncorrectPathAndGrpTest() throws  ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
                 .newBuild();
         addSources(reactor, MULTIPLE_AUGMENT_INCORRECT2);
@@ -130,7 +126,7 @@ public class AugmentProcessTest {
     }
 
     @Test
-    public void readAndParseYangFileTest() throws SourceException, ReactorException {
+    public void readAndParseYangFileTest() throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
                 .newBuild();
         addSources(reactor, AUGMENTED, ROOT);
index 26b7aa356151075fa0713c02b754c968135cb2a0..94c480952ce7a88c2376043704a9c34b762bd0bf 100644 (file)
@@ -11,7 +11,6 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
-import java.util.Date;
 import java.util.List;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -33,16 +32,17 @@ public class Bug3874ExtensionTest {
     public void test() throws Exception {
             SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug3874");
 
-            Date revision = QName.parseRevision("1970-01-01");
-            QNameModule foo = QNameModule.create(new URI("foo"), revision);
+            QNameModule foo = QNameModule.create(new URI("foo"), null);
             QName myContainer2QName = QName.create(foo, "my-container-2");
             QName myAnyXmlDataQName = QName.create(foo, "my-anyxml-data");
 
             DataSchemaNode dataChildByName = context.getDataChildByName(myAnyXmlDataQName);
             assertTrue(dataChildByName instanceof YangModeledAnyXmlEffectiveStatementImpl);
-            YangModeledAnyXmlEffectiveStatementImpl yangModeledAnyXml = (YangModeledAnyXmlEffectiveStatementImpl) dataChildByName;
+            YangModeledAnyXmlEffectiveStatementImpl yangModeledAnyXml =
+                    (YangModeledAnyXmlEffectiveStatementImpl) dataChildByName;
 
-            SchemaNode myContainer2 = SchemaContextUtil.findDataSchemaNode(context, SchemaPath.create(true, myContainer2QName));
+            SchemaNode myContainer2 = SchemaContextUtil.findDataSchemaNode(context,
+                SchemaPath.create(true, myContainer2QName));
             assertTrue(myContainer2 instanceof ContainerSchemaNode);
             assertEquals(myContainer2, yangModeledAnyXml.getSchemaOfAnyXmlData());
 
@@ -51,8 +51,11 @@ public class Bug3874ExtensionTest {
 
             UnknownSchemaNode next = unknownSchemaNodes.iterator().next();
             assertTrue(next instanceof AnyxmlSchemaLocationEffectiveStatementImpl);
-            AnyxmlSchemaLocationEffectiveStatementImpl anyxmlSchemaLocationUnknownNode= (AnyxmlSchemaLocationEffectiveStatementImpl) next;
-            assertEquals(SupportedExtensionsMapping.ANYXML_SCHEMA_LOCATION.getStatementName(), anyxmlSchemaLocationUnknownNode.getNodeType());
-            assertEquals(SupportedExtensionsMapping.ANYXML_SCHEMA_LOCATION.getStatementName(), anyxmlSchemaLocationUnknownNode.getQName());
+            AnyxmlSchemaLocationEffectiveStatementImpl anyxmlSchemaLocationUnknownNode =
+                    (AnyxmlSchemaLocationEffectiveStatementImpl) next;
+            assertEquals(SupportedExtensionsMapping.ANYXML_SCHEMA_LOCATION.getStatementName(),
+                anyxmlSchemaLocationUnknownNode.getNodeType());
+            assertEquals(SupportedExtensionsMapping.ANYXML_SCHEMA_LOCATION.getStatementName(),
+                anyxmlSchemaLocationUnknownNode.getQName());
     }
 }
index 389f9b2fdff572d0c876bfeb965d6f98ef20e989..5543b3f25177ce7f0a4451b57d8120f8c469ebb2 100644 (file)
@@ -26,7 +26,7 @@ public class Bug4410Test {
             Throwable rootCause = Throwables.getRootCause(e);
             assertTrue(rootCause instanceof InferenceException);
             final String message = rootCause.getMessage();
-            assertTrue(message.startsWith("Type [(foo?revision=1970-01-01)"));
+            assertTrue(message.startsWith("Type [(foo)"));
             assertTrue(message.contains("was not found"));
         }
     }
index 1c6452f960168e0ac24b69bde8549d3acba90fbb..638e0cc55f5dacbe0b2874d7817ff1699446cccc 100644 (file)
@@ -8,8 +8,6 @@
 
 package org.opendaylight.yangtools.yang.stmt;
 
-import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.DEFAULT_DATE_REV;
-
 import com.google.common.collect.Range;
 import java.io.File;
 import java.net.URI;
@@ -38,7 +36,7 @@ public class Bug4623Test {
         final SchemaContext schemaContext = TestUtils.parseYangSources(extdef, stringWithExt);
 
         final LeafSchemaNode leaf = (LeafSchemaNode) typesModule(schemaContext).getDataChildByName(
-            QName.create(URI.create("urn:custom.types.demo"), DEFAULT_DATE_REV, "leaf-length-pattern-unknown"));
+            QName.create(URI.create("urn:custom.types.demo"), null, "leaf-length-pattern-unknown"));
 
         // then
         Assert.assertNotNull(leaf);
@@ -80,7 +78,7 @@ public class Bug4623Test {
         final SchemaContext schemaContext = TestUtils.parseYangSources(extdef, stringWithExt);
 
         final LeafSchemaNode leaf = (LeafSchemaNode) typesModule(schemaContext).getDataChildByName(
-                QName.create(URI.create("urn:custom.types.demo"), DEFAULT_DATE_REV, "leaf-length-unknown-pattern"));
+                QName.create(URI.create("urn:custom.types.demo"), null, "leaf-length-unknown-pattern"));
 
         // then
         Assert.assertNotNull(leaf);
@@ -122,7 +120,7 @@ public class Bug4623Test {
         final SchemaContext schemaContext = TestUtils.parseYangSources(extdef, stringWithExt);
 
         final LeafSchemaNode leaf = (LeafSchemaNode) typesModule(schemaContext).getDataChildByName(
-                QName.create(URI.create("urn:custom.types.demo"), DEFAULT_DATE_REV, "leaf-unknown-length-pattern"));
+                QName.create(URI.create("urn:custom.types.demo"), null, "leaf-unknown-length-pattern"));
 
         // then
         Assert.assertNotNull(leaf);
index 816aa58bb859713c7be1160aafc8ebaee24e2b85..e0d0f4cabdefc35117f07d6f84ec86be3e90a7ed 100644 (file)
@@ -32,8 +32,8 @@ public class Bug5396Test {
         SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5396");
         assertNotNull(context);
 
-        QName root = QName.create("foo", "1970-01-01", "root");
-        QName myLeaf2 = QName.create("foo", "1970-01-01", "my-leaf2");
+        QName root = QName.create("foo", "root");
+        QName myLeaf2 = QName.create("foo", "my-leaf2");
 
         SchemaPath schemaPath = SchemaPath.create(true, root, myLeaf2);
         SchemaNode findDataSchemaNode = SchemaContextUtil.findDataSchemaNode(context, schemaPath);
index 0b63b0669bcb4a045ae79471a860ac90fdd48f80..331fd8fa6af4d4af8d38e33a41c38b3b72af5da0 100644 (file)
@@ -25,7 +25,7 @@ public class Bug5518Test {
         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug5518");
         assertNotNull(context);
 
-        final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "1970-01-01", "root"));
+        final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "root"));
         assertTrue(dataChildByName instanceof ContainerSchemaNode);
         final ContainerSchemaNode root = (ContainerSchemaNode) dataChildByName;
         final Set<MustDefinition> mustConstraints = root.getConstraints().getMustConstraints();
index c1b0c31bc65fd9c28cc1aac2d3d308d0a65a459c..9bf6bc26846ee14fcc0ec8a175ecc7c7417b8eb4 100644 (file)
@@ -24,7 +24,6 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class Bug6183Test {
     private static final String FOO_NS = "foo";
-    private static final String FOO_REV = "1970-01-01";
 
     @Test
     public void testYang10() throws Exception {
@@ -85,10 +84,12 @@ public class Bug6183Test {
 
         assertEquals(2, secondImplCaseContainer.getChildNodes().size());
         assertTrue(getLeafSchemaNode(secondImplCaseContainer, "leaf-inside-second-container").isAugmenting());
-        assertFalse(getLeafSchemaNode(secondImplCaseContainer, "declared-leaf-in-second-case-container").isAugmenting());
+        assertFalse(getLeafSchemaNode(secondImplCaseContainer, "declared-leaf-in-second-case-container")
+            .isAugmenting());
     }
 
-    private static ContainerSchemaNode getContainerSchemaNode(final DataNodeContainer parent, final String containerName) {
+    private static ContainerSchemaNode getContainerSchemaNode(final DataNodeContainer parent,
+            final String containerName) {
         final DataSchemaNode dataChildByName = parent.getDataChildByName(foo(containerName));
         assertTrue(dataChildByName instanceof ContainerSchemaNode);
         return (ContainerSchemaNode) dataChildByName;
@@ -101,6 +102,6 @@ public class Bug6183Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, FOO_REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 }
index a4a5dac031d0d2e5787519033eeaee2bd682dd45..28372cb604a9e801b216fd85bbfa9e2e916ae5f5 100644 (file)
@@ -34,8 +34,7 @@ public class Bug6316Test {
     }
 
     private static void verifyEnumTypedefinition(final SchemaContext context) {
-        final DataSchemaNode dataChildByName = context.getDataChildByName(QName
-                .create("foo", "1970-01-01", "enum-leaf"));
+        final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "enum-leaf"));
         assertTrue(dataChildByName instanceof LeafSchemaNode);
         final LeafSchemaNode enumLeaf = (LeafSchemaNode) dataChildByName;
         final TypeDefinition<? extends TypeDefinition<?>> type = enumLeaf.getType();
@@ -67,8 +66,7 @@ public class Bug6316Test {
     }
 
     private static void verifyBitsTypedefinition(final SchemaContext context) {
-        final DataSchemaNode dataChildByName = context.getDataChildByName(QName
-                .create("foo", "1970-01-01", "bits-leaf"));
+        final DataSchemaNode dataChildByName = context.getDataChildByName(QName.create("foo", "bits-leaf"));
         assertTrue(dataChildByName instanceof LeafSchemaNode);
         final LeafSchemaNode bitsLeaf = (LeafSchemaNode) dataChildByName;
         final TypeDefinition<? extends TypeDefinition<?>> type = bitsLeaf.getType();
index 665dfa8da844d049961ac8680366ed60d902b0d7..a8575b197cfe3bb2d2a94485ea4b32cc755784a8 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.stmt;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.DEFAULT_DATE_REV;
 import static org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil.getRevisionFormat;
 
 import java.text.ParseException;
@@ -31,10 +30,10 @@ public class Bug6491Test {
 
     @Test
     public void tetststs() throws Exception {
-        testRevision("withoutRevision", DEFAULT_DATE_REV, DEFAULT_DATE_REV);
+        testRevision("withoutRevision", null, null);
         testRevision("withRevision", date, date);
-        testRevision("importedModuleRevisionOnly", DEFAULT_DATE_REV, date);
-        testRevision("moduleRevisionOnly", date, DEFAULT_DATE_REV);
+        testRevision("importedModuleRevisionOnly", null, date);
+        testRevision("moduleRevisionOnly", date, null);
     }
 
     private static void testRevision(final String path, final Date moduleRevision, final Date importedRevision)
index 411383f101e1b00f129e5ebedea4766f377587b2..af931ca43ea63f9b4b02809ea1ac64c6aff73570 100644 (file)
@@ -21,11 +21,10 @@ import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 
 public class Bug6771Test {
     private static final String NS = "http://www.example.com/typedef-bug";
-    private static final String REV = "1970-01-01";
-    private static final QName ROOT = QName.create(NS, REV, "root");
-    private static final QName CONT_B = QName.create(NS, REV, "container-b");
-    private static final QName LEAF_CONT_B = QName.create(NS, REV, "leaf-container-b");
-    private static final QName INNER_CONTAINER = QName.create(NS, REV, "inner-container");
+    private static final QName ROOT = QName.create(NS, "root");
+    private static final QName CONT_B = QName.create(NS, "container-b");
+    private static final QName LEAF_CONT_B = QName.create(NS, "leaf-container-b");
+    private static final QName INNER_CONTAINER = QName.create(NS, "inner-container");
 
     @Test
     public void augmentTest() throws Exception {
@@ -43,13 +42,13 @@ public class Bug6771Test {
         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug6771/choice-case");
         assertNotNull(context);
 
-        final QName myChoice = QName.create(NS, REV, "my-choice");
-        final QName caseOne = QName.create(NS, REV, "one");
-        final QName caseTwo = QName.create(NS, REV, "two");
-        final QName caseThree = QName.create(NS, REV, "three");
-        final QName containerOne = QName.create(NS, REV, "container-one");
-        final QName containerTwo = QName.create(NS, REV, "container-two");
-        final QName containerThree = QName.create(NS, REV, "container-three");
+        final QName myChoice = QName.create(NS, "my-choice");
+        final QName caseOne = QName.create(NS, "one");
+        final QName caseTwo = QName.create(NS, "two");
+        final QName caseThree = QName.create(NS, "three");
+        final QName containerOne = QName.create(NS, "container-one");
+        final QName containerTwo = QName.create(NS, "container-two");
+        final QName containerThree = QName.create(NS, "container-three");
 
         verifyLeafType(SchemaContextUtil.findDataSchemaNode(context,
                 SchemaPath.create(true, ROOT, myChoice, caseOne, containerOne, LEAF_CONT_B)));
index c10a1559f3db83f0785f815ccc6e003f4d104770..1275578342738375762edec5c753908facd67021 100644 (file)
@@ -26,7 +26,6 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 public class Bug7037Test {
     private static final String FOO_NS = "foo";
     private static final String BAR_NS = "bar";
-    private static final String REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
@@ -79,10 +78,10 @@ public class Bug7037Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 
     private static QName bar(final String localName) {
-        return QName.create(BAR_NS, REV, localName);
+        return QName.create(BAR_NS, localName);
     }
 }
index 6aef3cbc311d50b96cd90c4bcd68bc4f98346655..7dbc82c697b9ceb6d3db52dce776f3f7b2149273 100644 (file)
@@ -21,8 +21,7 @@ public class Bug7424Test {
             fail("Test should fail due to invalid yang model.");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                        "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
-                        + "Node name collision: '(foo?revision=1970-01-01)name' already declared"));
+                "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
         }
     }
 
@@ -33,8 +32,7 @@ public class Bug7424Test {
             fail("Test should fail due to invalid yang model.");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                        "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
-                        + "Node name collision: '(foo?revision=1970-01-01)name' already declared"));
+                "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
         }
     }
 
@@ -45,8 +43,7 @@ public class Bug7424Test {
             fail("Test should fail due to invalid yang model.");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                        "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
-                        + "Node name collision: '(foo?revision=1970-01-01)name' already declared"));
+                "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
         }
     }
 
@@ -57,8 +54,7 @@ public class Bug7424Test {
             fail("Test should fail due to invalid yang model.");
         } catch (final SomeModifiersUnresolvedException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                        "Error in module 'foo': cannot add '(foo?revision=1970-01-01)name'. "
-                        + "Node name collision: '(foo?revision=1970-01-01)name' already declared"));
+                "Error in module 'foo': cannot add '(foo)name'. Node name collision: '(foo)name' already declared"));
         }
     }
 }
index 90a26b3b4acb1a6ca9b5b6fc06f407e0193d9da5..8298bb79858d6772a27e78de50b9ebb0057e4d21 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 
 public class Bug7865Test {
     private static final String NS = "foo";
-    private static final String REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
@@ -48,7 +47,7 @@ public class Bug7865Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(NS, REV, localName);
+        return QName.create(NS, localName);
     }
 
 }
index 0aca667c22b8ee4a48052a6a9855934b4391c0cd..20e7a6db385fd5a3cf056ceaa3145f029cf7e25a 100644 (file)
@@ -23,14 +23,14 @@ import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 
 public class Bug7879Test {
     private static final String NS = "my-model-ns";
-    private static final String REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
         final SchemaContext context = TestUtils.parseYangSources("/bugs/bug7879");
         assertNotNull(context);
 
-        assertTrue(findNode(context, ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-container"))) instanceof ContainerSchemaNode);
+        assertTrue(findNode(context, ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-container")))
+            instanceof ContainerSchemaNode);
         final SchemaNode myEventValueLeaf = findNode(context,
                 ImmutableList.of(qN("my-alarm"), qN("my-content"), qN("my-event-value")));
         assertTrue(myEventValueLeaf instanceof LeafSchemaNode);
@@ -42,6 +42,6 @@ public class Bug7879Test {
     }
 
     private static QName qN(final String localName) {
-        return QName.create(NS, REV, localName);
+        return QName.create(NS, localName);
     }
 }
index 1148994dcc703ee72701a682367243eb9176f6e8..9149dfbcc20499a6b7103c532be75ed726e43a64 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 public class Bug8126Test {
     private static final String FOO_NS = "foo";
     private static final String BAR_NS = "bar";
-    private static final String REV = "1970-01-01";
 
     @Test
     public void test() throws Exception {
@@ -31,10 +30,12 @@ public class Bug8126Test {
         assertNotNull(context);
         assertTrue(findNode(context, ImmutableList.of(foo("root"), bar("my-container"), bar("my-choice"), bar("one"),
                 bar("one"), bar("mandatory-leaf"))) instanceof LeafSchemaNode);
-        assertTrue(findNode(context, ImmutableList.of(foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2"))) instanceof LeafSchemaNode);
+        assertTrue(findNode(context, ImmutableList.of(foo("root"), bar("my-list"), bar("two"), bar("mandatory-leaf-2")))
+            instanceof LeafSchemaNode);
 
         assertNull(findNode(context, ImmutableList.of(foo("root"), bar("mandatory-list"))));
-        assertNull(findNode(context, ImmutableList.of(foo("root"), bar("mandatory-container"), bar("mandatory-choice"))));
+        assertNull(findNode(context, ImmutableList.of(foo("root"), bar("mandatory-container"),
+            bar("mandatory-choice"))));
         assertNull(findNode(context,
                 ImmutableList.of(foo("root"), bar("mandatory-container-2"), bar("one"), bar("mandatory-leaf-3"))));
     }
@@ -44,10 +45,10 @@ public class Bug8126Test {
     }
 
     private static QName foo(final String localName) {
-        return QName.create(FOO_NS, REV, localName);
+        return QName.create(FOO_NS, localName);
     }
 
     private static QName bar(final String localName) {
-        return QName.create(BAR_NS, REV, localName);
+        return QName.create(BAR_NS, localName);
     }
 }
index 9f512b41ee56dd693298a5d9a31b098e7b6c1ade..46d3ffc67a22b3a9aa09e3ad3eea17923e1568ed 100644 (file)
@@ -14,7 +14,6 @@ import static org.junit.Assert.fail;
 import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -25,7 +24,7 @@ public class Bug8597Test {
         final SchemaContext context = StmtTestUtils.parseYangSources("/bugs/bug8597");
         assertNotNull(context);
 
-        final Module foo = context.findModule("foo", SimpleDateFormatUtil.DEFAULT_DATE_REV).get();
+        final Module foo = context.findModule("foo", null).get();
         final Set<ModuleImport> imports = foo.getImports();
 
         for (final ModuleImport moduleImport : imports) {
index adf893c565b0dd387af5301fee91fdac93628afe..af6afaa511d74d896d49e2ff9a2f4579a306b3fd 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 
 public class Bug8922Test {
     private static final String NS = "foo";
-    private static final String REV = "1970-01-01";
 
     @Test
     public void testAllFeaturesSupported() throws Exception {
@@ -48,6 +47,6 @@ public class Bug8922Test {
     }
 
     private static QName qN(final String localName) {
-        return QName.create(NS, REV, localName);
+        return QName.create(NS, localName);
     }
 }
index f7b343daf8271b74e790b394fb631c049a4d9148..3ffe1129083519e708b6ce027b9088088073ee00 100644 (file)
@@ -21,7 +21,6 @@ import java.util.Set;
 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.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
@@ -39,8 +38,7 @@ public class EffectiveBuildTest {
 
     private static final StatementStreamSource SIMPLE_MODULE = sourceForResource(
             "/stmt-test/effective-build/simple-module.yang");
-    private static final QNameModule SIMPLE_MODULE_QNAME = QNameModule.create(
-            URI.create("simple.yang"), SimpleDateFormatUtil.DEFAULT_DATE_REV);
+    private static final QNameModule SIMPLE_MODULE_QNAME = QNameModule.create(URI.create("simple.yang"), null);
     private static final StatementStreamSource YANG_EXT = sourceForResource(
             "/stmt-test/extensions/yang-ext.yang");
 
index 098022c1d44b25ac8220427946e709be662b87f7..af298cd1d4eb91ea923a41e08badd2c3540d3d6d 100644 (file)
@@ -18,7 +18,6 @@ import com.google.common.collect.Iterables;
 import java.net.URISyntaxException;
 import java.util.Set;
 import org.junit.Test;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
 import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -56,14 +55,13 @@ public class EffectiveIdentityTest {
     public void identityTest() throws SourceException, ReactorException,
             URISyntaxException {
 
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
-                .newBuild();
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         reactor.addSources(IDENTITY_TEST);
         SchemaContext result = reactor.buildEffective();
 
         assertNotNull(result);
 
-        Module module = result.findModule("identity-test", SimpleDateFormatUtil.DEFAULT_DATE_REV).get();
+        Module module = result.findModule("identity-test", null).get();
         Set<IdentitySchemaNode> identities = module.getIdentities();
 
         assertNotNull(identities);
index f5455fbc1262684544098ee53b16e84234b2bb19..25d0b04acc17147c1a1ef66ba2c103aab1749461 100644 (file)
@@ -19,7 +19,6 @@ import java.util.Set;
 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.common.YangVersion;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
@@ -50,8 +49,7 @@ public class EffectiveModuleTest {
     private static final StatementStreamSource SUBMODULE = sourceForResource(
             "/semantic-statement-parser/effective-module/submod.yang");
 
-    private static final QNameModule ROOT_MODULE_QNAME = QNameModule.create(URI.create("root-ns"),
-            SimpleDateFormatUtil.DEFAULT_DATE_REV);
+    private static final QNameModule ROOT_MODULE_QNAME = QNameModule.create(URI.create("root-ns"), null);
 
     private static final QName cont = QName.create(ROOT_MODULE_QNAME, "cont");
     private static final QName feature1 = QName.create(ROOT_MODULE_QNAME, "feature1");
index 057bf5f91ce48ab73dde2eac98774a5665b3d6b4..fe851f27696955595e0f41563bc46a0f954623db 100644 (file)
@@ -14,18 +14,15 @@ import static org.junit.Assert.assertNotNull;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.Collection;
 import java.util.Set;
 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.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
@@ -44,8 +41,7 @@ public class EffectiveModulesAndSubmodulesTest {
             "/stmt-test/submodules/submodule-to-submodule-1.yang");
 
     @Test
-    public void modulesAndSubmodulesSimpleReferencesTest()
-            throws SourceException, ReactorException, URISyntaxException {
+    public void modulesAndSubmodulesSimpleReferencesTest() throws ReactorException {
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR
                 .newBuild();
         reactor.addSources(ROOT_MODULE, IMPORTED_MODULE,
@@ -113,10 +109,8 @@ public class EffectiveModulesAndSubmodulesTest {
         assertNotNull(sub1);
         assertNotNull(sub2);
 
-        assertEquals(QNameModule.create(new URI("root-module"),
-                SimpleDateFormatUtil.DEFAULT_DATE_REV), sub1.getQNameModule());
-        assertEquals(QNameModule.create(new URI("root-module"),
-                SimpleDateFormatUtil.DEFAULT_DATE_REV), sub2.getQNameModule());
+        assertEquals(QNameModule.create(URI.create("root-module"), null), sub1.getQNameModule());
+        assertEquals(QNameModule.create(URI.create("root-module"), null), sub2.getQNameModule());
 
         final Collection<DataSchemaNode> sub1ChildNodes = sub1.getChildNodes();
         final Collection<DataSchemaNode> sub2ChildNodes = sub2.getChildNodes();
@@ -148,9 +142,7 @@ public class EffectiveModulesAndSubmodulesTest {
 
         assertNotNull(sub1Submodule);
 
-        assertEquals(QNameModule.create(new URI("root-module"),
-                SimpleDateFormatUtil.DEFAULT_DATE_REV),
-                sub1Submodule.getQNameModule());
+        assertEquals(QNameModule.create(URI.create("root-module"), null), sub1Submodule.getQNameModule());
 
         final Collection<DataSchemaNode> sub1SubmoduleChildNodes = sub1Submodule.getChildNodes();
         assertNotNull(sub1SubmoduleChildNodes);
@@ -172,12 +164,10 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals("desc", containerInRoot.getDescription());
     }
 
-    private static void findModulesSubTest(final SchemaContext result, final Module root, final Module imported)
-            throws URISyntaxException {
-        final Module foundRoot = result.findModule("root-module", SimpleDateFormatUtil.DEFAULT_DATE_REV).get();
-        final Set<Module> foundRoots = result.findModules(new URI("root-module"));
-        final Module foundRoot3 = result.findModule(new URI("root-module"), SimpleDateFormatUtil.DEFAULT_DATE_REV)
-                .get();
+    private static void findModulesSubTest(final SchemaContext result, final Module root, final Module imported) {
+        final Module foundRoot = result.findModule("root-module", null).get();
+        final Set<Module> foundRoots = result.findModules(URI.create("root-module"));
+        final Module foundRoot3 = result.findModule(URI.create("root-module"), null).get();
 
         assertNotNull(foundRoot);
         assertNotNull(foundRoots);
@@ -191,10 +181,9 @@ public class EffectiveModulesAndSubmodulesTest {
         assertEquals(root, foundRoot2);
         assertEquals(root, foundRoot3);
 
-        final Module foundImported = result.findModule("imported-module", SimpleDateFormatUtil.DEFAULT_DATE_REV).get();
-        final Set<Module> foundImporteds = result.findModules(new URI("imported-module"));
-        final Module foundImported3 = result.findModule(new URI("imported-module"),
-            SimpleDateFormatUtil.DEFAULT_DATE_REV).get();
+        final Module foundImported = result.findModule("imported-module", null).get();
+        final Set<Module> foundImporteds = result.findModules(URI.create("imported-module"));
+        final Module foundImported3 = result.findModule(URI.create("imported-module"), null).get();
 
         assertNotNull(foundImported);
         assertNotNull(foundImporteds);
index a4c6cc1e5d8cfa3cfe7d3324d7678ae781e32d6e..b49fec820c7f846398e52a045ede2ade368547ab 100644 (file)
@@ -35,10 +35,10 @@ public class IfFeatureResolutionTest {
     @Test
     public void testSomeFeaturesSupported() throws ReactorException {
         final Set<QName> supportedFeatures = ImmutableSet.of(
-                QName.create("foo-namespace", "1970-01-01", "test-feature-1"),
-                QName.create("foo-namespace", "1970-01-01", "test-feature-2"),
-                QName.create("foo-namespace", "1970-01-01", "test-feature-3"),
-                QName.create("bar-namespace", "1970-01-01", "imp-feature"));
+                QName.create("foo-namespace", "test-feature-1"),
+                QName.create("foo-namespace", "test-feature-2"),
+                QName.create("foo-namespace", "test-feature-3"),
+                QName.create("bar-namespace", "imp-feature"));
 
         final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         reactor.addSources(FOO_MODULE, BAR_MODULE);
@@ -47,9 +47,7 @@ public class IfFeatureResolutionTest {
         final SchemaContext schemaContext = reactor.buildEffective();
         assertNotNull(schemaContext);
 
-        final Module testModule = schemaContext.findModules("foo").iterator().next();
-        assertNotNull(testModule);
-
+        final Module testModule = schemaContext.findModule("foo", null).get();
         assertEquals(9, testModule.getChildNodes().size());
 
         final ContainerSchemaNode testContainerA = (ContainerSchemaNode) testModule.getDataChildByName(
index 8b306941b94b59e211e3a83d8831fdf282574039..7002de1eb7c211497cecfa62923e6c895b2dddf4 100644 (file)
@@ -37,8 +37,6 @@ public class ImportRevisionsTest {
             "/import-revision-date-test/root-without-revision-date.yang");
     private static final StatementStreamSource IMPORTED_WITH_DATE = sourceForResource(
             "/import-revision-date-test/imported-module-with-revision-date.yang");
-    private static final StatementStreamSource ROOT_WITH_1970_DATE = sourceForResource(
-            "/import-revision-date-test/root-with-1970-revision-date.yang");
     private static final StatementStreamSource ROOT_WITH_NO_DATE = sourceForResource(
             "/import-revision-date-test/root-with-no-revision-date.yang");
     private static final StatementStreamSource IMPORTED_WITH_NO_DATE = sourceForResource(
@@ -81,15 +79,6 @@ public class ImportRevisionsTest {
         assertNotNull(result);
     }
 
-    @Test
-    public void revision1970InRootOnlyTest() throws ReactorException {
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        reactor.addSources(ROOT_WITH_1970_DATE, IMPORTED_WITHOUT_DATE);
-
-        EffectiveModelContext result = reactor.build();
-        assertNotNull(result);
-    }
-
     @Test
     public void noRevisionInRootAndImportedTest() throws ReactorException {
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
index efe2107c96edb44cbfdf0d49e72bb02a97e46d5b..20d647f98568b6777101eba744ea21b9031ec472 100644 (file)
@@ -18,7 +18,6 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
-import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
@@ -34,13 +33,11 @@ public class IncludeRevisionsTest {
     private static final StatementStreamSource SUBMOD_ONLY_REV = sourceForResource("/revisions/submod-only-rev.yang");
     private static final StatementStreamSource MOD_ONLY_ROOT = sourceForResource("/revisions/mod-only-root.yang");
     private static final StatementStreamSource MOD_ONLY_REV = sourceForResource("/revisions/mod-only-rev.yang");
-    private static final StatementStreamSource MOD_ONLY_1970_ROOT = sourceForResource("/revisions/mod-1970-root.yang");
-    private static final StatementStreamSource MOD_ONLY_1970_REV = sourceForResource("/revisions/mod-1970-rev.yang");
     private static final StatementStreamSource NOWHERE_ROOT = sourceForResource("/revisions/nowhere-root.yang");
     private static final StatementStreamSource NOWHERE_REV = sourceForResource("/revisions/nowhere-rev.yang");
 
     @Test
-    public void revsEqualTest() throws SourceException, ReactorException {
+    public void revsEqualTest() throws ReactorException {
 
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         addSources(reactor, EQUAL_REV, EQUAL_ROOT);
@@ -50,7 +47,7 @@ public class IncludeRevisionsTest {
     }
 
     @Test
-    public void revsUnequalTest() throws SourceException, ReactorException {
+    public void revsUnequalTest() throws ReactorException {
 
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         addSources(reactor, UNEQUAL_REV, UNEQUAL_ROOT);
@@ -65,7 +62,7 @@ public class IncludeRevisionsTest {
     }
 
     @Test
-    public void revIncludeOnly() throws SourceException, ReactorException {
+    public void revIncludeOnly() throws ReactorException {
 
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         addSources(reactor, SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT);
@@ -75,7 +72,7 @@ public class IncludeRevisionsTest {
     }
 
     @Test
-    public void revInModuleOnly() throws SourceException, ReactorException {
+    public void revInModuleOnly() throws ReactorException {
 
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         addSources(reactor, MOD_ONLY_REV, MOD_ONLY_ROOT);
@@ -90,17 +87,7 @@ public class IncludeRevisionsTest {
     }
 
     @Test
-    public void rev1970InModuleOnlyTest() throws SourceException, ReactorException {
-
-        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor, MOD_ONLY_1970_REV, MOD_ONLY_1970_ROOT);
-
-        EffectiveModelContext result = reactor.build();
-        assertNotNull(result);
-    }
-
-    @Test
-    public void revNowhereTest() throws SourceException, ReactorException {
+    public void revNowhereTest() throws ReactorException {
 
         CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
         addSources(reactor, NOWHERE_REV, NOWHERE_ROOT);
index 1fe90cff613d653563e066825510f52c784beb58..dcc3f3054853162d2ff33041c5b5682af540929f 100644 (file)
@@ -20,7 +20,6 @@ import java.util.Set;
 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.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
@@ -251,11 +250,10 @@ public class MoreRevisionsTest {
     private static void checkNetconfMonitoringModuleSimpleTest(final SchemaContext context,
             final Date rev20130715, final QName dateTimeTypeDef_20130715) {
         URI monitoringNS = URI.create("urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring");
-        final QNameModule monitoring_19700101 = QNameModule.create(monitoringNS, SimpleDateFormatUtil.DEFAULT_DATE_REV);
+        final QNameModule monitoring_19700101 = QNameModule.create(monitoringNS, null);
         QName lockedTime = QName.create(monitoring_19700101, "locked-time");
 
-        Module monitoringModule_19700101 = context.findModule("ietf-netconf-monitoring",
-            SimpleDateFormatUtil.DEFAULT_DATE_REV).get();
+        Module monitoringModule_19700101 = context.findModule("ietf-netconf-monitoring", null).get();
         DataSchemaNode leafLockedTime = monitoringModule_19700101.getDataChildByName(lockedTime);
         assertNotNull(leafLockedTime);
 
index 671ed873483dcfa7274ea82d3cbf6d207dd4cac9..b82265ce460706833240e3b2e7a4a18767642cc3 100644 (file)
@@ -76,7 +76,7 @@ public class YangParserNegativeTest {
             final Throwable rootCause = Throwables.getRootCause(e);
             assertTrue(rootCause instanceof InferenceException);
             assertTrue(rootCause.getMessage().startsWith(
-                "Augment target 'Absolute{path=[(urn:simple.container.demo?revision=1970-01-01)unknown]}' not found"));
+                "Augment target 'Absolute{path=[(urn:simple.container.demo)unknown]}' not found"));
         }
     }
 
@@ -87,7 +87,7 @@ public class YangParserNegativeTest {
             fail("ReactorException should be thrown");
         } catch (final ReactorException e) {
             assertTrue(e.getCause().getMessage().contains("Error in module 'test4' in the refine of uses " +
-                    "'Relative{path=[(urn:simple.container.demo?revision=1970-01-01)node]}': can not perform refine of 'PRESENCE' for" +
+                    "'Relative{path=[(urn:simple.container.demo)node]}': can not perform refine of 'PRESENCE' for" +
                     " the target 'LEAF_LIST'."));
         }
     }
@@ -121,8 +121,7 @@ public class YangParserNegativeTest {
             fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             final String expected = "Error in module 'container': cannot add '(urn:simple.container" +
-                    ".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
-                    ".demo?revision=1970-01-01)foo' already declared";
+                    ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared";
             assertTrue(e.getCause().getMessage().contains(expected));
         }
     }
@@ -134,8 +133,7 @@ public class YangParserNegativeTest {
             fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             final String expected = "Error in module 'container-list': cannot add '(urn:simple.container" +
-                    ".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
-                    ".demo?revision=1970-01-01)foo' already declared";
+                    ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared";
             assertTrue(e.getCause().getMessage().contains(expected));
         }
     }
@@ -147,8 +145,7 @@ public class YangParserNegativeTest {
             fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             final String expected = "Error in module 'container-leaf': cannot add '(urn:simple.container" +
-                    ".demo?revision=1970-01-01)foo'. Node name collision: '(urn:simple.container" +
-                    ".demo?revision=1970-01-01)foo' already declared";
+                    ".demo)foo'. Node name collision: '(urn:simple.container.demo)foo' already declared";
             assertTrue(e.getCause().getMessage().contains(expected));
         }
     }
@@ -160,7 +157,7 @@ public class YangParserNegativeTest {
             fail("SourceException should be thrown");
         } catch (final ReactorException e) {
             assertTrue(e.getCause().getMessage().startsWith(
-                "Duplicate name for typedef (urn:simple.container.demo?revision=1970-01-01)int-ext [at"));
+                "Duplicate name for typedef (urn:simple.container.demo)int-ext [at"));
         }
     }
 
@@ -198,8 +195,7 @@ public class YangParserNegativeTest {
             TestUtils.loadModuleResources(getClass(), "/negative-scenario/invalid-list-key-def.yang");
             fail("InferenceException should be thrown");
         } catch (final ReactorException e) {
-            final String expected = "Key 'rib-id' misses node 'rib-id' in list "
-                    + "'(invalid:list:key:def?revision=1970-01-01)application-map'";
+            final String expected = "Key 'rib-id' misses node 'rib-id' in list '(invalid:list:key:def)application-map'";
             assertTrue(e.getCause().getMessage().startsWith(expected));
         }
     }
index a65714d96ec3a4e17f405ffe4409397c1dc6b133..1f0291c459d62e487a8832b79c9a4b5530e74e99 100644 (file)
@@ -16,7 +16,6 @@ import java.net.URI;
 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.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
@@ -36,8 +35,7 @@ public class YangTypes2StmtTest {
     private static final StatementStreamSource TYPEFILE4 = sourceForResource(
             "/semantic-statement-parser/identityreftest.yang");
 
-    private static final QNameModule types2Module = QNameModule.create(URI.create("types2"),
-            SimpleDateFormatUtil.DEFAULT_DATE_REV);
+    private static final QNameModule types2Module = QNameModule.create(URI.create("types2"), null);
 
     private static final QName lfDecimal = QName.create(types2Module, "lf-decimal");
     private static final QName lfMyString = QName.create(types2Module, "lf-my-string");
index 81262a49ca44c7eddb35c83814cebc634c3197da..53933129797d79a3cf99d3a8a81949ad5f1e38a0 100644 (file)
@@ -2,7 +2,7 @@ module foo {
     namespace foo;
     prefix foo;
 
-    import bar { prefix bar; revision-date 1970-01-01; }
+    import bar { prefix bar; }
 
     extension foo-ext {
         argument arg;
index fa6f4841b8183c47fef5459ef5f14775088f55ed..c9cd57bfb7de61e351d2c701d49afba0acddbd98 100644 (file)
@@ -2,7 +2,7 @@ module bar {
     namespace bar;
     prefix bar;
 
-    import foo { prefix decimal64; revision-date 1970-01-01; }
+    import foo { prefix decimal64; }
 
     decimal64:decimal64 decimal64;
 }
index c7db6443aed4dc09f530b8230d758f13c37bdb64..c142cbed06bd06d0dff7e92566eea1d5245e9d12 100644 (file)
@@ -2,7 +2,7 @@ module bar {
     namespace bar;
     prefix bar;
 
-    import foo { prefix foo; revision-date 1970-01-01; }
+    import foo { prefix foo; }
 
     //valid augments (non-mandatory choice)
     augment "/foo:root" {
diff --git a/yang/yang-parser-impl/src/test/resources/import-revision-date-test/root-with-1970-revision-date.yang b/yang/yang-parser-impl/src/test/resources/import-revision-date-test/root-with-1970-revision-date.yang
deleted file mode 100644 (file)
index 4fc2dee..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-module root-with-1970-revision-date {
-    namespace "urn:opendaylight.org/root-with-1970-revision-date";
-    prefix "root-1970-date";
-
-    import imported-module-without-revision-date {
-        prefix "imported-without-date";
-        revision-date "1970-01-01";
-    }
-
-}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-rev.yang b/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-rev.yang
deleted file mode 100644 (file)
index d2f24a6..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-submodule mod-1970-rev {
-    belongs-to "mod-1970-root" {
-        prefix mod-1970-root;
-    }
-}
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-root.yang b/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-root.yang
deleted file mode 100644 (file)
index 7912ea1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-module mod-1970-root {
-    namespace mod-1970-root;
-    prefix mod-1970-root;
-
-    include mod-1970-rev {
-        revision-date "1970-01-01";
-    }
-}
index f0cb96cce70aacefba9d1296b46ac454b3340da5..7b576f94ef49492a8bfb62e871feade4660dced0 100644 (file)
@@ -5,9 +5,7 @@ module foo {
     include sub-foo {
         revision-date 2017-02-09;
     }
-    include sub-foo-2 {
-        revision-date 1970-01-01;
-    }
+    include sub-foo-2;
 
     container root {
     }
index e8d21584380c26aa8aa81808b588f825ff366744..b7546d1bbaad36f0c8907a520e6241ed563e06c7 100644 (file)
@@ -3,9 +3,7 @@ submodule sub-foo {
         prefix foo;
     }
 
-    include sub-foo-2 {
-        revision-date 1970-01-01;
-    }
+    include sub-foo-2;
 
     revision 2017-02-09;
 
index fc31a72fa418c50f3ea1440714297292be16c0ab..0aefd033d9dee7bec9098c22f167c347bd09bf8d 100644 (file)
@@ -6,9 +6,7 @@ module foo {
     include sub-foo {
         revision-date 2017-02-09;
     }
-    include sub-foo-2 {
-        revision-date 1970-01-01;
-    }
+    include sub-foo-2;
 
     container root {
     }
index 5ec75d342b24b98f1a3f68e5e7f1fbe383b4cb23..d27d804051bb49ee85ee19475ab674447435d11a 100644 (file)
@@ -3,9 +3,9 @@ module multiple-augment-root {
     namespace "multiple-augment-root";
     prefix root;
 
-    import multiple-augment-imported { prefix imp; revision-date 1970-01-01; }
+    import multiple-augment-imported { prefix imp; }
 
-    include multiple-augment-submodule { revision-date 1970-01-01; }
+    include multiple-augment-submodule;
 
     augment /imp:root-container/imp:container-from-grp1/imp:sub-container-from-grp1/imp:container-in-uses-augment/imp:sub-container-from-augment2 {
         container sub-container-from-augment3 {
index 0756bcd5b9299a4e658d4a48a622ad4b514ffb52..880e6ee8b3c0a5fc058fe7e0a6688650aeb6fde9 100644 (file)
@@ -2,10 +2,10 @@ module root-module {
     namespace "root-module";
     prefix root;
 
-    import imported-module { prefix imp; revision-date 1970-01-01; }
+    import imported-module { prefix imp; }
     
-    include submodule-1 { revision-date 1970-01-01; }
-    include submodule-2 { revision-date 1970-01-01; }
+    include submodule-1;
+    include submodule-2;
 
     container container-in-root-module {
         description "desc";
index 406551e0546e7346cf43b59656c83abfd6844287..45e1bf23de4df99e6337f21d81f2d72721faa6a7 100644 (file)
@@ -4,7 +4,7 @@ submodule submodule-1 {
         prefix root;
     }
     
-    include submodule-to-submodule-1 { revision-date 1970-01-01; }
+    include submodule-to-submodule-1;
     
     container container-in-submodule-1 {
     }
index 1538995400ddc37bd1afe3dca9a61afb07213a93..1cdbff5883ccb96da7c82bffdf08d4775b91eeee 100644 (file)
@@ -15,7 +15,6 @@ import com.google.common.base.Strings;
 import com.google.common.collect.ImmutableList;
 import java.util.Collection;
 import java.util.Date;
-import java.util.Optional;
 import java.util.Set;
 import java.util.function.Predicate;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -500,16 +499,7 @@ public final class StmtContextUtils {
 
         qnameModule = InferenceException.throwIfNull(qnameModule, ctx.getStatementSourceReference(),
             "Cannot resolve QNameModule for '%s'", value);
-
-        final QNameModule resultQNameModule;
-        if (qnameModule.getRevision() == null) {
-            resultQNameModule = QNameModule.create(qnameModule.getNamespace(), SimpleDateFormatUtil.DEFAULT_DATE_REV)
-                .intern();
-        } else {
-            resultQNameModule = qnameModule;
-        }
-
-        return ctx.getFromNamespace(QNameCacheNamespace.class, QName.create(resultQNameModule, localName));
+        return ctx.getFromNamespace(QNameCacheNamespace.class, QName.create(qnameModule, localName));
     }
 
     public static QNameModule getRootModuleQName(final StmtContext<?, ?, ?> ctx) {
@@ -531,11 +521,7 @@ public final class StmtContextUtils {
         }
 
         checkArgument(qnameModule != null, "Failed to look up root QNameModule for %s", ctx);
-        if (qnameModule.getRevision() != null) {
-            return qnameModule;
-        }
-
-        return QNameModule.create(qnameModule.getNamespace(), SimpleDateFormatUtil.DEFAULT_DATE_REV).intern();
+        return qnameModule;
     }
 
     public static QNameModule getModuleQNameByPrefix(final StmtContext<?, ?, ?> ctx, final String prefix) {
@@ -558,15 +544,19 @@ public final class StmtContextUtils {
         final QNameModule qNameModule = root.getFromNamespace(ModuleCtxToModuleQName.class, root);
         if (qNameModule != null) {
             // creates SourceIdentifier for a module
+            if (qNameModule.getFormattedRevision() == null) {
+                return RevisionSourceIdentifier.create((String) root.getStatementArgument());
+            }
+
             return RevisionSourceIdentifier.create((String) root.getStatementArgument(),
                 qNameModule.getFormattedRevision());
         }
 
         // creates SourceIdentifier for a submodule
-        final Date revision = Optional.ofNullable(getLatestRevision(root.declaredSubstatements()))
-                .orElse(SimpleDateFormatUtil.DEFAULT_DATE_REV);
-        final String formattedRevision = SimpleDateFormatUtil.getRevisionFormat().format(revision);
-        return RevisionSourceIdentifier.create((String) root.getStatementArgument(), formattedRevision);
+        final Date revision = getLatestRevision(root.declaredSubstatements());
+        return revision == null ? RevisionSourceIdentifier.create((String) root.getStatementArgument())
+                : RevisionSourceIdentifier.create((String) root.getStatementArgument(),
+                    SimpleDateFormatUtil.getRevisionFormat().format(revision));
     }
 
     public static Date getLatestRevision(final Iterable<? extends StmtContext<?, ?, ?>> subStmts) {