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=7ad1e38e2c4a340cb36d6577eb132234f9bf0cb4;hb=c18f35dc4659c301354e25aca4d41178201975f1;hp=1b6dc3cc2c1413fae485dd08f0c3d1bfde80e0e4;hpb=4588c8fc9faaf73b84fdcf63d9be82e14087dffe;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 1b6dc3cc2c..7ad1e38e2c 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 @@ -22,6 +22,7 @@ import org.junit.Test; 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.api.RpcProviderService; 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; @@ -41,21 +42,18 @@ public class OpenDaylightToasterTest extends AbstractConcurrentDataBrokerTest { @Before public void setupToaster() { - toaster = new OpendaylightToaster(); - toaster.setDataBroker(getDataBroker()); - toaster.init(); - - // We'll mock the NotificationProviderService. - NotificationPublishService mockNotification = mock(NotificationPublishService.class); - toaster.setNotificationProvider(mockNotification); + toaster = new OpendaylightToaster(getDataBroker(), mock(NotificationPublishService.class), + mock(RpcProviderService.class)); } @Test public void testToasterInitOnStartUp() throws Exception { DataBroker broker = getDataBroker(); - ReadTransaction readTx = broker.newReadOnlyTransaction(); - Optional optional = readTx.read(LogicalDatastoreType.OPERATIONAL, TOASTER_IID).get(); + Optional optional; + try (ReadTransaction readTx = broker.newReadOnlyTransaction()) { + optional = readTx.read(LogicalDatastoreType.OPERATIONAL, TOASTER_IID).get(); + } assertNotNull(optional); assertTrue("Operational toaster not present", optional.isPresent()); @@ -65,15 +63,17 @@ public class OpenDaylightToasterTest extends AbstractConcurrentDataBrokerTest { assertEquals(new DisplayString("Opendaylight"), toasterData.getToasterManufacturer()); assertEquals(new DisplayString("Model 1 - Binding Aware"), toasterData.getToasterModelNumber()); - Optional configToaster = readTx.read(LogicalDatastoreType.CONFIGURATION, TOASTER_IID).get(); - assertFalse("Didn't expect config data for toaster.", configToaster.isPresent()); + try (ReadTransaction readTx = broker.newReadOnlyTransaction()) { + Boolean configToaster = readTx.exists(LogicalDatastoreType.CONFIGURATION, TOASTER_IID).get(); + assertFalse("Didn't expect config data for toaster.", configToaster); + } } @Test @Ignore //ignored because it is not a test right now. Illustrative purposes only. public void testSomething() throws Exception { MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(Uint32.valueOf(1)) - .setToasterToastType(WheatBread.class).build(); + .setToasterToastType(WheatBread.VALUE).build(); // NOTE: In a real test we would want to override the Thread.sleep() to // prevent our junit test