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