* a candidate commit needs to be coordinated across distributed parties.
*/
@Beta
-public interface DataTreeCandidateTip extends DataTreeCandidate, TipProducingDataTreeTip {
+public interface DataTreeCandidateTip extends DataTreeCandidate, DataTreeTip {
}
* Data tree modification.
* @return candidate data tree
*/
- DataTreeCandidate prepare(DataTreeModification modification);
+ DataTreeCandidateTip prepare(DataTreeModification modification);
/**
* {@inheritDoc}
+++ /dev/null
-/*
- * 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 {
-
-}
+++ /dev/null
-/*
- * 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);
-}
*/
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;
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 {
@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);
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);
}
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;
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;
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());
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;
}
@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();
}
@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");
}
@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");
}
@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");
}
@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");
}
@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");
}
@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");
}
@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");
}
@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");
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>
<!--
--- /dev/null
+/*
+ * 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;
+ }
+ }
+}
--- /dev/null
+/*
+ * 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
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;
/**
* 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);
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;
/**
* 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);
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());
// 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;
- }
}
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;
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;
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);
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;
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"));
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;
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;
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;
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;
}
@BeforeClass
- public static void init() throws FileNotFoundException, ReactorException,
- URISyntaxException {
+ public static void init() {
initSchemaContext();
initLeafRefContext();
}
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();
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;
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;
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;
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;
}
@BeforeClass
- public static void init() throws FileNotFoundException, ReactorException, URISyntaxException {
-
+ public static void init() {
initSchemaContext();
initLeafRefContext();
initQnames();
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();
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;
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;
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();
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;
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 {
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);
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;
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 {
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()
}
@Test
- public void testInAugmentLeafOverride() throws Exception {
+ public void testInAugmentLeafOverride() {
final LeafNode<Object> lastLeaf = Builders.leafBuilder().withNodeIdentifier(augmentedLeaf)
.withValue("randomValue").build();
}
@Test
- public void testListChoice() throws Exception {
+ public void testListChoice() {
final LeafNode<?> leaf = Builders.leafBuilder().withNodeIdentifier(leafFromCase).withValue("").build();
final ContainerNode expectedFilter = Builders
.containerBuilder()
}
@Test
- public void testTopContainerLastChildOverride() throws Exception {
+ public void testTopContainerLastChildOverride() {
final ContainerNode expectedStructure = Builders
.containerBuilder()
.withNodeIdentifier(rootContainer)
}
@Test
- public void testListLastChildOverride() throws Exception {
+ public void testListLastChildOverride() {
final MapEntryNode outerListEntry = Builders
.mapEntryBuilder()
.withNodeIdentifier(outerListWithKey)
}
@Test
- public void testLeafList() throws Exception {
+ public void testLeafList() {
final ContainerNode expectedFilter = Builders
.containerBuilder()
.withNodeIdentifier(rootContainer)
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;
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 {
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");
}
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 {
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);
}
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;
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
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
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;
public class Bug4295Test {
- private TipProducingDataTree inMemoryDataTree;
+ private DataTree inMemoryDataTree;
private SchemaContext context;
private QName root;
private QName subRoot;
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
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;
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 {
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();
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");
}
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";
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();
}
@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);
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);
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);
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);
}
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")))
.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);
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")))
.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);
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")))
.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);
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";
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(
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 {
}
@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 {
}
@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");
}
}
- 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);
"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);
}
@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);
}
@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();
}
@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");
}
@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());
}
@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());
}
@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());
}
@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());
}
@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());
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"))),
}
@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());
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"))),
}
}
- @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());
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";
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(
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 {
}
@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 {
}
@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");
}
}
- 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);
}
"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);
}
@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);
}
@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();
}
@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");
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;
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(
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)))
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 {
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)
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();
@Test
public void testWriteCase1All() throws DataValidationFailedException {
- final InMemoryDataTree inMemoryDataTree = initDataTree();
+ final DataTree inMemoryDataTree = initDataTree();
AugmentationNode augmentationNode = Builders.augmentationBuilder()
.withNodeIdentifier(AUGMENT_ID)
.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();
@Test(expected = IllegalArgumentException.class)
public void testWriteConflict() throws DataValidationFailedException {
- final InMemoryDataTree inMemoryDataTree = initDataTree();
+ final DataTree inMemoryDataTree = initDataTree();
AugmentationNode augmentationNode = Builders.augmentationBuilder()
.withNodeIdentifier(AUGMENT_ID)
.build()).build();
try {
- final InMemoryDataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
+ final DataTreeModification modificationTree = inMemoryDataTree.takeSnapshot().newModification();
modificationTree.write(TestModel.TEST_PATH, container);
modificationTree.ready();
throw e;
}
}
-
}
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
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();
@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
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();
@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();
.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();
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;
.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() {
@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();
@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();
@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();
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();
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();
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();
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);
}
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();
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());
}
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();
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);
}
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();
}
- 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());
}
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();
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);
}
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();
}
- final InMemoryDataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
+ final DataTreeSnapshot snapshotAfterCommits = inMemoryDataTree.takeSnapshot();
assertFalse(snapshotAfterCommits.readNode(TestModel.TEST_PATH).isPresent());
}
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();
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);
}
.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();
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);
}
.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();
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);
}
.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();
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);
}
.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();
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);
}
.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();
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());
}
.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();
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());
}
}
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 {
}
@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());
@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);
@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);
@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(
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);
@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);
@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))
@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)
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
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());
@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
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();
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
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();
@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();
.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();
@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
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();
@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
.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();
@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();
.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);
@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();
.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);
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
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,
/**
* 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);
/**
*
* 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;
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;
public class OrderedListTest {
private static final Logger LOG = LoggerFactory.getLogger(OrderedListTest.class);
- private TipProducingDataTree inMemoryDataTree;
+ private DataTree inMemoryDataTree;
private SchemaContext context;
private QNameModule testModule;
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
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;
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,
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;
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;
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 {
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();
false));
assertNotNull(xpathExpression);
- xpathDocument = xpathSchemaContext.createDocument(createNormalizedNodes());
+ xpathDocument = xpathSchemaContext.createDocument(TestUtils.createNormalizedNodes());
assertNotNull(xpathDocument);
String rootNodeName = xpathDocument.getRootNode().getNodeType().getLocalName();
assertNotNull(rootNodeName);
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");
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;
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;
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);