Bug 2538: Remove redundant Augmentation checks and tests
[controller.git] / opendaylight / md-sal / sal-binding-dom-it / src / test / java / org / opendaylight / controller / md / sal / binding / data / ConcurrentImplicitCreateTest.java
1 /*
2  * Copyright (c) 2014 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 package org.opendaylight.controller.md.sal.binding.data;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12
13 import java.util.concurrent.ExecutionException;
14 import java.util.concurrent.Future;
15
16 import org.junit.Test;
17 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
18 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
19 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
25 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
26 import org.opendaylight.yangtools.yang.common.RpcResult;
27
28 /*
29  * FIXME: THis test should be moved to sal-binding-broker and rewriten
30  * to use new DataBroker API
31  */
32 @SuppressWarnings("deprecation")
33 public class ConcurrentImplicitCreateTest extends AbstractDataServiceTest {
34
35     private static final NodeKey NODE_FOO_KEY = new NodeKey(new NodeId("foo"));
36     private static final NodeKey NODE_BAR_KEY = new NodeKey(new NodeId("foo"));
37     private static InstanceIdentifier<Nodes> NODES_PATH = InstanceIdentifier.builder(Nodes.class).build();
38     private static InstanceIdentifier<Node> NODE_FOO_PATH = NODES_PATH.child(Node.class, NODE_FOO_KEY);
39     private static InstanceIdentifier<Node> NODE_BAR_PATH = NODES_PATH.child(Node.class, NODE_FOO_KEY);
40
41     @Test
42     public void testConcurrentCreate() throws InterruptedException, ExecutionException {
43
44         DataModificationTransaction fooTx = baDataService.beginTransaction();
45         DataModificationTransaction barTx = baDataService.beginTransaction();
46
47         fooTx.putOperationalData(NODE_FOO_PATH, new NodeBuilder().setKey(NODE_FOO_KEY).build());
48         barTx.putOperationalData(NODE_BAR_PATH, new NodeBuilder().setKey(NODE_BAR_KEY).build());
49
50         Future<RpcResult<TransactionStatus>> fooFuture = fooTx.commit();
51         Future<RpcResult<TransactionStatus>> barFuture = barTx.commit();
52
53         RpcResult<TransactionStatus> fooResult = fooFuture.get();
54         RpcResult<TransactionStatus> barResult = barFuture.get();
55
56         assertTrue(fooResult.isSuccessful());
57         assertTrue(barResult.isSuccessful());
58
59         assertEquals(TransactionStatus.COMMITED, fooResult.getResult());
60         assertEquals(TransactionStatus.COMMITED, barResult.getResult());
61
62     }
63 }