AbstractConcurrentDataBrokerTest @deprecate-s the AbstractDataBrokerTest
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / md / sal / binding / impl / test / ForwardedBackwardsCompatibleDataBrokerTest.java
index f91e356b8e2a1d883a2dfee05142e2250aa4b3be..3cdd9b5fcc0d59492c12e0f8356bc1c6838be91d 100644 (file)
@@ -1,10 +1,22 @@
+/*
+ * Copyright (c) 2014, 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.controller.md.sal.binding.impl.test;
 
+import static junit.framework.TestCase.assertNotNull;
+
+import com.google.common.collect.ImmutableSet;
+import java.util.concurrent.ExecutionException;
+import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.binding.impl.ForwardedBackwardsCompatibleDataBroker;
-import org.opendaylight.controller.md.sal.binding.test.AbstractSchemaAwareTest;
+import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
+import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestCustomizer;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
@@ -12,37 +24,32 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-
-import java.util.concurrent.ExecutionException;
-
-import static junit.framework.TestCase.assertNotNull;
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
 
-public class ForwardedBackwardsCompatibleDataBrokerTest extends
-    AbstractSchemaAwareTest {
-
-    private DataBrokerTestCustomizer testCustomizer;
-    private ForwardedBackwardsCompatibleDataBroker dataBroker;
-    private DOMDataBroker domBroker;
+@Deprecated
+public class ForwardedBackwardsCompatibleDataBrokerTest extends AbstractConcurrentDataBrokerTest {
 
+    private HydrogenDataBrokerAdapter dataBroker;
     private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
     private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
     private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
     private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
 
-    protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
-        return new DataBrokerTestCustomizer();
+    @Override
+    protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
+        return ImmutableSet.of(BindingReflections.getModuleInfo(TopLevelList.class));
     }
 
     @Override
-    protected void setupWithSchema(final SchemaContext context) {
-        testCustomizer = createDataBrokerTestCustomizer();
-
-        domBroker = testCustomizer.createDOMDataBroker();
-        dataBroker = testCustomizer.createBackwardsCompatibleDataBroker();
-        testCustomizer.updateSchema(context);
+    protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+        return new DataBrokerTestCustomizer();
     }
 
+    @Before
+    public void setupWithDataBroker() {
+        this.dataBroker = new HydrogenDataBrokerAdapter(getDataBroker());
+    }
 
     /**
      * The purpose of this test is to exercise the backwards compatible broker
@@ -53,16 +60,16 @@ public class ForwardedBackwardsCompatibleDataBrokerTest extends
      * @see org.opendaylight.controller.md.sal.binding.impl.AbstractReadWriteTransaction#ensureParentsByMerge(org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType, org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier, org.opendaylight.yangtools.yang.binding.InstanceIdentifier)
      */
     @Test
-    public void test() throws InterruptedException, ExecutionException {
-        DataModificationTransaction writeTx =
+    public void testEnsureParentsByMerge() throws InterruptedException, ExecutionException {
+        final DataModificationTransaction writeTx =
             dataBroker.beginTransaction();
 
         writeTx.putOperationalData(NODE_PATH, NODE);
 
-        writeTx.commit();
+        writeTx.commit().get();
 
         // TOP_PATH should exist as it is the parent of NODE_PATH
-        DataObject object = dataBroker.readOperationalData(TOP_PATH);
+        final DataObject object = dataBroker.readOperationalData(TOP_PATH);
 
         assertNotNull(object);