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.md.sal.binding.test;
10 import static org.junit.Assert.assertEquals;
12 import java.util.concurrent.ExecutionException;
13 import java.util.concurrent.TimeUnit;
14 import java.util.concurrent.TimeoutException;
16 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
17 import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
18 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
19 import org.opendaylight.yangtools.yang.common.RpcResult;
20 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
22 import com.google.common.util.concurrent.ListenableFuture;
24 public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
26 private DataBrokerTestCustomizer testCustomizer;
27 private DataBroker dataBroker;
28 private DOMDataBroker domBroker;
32 protected void setupWithSchema(final SchemaContext context) {
33 testCustomizer = createDataBrokerTestCustomizer();
34 dataBroker = testCustomizer.createDataBroker();
35 domBroker = testCustomizer.createDOMDataBroker();
36 testCustomizer.updateSchema(context);
37 setupWithDataBroker(dataBroker);
40 protected void setupWithDataBroker(final DataBroker dataBroker) {
41 // Intentionally left No-op, subclasses may customize it
44 protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
45 return new DataBrokerTestCustomizer();
48 public DataBroker getDataBroker() {
52 public DOMDataBroker getDomBroker() {
56 protected static final void assertCommit(final ListenableFuture<RpcResult<TransactionStatus>> commit) {
58 assertEquals(TransactionStatus.COMMITED,commit.get(500, TimeUnit.MILLISECONDS).getResult());
59 } catch (InterruptedException | ExecutionException | TimeoutException e) {
60 throw new IllegalStateException(e);