Cleanup DataTree interfaces and InMemmoryDataTreeFactory 95/65795/3
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Nov 2017 11:49:29 +0000 (12:49 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 21 Nov 2017 12:25:38 +0000 (13:25 +0100)
TipProducingDataTree is a remnant of an API freeze, merge its behavior
into baseline DataTree, adjusting callers.

Also make sure we publish DataTreeFactory properly, so users do not
have to rely on specific implementation -- cleaning up tests in process.

Change-Id: Ic2263a084ba7b8d2c611eb14407e09a78f6d922a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
42 files changed:
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTreeCandidateTip.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/DataTreeTip.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/TipProducingDataTree.java [deleted file]
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/TipProducingDataTreeTip.java [deleted file]
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/SchemaOrderedNormalizedNodeWriterTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlStreamUtilsTest.java
yang/yang-data-codec-xml/src/test/java/org/opendaylight/yangtools/yang/data/codec/xml/XmlToNormalizedNodesTest.java
yang/yang-data-impl/pom.xml
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/osgi/Activator.java [new file with mode: 0644]
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/osgi/package-info.java [new file with mode: 0644]
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTree.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/InMemoryDataTreeFactory.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/context/Bug8713Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest2.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/leafref/context/DataTreeCandidateValidatorTest3.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/BuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/InstanceIdToNodesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/NormalizedDataBuilderTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug2690Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug3674Test.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/Bug4454Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug5830Test.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug5968MergeTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/Bug5968Test.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/CaseAugmentTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/CaseExclusionTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ConcurrentTreeModificationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ConfigStatementValidationTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/DataTreeCandidatesTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/DataTreeTransactionTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ErrorReportingTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ListConstraintsValidation.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/MandatoryLeafTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/ModificationMetadataTreeTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/OrderedListTest.java
yang/yang-data-impl/src/test/java/org/opendaylight/yangtools/yang/data/impl/schema/tree/StoreTreeNodesTest.java
yang/yang-data-jaxen/src/test/java/org/opendaylight/yangtools/yang/data/jaxen/JaxenTest.java
yang/yang-model-export/src/test/java/org/opendaylight/yangtools/yang/model/export/test/SchemaContextEmitterTest.java

index ed082df336af868a2633d0f28143145fcffa427b..7045a9edc9dc3ddf1cd64b248d908956b561e725 100644 (file)
@@ -17,6 +17,6 @@ import com.google.common.annotations.Beta;
  * a candidate commit needs to be coordinated across distributed parties.
  */
 @Beta
-public interface DataTreeCandidateTip extends DataTreeCandidate, TipProducingDataTreeTip {
+public interface DataTreeCandidateTip extends DataTreeCandidate, DataTreeTip {
 
 }
index dae1e244eb92253b3a3ef016d9480c1911a0391d..8f23488474a79e81c6542a8171a3ba30975352b6 100644 (file)
@@ -31,7 +31,7 @@ public interface DataTreeTip {
      *                  Data tree modification.
      * @return candidate data tree
      */
-    DataTreeCandidate prepare(DataTreeModification modification);
+    DataTreeCandidateTip prepare(DataTreeModification modification);
 
     /**
      * {@inheritDoc}
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/TipProducingDataTree.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/TipProducingDataTree.java
deleted file mode 100644 (file)
index 7baa814..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.data.api.schema.tree;
-
-/**
- * A {@link DataTree} which produces {@link DataTreeCandidateTip} candidates,
- * thus allowing existence of multiple candidates, which can be {@link #commit(DataTreeCandidate)}ed
- * in sequence.
- */
-public interface TipProducingDataTree extends DataTree, TipProducingDataTreeTip {
-
-}
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/TipProducingDataTreeTip.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/tree/TipProducingDataTreeTip.java
deleted file mode 100644 (file)
index 6121d7f..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (c) 2015 Pantheon Technologies, s.r.o. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang.data.api.schema.tree;
-
-/**
- * A {@link DataTreeCandidateTip} which produces {@link DataTreeCandidateTip}s from its
- * {@link #prepare(DataTreeModification)} method.
- */
-public interface TipProducingDataTreeTip extends DataTreeTip {
-    @Override
-    DataTreeCandidateTip prepare(DataTreeModification modification);
-}
index fc9caa57084c8b167c8a1610ce67f67dc5473ac5..b2cfba716e6fddcfd54668e1b3fe4ed57f4cfc18 100644 (file)
@@ -7,12 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.data.codec.xml;
 
-import java.io.FileNotFoundException;
+import java.io.IOException;
 import java.io.StringWriter;
-import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
+import javax.xml.stream.FactoryConfigurationError;
 import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.XMLAssert;
@@ -31,8 +32,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.SchemaOrderedNormalizedNodeWriter;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
+import org.xml.sax.SAXException;
 
 public class SchemaOrderedNormalizedNodeWriterTest {
 
@@ -75,12 +76,12 @@ public class SchemaOrderedNormalizedNodeWriterTest {
 
 
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         XMLUnit.setIgnoreWhitespace(true);
     }
 
     @Test
-    public void testWrite() throws Exception {
+    public void testWrite() throws XMLStreamException, FactoryConfigurationError, IOException, SAXException {
         final StringWriter stringWriter = new StringWriter();
         final XMLStreamWriter xmlStreamWriter = XMLOutputFactory.newFactory().createXMLStreamWriter(stringWriter);
 
@@ -166,8 +167,7 @@ public class SchemaOrderedNormalizedNodeWriterTest {
         XMLAssert.assertXMLIdentical(new Diff(EXPECTED_2, stringWriter.toString()), true);
     }
 
-    private static SchemaContext getSchemaContext(final String filePath) throws URISyntaxException,
-            ReactorException, FileNotFoundException {
+    private static SchemaContext getSchemaContext(final String filePath) {
         return YangParserTestUtils.parseYangResource(filePath);
     }
 
index 80883180c92a66029d46264fa260f9b62fdf2b8d..1d7e209ed011a0a6d4079802ed48904a63a636b4 100644 (file)
@@ -15,9 +15,7 @@ import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
-import java.io.FileNotFoundException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.AbstractMap;
 import java.util.HashMap;
 import java.util.Map;
@@ -44,7 +42,6 @@ import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefi
 import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 
@@ -56,7 +53,7 @@ public class XmlStreamUtilsTest {
     private static Module leafRefModule;
 
     @BeforeClass
-    public static void initialize() throws URISyntaxException, FileNotFoundException, ReactorException {
+    public static void initialize() {
         schemaContext = YangParserTestUtils.parseYangResource("/leafref-test.yang");
         assertNotNull(schemaContext);
         assertEquals(1, schemaContext.getModules().size());
index c3775019eff110826e11332a22481a107b3999d8..7852a09b050d20791dbc428f869c96ffc4b7d099 100644 (file)
@@ -47,7 +47,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.xml.sax.SAXException;
 
@@ -121,8 +120,8 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void testComplexXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException,
-            ParserConfigurationException, SAXException {
+    public void testComplexXmlParsing() throws IOException, SAXException, URISyntaxException, XMLStreamException,
+            ParserConfigurationException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/baz.xml");
 
         final XMLInputFactory factory = XMLInputFactory.newInstance();
@@ -147,7 +146,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void testSimpleXmlParsing() throws IOException, URISyntaxException, ReactorException, XMLStreamException,
+    public void testSimpleXmlParsing() throws IOException, URISyntaxException, XMLStreamException,
             ParserConfigurationException, SAXException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/foo.xml");
 
@@ -165,7 +164,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void shouldFailOnDuplicateLeaf() throws ReactorException, XMLStreamException, IOException,
+    public void shouldFailOnDuplicateLeaf() throws XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo.xml");
 
@@ -186,7 +185,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void shouldFailOnDuplicateAnyXml() throws ReactorException, XMLStreamException, IOException,
+    public void shouldFailOnDuplicateAnyXml() throws XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-2.xml");
 
@@ -206,7 +205,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void shouldFailOnDuplicateContainer() throws ReactorException, XMLStreamException, IOException,
+    public void shouldFailOnDuplicateContainer() throws XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-foo-3.xml");
 
@@ -226,7 +225,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void shouldFailOnUnterminatedLeafElement() throws ReactorException, XMLStreamException, IOException,
+    public void shouldFailOnUnterminatedLeafElement() throws XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz.xml");
 
@@ -247,7 +246,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void shouldFailOnUnterminatedLeafElement2() throws ReactorException, XMLStreamException, IOException,
+    public void shouldFailOnUnterminatedLeafElement2() throws XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-2.xml");
 
@@ -268,7 +267,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void shouldFailOnUnterminatedContainerElement() throws ReactorException, XMLStreamException, IOException,
+    public void shouldFailOnUnterminatedContainerElement() throws XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-4.xml");
 
@@ -289,7 +288,7 @@ public class XmlToNormalizedNodesTest {
     }
 
     @Test
-    public void shouldFailOnUnknownChildNode() throws ReactorException, XMLStreamException, IOException,
+    public void shouldFailOnUnknownChildNode() throws XMLStreamException, IOException,
             ParserConfigurationException, SAXException, URISyntaxException {
         final InputStream resourceAsStream = XmlToNormalizedNodesTest.class.getResourceAsStream("/invalid-baz-3.xml");
 
index 157d3e012c4fb4ca7d873014f55ca84ff6e29a87..c04fb37cd6923858dd1fcabc1d7fee7136b5f4f9 100644 (file)
@@ -73,6 +73,8 @@
                             org.opendaylight.yangtools.yang.data.impl.*,
                             ;-split-package:=error
                         </Export-Package>
+                        <Include-Resource>{META-INF/services=${project.build.directory}/classes/META-INF/services}</Include-Resource>
+                        <Bundle-Activator>org.opendaylight.yangtools.yang.data.impl.osgi.Activator</Bundle-Activator>
                     </instructions>
                 </configuration>
             </plugin>
             <groupId>com.google.guava</groupId>
             <artifactId>guava</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.antlr</groupId>
+            <artifactId>antlr4-runtime</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.kohsuke.metainf-services</groupId>
+            <artifactId>metainf-services</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <artifactId>commons-lang</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.antlr</groupId>
-            <artifactId>antlr4-runtime</artifactId>
-        </dependency>
     </dependencies>
 
     <!--
diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/osgi/Activator.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/osgi/Activator.java
new file mode 100644 (file)
index 0000000..183e286
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.data.impl.osgi;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeFactory;
+import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceRegistration;
+
+/**
+ * YANG data implementation activator. Publishes a {@link DataTreeFactory} implementation on bundle start.
+ *
+ * @author Robert Varga
+ */
+public final class Activator implements BundleActivator {
+    private ServiceRegistration<@NonNull DataTreeFactory> registration;
+
+    @Override
+    public void start(final BundleContext context) throws Exception {
+        registration = context.registerService(DataTreeFactory.class, new InMemoryDataTreeFactory(), null);
+    }
+
+    @Override
+    public void stop(final BundleContext context) throws Exception {
+        if (registration != null) {
+            registration.unregister();
+            registration = null;
+        }
+    }
+}
diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/osgi/package-info.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/osgi/package-info.java
new file mode 100644 (file)
index 0000000..b184727
--- /dev/null
@@ -0,0 +1,11 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+/**
+ * OSGi-specific YANG data implementation code. Contains activators and similar.
+ */
+package org.opendaylight.yangtools.yang.data.impl.osgi;
\ No newline at end of file
index 75c9af59b375b11d82a2bd0f5eb74158c9015f8a..523ffee223c070f298598ccc5c8131896bf4ca99 100644 (file)
@@ -13,9 +13,9 @@ import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodes;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNode;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextNode;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
@@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory;
 /**
  * Read-only snapshot of the data tree.
  */
-final class InMemoryDataTree extends AbstractDataTreeTip implements TipProducingDataTree {
+final class InMemoryDataTree extends AbstractDataTreeTip implements DataTree {
     private static final AtomicReferenceFieldUpdater<InMemoryDataTree, DataTreeState> STATE_UPDATER =
             AtomicReferenceFieldUpdater.newUpdater(InMemoryDataTree.class, DataTreeState.class, "state");
     private static final Logger LOG = LoggerFactory.getLogger(InMemoryDataTree.class);
index 8511e8af7bb5a9e5266af2e87a54efb9bb0416b2..b36776d88c479ed86695185e768c801830cce934 100644 (file)
@@ -8,18 +8,19 @@
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import com.google.common.base.Preconditions;
+import org.kohsuke.MetaInfServices;
 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;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNodeContainer;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
@@ -35,30 +36,25 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 /**
  * A factory for creating in-memory data trees.
  */
+@MetaInfServices
 public final class InMemoryDataTreeFactory implements DataTreeFactory {
-    private static final InMemoryDataTreeFactory INSTANCE = new InMemoryDataTreeFactory();
     private static final NormalizedNode<?, ?> ROOT_CONTAINER = ImmutableNodes.containerNode(SchemaContext.NAME);
 
-    private InMemoryDataTreeFactory() {
-        // Never instantiated externally
-    }
-
     @Override
-    public TipProducingDataTree create(final DataTreeConfiguration treeConfig) {
+    public DataTree create(final DataTreeConfiguration treeConfig) {
         return new InMemoryDataTree(TreeNodeFactory.createTreeNode(createRoot(treeConfig.getRootPath()),
             Version.initial()), treeConfig, null);
     }
 
     @Override
-    public TipProducingDataTree create(final DataTreeConfiguration treeConfig,
-            final SchemaContext initialSchemaContext) {
+    public DataTree create(final DataTreeConfiguration treeConfig, final SchemaContext initialSchemaContext) {
         return create(treeConfig, initialSchemaContext, true);
     }
 
     @Override
-    public TipProducingDataTree create(final DataTreeConfiguration treeConfig, final SchemaContext initialSchemaContext,
+    public DataTree create(final DataTreeConfiguration treeConfig, final SchemaContext initialSchemaContext,
             final NormalizedNodeContainer<?, ?, ?> initialRoot) throws DataValidationFailedException {
-        final TipProducingDataTree ret = create(treeConfig, initialSchemaContext, false);
+        final DataTree ret = create(treeConfig, initialSchemaContext, false);
 
         final DataTreeModification mod = ret.takeSnapshot().newModification();
         mod.write(YangInstanceIdentifier.EMPTY, initialRoot);
@@ -70,8 +66,8 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
         return ret;
     }
 
-    private static TipProducingDataTree create(final DataTreeConfiguration treeConfig,
-            final SchemaContext initialSchemaContext, final boolean maskMandatory) {
+    private static DataTree create(final DataTreeConfiguration treeConfig, final SchemaContext initialSchemaContext,
+            final boolean maskMandatory) {
         final DataSchemaNode rootSchemaNode = getRootSchemaNode(initialSchemaContext, treeConfig.getRootPath());
         final NormalizedNode<?, ?> rootDataNode = createRoot((DataNodeContainer)rootSchemaNode,
             treeConfig.getRootPath());
@@ -132,13 +128,4 @@ public final class InMemoryDataTreeFactory implements DataTreeFactory {
         // FIXME: implement augmentations and leaf-lists
         throw new IllegalArgumentException("Unsupported root node " + arg);
     }
-
-    /**
-     * Get an instance of this factory. This method cannot fail.
-     *
-     * @return Data tree factory instance.
-     */
-    public static InMemoryDataTreeFactory getInstance() {
-        return INSTANCE;
-    }
 }
index 6dc9c686d05798803124f2eb65cf4692c024e652..e024f9599b4ae19139a1cbef28af8a2611ae98c4 100644 (file)
@@ -13,9 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.fail;
 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
 
-import java.io.FileNotFoundException;
 import java.net.URI;
-import java.net.URISyntaxException;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.QNameModule;
@@ -24,7 +22,6 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 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.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -34,8 +31,7 @@ public class StringPatternCheckingCodecTest {
     private static final Logger LOG = LoggerFactory.getLogger(StringPatternCheckingCodecTest.class);
 
     @Test
-    public void testStringPatternCheckingCodec() throws ReactorException, URISyntaxException,
-            FileNotFoundException {
+    public void testStringPatternCheckingCodec() {
         final SchemaContext schemaContext = YangParserTestUtils.parseYangResource(
             "/string-pattern-checking-codec-test.yang");
         assertNotNull(schemaContext);
index 24163dadef629f24c2a986b3f409347597f3856e..e597cd352b655b0cf2c3ec77d3808e44b6e12ea6 100644 (file)
@@ -12,10 +12,10 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
@@ -33,9 +33,8 @@ public class Bug8713Test {
     public void dataTreeCanditateValidationTest() throws Exception {
         final SchemaContext context = YangParserTestUtils.parseYangResourceDirectory("/bug8713/");
         final LeafRefContext rootLeafRefContext = LeafRefContext.create(context);
-        final TipProducingDataTree inMemoryDataTree = InMemoryDataTreeFactory.getInstance()
-                .create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(context);
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
 
         final ContainerNode root = createRootContainer();
         final YangInstanceIdentifier rootPath = YangInstanceIdentifier.of(foo("root"));
index 7967816bbc1cc28c8f3b25607bb2debf83a963d7..50ed509566be891e2bd7c4d1b4617b44abfd9b99 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.yangtools.yang.data.impl.leafref.context;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
@@ -31,10 +29,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -50,7 +48,6 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 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.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -61,7 +58,7 @@ public class DataTreeCandidateValidatorTest {
     private static Module valModule;
     private static QNameModule valModuleQname;
     private static LeafRefContext rootLeafRefContext;
-    public static TipProducingDataTree inMemoryDataTree;
+    public static DataTree inMemoryDataTree;
 
     private static QName odl;
     private static QName project;
@@ -102,8 +99,7 @@ public class DataTreeCandidateValidatorTest {
     }
 
     @BeforeClass
-    public static void init() throws FileNotFoundException, ReactorException,
-            URISyntaxException {
+    public static void init()  {
         initSchemaContext();
 
         initLeafRefContext();
@@ -170,8 +166,7 @@ public class DataTreeCandidateValidatorTest {
     }
 
     private static void initDataTree() {
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(context);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
 
         final DataTreeModification initialDataTreeModification = inMemoryDataTree
                 .takeSnapshot().newModification();
index 72e5d89d813dbdbf1279d150458e02c86e218283..b3ff359d87a0ab2f0bd14889a9ac6902a9ff5550 100644 (file)
@@ -10,8 +10,6 @@ package org.opendaylight.yangtools.yang.data.impl.leafref.context;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.io.FileNotFoundException;
-import java.net.URISyntaxException;
 import java.util.Set;
 import org.apache.log4j.BasicConfigurator;
 import org.junit.BeforeClass;
@@ -25,10 +23,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -41,7 +39,6 @@ import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 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.test.util.YangParserTestUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -52,7 +49,7 @@ public class DataTreeCandidateValidatorTest2 {
     private static Module mainModule;
     private static QNameModule rootModuleQname;
     private static LeafRefContext rootLeafRefContext;
-    public static TipProducingDataTree inMemoryDataTree;
+    public static DataTree inMemoryDataTree;
 
     private static QName chips;
     private static QName chip;
@@ -80,8 +77,7 @@ public class DataTreeCandidateValidatorTest2 {
     }
 
     @BeforeClass
-    public static void init() throws FileNotFoundException, ReactorException, URISyntaxException {
-
+    public static void init() {
         initSchemaContext();
         initLeafRefContext();
         initQnames();
@@ -167,8 +163,7 @@ public class DataTreeCandidateValidatorTest2 {
 
     private static void initDataTree() {
 
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(context);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
 
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
 
index a7bb5162ea9332f6b3fc9deb2e80118a9fd7ae86..1f2e1e9e98258153381e92b24023c5cdda1e65f9 100644 (file)
@@ -23,10 +23,10 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidatation;
@@ -49,7 +49,7 @@ public class DataTreeCandidateValidatorTest3 {
     private static Module mainModule;
     private static QNameModule rootModuleQname;
     private static LeafRefContext rootLeafRefContext;
-    public static TipProducingDataTree inMemoryDataTree;
+    public static DataTree inMemoryDataTree;
 
     private static QName chips;
     private static QName chip;
@@ -210,8 +210,7 @@ public class DataTreeCandidateValidatorTest3 {
 
     private static void initDataTree() {
 
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(context);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
 
         final DataTreeModification initialDataTreeModification = inMemoryDataTree.takeSnapshot().newModification();
 
index 29287654611bd88c6af2337bbd1c14dc7253b625..cfc3ae7a6b2c46636f94c53c28df385af6b1c2b4 100644 (file)
@@ -13,7 +13,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.mockito.Mockito.mock;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.LinkedList;
@@ -63,7 +62,6 @@ import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 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.test.util.YangParserTestUtils;
 
 public class BuilderTest {
@@ -92,7 +90,7 @@ public class BuilderTest {
     private LeafListSchemaNode leafList;
 
     @Before
-    public void setup() throws FileNotFoundException, ReactorException, URISyntaxException {
+    public void setup() throws URISyntaxException {
         final File leafRefTestYang = new File(getClass().getResource("/builder-test/immutable-ordered-map-node.yang")
                 .toURI());
         final SchemaContext schema = YangParserTestUtils.parseYangFiles(leafRefTestYang);
index 6e91d46a491034349fa0f02b33ad0da9426a4e99..7cf9c328b92a3df9ef9ee347fcfb46ab750953dd 100644 (file)
@@ -9,8 +9,6 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import static org.junit.Assert.assertEquals;
 
-import java.io.IOException;
-import java.net.URISyntaxException;
 import java.util.Collections;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -26,8 +24,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class InstanceIdToNodesTest {
@@ -54,19 +50,17 @@ public class InstanceIdToNodesTest {
     private final NodeWithValue<?> leafListWithValue = new NodeWithValue<>(
             leafList.getNodeType(), "abcd");
 
-    static SchemaContext createTestContext() throws URISyntaxException, ReactorException, IOException,
-            YangSyntaxErrorException {
+    static SchemaContext createTestContext() {
         return YangParserTestUtils.parseYangResources(InstanceIdToNodesTest.class, "/filter-test.yang");
     }
 
     @BeforeClass
-    public static void setUp() throws Exception {
+    public static void setUp() {
         ctx = createTestContext();
-
     }
 
     @Test
-    public void testInAugment() throws Exception {
+    public void testInAugment() {
         final LeafNode<?> leaf = Builders.leafBuilder().withNodeIdentifier(augmentedLeaf).withValue("").build();
         final ContainerNode expectedFilter = Builders
                 .containerBuilder()
@@ -86,7 +80,7 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testInAugmentLeafOverride() throws Exception {
+    public void testInAugmentLeafOverride() {
         final LeafNode<Object> lastLeaf = Builders.leafBuilder().withNodeIdentifier(augmentedLeaf)
                 .withValue("randomValue").build();
 
@@ -106,7 +100,7 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testListChoice() throws Exception {
+    public void testListChoice() {
         final LeafNode<?> leaf = Builders.leafBuilder().withNodeIdentifier(leafFromCase).withValue("").build();
         final ContainerNode expectedFilter = Builders
                 .containerBuilder()
@@ -137,7 +131,7 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testTopContainerLastChildOverride() throws Exception {
+    public void testTopContainerLastChildOverride() {
         final ContainerNode expectedStructure = Builders
                 .containerBuilder()
                 .withNodeIdentifier(rootContainer)
@@ -168,7 +162,7 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testListLastChildOverride() throws Exception {
+    public void testListLastChildOverride() {
         final MapEntryNode outerListEntry = Builders
                 .mapEntryBuilder()
                 .withNodeIdentifier(outerListWithKey)
@@ -189,7 +183,7 @@ public class InstanceIdToNodesTest {
     }
 
     @Test
-    public void testLeafList() throws Exception {
+    public void testLeafList() {
         final ContainerNode expectedFilter = Builders
                 .containerBuilder()
                 .withNodeIdentifier(rootContainer)
index dc7f12f1315aaeb48d4310a0bc130ebe17648a20..7cd56d9a5422ae0ef884d48ff89f616aabd6629a 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.data.impl.schema;
 import static com.google.common.base.Preconditions.checkState;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Collections;
@@ -42,7 +41,6 @@ import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 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.test.util.YangParserTestUtils;
 
 public class NormalizedDataBuilderTest {
@@ -51,10 +49,8 @@ public class NormalizedDataBuilderTest {
     private SchemaContext schema;
 
     @Before
-    public void setUp() throws URISyntaxException, FileNotFoundException, ReactorException {
-        final File resourceFile = new File(getClass().getResource(
-                "test.yang").toURI());
-        schema = YangParserTestUtils.parseYangFiles(resourceFile);
+    public void setUp() throws URISyntaxException {
+        schema = YangParserTestUtils.parseYangFiles(new File(getClass().getResource("test.yang").toURI()));
         containerNode = (ContainerSchemaNode) getSchemaNode(schema, "test", "container");
     }
 
index ea42ee879ab58b9f17c87de0c933657f3c2bdddb..f4fcdfd6222190fa5985b27aaa28506d3e832a1a 100644 (file)
@@ -29,7 +29,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailed
 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;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug2690Test {
@@ -38,14 +37,14 @@ public class Bug2690Test {
     private DataTree inMemoryDataTree;
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_OPERATIONAL, schemaContext);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            schemaContext);
     }
 
-    public static SchemaContext createTestContext() throws ReactorException {
+    public static SchemaContext createTestContext() {
         return YangParserTestUtils.parseYangResource(ODL_DATASTORE_TEST_YANG);
     }
 
index 0ac30537affdaf69bbe678a399471a4c20695bcf..f70789933330451af7100ce4b5bbd6b209e2368a 100644 (file)
@@ -9,7 +9,6 @@ package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import static org.junit.Assert.assertEquals;
 
-import java.io.IOException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
@@ -19,8 +18,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguratio
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModificationType;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 /**
  * BUG-3674: issuing a delete on a non-existent entry must be preserved in
@@ -31,8 +28,8 @@ public class Bug3674Test {
     private DataTree tree;
 
     @Before
-    public void setUp() throws ReactorException, IOException, YangSyntaxErrorException {
-        tree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+    public void setUp() {
+        tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
             TestModel.createTestContext());
 
         // Create the top-level container
index b049098ad136a4be7fe7ac16a5d0ddf3e5326010..9816142320dbb0f5f0eacdc8c03f89638da5fb24 100644 (file)
@@ -20,10 +20,10 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
@@ -33,7 +33,7 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug4295Test {
 
-    private TipProducingDataTree inMemoryDataTree;
+    private DataTree inMemoryDataTree;
     private SchemaContext context;
     private QName root;
     private QName subRoot;
@@ -57,8 +57,7 @@ public class Bug4295Test {
         iid = QName.create(foo, "i-id");
         oleaf = QName.create(foo, "o");
         ileaf = QName.create(foo, "i");
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(context);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
     }
 
     @Test
index b8a4ad363d97fef344d6abe5ce8b6bf55595e2ff..61ba257b2a94148da6d03d3e72b665be373cee7e 100644 (file)
@@ -12,8 +12,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import com.google.common.collect.ImmutableMap;
-import java.io.IOException;
-import java.net.URISyntaxException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
@@ -43,8 +41,6 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLe
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableLeafSetNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableMapEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class Bug4454Test {
@@ -103,11 +99,11 @@ public class Bug4454Test {
     private DataTree inMemoryDataTree;
 
     @Before
-    public void prepare() throws IOException, YangSyntaxErrorException, ReactorException, URISyntaxException {
+    public void prepare() {
         SchemaContext schemaContext = createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        inMemoryDataTree =  InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_OPERATIONAL, schemaContext);
+        inMemoryDataTree =  new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            schemaContext);
         final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
         final DataTreeModification modificationTree = initialDataTreeSnapshot.newModification();
 
@@ -116,8 +112,7 @@ public class Bug4454Test {
         inMemoryDataTree.commit(inMemoryDataTree.prepare(modificationTree));
     }
 
-    public static SchemaContext createTestContext() throws IOException, YangSyntaxErrorException, ReactorException,
-            URISyntaxException {
+    public static SchemaContext createTestContext() {
         return YangParserTestUtils.parseYangResource("/bug-4454-test.yang");
     }
 
index d658053f2dc94347ea415eb2899bfa2b53d4ffe7..91fc0dce72e5842b3ac85e9202f822990e776059 100644 (file)
@@ -22,14 +22,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class Bug5830Test {
     private static final String NS = "foo";
@@ -46,14 +47,13 @@ public class Bug5830Test {
     private static final QName PRESENCE_CONTAINER_2 = QName.create(NS, REV, "presence-container-2");
     private static final QName MANDATORY_LEAF_2 = QName.create(NS, REV, "mandatory-leaf-2");
 
-    private static InMemoryDataTree initDataTree(final SchemaContext schemaContext)
+    private static DataTree initDataTree(final SchemaContext schemaContext)
             throws DataValidationFailedException {
-        InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+                DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
 
         final MapNode taskNode = Builders.mapBuilder().withNodeIdentifier(new NodeIdentifier(TASK)).build();
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK), taskNode);
         modificationTree.ready();
 
@@ -64,13 +64,13 @@ public class Bug5830Test {
     }
 
     @Test
-    public void testMandatoryNodes() throws ReactorException, DataValidationFailedException {
+    public void testMandatoryNodes() throws DataValidationFailedException {
         testPresenceContainer();
         testNonPresenceContainer();
         testMultipleContainers();
     }
 
-    private static void testPresenceContainer() throws ReactorException, DataValidationFailedException {
+    private static void testPresenceContainer() throws DataValidationFailedException {
         final SchemaContext schemaContext = TestModel.createTestContext("/bug5830/foo-presence.yang");
         assertNotNull("Schema context must not be null.", schemaContext);
 
@@ -86,7 +86,7 @@ public class Bug5830Test {
         testMandatoryDataLeafIsPresent(schemaContext);
     }
 
-    private static void testNonPresenceContainer() throws ReactorException, DataValidationFailedException {
+    private static void testNonPresenceContainer() throws DataValidationFailedException {
         final SchemaContext schemaContext = TestModel.createTestContext("/bug5830/foo-non-presence.yang");
         assertNotNull("Schema context must not be null.", schemaContext);
 
@@ -110,7 +110,7 @@ public class Bug5830Test {
         testMandatoryDataLeafIsPresent(schemaContext);
     }
 
-    private static void testMultipleContainers() throws ReactorException, DataValidationFailedException {
+    private static void testMultipleContainers() throws DataValidationFailedException {
         final SchemaContext schemaContext = TestModel.createTestContext("/bug5830/foo-multiple.yang");
         assertNotNull("Schema context must not be null.", schemaContext);
 
@@ -147,13 +147,13 @@ public class Bug5830Test {
 
     private static void testContainerIsNotPresent(final SchemaContext schemaContext)
             throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext);
+        final DataTree inMemoryDataTree = initDataTree(schemaContext);
         final MapEntryNode taskEntryNode = Builders.mapEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123")))
                 .withChild(ImmutableNodes.leafNode(TASK_ID, "123"))
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data")).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
                 YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK)
                         .node(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123"))), taskEntryNode);
@@ -165,7 +165,7 @@ public class Bug5830Test {
     }
 
     private static void testContainerIsPresent(final SchemaContext schemaContext) throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext);
+        final DataTree inMemoryDataTree = initDataTree(schemaContext);
 
         final MapEntryNode taskEntryNode = Builders.mapEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123")))
@@ -173,7 +173,7 @@ public class Bug5830Test {
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data"))
                 .withChild(createTaskDataContainer(false)).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
                 YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK)
                         .node(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123"))), taskEntryNode);
@@ -186,7 +186,7 @@ public class Bug5830Test {
 
     private static void testMandatoryDataLeafIsPresent(final SchemaContext schemaContext)
             throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext);
+        final DataTree inMemoryDataTree = initDataTree(schemaContext);
 
         final MapEntryNode taskEntryNode = Builders.mapEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123")))
@@ -194,7 +194,7 @@ public class Bug5830Test {
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data"))
                 .withChild(createTaskDataContainer(true)).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
                 YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK)
                         .node(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123"))), taskEntryNode);
@@ -207,7 +207,7 @@ public class Bug5830Test {
 
     private static void testMandatoryLeaf2IsPresent(final SchemaContext schemaContext,
             final boolean withPresenceContianer) throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext);
+        final DataTree inMemoryDataTree = initDataTree(schemaContext);
 
         final MapEntryNode taskEntryNode = Builders.mapEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123")))
@@ -215,7 +215,7 @@ public class Bug5830Test {
                 .withChild(ImmutableNodes.leafNode(TASK_MANDATORY_LEAF, "mandatory data"))
                 .withChild(createTaskDataMultipleContainer(withPresenceContianer)).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
                 YangInstanceIdentifier.of(TASK_CONTAINER).node(TASK)
                         .node(new NodeIdentifierWithPredicates(TASK, ImmutableMap.of(TASK_ID, "123"))), taskEntryNode);
index 79568b97be02ae01daf9a89fd25ae17bdba75786..7ffedcab0a2bf9d4c583e4982fc9edaaf4a9a4fe 100644 (file)
@@ -21,15 +21,16 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.CollectionNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class Bug5968MergeTest {
     private static final String NS = "foo";
@@ -42,20 +43,19 @@ public class Bug5968MergeTest {
     private SchemaContext schemaContext;
 
     @Before
-    public void init() throws ReactorException {
+    public void init() {
         this.schemaContext = TestModel.createTestContext("/bug5968/foo.yang");
         assertNotNull("Schema context must not be null.", this.schemaContext);
     }
 
-    private static InMemoryDataTree initDataTree(final SchemaContext schemaContext, final boolean withMapNode)
+    private static DataTree initDataTree(final SchemaContext schemaContext, final boolean withMapNode)
             throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+                DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
 
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT));
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.merge(
                 YangInstanceIdentifier.of(ROOT),
                 withMapNode ? root.withChild(
@@ -70,24 +70,20 @@ public class Bug5968MergeTest {
         return inMemoryDataTree;
     }
 
-    private static InMemoryDataTree emptyDataTree(final SchemaContext schemaContext)
+    private static DataTree emptyDataTree(final SchemaContext schemaContext)
             throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
-
-        return inMemoryDataTree;
+        return new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
     }
 
     @Test
-    public void mergeInvalidContainerTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
+    public void mergeInvalidContainerTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
 
         final MapNode myList = createMap(true);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.merge(YangInstanceIdentifier.of(ROOT), root.build());
 
         try {
@@ -104,9 +100,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void mergeInvalidMapTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void mergeInvalidMapTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         mergeMap(modificationTree, true);
 
         try {
@@ -123,9 +119,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void mergeInvalidMapEntryTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext, true);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void mergeInvalidMapEntryTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = initDataTree(schemaContext, true);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         mergeMapEntry(modificationTree, "1", null, "common-value");
 
@@ -142,7 +138,7 @@ public class Bug5968MergeTest {
         }
     }
 
-    private static void mergeMap(final InMemoryDataTreeModification modificationTree,
+    private static void mergeMap(final DataTreeModification modificationTree,
             final boolean mandatoryDataMissing) throws DataValidationFailedException {
         final MapNode myList = createMap(mandatoryDataMissing);
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), myList);
@@ -157,7 +153,7 @@ public class Bug5968MergeTest {
                                 "mandatory-value", "common-value")).build();
     }
 
-    private static void mergeMapEntry(final InMemoryDataTreeModification modificationTree, final Object listIdValue,
+    private static void mergeMapEntry(final DataTreeModification modificationTree, final Object listIdValue,
             final Object mandatoryLeafValue, final Object commonLeafValue) throws DataValidationFailedException {
         final MapEntryNode taskEntryNode = mandatoryLeafValue == null ? createMapEntry(listIdValue, commonLeafValue)
                 : createMapEntry(listIdValue, mandatoryLeafValue, commonLeafValue);
@@ -194,14 +190,14 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void mergeValidContainerTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
+    public void mergeValidContainerTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
 
         final MapNode myList = createMap(false);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.merge(YangInstanceIdentifier.of(ROOT), root.build());
         modificationTree.ready();
         inMemoryDataTree.validate(modificationTree);
@@ -210,9 +206,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void mergeValidMapTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void mergeValidMapTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         mergeMap(modificationTree, false);
 
         modificationTree.ready();
@@ -222,9 +218,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void mergeValidMapEntryTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext, true);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void mergeValidMapEntryTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = initDataTree(schemaContext, true);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         mergeMapEntry(modificationTree, "1", "mandatory-value", "common-value");
 
@@ -235,9 +231,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void validMultiStepsMergeTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void validMultiStepsMergeTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         modificationTree.merge(YangInstanceIdentifier.of(ROOT), createContainerBuilder().build());
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
@@ -257,9 +253,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void invalidMultiStepsMergeTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void invalidMultiStepsMergeTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         modificationTree.merge(YangInstanceIdentifier.of(ROOT), createContainerBuilder().build());
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
@@ -301,9 +297,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void validMultiStepsWriteAndMergeTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void validMultiStepsWriteAndMergeTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         modificationTree.write(YangInstanceIdentifier.of(ROOT), createContainerBuilder().build());
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
@@ -323,9 +319,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void invalidMultiStepsWriteAndMergeTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void invalidMultiStepsWriteAndMergeTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         modificationTree.write(YangInstanceIdentifier.of(ROOT), createContainerBuilder().build());
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
@@ -352,9 +348,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void validMapEntryMultiCommitMergeTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void validMapEntryMultiCommitMergeTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         modificationTree.write(YangInstanceIdentifier.of(ROOT), createContainerBuilder().build());
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
@@ -372,7 +368,7 @@ public class Bug5968MergeTest {
         final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
         inMemoryDataTree.commit(prepare);
 
-        final InMemoryDataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree2.merge(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
                         .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
@@ -384,9 +380,9 @@ public class Bug5968MergeTest {
     }
 
     @Test
-    public void invalidMapEntryMultiCommitMergeTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void invalidMapEntryMultiCommitMergeTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         modificationTree.write(YangInstanceIdentifier.of(ROOT), createContainerBuilder().build());
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
@@ -404,7 +400,7 @@ public class Bug5968MergeTest {
         final DataTreeCandidate prepare = inMemoryDataTree.prepare(modificationTree);
         inMemoryDataTree.commit(prepare);
 
-        final InMemoryDataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree2.write(
                 YangInstanceIdentifier.of(ROOT).node(MY_LIST)
                         .node(new NodeIdentifierWithPredicates(MY_LIST, ImmutableMap.of(LIST_ID, "1"))),
@@ -430,16 +426,16 @@ public class Bug5968MergeTest {
         }
     }
 
-    @Test
     /*
      * This test consists of two transactions (i.e. data tree modifications) on
      * empty data tree. The first one writes mandatory data and second one
      * writes common data without any mandatory data.
      */
-    public void validMapEntryMultiCommitMergeTest2() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
-        final InMemoryDataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
+    @Test
+    public void validMapEntryMultiCommitMergeTest2() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
 
         modificationTree.write(YangInstanceIdentifier.of(ROOT), createContainerBuilder().build());
         modificationTree.merge(YangInstanceIdentifier.of(ROOT).node(MY_LIST), createMapBuilder().build());
index 620342422c2e2f7316e2dad6a5005614b480c615..952e0e569ef5c15e79c7bf7d62342e034174fff6 100644 (file)
@@ -21,14 +21,15 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class Bug5968Test {
     private static final String NS = "foo";
@@ -41,20 +42,19 @@ public class Bug5968Test {
     private SchemaContext schemaContext;
 
     @Before
-    public void init() throws ReactorException {
+    public void init() {
         this.schemaContext = TestModel.createTestContext("/bug5968/foo.yang");
         assertNotNull("Schema context must not be null.", this.schemaContext);
     }
 
-    private static InMemoryDataTree initDataTree(final SchemaContext schemaContext, final boolean withMapNode)
+    private static DataTree initDataTree(final SchemaContext schemaContext, final boolean withMapNode)
             throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+                DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
 
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT));
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
                 YangInstanceIdentifier.of(ROOT),
                 withMapNode ? root.withChild(
@@ -69,24 +69,20 @@ public class Bug5968Test {
         return inMemoryDataTree;
     }
 
-    private static InMemoryDataTree emptyDataTree(final SchemaContext schemaContext)
+    private static DataTree emptyDataTree(final SchemaContext schemaContext)
             throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
-
-        return inMemoryDataTree;
+        return new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
     }
 
     @Test
-    public void writeInvalidContainerTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
+    public void writeInvalidContainerTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
 
         final MapNode myList = createMap(true);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(YangInstanceIdentifier.of(ROOT), root.build());
 
         try {
@@ -103,9 +99,9 @@ public class Bug5968Test {
     }
 
     @Test
-    public void writeInvalidMapTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void writeInvalidMapTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         writeMap(modificationTree, true);
 
         try {
@@ -122,9 +118,9 @@ public class Bug5968Test {
     }
 
     @Test
-    public void writeInvalidMapEntryTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext, true);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void writeInvalidMapEntryTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = initDataTree(schemaContext, true);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         writeMapEntry(modificationTree, "1", null, "common-value");
 
@@ -141,8 +137,7 @@ public class Bug5968Test {
         }
     }
 
-    private static void writeMap(final InMemoryDataTreeModification modificationTree,
-            final boolean mandatoryDataMissing) {
+    private static void writeMap(final DataTreeModification modificationTree, final boolean mandatoryDataMissing) {
         final MapNode myList = createMap(mandatoryDataMissing);
         modificationTree.write(YangInstanceIdentifier.of(ROOT).node(MY_LIST), myList);
     }
@@ -156,7 +151,7 @@ public class Bug5968Test {
                                 "mandatory-value", "common-value")).build();
     }
 
-    private static void writeMapEntry(final InMemoryDataTreeModification modificationTree, final Object listIdValue,
+    private static void writeMapEntry(final DataTreeModification modificationTree, final Object listIdValue,
             final Object mandatoryLeafValue, final Object commonLeafValue) throws DataValidationFailedException {
         final MapEntryNode taskEntryNode = mandatoryLeafValue == null ? createMapEntry(listIdValue, commonLeafValue)
                 : createMapEntry(listIdValue, mandatoryLeafValue, commonLeafValue);
@@ -184,14 +179,14 @@ public class Bug5968Test {
     }
 
     @Test
-    public void writeValidContainerTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
+    public void writeValidContainerTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
 
         final MapNode myList = createMap(false);
         final DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> root = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(ROOT)).withChild(myList);
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(YangInstanceIdentifier.of(ROOT), root.build());
         modificationTree.ready();
         inMemoryDataTree.validate(modificationTree);
@@ -200,9 +195,9 @@ public class Bug5968Test {
     }
 
     @Test
-    public void writeValidMapTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = emptyDataTree(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void writeValidMapTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = emptyDataTree(schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         writeMap(modificationTree, false);
 
         modificationTree.ready();
@@ -212,9 +207,9 @@ public class Bug5968Test {
     }
 
     @Test
-    public void writeValidMapEntryTest() throws ReactorException, DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext, true);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    public void writeValidMapEntryTest() throws DataValidationFailedException {
+        final DataTree inMemoryDataTree = initDataTree(schemaContext, true);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         writeMapEntry(modificationTree, "1", "mandatory-value", "common-value");
 
index 842c908b7fa540d9ddca4c1d4d9dcf81decb5e0e..04fdc98ea05fd82b18150833d07e10c26eea94df 100644 (file)
@@ -17,8 +17,10 @@ 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;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
@@ -39,24 +41,22 @@ public class Bug8291Test {
         assertNotNull("Schema context must not be null.", this.schemaContext);
     }
 
-    private static InMemoryDataTree initDataTree(final SchemaContext schemaContext)
+    private static DataTree initDataTree(final SchemaContext schemaContext)
             throws DataValidationFailedException {
         final DataTreeConfiguration config = new DataTreeConfiguration.Builder(TreeType.CONFIGURATION).setRootPath(
                 YangInstanceIdentifier.of(ROOT).node(OUTER_LIST)).build();
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-                config, schemaContext);
-        return inMemoryDataTree;
+        return new InMemoryDataTreeFactory().create(config, schemaContext);
     }
 
     @Test
     public void test() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(schemaContext);
+        final DataTree inMemoryDataTree = initDataTree(schemaContext);
         writeOuterListMapEntry(inMemoryDataTree);
         writeInnerList(inMemoryDataTree);
     }
 
-    private static void writeInnerList(final InMemoryDataTree inMemoryDataTree) throws DataValidationFailedException {
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+    private static void writeInnerList(final DataTree inMemoryDataTree) throws DataValidationFailedException {
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(
                 YangInstanceIdentifier.create(
                         new NodeIdentifierWithPredicates(OUTER_LIST, ImmutableMap.of(OUTER_LIST_ID, 1))).node(
@@ -68,9 +68,9 @@ public class Bug8291Test {
         inMemoryDataTree.commit(prepare);
     }
 
-    private static void writeOuterListMapEntry(final InMemoryDataTree inMemoryDataTree)
+    private static void writeOuterListMapEntry(final DataTree inMemoryDataTree)
             throws DataValidationFailedException {
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
 
         final MapEntryNode outerListMapEntry = Builders.mapEntryBuilder()
                 .withNodeIdentifier(new NodeIdentifierWithPredicates(OUTER_LIST, ImmutableMap.of(OUTER_LIST_ID, 1)))
index 34fc961311c1f1d7095ab71ce37cf59b310ba661..edc2091720bc7183041504eca9ee408ba9398d5f 100644 (file)
@@ -19,12 +19,13 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.Augmentat
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class CaseAugmentTest {
 
@@ -39,21 +40,20 @@ public class CaseAugmentTest {
         ImmutableSet.of(C1L2_QNAME, C1L3_QNAME));
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = TestModel.createTestContext("/case-augment-test.yang");
         assertNotNull("Schema context must not be null.", schemaContext);
     }
 
-    private InMemoryDataTree initDataTree() {
-        InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+    private DataTree initDataTree() {
+        DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
         return inMemoryDataTree;
     }
 
     @Test
     public void testWriteAugment() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree();
+        final DataTree inMemoryDataTree = initDataTree();
 
         AugmentationNode augmentationNode = Builders.augmentationBuilder()
                 .withNodeIdentifier(AUGMENT_ID)
@@ -66,7 +66,7 @@ public class CaseAugmentTest {
                         Builders.choiceBuilder().withNodeIdentifier(CHOICE_ID)
                                 .withChild(augmentationNode)
                                 .build()).build();
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, container);
         modificationTree.ready();
 
@@ -77,7 +77,7 @@ public class CaseAugmentTest {
 
     @Test
     public void testWriteCase1All() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree();
+        final DataTree inMemoryDataTree = initDataTree();
 
         AugmentationNode augmentationNode = Builders.augmentationBuilder()
                 .withNodeIdentifier(AUGMENT_ID)
@@ -93,7 +93,7 @@ public class CaseAugmentTest {
                                 .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
                                 .withChild(augmentationNode)
                                 .build()).build();
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, container);
         modificationTree.ready();
 
@@ -104,7 +104,7 @@ public class CaseAugmentTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testWriteConflict() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree();
+        final DataTree inMemoryDataTree = initDataTree();
 
         AugmentationNode augmentationNode = Builders.augmentationBuilder()
                 .withNodeIdentifier(AUGMENT_ID)
@@ -120,7 +120,7 @@ public class CaseAugmentTest {
                                 .build()).build();
 
         try {
-            final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+            final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
             modificationTree.write(TestModel.TEST_PATH, container);
             modificationTree.ready();
 
@@ -132,5 +132,4 @@ public class CaseAugmentTest {
             throw e;
         }
     }
-
 }
index 77878f549cb9621d257e4b9d90f47f709e0ae397..89a2c0be84a73072b7d940a8b5f94e80e410cfff 100644 (file)
@@ -17,34 +17,32 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 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 CaseExclusionTest {
 
     private SchemaContext schemaContext;
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = TestModel.createTestContext("/case-exclusion-test.yang");
         assertNotNull("Schema context must not be null.", schemaContext);
     }
 
-    private InMemoryDataTree initDataTree() {
-        InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
-        return inMemoryDataTree;
+    private DataTree initDataTree() {
+        return new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
     }
 
     @Test
     public void testCorrectCaseWrite() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree();
+        final DataTree inMemoryDataTree = initDataTree();
         final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
         final ContainerNode container = Builders
@@ -54,7 +52,7 @@ public class CaseExclusionTest {
                         Builders.choiceBuilder().withNodeIdentifier(choice1Id)
                                 .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value"))
                                 .build()).build();
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, container);
         modificationTree.ready();
 
@@ -65,7 +63,7 @@ public class CaseExclusionTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testCaseExclusion() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree();
+        final DataTree inMemoryDataTree = initDataTree();
         final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
         final ContainerNode container = Builders
@@ -79,7 +77,7 @@ public class CaseExclusionTest {
                                         ImmutableNodes.containerNode(QName.create(TestModel.TEST_QNAME, "case2-cont")))
                                 .build()).build();
         try {
-            final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+            final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
             modificationTree.write(TestModel.TEST_PATH, container);
             modificationTree.ready();
 
@@ -94,12 +92,12 @@ public class CaseExclusionTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testCaseExclusionOnChoiceWrite() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree();
+        final DataTree inMemoryDataTree = initDataTree();
         // Container write
         final ContainerNode container = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
-        final InMemoryDataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree1.write(TestModel.TEST_PATH, container);
         modificationTree1.ready();
 
@@ -114,7 +112,7 @@ public class CaseExclusionTest {
                 .withChild(ImmutableNodes.containerNode(QName.create(TestModel.TEST_QNAME, "case2-cont"))).build();
 
         try {
-            final InMemoryDataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
+            final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
             modificationTree2.write(TestModel.TEST_PATH.node(choice1Id), choice);
             modificationTree2.ready();
 
index a696d5a5c816cd65181a48dcff7aa8e38a5a5258..f511fc326b7ee1fd0be1e3dcee082af12e9c3876 100644 (file)
@@ -23,14 +23,15 @@ import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -59,15 +60,14 @@ public class ConcurrentTreeModificationTest {
             .build();
 
     private SchemaContext schemaContext;
-    private InMemoryDataTree inMemoryDataTree;
+    private DataTree inMemoryDataTree;
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = TestModel.createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            schemaContext);
     }
 
     private static ContainerNode createFooTestContainerNode() {
@@ -96,7 +96,7 @@ public class ConcurrentTreeModificationTest {
 
     @Test
     public void writeWrite1stLevelEmptyTreeTest() throws DataValidationFailedException {
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -125,7 +125,7 @@ public class ConcurrentTreeModificationTest {
 
     @Test
     public void writeMerge1stLevelEmptyTreeTest() throws DataValidationFailedException {
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -150,7 +150,7 @@ public class ConcurrentTreeModificationTest {
 
     @Test
     public void writeWriteFooBar1stLevelEmptyTreeTest() throws DataValidationFailedException {
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -173,14 +173,14 @@ public class ConcurrentTreeModificationTest {
             LOG.debug("ConflictingModificationAppliedException - '{}' was thrown as expected.");
         }
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertFalse(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH).isPresent());
     }
 
     @Test
     public void writeMergeFooBar1stLevelEmptyTreeTest() throws DataValidationFailedException {
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -198,14 +198,14 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
 
     @Test
     public void mergeWriteFooBar1stLevelEmptyTreeTest() throws DataValidationFailedException {
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -228,14 +228,14 @@ public class ConcurrentTreeModificationTest {
             LOG.debug("ConflictingModificationAppliedException - '{}' was thrown as expected.");
         }
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertFalse(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH).isPresent());
     }
 
     @Test
     public void mergeMergeFooBar1stLevelEmptyTreeTest() throws DataValidationFailedException {
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -253,7 +253,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
@@ -264,7 +264,7 @@ public class ConcurrentTreeModificationTest {
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -287,7 +287,7 @@ public class ConcurrentTreeModificationTest {
             LOG.debug("ConflictingModificationAppliedException - '{}' was thrown as expected.");
         }
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertFalse(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH).isPresent());
     }
@@ -298,7 +298,7 @@ public class ConcurrentTreeModificationTest {
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -316,7 +316,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
@@ -327,7 +327,7 @@ public class ConcurrentTreeModificationTest {
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -351,7 +351,7 @@ public class ConcurrentTreeModificationTest {
         }
 
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertFalse(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH).isPresent());
     }
@@ -362,7 +362,7 @@ public class ConcurrentTreeModificationTest {
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -380,7 +380,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
@@ -391,7 +391,7 @@ public class ConcurrentTreeModificationTest {
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -415,7 +415,7 @@ public class ConcurrentTreeModificationTest {
         }
 
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertFalse(snapshotAfterCommits.readNode(TestModel.TEST_PATH).isPresent());
     }
 
@@ -425,7 +425,7 @@ public class ConcurrentTreeModificationTest {
         initialDataTreeModification.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -443,7 +443,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
 
@@ -455,7 +455,7 @@ public class ConcurrentTreeModificationTest {
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -473,7 +473,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
@@ -486,7 +486,7 @@ public class ConcurrentTreeModificationTest {
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -504,7 +504,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
@@ -517,7 +517,7 @@ public class ConcurrentTreeModificationTest {
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -535,7 +535,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
@@ -548,7 +548,7 @@ public class ConcurrentTreeModificationTest {
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -566,7 +566,7 @@ public class ConcurrentTreeModificationTest {
         final DataTreeCandidate prepare2 = inMemoryDataTree.prepare(modificationTree2);
         inMemoryDataTree.commit(prepare2);
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_1_PATH), MapEntryNode.class);
         assertPresentAndType(snapshotAfterCommits.readNode(OUTER_LIST_2_PATH), MapEntryNode.class);
     }
@@ -579,7 +579,7 @@ public class ConcurrentTreeModificationTest {
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -602,7 +602,7 @@ public class ConcurrentTreeModificationTest {
             LOG.debug("Exception was thrown because path no longer exist in tree", e);
         }
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertFalse(snapshotAfterCommits.readNode(TestModel.TEST_PATH).isPresent());
     }
 
@@ -614,7 +614,7 @@ public class ConcurrentTreeModificationTest {
             .build());
         initialDataTreeModification.ready();
         inMemoryDataTree.commit(inMemoryDataTree.prepare(initialDataTreeModification));
-        final InMemoryDataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
 
         final DataTreeModification modificationTree1 = initialDataTreeSnapshot.newModification();
         final DataTreeModification modificationTree2 = initialDataTreeSnapshot.newModification();
@@ -637,7 +637,7 @@ public class ConcurrentTreeModificationTest {
             LOG.debug("Exception was thrown because path no longer exist in tree", e);
         }
 
-        final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+        final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
         assertFalse(snapshotAfterCommits.readNode(TestModel.TEST_PATH).isPresent());
     }
 }
index d2da63d0f0f5bd3c246a93883277b889f000575b..33b1701f83118bfac88d305ea3b12ec8d47c3c29 100644 (file)
@@ -21,14 +21,15 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 // TODO: expand these tests to catch some more obscure cases
 public class ConfigStatementValidationTest {
@@ -75,17 +76,16 @@ public class ConfigStatementValidationTest {
     }
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = TestModel.createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
     }
 
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnPathFail() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         final YangInstanceIdentifier ii = OUTER_LIST_1_PATH.node(
                 new YangInstanceIdentifier.NodeIdentifier(TestModel.INNER_LIST_QNAME)).node(
                 INNER_FOO_ENTRY_NODE.getIdentifier());
@@ -98,10 +98,9 @@ public class ConfigStatementValidationTest {
 
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnDataFail() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, createFooTestContainerNode());
         modificationTree.ready();
         inMemoryDataTree.validate(modificationTree);
@@ -111,10 +110,9 @@ public class ConfigStatementValidationTest {
 
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnDataLeafFail() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, createBarTestContainerNode());
         modificationTree.ready();
         inMemoryDataTree.validate(modificationTree);
@@ -124,9 +122,8 @@ public class ConfigStatementValidationTest {
 
     @Test(expected = SchemaValidationFailedException.class)
     public void testOnPathCaseLeafFail() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
         final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(
                 TestModel.TEST_QNAME, "choice1"));
         final YangInstanceIdentifier.NodeIdentifier case2ContId = new YangInstanceIdentifier.NodeIdentifier(
@@ -135,7 +132,7 @@ public class ConfigStatementValidationTest {
         final ContainerNode case2Cont = Builders.containerBuilder().withNodeIdentifier(case2ContId)
                 .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf1"), "leaf-value")).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(ii, case2Cont);
         modificationTree.ready();
         inMemoryDataTree.validate(modificationTree);
@@ -145,16 +142,15 @@ public class ConfigStatementValidationTest {
 
     @Test(expected = VerifyException.class)
     public void testOnDataCaseLeafFail() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_CONFIGURATION);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        final DataTree inMemoryDataTree = new InMemoryDataTreeFactory().create(
+            DataTreeConfiguration.DEFAULT_CONFIGURATION, schemaContext);
         final YangInstanceIdentifier.NodeIdentifier choice1Id = new YangInstanceIdentifier.NodeIdentifier(QName.create(
                 TestModel.TEST_QNAME, "choice1"));
         final YangInstanceIdentifier ii = TestModel.TEST_PATH.node(choice1Id);
         final ChoiceNode choice1 = Builders.choiceBuilder().withNodeIdentifier(choice1Id)
                 .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case1-leaf1"), "leaf-value")).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(ii, choice1);
         modificationTree.ready();
         inMemoryDataTree.validate(modificationTree);
index 55c4e395a4182c5e153498a634d6225fca110e17..6a45d8590ee105fd8d9f2ec6c1e8aea73d7003fa 100644 (file)
@@ -41,8 +41,7 @@ public class DataTreeCandidatesTest {
 
     @Before
     public void setUp() throws Exception {
-        dataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        dataTree.setSchemaContext(SCHEMA_CONTEXT);
+        dataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, SCHEMA_CONTEXT);
 
         final ContainerNode testContainer = ImmutableContainerNodeBuilder.create()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME))
@@ -64,7 +63,7 @@ public class DataTreeCandidatesTest {
 
     @Test
     public void testRootedCandidate() throws DataValidationFailedException {
-        final DataTree innerDataTree = InMemoryDataTreeFactory.getInstance().create(
+        final DataTree innerDataTree = new InMemoryDataTreeFactory().create(
             new DataTreeConfiguration.Builder(TreeType.OPERATIONAL)
             .setMandatoryNodesValidation(true)
             .setRootPath(TestModel.INNER_CONTAINER_PATH)
index 1f1e7cb90a568617cfece090610724dcb680b539..1ce0fdb7bbbd4629c8be8376e550c8bc740c5e7d 100644 (file)
@@ -13,15 +13,14 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class DataTreeTransactionTest {
     private DataTree tree;
 
     @Before
-    public void setUp() throws ReactorException {
-        tree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        tree.setSchemaContext(TestModel.createTestContext());
+    public void setUp() {
+        tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            TestModel.createTestContext());
     }
 
     @Test
index 2618589f1bd479412c8bd632e8e2d531d35bd64c..90928a1a30b46884e5980563cb8af14196528e7e 100644 (file)
@@ -13,26 +13,26 @@ import static org.junit.Assert.fail;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ModifiedNodeDoesNotExistException;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class ErrorReportingTest {
 
-    private InMemoryDataTree tree;
+    private DataTree tree;
 
     @Before
-    public void setup() throws ReactorException {
-        tree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
-            DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        tree.setSchemaContext(TestModel.createTestContext());
+    public void setup() {
+        tree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            TestModel.createTestContext());
     }
 
     @Test
     public void writeWithoutParentExisting() {
-        InMemoryDataTreeModification modification = tree.takeSnapshot().newModification();
+        DataTreeModification modification = tree.takeSnapshot().newModification();
         // We write node without creating parent
         modification.write(TestModel.OUTER_LIST_PATH, ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
             .build());
@@ -49,15 +49,15 @@ public class ErrorReportingTest {
 
     @Test
     public void parentConcurrentlyDeletedExisting() {
-        InMemoryDataTreeModification initial = tree.takeSnapshot().newModification();
+        DataTreeModification initial = tree.takeSnapshot().newModification();
         // We write node without creating parent
         initial.write(TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
         initial.ready();
         // We commit transaction
         tree.commit(tree.prepare(initial));
 
-        final InMemoryDataTreeModification writeTx = tree.takeSnapshot().newModification();
-        final InMemoryDataTreeModification deleteTx = tree.takeSnapshot().newModification();
+        final DataTreeModification writeTx = tree.takeSnapshot().newModification();
+        final DataTreeModification deleteTx = tree.takeSnapshot().newModification();
         deleteTx.delete(TestModel.TEST_PATH);
         deleteTx.ready();
         // We commit delete modification
index 874e43f0aeb70115cbfdb1844d6cc560ddc7a291..7a3fa56c84e4fd5c08078599de42ea9d28a7cafc 100644 (file)
@@ -75,8 +75,8 @@ public class ListConstraintsValidation {
     public void prepare() {
         schemaContext = createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(schemaContext);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            schemaContext);
         final DataTreeSnapshot initialDataTreeSnapshot = inMemoryDataTree.takeSnapshot();
         final DataTreeModification modificationTree = initialDataTreeSnapshot.newModification();
 
index 12168b9d1b0b9ca88b0af9df56f9c8cc254d5dab..a9509322919a9e705d6c6b880b5bc4aa2fa61ea6 100644 (file)
@@ -17,35 +17,34 @@ import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.TreeType;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 public class MandatoryLeafTest {
 
     private SchemaContext schemaContext;
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = TestModel.createTestContext("/mandatory-leaf-test.yang");
         assertNotNull("Schema context must not be null.", schemaContext);
     }
 
-    private InMemoryDataTree initDataTree(final boolean enableValidation) {
-        final InMemoryDataTree inMemoryDataTree = (InMemoryDataTree) InMemoryDataTreeFactory.getInstance().create(
+    private DataTree initDataTree(final boolean enableValidation) {
+        return new InMemoryDataTreeFactory().create(
                 new DataTreeConfiguration.Builder(TreeType.CONFIGURATION).setMandatoryNodesValidation(enableValidation)
-                        .build());
-        inMemoryDataTree.setSchemaContext(schemaContext);
-        return inMemoryDataTree;
+                        .build(), schemaContext);
     }
 
     @Test
     public void testCorrectMandatoryLeafWrite() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(true);
+        final DataTree inMemoryDataTree = initDataTree(true);
         final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
         final ContainerNode container = Builders
@@ -66,7 +65,7 @@ public class MandatoryLeafTest {
                                                         leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"),
                                                                 "leaf-value2")).build()).build()).build();
 
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, container);
         modificationTree.ready();
 
@@ -77,12 +76,12 @@ public class MandatoryLeafTest {
 
     @Test
     public void testCorrectMandatoryLeafChoiceWrite() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(true);
+        final DataTree inMemoryDataTree = initDataTree(true);
         // Container write
         final ContainerNode container = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
-        final InMemoryDataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree1.write(TestModel.TEST_PATH, container);
         modificationTree1.ready();
 
@@ -103,7 +102,7 @@ public class MandatoryLeafTest {
                                 .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                                 .build()).build();
 
-        final InMemoryDataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree2.write(TestModel.TEST_PATH.node(choice1Id), choice);
         modificationTree2.ready();
 
@@ -114,7 +113,7 @@ public class MandatoryLeafTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testMandatoryLeafViolation() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(true);
+        final DataTree inMemoryDataTree = initDataTree(true);
         final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
         final ContainerNode container = Builders
@@ -132,7 +131,7 @@ public class MandatoryLeafTest {
                                                         leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"),
                                                                 "leaf-value2")).build()).build()).build();
         try {
-            final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+            final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
             modificationTree.write(TestModel.TEST_PATH, container);
             modificationTree.ready();
 
@@ -150,7 +149,7 @@ public class MandatoryLeafTest {
 
     @Test
     public void testDisabledValidation() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(false);
+        final DataTree inMemoryDataTree = initDataTree(false);
         final NodeIdentifier choice1Id = new NodeIdentifier(QName.create(TestModel.TEST_QNAME, "choice1"));
 
         final ContainerNode container = Builders
@@ -167,7 +166,7 @@ public class MandatoryLeafTest {
                                                 .withChild(
                                                         leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"),
                                                                 "leaf-value2")).build()).build()).build();
-        final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree.write(TestModel.TEST_PATH, container);
         modificationTree.ready();
 
@@ -178,12 +177,12 @@ public class MandatoryLeafTest {
 
     @Test(expected = IllegalArgumentException.class)
     public void testMandatoryLeafViolationChoiceWrite() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(true);
+        final DataTree inMemoryDataTree = initDataTree(true);
         // Container write
         final ContainerNode container = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
-        final InMemoryDataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree1.write(TestModel.TEST_PATH, container);
         modificationTree1.ready();
 
@@ -204,7 +203,7 @@ public class MandatoryLeafTest {
                                 .build()).build();
 
         try {
-            final InMemoryDataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
+            final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
             modificationTree2.write(TestModel.TEST_PATH.node(choice1Id), choice);
             modificationTree2.ready();
             inMemoryDataTree.validate(modificationTree2);
@@ -221,12 +220,12 @@ public class MandatoryLeafTest {
 
     @Test
     public void testDisabledValidationChoiceWrite() throws DataValidationFailedException {
-        final InMemoryDataTree inMemoryDataTree = initDataTree(false);
+        final DataTree inMemoryDataTree = initDataTree(false);
         // Container write
         final ContainerNode container = Builders.containerBuilder()
                 .withNodeIdentifier(new NodeIdentifier(TestModel.TEST_QNAME)).build();
 
-        final InMemoryDataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree1 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree1.write(TestModel.TEST_PATH, container);
         modificationTree1.ready();
 
@@ -246,7 +245,7 @@ public class MandatoryLeafTest {
                                 .withChild(leafNode(QName.create(TestModel.TEST_QNAME, "case2-leaf2"), "leaf-value2"))
                                 .build()).build();
 
-        final InMemoryDataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
+        final DataTreeModification modificationTree2 = inMemoryDataTree.takeSnapshot().newModification();
         modificationTree2.write(TestModel.TEST_PATH.node(choice1Id), choice);
         modificationTree2.ready();
         inMemoryDataTree.validate(modificationTree2);
index 3c75e42cf0626c650ec520bbfa38881d6dc224d3..c44addb20500a363fac4233364b85b1bb19977db 100644 (file)
@@ -33,7 +33,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 
 /*
  * Schema structure of document is
@@ -95,7 +94,7 @@ public class ModificationMetadataTreeTest {
     private RootModificationApplyOperation rootOper;
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = TestModel.createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
         rootOper = RootModificationApplyOperation.from(SchemaAwareApplyOperation.from(schemaContext,
@@ -166,8 +165,8 @@ public class ModificationMetadataTreeTest {
         /**
          * Creates empty Snapshot with associated schema context.
          */
-        final DataTree t = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        t.setSchemaContext(schemaContext);
+        final DataTree t = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL,
+            schemaContext);
 
         /**
          *
index 51cab66dad45106f10954986061d0648a6f0f789..f9ce1c1b30b5acd925a823f5acd55fa0b102fb76 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.yangtools.yang.data.impl.schema.tree;
 
 import static org.junit.Assert.assertFalse;
@@ -27,11 +26,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
 import org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.ConflictingModificationAppliedException;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeSnapshot;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
-import org.opendaylight.yangtools.yang.data.api.schema.tree.TipProducingDataTree;
 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -41,7 +40,7 @@ import org.slf4j.LoggerFactory;
 public class OrderedListTest {
     private static final Logger LOG = LoggerFactory.getLogger(OrderedListTest.class);
 
-    private TipProducingDataTree inMemoryDataTree;
+    private DataTree inMemoryDataTree;
     private SchemaContext context;
 
     private QNameModule testModule;
@@ -66,8 +65,7 @@ public class OrderedListTest {
         childKeyLeaf = QName.create(testModule, "child-key-leaf");
         parentOrdinaryLeaf = QName.create(testModule, "parent-ordinary-leaf");
         childOrdinaryLeaf = QName.create(testModule, "child-ordinary-leaf");
-        inMemoryDataTree = InMemoryDataTreeFactory.getInstance().create(DataTreeConfiguration.DEFAULT_OPERATIONAL);
-        inMemoryDataTree.setSchemaContext(context);
+        inMemoryDataTree = new InMemoryDataTreeFactory().create(DataTreeConfiguration.DEFAULT_OPERATIONAL, context);
     }
 
     @Test
index 4635ee64458a281304319d34faea331c0f85af14..919178ca17dcce3e4fb8a2bfd34dcd6800ec1c0d 100644 (file)
@@ -31,7 +31,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.TreeNodeFactory;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.spi.Version;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -69,7 +68,7 @@ public class StoreTreeNodesTest {
     private RootModificationApplyOperation rootOper;
 
     @Before
-    public void prepare() throws ReactorException {
+    public void prepare() {
         schemaContext = TestModel.createTestContext();
         assertNotNull("Schema context must not be null.", schemaContext);
         rootOper = RootModificationApplyOperation.from(SchemaAwareApplyOperation.from(schemaContext,
index e0144cda42013e5b2499ab495657822df2c505e3..6bfd4f3dc2113466dd51b3d4ddb24b137a022e52 100644 (file)
@@ -19,10 +19,7 @@ import com.google.common.base.VerifyException;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.HashBiMap;
 import com.google.common.collect.Maps;
-import java.io.IOException;
 import java.net.URI;
-import java.net.URISyntaxException;
-import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
@@ -33,7 +30,6 @@ import org.jaxen.Context;
 import org.jaxen.Function;
 import org.jaxen.FunctionCallException;
 import org.jaxen.UnresolvableException;
-import org.jaxen.UnsupportedAxisException;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -48,7 +44,6 @@ import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathResult;
 import org.opendaylight.yangtools.yang.data.api.schema.xpath.XPathSchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
 public class JaxenTest {
@@ -69,9 +64,8 @@ public class JaxenTest {
     private QName containerBQName;
 
     @Before
-    public void setup() throws URISyntaxException, IOException, ParseException, XPathExpressionException,
-            UnsupportedAxisException, ReactorException {
-        final SchemaContext schemaContext = createSchemaContext();
+    public void setup() throws XPathExpressionException {
+        final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory("/test/documentTest");
         assertNotNull(schemaContext);
 
         initQNames();
@@ -82,7 +76,7 @@ public class JaxenTest {
                     false));
         assertNotNull(xpathExpression);
 
-        xpathDocument = xpathSchemaContext.createDocument(createNormalizedNodes());
+        xpathDocument = xpathSchemaContext.createDocument(TestUtils.createNormalizedNodes());
         assertNotNull(xpathDocument);
         String rootNodeName = xpathDocument.getRootNode().getNodeType().getLocalName();
         assertNotNull(rootNodeName);
@@ -219,16 +213,8 @@ public class JaxenTest {
         return SchemaPath.create(true, rootQName, listAQName, leafAQName);
     }
 
-    private static SchemaContext createSchemaContext() throws IOException, URISyntaxException, ReactorException {
-        return YangParserTestUtils.parseYangResourceDirectory("/test/documentTest");
-    }
-
-    private static NormalizedNode<?, ?> createNormalizedNodes() {
-        return TestUtils.createNormalizedNodes();
-    }
-
-    private void initQNames() throws URISyntaxException, ParseException {
-        this.moduleQName = QNameModule.create(new URI("urn:opendaylight.test2"), Revision.of("2015-08-08"));
+    private void initQNames() {
+        this.moduleQName = QNameModule.create(URI.create("urn:opendaylight.test2"), Revision.of("2015-08-08"));
         this.rootQName = QName.create(moduleQName, "root");
         this.listAQName = QName.create(moduleQName, "list-a");
         this.listBQName = QName.create(moduleQName, "list-b");
index 1ef59e0b9fdc2c4d416a60ac4519b32e7ec65c77..ae0979cd29df83121c97ceec1b1c1ec32a282f20 100644 (file)
@@ -16,7 +16,6 @@ import java.io.BufferedOutputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
-import java.net.URISyntaxException;
 import javax.xml.stream.XMLStreamException;
 import org.custommonkey.xmlunit.Diff;
 import org.custommonkey.xmlunit.ElementNameAndAttributeQualifier;
@@ -26,7 +25,6 @@ import org.junit.Test;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.export.YinExportUtils;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 import org.xml.sax.SAXException;
@@ -34,8 +32,7 @@ import org.xml.sax.SAXException;
 public class SchemaContextEmitterTest {
 
     @Test
-    public void testSchemaContextEmitter() throws ReactorException, IOException, URISyntaxException,
-            XMLStreamException, SAXException {
+    public void testSchemaContextEmitter() throws IOException, XMLStreamException, SAXException {
         final SchemaContext schemaContext = YangParserTestUtils.parseYangResourceDirectory(
             "/schema-context-emitter-test");
         assertNotNull(schemaContext);