2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.controller.sal.binding.test.bugfix;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
13 import com.google.common.util.concurrent.ListeningExecutorService;
14 import com.google.common.util.concurrent.MoreExecutors;
15 import java.util.Collections;
16 import java.util.concurrent.Callable;
17 import java.util.concurrent.ExecutorService;
18 import java.util.concurrent.Executors;
19 import java.util.concurrent.Future;
20 import org.junit.Test;
21 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
22 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
23 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
24 import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
28 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
29 import org.opendaylight.yangtools.yang.common.RpcResult;
31 @SuppressWarnings("deprecation")
32 public class DOMCodecBug02Test extends AbstractDataServiceTest {
34 private static final InstanceIdentifier<Top> TOP_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) //
38 * This test is ignored, till found out better way to test generation of
39 * classes without leaking of instances from previous run
46 ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
47 BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
48 factory.setExecutor(executor);
49 factory.setStartWithParsedSchema(getStartWithSchema());
50 testContext = factory.getTestContext();
53 baDataService = testContext.getBindingDataBroker();
54 biDataService = testContext.getDomDataBroker();
58 public void testSchemaContextNotAvailable() throws Exception {
60 ExecutorService testExecutor = Executors.newFixedThreadPool(1);
61 testContext.loadYangSchemaFromClasspath();
62 Future<Future<RpcResult<TransactionStatus>>> future = testExecutor
63 .submit(new Callable<Future<RpcResult<TransactionStatus>>>() {
65 public Future<RpcResult<TransactionStatus>> call() throws Exception {
66 TopBuilder topBuilder = new TopBuilder();
67 topBuilder.setTopLevelList(Collections.<TopLevelList> emptyList());
68 DataModificationTransaction transaction = baDataService.beginTransaction();
69 transaction.putOperationalData(TOP_INSTANCE_ID_BA, topBuilder.build());
70 return transaction.commit();
74 RpcResult<TransactionStatus> result = future.get().get();
75 assertEquals(TransactionStatus.COMMITED, result.getResult());
77 Top top = checkForTop();
82 private Top checkForTop() {
83 return (Top) baDataService.readOperationalData(TOP_INSTANCE_ID_BA);
88 protected boolean getStartWithSchema() {