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 test.mock.util;
10 import com.google.common.util.concurrent.ListenableFuture;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
13 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
15 import java.util.concurrent.ExecutionException;
16 import java.util.concurrent.TimeUnit;
17 import java.util.concurrent.TimeoutException;
19 public class AbstractDataBrokerTest extends AbstractSchemaAwareTest {
21 private DataBrokerTestCustomizer testCustomizer;
22 private DataBroker dataBroker;
23 private DOMDataBroker domBroker;
27 protected void setupWithSchema(final SchemaContext context) {
28 testCustomizer = createDataBrokerTestCustomizer();
29 dataBroker = testCustomizer.createDataBroker();
30 domBroker = testCustomizer.createDOMDataBroker();
31 testCustomizer.updateSchema(context);
32 setupWithDataBroker(dataBroker);
35 protected void setupWithDataBroker(final DataBroker dataBroker) {
36 // Intentionally left No-op, subclasses may customize it
39 protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() {
40 return new DataBrokerTestCustomizer();
43 public DataBroker getDataBroker() {
47 public DOMDataBroker getDomBroker() {
51 protected static final void assertCommit(final ListenableFuture<Void> commit) {
53 commit.get(500, TimeUnit.MILLISECONDS);
54 } catch (InterruptedException | ExecutionException | TimeoutException e) {
55 throw new IllegalStateException(e);