X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fforwardingrules-manager%2Fsrc%2Ftest%2Fjava%2Ftest%2Fmock%2Futil%2FAbstractDataBrokerTest.java;fp=opendaylight%2Fmd-sal%2Fforwardingrules-manager%2Fsrc%2Ftest%2Fjava%2Ftest%2Fmock%2Futil%2FAbstractDataBrokerTest.java;h=f9efa51d41be443f9037ad1799a0a249e56da1d0;hb=3ed53ef05d371492040ca3e67b98a8cfebdcc76d;hp=0000000000000000000000000000000000000000;hpb=413e4ecb09769460eaf740f067e06f198957ce13;p=controller.git diff --git a/opendaylight/md-sal/forwardingrules-manager/src/test/java/test/mock/util/AbstractDataBrokerTest.java b/opendaylight/md-sal/forwardingrules-manager/src/test/java/test/mock/util/AbstractDataBrokerTest.java new file mode 100644 index 0000000000..f9efa51d41 --- /dev/null +++ b/opendaylight/md-sal/forwardingrules-manager/src/test/java/test/mock/util/AbstractDataBrokerTest.java @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package test.mock.util; + +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; + +import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +public class AbstractDataBrokerTest extends AbstractSchemaAwareTest { + + private DataBrokerTestCustomizer testCustomizer; + private DataBroker dataBroker; + private DOMDataBroker domBroker; + + + @Override + protected void setupWithSchema(final SchemaContext context) { + testCustomizer = createDataBrokerTestCustomizer(); + dataBroker = testCustomizer.createDataBroker(); + domBroker = testCustomizer.createDOMDataBroker(); + testCustomizer.updateSchema(context); + setupWithDataBroker(dataBroker); + } + + protected void setupWithDataBroker(final DataBroker dataBroker) { + // Intentionally left No-op, subclasses may customize it + } + + protected DataBrokerTestCustomizer createDataBrokerTestCustomizer() { + return new DataBrokerTestCustomizer(); + } + + public DataBroker getDataBroker() { + return dataBroker; + } + + public DOMDataBroker getDomBroker() { + return domBroker; + } + + protected static final void assertCommit(final ListenableFuture commit) { + try { + commit.get(500, TimeUnit.MILLISECONDS); + } catch (InterruptedException | ExecutionException | TimeoutException e) { + throw new IllegalStateException(e); + } + } + + +}