Renamed controller.md.sal.binding.api to mdsal.binding.api
[mdsal.git] / binding / mdsal-binding-dom-adapter / src / test / java / org / opendaylight / mdsal / binding / dom / adapter / test / AbstractDataBrokerTest.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.mdsal.binding.dom.adapter.test;
9
10 import org.opendaylight.mdsal.binding.api.DataBroker;
11
12 import java.util.concurrent.ExecutionException;
13 import java.util.concurrent.TimeUnit;
14 import java.util.concurrent.TimeoutException;
15 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import com.google.common.util.concurrent.ListenableFuture;
18
19 public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
20
21     private DataBrokerTestCustomizer testCustomizer;
22     private DataBroker dataBroker;
23     private DOMDataBroker domBroker;
24
25
26     @Override
27     protected void setupWithSchema(final SchemaContext context) {
28         testCustomizer = createDataBrokerTestCustomizer();
29         dataBroker = testCustomizer.createDataBroker();
30         domBroker = testCustomizer.createDOMDataBroker();
31         testCustomizer.updateSchema(context);
32         setupWithDataBroker(dataBroker);
33     }
34
35     protected void setupWithDataBroker(final DataBroker dataBroker) {
36         // Intentionally left No-op, subclasses may customize it
37     }
38
39    protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
40         return new DataBrokerTestCustomizer();
41     }
42
43     public DataBroker getDataBroker() {
44         return dataBroker;
45     }
46
47     public DOMDataBroker getDomBroker() {
48         return domBroker;
49     }
50
51     protected static final void assertCommit(final ListenableFuture<Void> commit) {
52         try {
53             commit.get(500, TimeUnit.MILLISECONDS);
54         } catch (InterruptedException | ExecutionException | TimeoutException e) {
55             throw new IllegalStateException(e);
56         }
57     }
58
59
60 }