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