+/*
+ * 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 com.google.common.util.concurrent.MoreExecutors;
+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;
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;
-
-public class ForwardedBackwardsCompatibleDataBrokerTest extends
- AbstractSchemaAwareTest {
+import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
- 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 = createBackwardsCompatibleDataBroker();
- testCustomizer.updateSchema(context);
+ protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
+ return new DataBrokerTestCustomizer();
}
- public ForwardedBackwardsCompatibleDataBroker createBackwardsCompatibleDataBroker() {
- return new ForwardedBackwardsCompatibleDataBroker(domBroker, testCustomizer.getBindingToNormalized(), testCustomizer.getSchemaService(), MoreExecutors
- .sameThreadExecutor());
+ @Before
+ public void setupWithDataBroker() {
+ this.dataBroker = new HydrogenDataBrokerAdapter(getDataBroker());
}
-
-
-
/**
* The purpose of this test is to exercise the backwards compatible broker
* <p>
*/
@Test
public void testEnsureParentsByMerge() throws InterruptedException, ExecutionException {
- DataModificationTransaction writeTx =
+ 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);