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.mdsal.binding.dom.adapter.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.mdsal.binding.api.DataBroker;
15 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
18 public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
20 private DataBrokerTestCustomizer testCustomizer;
21 private DataBroker dataBroker;
22 private DOMDataBroker domBroker;
26 protected void setupWithSchema(final SchemaContext context) {
27 testCustomizer = createDataBrokerTestCustomizer();
28 dataBroker = testCustomizer.createDataBroker();
29 domBroker = testCustomizer.createDOMDataBroker();
30 testCustomizer.updateSchema(context);
31 setupWithDataBroker(dataBroker);
34 protected void setupWithDataBroker(final DataBroker dataBroker) {
35 // Intentionally left No-op, subclasses may customize it
38 protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
39 return new DataBrokerTestCustomizer();
42 public DataBroker getDataBroker() {
46 public DOMDataBroker getDomBroker() {
50 protected static final void assertCommit(final ListenableFuture<Void> commit) {
52 commit.get(500, TimeUnit.MILLISECONDS);
53 } catch (InterruptedException | ExecutionException | TimeoutException e) {
54 throw new IllegalStateException(e);