2 * Copyright (c) 2017 Red Hat, 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 com.google.common.util.concurrent.ListenableFuture;
11 import java.util.concurrent.ExecutionException;
12 import java.util.concurrent.TimeUnit;
13 import java.util.concurrent.TimeoutException;
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;
18 public abstract class AbstractBaseDataBrokerTest extends AbstractSchemaAwareTest {
20 private static final int ASSERT_COMMIT_DEFAULT_TIMEOUT = 5000;
22 private AbstractDataBrokerTestCustomizer testCustomizer;
23 private DataBroker dataBroker;
24 private DOMDataBroker domBroker;
26 protected abstract AbstractDataBrokerTestCustomizer createDataBrokerTestCustomizer();
29 protected void setupWithSchema(final SchemaContext context) {
30 testCustomizer = createDataBrokerTestCustomizer();
31 dataBroker = testCustomizer.createDataBroker();
32 domBroker = testCustomizer.createDOMDataBroker();
33 testCustomizer.updateSchema(context);
36 public DataBroker getDataBroker() {
40 public DOMDataBroker getDomBroker() {
44 protected static final void assertCommit(final ListenableFuture<Void> commit) {
45 assertCommit(commit, ASSERT_COMMIT_DEFAULT_TIMEOUT);
48 protected static final void assertCommit(final ListenableFuture<Void> commit, long timeoutInMS) {
50 commit.get(timeoutInMS, TimeUnit.MILLISECONDS);
51 } catch (InterruptedException | ExecutionException | TimeoutException e) {
52 throw new IllegalStateException(e);