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 java.util.concurrent.ExecutionException;
11 import java.util.concurrent.TimeUnit;
12 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 import com.google.common.util.concurrent.ListenableFuture;
20 public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
22 private DataBrokerTestCustomizer testCustomizer;
23 private DataBroker dataBroker;
24 private DOMDataBroker domBroker;
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);
36 protected void setupWithDataBroker(final DataBroker dataBroker) {
37 // Intentionally left No-op, subclasses may customize it
40 protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
41 return new DataBrokerTestCustomizer();
44 public DataBroker getDataBroker() {
48 public DOMDataBroker getDomBroker() {
52 protected static final void assertCommit(final ListenableFuture<Void> commit) {
54 commit.get(500, TimeUnit.MILLISECONDS);
55 } catch (InterruptedException | ExecutionException | TimeoutException e) {
56 throw new IllegalStateException(e);