--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.binding.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class DataTreeIdentifierTest {
+ private static final DataTreeIdentifier<TestDataObject1> TEST_IDENTIFIER1 = DataTreeIdentifier.create(
+ LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(TestDataObject1.class));
+ private static final DataTreeIdentifier<TestDataObject2> TEST_IDENTIFIER2 = DataTreeIdentifier.create(
+ LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(TestDataObject2.class));
+
+ @Test
+ public void containsTest() {
+ assertTrue("Contains", TEST_IDENTIFIER1.contains(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(TestDataObject1.class))));
+ assertFalse("Not Contains", TEST_IDENTIFIER1.contains(TEST_IDENTIFIER2));
+ }
+
+ @Test
+ public void hashCodeTest() {
+ assertEquals("hashCode", TEST_IDENTIFIER1.hashCode(), DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(TestDataObject1.class)).hashCode());
+ assertNotEquals("hashCode", TEST_IDENTIFIER1.hashCode(), TEST_IDENTIFIER2.hashCode());
+ }
+
+ @Test
+ public void equalsTest() {
+ assertTrue("Equals", TEST_IDENTIFIER1.equals(DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL,
+ InstanceIdentifier.create(TestDataObject1.class))));
+ assertFalse("Different", TEST_IDENTIFIER1.equals(DataTreeIdentifier.create(LogicalDatastoreType.CONFIGURATION,
+ InstanceIdentifier.create(TestDataObject1.class))));
+ assertFalse("Different", TEST_IDENTIFIER1.equals(TEST_IDENTIFIER2));
+ }
+
+ private static class TestDataObject1 implements DataObject {
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return null;
+ }
+ }
+
+ private static class TestDataObject2 implements DataObject {
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ return null;
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.binding.data.codec.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.lang.reflect.Method;
+import org.junit.Before;
+import org.junit.Test;
+
+public class UnionValueOptionContextTest {
+ private static UnionValueOptionContext TEST_UVOC_1;
+ private static UnionValueOptionContext TEST_UVOC_2;
+
+ @Before
+ public void setUp() throws Exception {
+ final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
+ final Method methodFoo2 = TestDataObject2.class.getMethod("foo");
+ TEST_UVOC_1 = new UnionValueOptionContext(TestDataObject1.class, methodFoo1, ValueTypeCodec.EMPTY_CODEC);
+ TEST_UVOC_2 = new UnionValueOptionContext(TestDataObject2.class, methodFoo2, ValueTypeCodec.EMPTY_CODEC);
+ }
+
+ @Test
+ public void hashCodeTest() throws Exception {
+ final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
+ final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(TestDataObject1.class, methodFoo1,
+ ValueTypeCodec.EMPTY_CODEC);
+
+ assertEquals("HashCode", test_uvoc.hashCode(), TEST_UVOC_1.hashCode());
+ assertNotEquals("HashCode", TEST_UVOC_1.hashCode(), TEST_UVOC_2.hashCode());
+ }
+
+ @Test
+ public void equalsTest() throws Exception {
+ final Method methodFoo1 = TestDataObject1.class.getMethod("foo");
+ final UnionValueOptionContext test_uvoc = new UnionValueOptionContext(TestDataObject1.class, methodFoo1,
+ ValueTypeCodec.EMPTY_CODEC);
+
+ assertTrue("Equals", TEST_UVOC_1.equals(test_uvoc));
+ assertFalse("Not equals", TEST_UVOC_1.equals(TEST_UVOC_2));
+ }
+
+ protected static final class TestDataObject1 {
+ public void foo() {}
+ }
+
+ protected static final class TestDataObject2 {
+ public void foo() {}
+ }
+}
\ No newline at end of file
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.test.mock.FooChild;
import org.opendaylight.yangtools.yang.binding.test.mock.InstantiatedFoo;
import org.opendaylight.yangtools.yang.binding.test.mock.Node;
@Test
public void constructWithPredicates() {
-
InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
assertNotNull(nodes);
@Test
public void fluentConstruction() {
-
InstanceIdentifier<Nodes> nodes = InstanceIdentifier.builder(Nodes.class).build();
- InstanceIdentifier<Node> node = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
+ InstanceIdentifier<Node> node =
+ InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
assertNotNull(node);
assertEquals(Node.class, node.getTargetType());
@Test
public void negativeContains() {
- InstanceIdentifier<FooChild> fooChild = InstanceIdentifier.builder(Nodes.class).child(InstantiatedFoo.class).child(FooChild.class).build();
+ InstanceIdentifier<FooChild> fooChild =
+ InstanceIdentifier.builder(Nodes.class).child(InstantiatedFoo.class).child(FooChild.class).build();
InstanceIdentifier<Node> nodeTen = InstanceIdentifier.builder(Nodes.class) //
.child(Node.class,new NodeKey(10)).build();
@Test
public void firstIdentifierOfTest() {
- InstanceIdentifier<Node> instanceIdentifier = InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
+ InstanceIdentifier<Node> instanceIdentifier =
+ InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
InstanceIdentifier<Nodes> nodesIdentifier = instanceIdentifier.firstIdentifierOf(Nodes.class);
assertNotNull(nodesIdentifier);
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import org.junit.Test;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public class DOMDataTreeIdentifierTest {
+ private static final String REF_LISTS = "ref-lists";
+ private static final String TEST_LISTS = "test-lists";
+ private static final String COMPARE_FIRST_LISTS = "A-test-lists";
+ private static final String COMPARE_SECOND_LISTS = "B-test-lists";
+ private static final QNameModule TEST_MODULE = QNameModule.create(URI.create(
+ "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
+ private static final YangInstanceIdentifier REF_YII_IID = YangInstanceIdentifier.create(
+ new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, REF_LISTS)));
+ private static final YangInstanceIdentifier TEST_YII_IID = YangInstanceIdentifier.create(
+ new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, TEST_LISTS)));
+ private static final DOMDataTreeIdentifier REF_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ REF_YII_IID);
+ private static final DOMDataTreeIdentifier TEST_DIFF_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ TEST_YII_IID);
+
+ @Test
+ public void constructTest() {
+ assertNotNull("Instantiation", new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, REF_YII_IID));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void firstArgumentNullTest() throws Exception {
+ new DOMDataTreeIdentifier(null, REF_YII_IID);
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void secondArgumentNullTest() throws Exception {
+ new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL, null);
+ }
+
+ @Test
+ public void hashCodeTest() {
+ assertEquals("hashCode", REF_TREE.hashCode(), new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ REF_YII_IID).hashCode());
+ assertNotEquals("hashCode", REF_TREE.hashCode(), TEST_DIFF_TREE.hashCode());
+ }
+
+ @Test
+ public void equalsTest() {
+ assertTrue("Equals same", REF_TREE.equals(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ REF_YII_IID)));
+ assertFalse("Different DataStoreType", REF_TREE.equals(new DOMDataTreeIdentifier(LogicalDatastoreType.CONFIGURATION,
+ REF_YII_IID)));
+ assertTrue("Equals same instance", REF_TREE.equals(REF_TREE));
+ assertFalse("Different object", REF_TREE.equals(new Object()));
+ assertFalse("Different instance", REF_TREE.equals(TEST_DIFF_TREE));
+ }
+
+ @Test
+ public void compareToTest() {
+ final YangInstanceIdentifier compareFirstIid = YangInstanceIdentifier.create(
+ new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, COMPARE_FIRST_LISTS)));
+ final YangInstanceIdentifier compareSecondIid = YangInstanceIdentifier.create(
+ new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, COMPARE_SECOND_LISTS)));
+
+ assertEquals("Compare same to same", REF_TREE.compareTo(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ REF_YII_IID)), 0);
+ assertNotEquals("Compare same to same with different datastore", REF_TREE.compareTo(new DOMDataTreeIdentifier(
+ LogicalDatastoreType.CONFIGURATION, REF_YII_IID)), 0);
+ assertEquals("Compare same to same with different datastore",
+ new DOMDataTreeIdentifier(
+ LogicalDatastoreType.OPERATIONAL,
+ YangInstanceIdentifier.create(
+ YangInstanceIdentifier.NodeIdentifier.create(QName.create(TEST_MODULE, REF_LISTS)),
+ YangInstanceIdentifier.NodeIdentifier.create(QName.create(TEST_MODULE, TEST_LISTS))))
+ .compareTo(REF_TREE), 1);
+ assertTrue("Compare first to second", new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ compareFirstIid).compareTo(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ compareSecondIid)) < 0);
+ assertTrue("Compare second to first", new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ compareSecondIid).compareTo(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ compareFirstIid)) > 0);
+ }
+
+ @Test
+ public void containsTest() {
+ assertTrue("Contains", REF_TREE.contains(new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ REF_YII_IID)));
+ assertEquals("Not contains", false, REF_TREE.contains(TEST_DIFF_TREE));
+ }
+
+ @Test
+ public void toStringTest() {
+ assertTrue("ToString", REF_TREE.toString().contains(REF_TREE.getRootIdentifier().toString()) && REF_TREE
+ .toString().contains(REF_TREE.getDatastoreType().toString()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import org.junit.Test;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public class DOMExceptionsTest {
+ private static final String TEST_MESSAGE = "TestMessage";
+ private static final String TEST_LISTS = "test-lists";
+ private static final QNameModule TEST_MODULE = QNameModule.create(URI.create(
+ "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
+ private static final YangInstanceIdentifier TEST_YI_ID = YangInstanceIdentifier.create(
+ new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_MODULE, TEST_LISTS)));
+ private static final DOMDataTreeIdentifier TEST_TREE = new DOMDataTreeIdentifier(LogicalDatastoreType.OPERATIONAL,
+ TEST_YI_ID);
+
+ @Test(expected = DOMDataTreeInaccessibleException.class)
+ public void DOMDataTreeInaccessibleExceptionTest() throws Exception {
+ final DOMDataTreeInaccessibleException testExc = new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+ assertNotNull(testExc.getTreeIdentifier());
+ assertEquals(TEST_TREE, testExc.getTreeIdentifier());
+
+ throw new DOMDataTreeInaccessibleException(TEST_TREE, TEST_MESSAGE, new Throwable());
+ }
+
+ @Test(expected = DOMDataTreeListeningException.class)
+ public void DOMDataTreeListeningExceptionTest() throws Exception {
+ final DOMDataTreeListeningException testExc = new DOMDataTreeListeningException(TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+
+ throw new DOMDataTreeListeningException(TEST_MESSAGE, new Throwable());
+ }
+
+ @Test(expected = DOMDataTreeLoopException.class)
+ public void DOMDataTreeLoopExceptionTest() throws Exception {
+ final DOMDataTreeLoopException testExc = new DOMDataTreeLoopException(TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+
+ throw new DOMDataTreeLoopException(TEST_MESSAGE, new Throwable());
+ }
+
+ @Test(expected = DOMDataTreeProducerBusyException.class)
+ public void DOMDataTreeProducerBusyExceptionTest() throws Exception {
+ final DOMDataTreeProducerBusyException testExc = new DOMDataTreeProducerBusyException(TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+
+ throw new DOMDataTreeProducerBusyException(TEST_MESSAGE, new Throwable());
+ }
+
+ @Test(expected = DOMDataTreeProducerException.class)
+ public void DOMDataTreeProducerExceptionTest() throws Exception {
+ final DOMDataTreeProducerException testExc = new DOMDataTreeProducerException(TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+
+ throw new DOMDataTreeProducerException(TEST_MESSAGE, new Throwable());
+ }
+
+ @Test(expected = DOMDataTreeShardingConflictException.class)
+ public void DOMDataTreeShardingConflictExceptionTest() throws Exception {
+ final DOMDataTreeShardingConflictException testExc = new DOMDataTreeShardingConflictException(TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+
+ throw new DOMDataTreeShardingConflictException(TEST_MESSAGE, new Throwable());
+ }
+
+ @Test(expected = DOMNotificationRejectedException.class)
+ public void DOMNotificationRejectedExceptionTest() throws Exception {
+ final DOMNotificationRejectedException testExc = new DOMNotificationRejectedException(TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+
+ throw new DOMNotificationRejectedException(TEST_MESSAGE, new Throwable());
+ }
+
+ @Test(expected = DOMRpcImplementationNotAvailableException.class)
+ public void DOMRpcImplementationNotAvailableExceptionTest() throws Exception {
+ final DOMRpcImplementationNotAvailableException testExc = new DOMRpcImplementationNotAvailableException(TEST_MESSAGE);
+ assertTrue(testExc.getMessage().contains(TEST_MESSAGE));
+
+ throw new DOMRpcImplementationNotAvailableException(new Throwable(), TEST_MESSAGE, new Object());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.api;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.net.URI;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class DOMRpcIdentifierTest {
+ private static final String LOCAL_IDENT = "local";
+ private static final QNameModule TEST_MODULE = QNameModule.create(URI.create(
+ "urn:opendaylight:params:xml:ns:yang:controller:md:sal:test:store"), null);
+ private static final DOMRpcIdentifier GLOBAL = DOMRpcIdentifier.create(SchemaPath.SAME, null);
+ private static final DOMRpcIdentifier LOCAL = DOMRpcIdentifier.create(SchemaPath.ROOT,YangInstanceIdentifier.create(
+ new NodeIdentifier(QName.create(TEST_MODULE, LOCAL_IDENT))));
+
+ @Test
+ public void createTest() {
+ assertTrue("Global instance", GLOBAL.getClass().getCanonicalName().contains("Global"));
+ assertTrue("Local instance", LOCAL.getClass().getCanonicalName().contains("Local"));
+ }
+
+ @Test
+ public void hashCodeTest() {
+ assertEquals("hashCode", GLOBAL.hashCode(), DOMRpcIdentifier.create(SchemaPath.ROOT).hashCode());
+ assertNotEquals("hashCode", GLOBAL.hashCode(), LOCAL.hashCode());
+ }
+
+ @Test
+ public void equalsTest() {
+ assertTrue("Equals same", GLOBAL.equals(DOMRpcIdentifier.create(SchemaPath.SAME)));
+ assertTrue("Equals same instance", GLOBAL.equals(GLOBAL));
+ assertFalse("Different object", GLOBAL.equals(new Object()));
+ assertFalse("Different instance", GLOBAL.equals(LOCAL));
+ }
+
+ @Test
+ public void toStringTest() {
+ assertTrue("ToString", GLOBAL.toString().contains(GLOBAL.getContextReference().toString()) && GLOBAL.toString()
+ .contains(GLOBAL.getType().toString()));
+ assertTrue("ToString", LOCAL.toString().contains(LOCAL.getContextReference().toString()) && LOCAL.toString()
+ .contains(LOCAL.getType().toString()));
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.api.clustering;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Test;
+import org.opendaylight.mdsal.common.api.clustering.EntityOwnershipChangeState;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+public class DOMEntityOwnershipChangeTest {
+ private static final String ENTITY_TYPE = "type";
+ private static final YangInstanceIdentifier ID = YangInstanceIdentifier.of(QName.create("test"));
+ private static final DOMEntity ENTITY = new DOMEntity(ENTITY_TYPE, ID);
+
+ @Test
+ public void createTest() {
+ assertNotNull(new DOMEntityOwnershipChange(ENTITY, EntityOwnershipChangeState.LOCAL_OWNERSHIP_GRANTED));
+ assertNotNull(new DOMEntityOwnershipChange(ENTITY, EntityOwnershipChangeState.LOCAL_OWNERSHIP_GRANTED, false));
+ }
+}
\ No newline at end of file
*/
package org.opendaylight.mdsal.dom.api.clustering;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
import static org.opendaylight.mdsal.dom.api.clustering.DOMEntity.ENTITY;
-import static org.junit.Assert.*;
+
import java.util.List;
import java.util.Map.Entry;
import org.junit.Test;
* @author Thomas Pantelis
*/
public class DOMEntityTest {
- static String ENTITY_TYPE1 = "type1";
- static String ENTITY_TYPE2 = "type2";
- static final YangInstanceIdentifier ID1 = YangInstanceIdentifier.of(QName.create("test", "2015-11-24", "one"));
- static final YangInstanceIdentifier ID2 = YangInstanceIdentifier.of(QName.create("test", "2015-11-24", "two"));
+ private static String ENTITY_TYPE1 = "type1";
+ private static String ENTITY_TYPE2 = "type2";
+ private static final YangInstanceIdentifier ID1 = YangInstanceIdentifier.of(QName.create(
+ "test", "2015-11-24", "one"));
+ private static final YangInstanceIdentifier ID2 = YangInstanceIdentifier.of(QName.create(
+ "test", "2015-11-24", "two"));
@Test
public void testHashCode() {
assertEquals("pathArgs size", 2, pathArgs.size());
assertEquals("First PathArgument node type", ENTITY, pathArgs.get(0).getNodeType());
assertEquals("Second PathArgument node type", ENTITY, pathArgs.get(1).getNodeType());
- Entry<QName, Object> key = ((NodeIdentifierWithPredicates) pathArgs.get(1)).getKeyValues().entrySet().iterator().next();
+ Entry<QName, Object> key = ((NodeIdentifierWithPredicates) pathArgs.get(1)).getKeyValues().entrySet()
+ .iterator().next();
assertEquals("Key node type", QName.create(ENTITY, "name"), key.getKey());
assertEquals("Key value", "foo", key.getValue());
}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.broker;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class GlobalDOMRpcRoutingTableEntryTest extends TestUtils {
+
+ @Test
+ public void basicTest() throws Exception {
+ final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> rpcImplementations = new HashMap<>();
+ final List<DOMRpcImplementation> rpcImplementation = new ArrayList<>();
+ final RpcDefinition rpcDefinition = mock(RpcDefinition.class);
+ final YangInstanceIdentifier yangInstanceIdentifier = YangInstanceIdentifier.builder().build();
+
+ doReturn(SchemaPath.ROOT).when(rpcDefinition).getPath();
+ final GlobalDOMRpcRoutingTableEntry globalDOMRpcRoutingTableEntry = new GlobalDOMRpcRoutingTableEntry(
+ rpcDefinition, new HashMap<>());
+ rpcImplementation.add(getTestRpcImplementation());
+ rpcImplementations.put(yangInstanceIdentifier, rpcImplementation);
+
+ assertTrue(globalDOMRpcRoutingTableEntry.getSchemaPath().equals(SchemaPath.ROOT));
+ assertTrue(globalDOMRpcRoutingTableEntry.getImplementations().isEmpty());
+ assertFalse(globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations).getImplementations().isEmpty());
+ assertTrue(globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations).getImplementations().containsValue(
+ rpcImplementation));
+
+ try{
+ globalDOMRpcRoutingTableEntry.newInstance(rpcImplementations)
+ .invokeRpc(TEST_CONTAINER).checkedGet();
+ fail("Expected DOMRpcImplementationNotAvailableException");
+ }catch(DOMRpcImplementationNotAvailableException e){
+ assertTrue(e.getMessage().contains(EXCEPTION_TEXT));
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.broker;
+
+import static org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes.leafNode;
+
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import org.opendaylight.mdsal.dom.api.DOMRpcException;
+import org.opendaylight.mdsal.dom.api.DOMRpcIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementationNotAvailableException;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.broker.test.util.TestModel;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
+import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+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.ImmutableMapEntryNodeBuilder;
+
+abstract class TestUtils {
+
+ private static final DataContainerChild<?, ?> OUTER_LIST = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1)).build();
+
+ private static final String TOP_LEVEL_LIST_FOO_KEY_VALUE = "foo";
+ private static final QName TOP_QNAME = TestModel.ID_QNAME;
+ private static final QName TOP_LEVEL_LIST_QNAME = QName.create(TOP_QNAME, "top-level-list");
+ private static final QName TOP_LEVEL_LIST_KEY_QNAME = QName.create(TOP_QNAME, "name");
+
+ private final static MapEntryNode topLevelListNormalized = ImmutableMapEntryNodeBuilder.create()
+ .withNodeIdentifier(
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ TOP_LEVEL_LIST_QNAME, TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .withChild(leafNode(TOP_LEVEL_LIST_KEY_QNAME, TOP_LEVEL_LIST_FOO_KEY_VALUE))
+ .build();
+
+ private static final DataContainerChild<?, ?> CHILD_LIST = ImmutableNodes.mapNodeBuilder(TestModel.TEST_QNAME)
+ .withNodeIdentifier(NodeIdentifier.create(TestModel.TEST_QNAME))
+ .withChild(topLevelListNormalized)
+ .build();
+
+ static final NormalizedNode<?, ?> TEST_CONTAINER = Builders.containerBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(OUTER_LIST)
+ .build();
+
+ static final NormalizedNode<?, ?> TEST_CHILD = Builders.containerBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(CHILD_LIST)
+ .build();
+
+ static final String EXCEPTION_TEXT = "TestRpcImplementationException";
+
+ static TestRpcImplementation getTestRpcImplementation(){
+ return new TestRpcImplementation();
+ }
+
+ private static final class TestRpcImplementation implements DOMRpcImplementation {
+ private final CheckedFuture<DOMRpcResult, DOMRpcException> unknownRpc;
+
+ private TestRpcImplementation() {
+ unknownRpc = Futures.immediateFailedCheckedFuture(
+ new DOMRpcImplementationNotAvailableException(EXCEPTION_TEXT));
+ }
+
+ @Nonnull
+ public CheckedFuture<DOMRpcResult, DOMRpcException> invokeRpc(
+ @Nonnull DOMRpcIdentifier rpc, @Nullable NormalizedNode<?, ?> input) {
+ return unknownRpc;
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.broker;
+
+import org.junit.Test;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+
+public class TransactionCommitFailedExceptionMapperTest {
+
+ @Test(expected = TransactionCommitFailedException.class)
+ public void create() throws Exception {
+ throw TransactionCommitFailedExceptionMapper.create("test").newWithCause("test_cause", new Throwable());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2016 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.mdsal.dom.broker;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.junit.Test;
+import org.opendaylight.mdsal.dom.api.DOMRpcImplementation;
+import org.opendaylight.mdsal.dom.broker.test.util.TestModel;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+
+public class UnknownDOMRpcRoutingTableEntryTest extends TestUtils {
+ private static final List<DOMRpcImplementation> TEST_LIST = new ArrayList<>();
+
+ @Test
+ public void basicTest() throws Exception {
+ final Map<YangInstanceIdentifier, List<DOMRpcImplementation>> emptyImpls = new HashMap<>();
+ final List<YangInstanceIdentifier> addList1 = new ArrayList<>();
+ final List<YangInstanceIdentifier> addList2 = new ArrayList<>();
+ final DOMRpcImplementation testClass = getTestRpcImplementation();
+ final UnknownDOMRpcRoutingTableEntry test = new UnknownDOMRpcRoutingTableEntry(SchemaPath.ROOT, emptyImpls);
+
+ TEST_LIST.add(testClass);
+ emptyImpls.put(YangInstanceIdentifier.EMPTY, TEST_LIST);
+
+ assertNotNull(test);
+ assertNotNull(test.newInstance(emptyImpls));
+ assertNotNull(test.invokeRpc(TEST_CONTAINER));
+ assertNotNull(test.getImplementations());
+ assertEquals(test.getImplementations(YangInstanceIdentifier.EMPTY), TEST_LIST);
+ assertTrue(test.containsContext(YangInstanceIdentifier.EMPTY));
+ assertTrue(test.registeredIdentifiers().contains(YangInstanceIdentifier.EMPTY));
+
+ addList1.add(YangInstanceIdentifier.EMPTY);
+ addList1.add(YangInstanceIdentifier.of(TestModel.TEST_QNAME));
+ addList2.add(YangInstanceIdentifier.of(TestModel.TEST2_QNAME));
+
+ final AbstractDOMRpcRoutingTableEntry tst = test.add(testClass, addList1);
+ final AbstractDOMRpcRoutingTableEntry tst1 = tst.add(testClass, addList2);
+ final AbstractDOMRpcRoutingTableEntry tst2 = tst1.remove(testClass, addList1);
+
+ assertEquals(1, test.getImplementations().size());
+ assertEquals(2, tst.getImplementations().size());
+ assertEquals(3, tst1.getImplementations().size());
+ assertNotNull(tst2.getImplementations());
+ assertEquals(2, tst2.getImplementations().size());
+ }
+}
\ No newline at end of file
* 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.mdsal.dom.broker.test;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;
-import org.opendaylight.mdsal.dom.broker.test.util.TestModel;
-
-import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
-import org.opendaylight.mdsal.dom.spi.store.DOMStore;
-
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitDeadlockException;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-import org.opendaylight.mdsal.dom.broker.AbstractDOMDataBroker;
-import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ForwardingExecutorService;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.ReadFailedException;
+import org.opendaylight.mdsal.common.api.TransactionCommitDeadlockException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.broker.AbstractDOMDataBroker;
+import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker;
+import org.opendaylight.mdsal.dom.broker.test.util.TestModel;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+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;
private CommitExecutorService commitExecutor;
@Before
- public void setupStore() throws Exception{
-
+ public void setupStore() throws Exception {
InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
MoreExecutors.newDirectExecutorService());
InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
operStore.onGlobalContextUpdated(schemaContext);
configStore.onGlobalContextUpdated(schemaContext);
- ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore> builder() //
- .put(CONFIGURATION, configStore) //
- .put(OPERATIONAL, operStore) //
+ ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore> builder()
+ .put(CONFIGURATION, configStore)
+ .put(OPERATIONAL, operStore)
.build();
commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor());
@Test(timeout=10000)
public void testTransactionIsolation() throws InterruptedException, ExecutionException {
-
assertNotNull(domBroker);
DOMDataTreeReadTransaction readTx = domBroker.newReadOnlyTransaction();
DOMDataTreeWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
assertNotNull(writeTx);
+
/**
*
* Writes /test in writeTx
*/
writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
-
/**
*
* Reads /test from readTx Read should return Absent.
@Test(timeout=10000)
public void testTransactionCommit() throws InterruptedException, ExecutionException {
-
DOMDataTreeWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
assertNotNull(writeTx);
/**
@Test(expected=TransactionCommitFailedException.class)
public void testRejectedCommit() throws Exception {
-
commitExecutor.delegate = Mockito.mock( ExecutorService.class );
Mockito.doThrow( new RejectedExecutionException( "mock" ) )
.when( commitExecutor.delegate ).execute( Mockito.any( Runnable.class ) );
return caughtEx;
}
+ @Test(expected = ReadFailedException.class)
+ public void basicTests() throws Exception {
+ final DataContainerChild<?, ?> outerList = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ .withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
+ .build();
+ final NormalizedNode<?, ?> testContainer = Builders.containerBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TestModel.TEST_QNAME))
+ .withChild(outerList)
+ .build();
+
+ DOMDataTreeWriteTransaction writeTx = domBroker.newWriteOnlyTransaction();
+ DOMDataTreeReadTransaction readRx = domBroker.newReadOnlyTransaction();
+ assertNotNull(writeTx);
+ assertNotNull(readRx);
+
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.submit().get();
+ assertFalse(writeTx.cancel());
+
+ assertEquals(false, domBroker.newReadOnlyTransaction().exists(CONFIGURATION, TestModel.TEST_PATH).get());
+ assertEquals(true, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
+ assertEquals(false, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST2_PATH).get());
+
+ writeTx = domBroker.newWriteOnlyTransaction();
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.delete(OPERATIONAL, TestModel.TEST_PATH);
+ writeTx.submit().get();
+ assertEquals(false, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
+ assertTrue(domBroker.newWriteOnlyTransaction().cancel());
+
+ writeTx = domBroker.newWriteOnlyTransaction();
+ writeTx.put(OPERATIONAL, TestModel.TEST_PATH, ImmutableNodes.containerNode(TestModel.TEST_QNAME));
+ writeTx.merge(OPERATIONAL, TestModel.TEST_PATH, testContainer);
+ writeTx.submit().get();
+ assertEquals(true, domBroker.newReadOnlyTransaction().exists(OPERATIONAL, TestModel.TEST_PATH).get());
+ assertEquals(true, domBroker.newReadOnlyTransaction().read(OPERATIONAL, TestModel.TEST_PATH).get()
+ .get().toString().contains(testContainer.toString()));
+
+ readRx.close();
+ //Expected exception after close call
+ readRx.read(OPERATIONAL, TestModel.TEST_PATH).checkedGet();
+ }
+
+ @Test
+ public void closeTest() throws Exception {
+ final String TEST_EXCEPTION = "TestException";
+
+ domBroker.setCloseable(() -> { throw new Exception(TEST_EXCEPTION); });
+ try{
+ domBroker.close();
+ }catch(Exception e){
+ assertTrue(e.getMessage().contains(TEST_EXCEPTION));
+ }
+ }
+
static class CommitExecutorService extends ForwardingExecutorService {
ExecutorService delegate;
* 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.mdsal.dom.broker.test;
import static org.junit.Assert.assertEquals;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.CONFIGURATION;
import static org.opendaylight.mdsal.common.api.LogicalDatastoreType.OPERATIONAL;
-import org.opendaylight.mdsal.dom.broker.test.util.TestModel;
-
-import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
-import org.opendaylight.mdsal.dom.spi.store.DOMStore;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.mdsal.common.api.TransactionCommitDeadlockException;
-import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
-import org.opendaylight.mdsal.dom.broker.AbstractDOMDataBroker;
-import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker;
-import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
-import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
import com.google.common.collect.ImmutableMap;
import com.google.common.util.concurrent.ForwardingExecutorService;
import com.google.common.util.concurrent.ListeningExecutorService;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.TransactionCommitDeadlockException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.mdsal.dom.api.DOMDataBrokerExtension;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeListener;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeChangeService;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeIdentifier;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.broker.AbstractDOMDataBroker;
+import org.opendaylight.mdsal.dom.broker.SerializedDOMDataBroker;
+import org.opendaylight.mdsal.dom.broker.test.util.TestModel;
+import org.opendaylight.mdsal.dom.spi.store.DOMStore;
+import org.opendaylight.mdsal.dom.store.inmemory.InMemoryDOMDataStore;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.util.concurrent.DeadlockDetectingListeningExecutorService;
import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
private ExecutorService futureExecutor;
private CommitExecutorService commitExecutor;
- private static final DataContainerChild<?, ?> OUTER_LIST = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ private static final DataContainerChild<?, ?> OUTER_LIST =
+ ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
.withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1))
.build();
- private static final DataContainerChild<?, ?> OUTER_LIST_2 = ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
+ private static final DataContainerChild<?, ?> OUTER_LIST_2 =
+ ImmutableNodes.mapNodeBuilder(TestModel.OUTER_LIST_QNAME)
.withChild(ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2))
.build();
LogicalDatastoreType.CONFIGURATION, TestModel.OUTER_LIST_PATH);
@Before
- public void setupStore() throws Exception{
+ public void setupStore() throws Exception {
InMemoryDOMDataStore operStore = new InMemoryDOMDataStore("OPER",
MoreExecutors.newDirectExecutorService());
InMemoryDOMDataStore configStore = new InMemoryDOMDataStore("CFG",
operStore.onGlobalContextUpdated(schemaContext);
configStore.onGlobalContextUpdated(schemaContext);
- ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder() //
- .put(CONFIGURATION, configStore) //
- .put(OPERATIONAL, operStore) //
+ ImmutableMap<LogicalDatastoreType, DOMStore> stores = ImmutableMap.<LogicalDatastoreType, DOMStore>builder()
+ .put(CONFIGURATION, configStore)
+ .put(OPERATIONAL, operStore)
.build();
commitExecutor = new CommitExecutorService(Executors.newSingleThreadExecutor());
dataTreeChangeService.registerDataTreeChangeListener(OUTER_LIST_DATA_TREE_ID, listener);
final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId1 =
- new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId2 =
- new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
final YangInstanceIdentifier.NodeIdentifierWithPredicates outerListEntryId3 =
- new YangInstanceIdentifier.NodeIdentifierWithPredicates(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3);
+ new YangInstanceIdentifier.NodeIdentifierWithPredicates(
+ TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 3);
final MapEntryNode outerListEntry1 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 1);
final MapEntryNode outerListEntry2 = ImmutableNodes.mapEntry(TestModel.OUTER_LIST_QNAME, TestModel.ID_QNAME, 2);
return dataTreeChangeService;
}
-
static class CommitExecutorService extends ForwardingExecutorService {
ExecutorService delegate;