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
1 /*
2  * Copyright (c) 2014, 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.controller.md.sal.binding.impl.test;
10
11 import static junit.framework.TestCase.assertNotNull;
12
13 import com.google.common.collect.ImmutableSet;
14 import java.util.concurrent.ExecutionException;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.opendaylight.controller.md.sal.binding.compat.HydrogenDataBrokerAdapter;
18 import org.opendaylight.controller.md.sal.binding.test.AbstractConcurrentDataBrokerTest;
19 import org.opendaylight.controller.md.sal.binding.test.DataBrokerTestCustomizer;
20 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
25 import org.opendaylight.yangtools.yang.binding.DataObject;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
27 import org.opendaylight.yangtools.yang.binding.YangModuleInfo;
28 import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
29
30 @Deprecated
31 public class ForwardedBackwardsCompatibleDataBrokerTest extends AbstractConcurrentDataBrokerTest {
32
33     private HydrogenDataBrokerAdapter dataBroker;
34     private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.create(Top.class);
35     private static final TopLevelListKey TOP_LIST_KEY = new TopLevelListKey("foo");
36     private static final InstanceIdentifier<TopLevelList> NODE_PATH = TOP_PATH.child(TopLevelList.class, TOP_LIST_KEY);
37     private static final TopLevelList NODE = new TopLevelListBuilder().setKey(TOP_LIST_KEY).build();
38
39     @Override
40     protected Iterable<YangModuleInfo> getModuleInfos() throws Exception {
41         return ImmutableSet.of(BindingReflections.getModuleInfo(TopLevelList.class));
42     }
43
44     @Override
45     protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
46         return new DataBrokerTestCustomizer();
47     }
48
49     @Before
50     public void setupWithDataBroker() {
51         this.dataBroker = new HydrogenDataBrokerAdapter(getDataBroker());
52     }
53
54     /**
55      * The purpose of this test is to exercise the backwards compatible broker
56      * <p>
57      * This test tries to execute the code which ensures that the parents
58      * for a given node get automatically created.
59      *
60      * @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)
61      */
62     @Test
63     public void testEnsureParentsByMerge() throws InterruptedException, ExecutionException {
64         final DataModificationTransaction writeTx =
65             dataBroker.beginTransaction();
66
67         writeTx.putOperationalData(NODE_PATH, NODE);
68
69         writeTx.commit().get();
70
71         // TOP_PATH should exist as it is the parent of NODE_PATH
72         final DataObject object = dataBroker.readOperationalData(TOP_PATH);
73
74         assertNotNull(object);
75
76     }
77
78
79 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.