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 java.util.Collections;
14 import java.util.concurrent.Callable;
15 import java.util.concurrent.ExecutorService;
16 import java.util.concurrent.Executors;
17 import java.util.concurrent.Future;
19 import org.junit.Test;
20 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
21 import org.opendaylight.controller.sal.binding.api.data.DataModificationTransaction;
22 import org.opendaylight.controller.sal.binding.test.AbstractDataServiceTest;
23 import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.Top;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.TopBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.list.rev140701.two.level.list.TopLevelList;
27 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 import org.opendaylight.yangtools.yang.common.RpcResult;
30 import com.google.common.util.concurrent.ListeningExecutorService;
31 import com.google.common.util.concurrent.MoreExecutors;
33 @SuppressWarnings("deprecation")
34 public class DOMCodecBug02Test extends AbstractDataServiceTest {
36 private static final InstanceIdentifier<Top> TOP_INSTANCE_ID_BA = InstanceIdentifier.builder(Top.class) //
40 * This test is ignored, till found out better way to test generation of
41 * classes without leaking of instances from previous run
48 ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
49 BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
50 factory.setExecutor(executor);
51 factory.setStartWithParsedSchema(getStartWithSchema());
52 testContext = factory.getTestContext();
55 baDataService = testContext.getBindingDataBroker();
56 biDataService = testContext.getDomDataBroker();
57 mappingService = testContext.getBindingToDomMappingService();
61 public void testSchemaContextNotAvailable() throws Exception {
63 ExecutorService testExecutor = Executors.newFixedThreadPool(1);
64 testContext.loadYangSchemaFromClasspath();
65 Future<Future<RpcResult<TransactionStatus>>> future = testExecutor
66 .submit(new Callable<Future<RpcResult<TransactionStatus>>>() {
68 public Future<RpcResult<TransactionStatus>> call() throws Exception {
69 TopBuilder topBuilder = new TopBuilder();
70 topBuilder.setTopLevelList(Collections.<TopLevelList> emptyList());
71 DataModificationTransaction transaction = baDataService.beginTransaction();
72 transaction.putOperationalData(TOP_INSTANCE_ID_BA, topBuilder.build());
73 return transaction.commit();
77 RpcResult<TransactionStatus> result = future.get().get();
78 assertEquals(TransactionStatus.COMMITED, result.getResult());
80 Top top = checkForTop();
85 private Top checkForTop() {
86 return (Top) baDataService.readOperationalData(TOP_INSTANCE_ID_BA);
91 protected boolean getStartWithSchema() {