Merge "Increase timeout for waiting for broker service in sal-binding-it."
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / sal / binding / test / AbstractDataServiceTest.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.sal.binding.test;
9
10 import org.junit.After;
11 import org.junit.Before;
12 import org.opendaylight.controller.sal.binding.api.data.DataProviderService;
13 import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService;
14 import org.opendaylight.controller.sal.binding.test.util.BindingBrokerTestFactory;
15 import org.opendaylight.controller.sal.binding.test.util.BindingTestContext;
16 import org.opendaylight.controller.sal.core.api.data.DataStore;
17 import org.opendaylight.controller.sal.dom.broker.impl.DataStoreStatsWrapper;
18 import org.opendaylight.controller.sal.dom.broker.impl.HashMapDataStore;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 import com.google.common.util.concurrent.ListeningExecutorService;
23 import com.google.common.util.concurrent.MoreExecutors;
24
25 public abstract class AbstractDataServiceTest {
26     private static Logger log = LoggerFactory.getLogger(AbstractDataServiceTest.class);
27
28     protected org.opendaylight.controller.sal.core.api.data.DataProviderService biDataService;
29     protected DataProviderService baDataService;
30     protected BindingIndependentMappingService mappingService;
31     private DataStoreStatsWrapper dataStoreStats;
32     protected DataStore dataStore;
33     protected BindingTestContext testContext;
34
35     @Before
36     public void setUp() {
37         ListeningExecutorService executor = MoreExecutors.sameThreadExecutor();
38         BindingBrokerTestFactory factory = new BindingBrokerTestFactory();
39         factory.setExecutor(executor);
40         factory.setStartWithParsedSchema(getStartWithSchema());
41         testContext = factory.getTestContext();
42         testContext.start();
43
44         baDataService = testContext.getBindingDataBroker();
45         biDataService = testContext.getDomDataBroker();
46         dataStore = testContext.getDomDataStore();
47         mappingService = testContext.getBindingToDomMappingService();
48     }
49
50     protected boolean getStartWithSchema() {
51         return true;
52     }
53
54     @After
55     public void afterTest() {
56
57         testContext.logDataStoreStatistics();
58
59     }
60 }