Another round of checkstyle fixes
[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 java.util.concurrent.ExecutionException;
11 import java.util.concurrent.TimeUnit;
12 import java.util.concurrent.TimeoutException;
13 import org.junit.Test;
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
15 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelListKey;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
23
24 // FIXME: THis test should be moved to sal-binding-broker and rewritten to use new DataBroker API
25 public class ConcurrentImplicitCreateTest extends AbstractDataServiceTest {
26
27     private static final TopLevelListKey FOO_KEY = new TopLevelListKey("foo");
28     private static final TopLevelListKey BAR_KEY = new TopLevelListKey("bar");
29     private static final InstanceIdentifier<Top> TOP_PATH = InstanceIdentifier.builder(Top.class).build();
30     private static final InstanceIdentifier<TopLevelList> FOO_PATH = TOP_PATH.child(TopLevelList.class, FOO_KEY);
31     private static final InstanceIdentifier<TopLevelList> BAR_PATH = TOP_PATH.child(TopLevelList.class, BAR_KEY);
32
33     @Test
34     public void testConcurrentCreate() throws InterruptedException, ExecutionException, TimeoutException {
35
36         DataBroker dataBroker = testContext.getDataBroker();
37         WriteTransaction fooTx = dataBroker.newWriteOnlyTransaction();
38         WriteTransaction barTx = dataBroker.newWriteOnlyTransaction();
39
40         fooTx.put(LogicalDatastoreType.OPERATIONAL, FOO_PATH, new TopLevelListBuilder().withKey(FOO_KEY).build());
41         barTx.put(LogicalDatastoreType.OPERATIONAL, BAR_PATH, new TopLevelListBuilder().withKey(BAR_KEY).build());
42
43         fooTx.submit().get(5, TimeUnit.SECONDS);
44         barTx.submit().get(5, TimeUnit.SECONDS);
45     }
46 }

©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.