X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsamples%2Ftoaster-provider%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsample%2Ftoaster%2Fprovider%2FOpenDaylightToasterTest.java;h=4851522cb81a691d6bc538dc9a6e9374fc05901b;hb=refs%2Fchanges%2F27%2F100827%2F7;hp=c6f0dc1d3f615b8159337ed22c891216dbcd2460;hpb=310e1cf3dca0c2e94994a09c0faf7483d738e576;p=controller.git diff --git a/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java b/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java index c6f0dc1d3f..4851522cb8 100644 --- a/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java +++ b/opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java @@ -14,37 +14,38 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; -import com.google.common.base.Optional; +import java.util.Optional; import java.util.concurrent.Future; +import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.opendaylight.controller.md.sal.binding.api.DataBroker; -import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService; -import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction; -import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest; -import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; +import org.opendaylight.mdsal.binding.api.DataBroker; +import org.opendaylight.mdsal.binding.api.NotificationPublishService; +import org.opendaylight.mdsal.binding.api.ReadTransaction; +import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest; +import org.opendaylight.mdsal.common.api.LogicalDatastoreType; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.DisplayString; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInput; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastInputBuilder; +import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.MakeToastOutput; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.Toaster; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WheatBread; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.Uint32; -public class OpenDaylightToasterTest extends AbstractDataBrokerTest { +public class OpenDaylightToasterTest extends AbstractConcurrentDataBrokerTest { - private static InstanceIdentifier TOASTER_IID = InstanceIdentifier.builder(Toaster.class).build(); - OpendaylightToaster toaster; + private static final InstanceIdentifier TOASTER_IID = InstanceIdentifier.builder(Toaster.class).build(); + private OpendaylightToaster toaster; - @Override - protected void setupWithDataBroker(DataBroker dataBroker) { + @Before + public void setupToaster() { toaster = new OpendaylightToaster(); - toaster.setDataBroker(dataBroker); + toaster.setDataBroker(getDataBroker()); + toaster.init(); - /** - * Doesn't look like we have support for the NotificationProviderService yet, so mock it - * for now. - */ + // We'll mock the NotificationProviderService. NotificationPublishService mockNotification = mock(NotificationPublishService.class); toaster.setNotificationProvider(mockNotification); } @@ -53,7 +54,7 @@ public class OpenDaylightToasterTest extends AbstractDataBrokerTest { public void testToasterInitOnStartUp() throws Exception { DataBroker broker = getDataBroker(); - ReadOnlyTransaction readTx = broker.newReadOnlyTransaction(); + ReadTransaction readTx = broker.newReadOnlyTransaction(); Optional optional = readTx.read(LogicalDatastoreType.OPERATIONAL, TOASTER_IID).get(); assertNotNull(optional); assertTrue("Operational toaster not present", optional.isPresent()); @@ -71,15 +72,15 @@ public class OpenDaylightToasterTest extends AbstractDataBrokerTest { @Test @Ignore //ignored because it is not a test right now. Illustrative purposes only. public void testSomething() throws Exception { - MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(1L) - .setToasterToastType(WheatBread.class).build(); + MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(Uint32.valueOf(1)) + .setToasterToastType(WheatBread.VALUE).build(); // NOTE: In a real test we would want to override the Thread.sleep() to // prevent our junit test // for sleeping for a second... - Future> makeToast = toaster.makeToast(toastInput); + Future> makeToast = toaster.makeToast(toastInput); - RpcResult rpcResult = makeToast.get(); + RpcResult rpcResult = makeToast.get(); assertNotNull(rpcResult); assertTrue(rpcResult.isSuccessful());