X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsamples%2Ftoaster-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsample%2Ftoaster%2Fit%2FToasterTest.java;h=30f1762197ecf58a35c8828775dfb009742a7025;hp=000783bd07e545ee16ae5e306c20c8d72f4d6e35;hb=dddc5c7faaa4991535e56c8b16c9ecb2f5303ab0;hpb=a2c374bb7bd34eb27bac4db587e843378181762e diff --git a/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java b/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java index 000783bd07..30f1762197 100644 --- a/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java +++ b/opendaylight/md-sal/samples/toaster-it/src/test/java/org/opendaylight/controller/sample/toaster/it/ToasterTest.java @@ -7,21 +7,11 @@ */ package org.opendaylight.controller.sample.toaster.it; -import static org.junit.Assert.assertEquals; -import static org.opendaylight.controller.test.sal.binding.it.TestHelper.*; -import static org.ops4j.pax.exam.CoreOptions.*; - -import javax.inject.Inject; -import javax.management.JMX; -import javax.management.MBeanServer; -import javax.management.ObjectName; - import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; -import org.opendaylight.controller.config.yang.config.toaster_consumer.impl.ToasterConsumerRuntimeMXBean; -import org.opendaylight.controller.config.yang.config.toaster_provider.impl.ToasterProviderRuntimeMXBean; -import org.opendaylight.controller.sample.toaster.provider.api.ToastConsumer; +import org.opendaylight.controller.sample.kitchen.api.EggsType; +import org.opendaylight.controller.sample.kitchen.api.KitchenService; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.HashBrown; import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WhiteBread; import org.ops4j.pax.exam.Configuration; @@ -31,14 +21,30 @@ import org.ops4j.pax.exam.options.DefaultCompositeOption; import org.ops4j.pax.exam.util.Filter; import org.ops4j.pax.exam.util.PathUtils; +import javax.inject.Inject; +import javax.management.MBeanServer; +import javax.management.ObjectName; + import java.lang.management.ManagementFactory; +import static org.junit.Assert.assertEquals; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.baseModelBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.bindingAwareSalBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.configMinumumBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.flowCapableModelBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.junitAndMockitoBundles; +import static org.opendaylight.controller.test.sal.binding.it.TestHelper.mdSalCoreBundles; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; +import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.CoreOptions.systemPackages; +import static org.ops4j.pax.exam.CoreOptions.systemProperty; + @RunWith(PaxExam.class) public class ToasterTest { @Inject @Filter(timeout=60*1000) - ToastConsumer toastConsumer; + KitchenService kitchenService; @Configuration public Option[] config() { @@ -72,7 +78,9 @@ public class ToasterTest { return new DefaultCompositeOption( mavenBundle("org.opendaylight.controller.samples", "sample-toaster-provider").versionAsInProject(), mavenBundle("org.opendaylight.controller.samples", "sample-toaster-consumer").versionAsInProject(), - mavenBundle("org.opendaylight.controller.samples", "sample-toaster").versionAsInProject() + mavenBundle("org.opendaylight.controller.samples", "sample-toaster").versionAsInProject(), + mavenBundle("org.openexi", "nagasena").versionAsInProject(), + mavenBundle("org.openexi", "nagasena-rta").versionAsInProject() ); } @@ -80,26 +88,22 @@ public class ToasterTest { public void testToaster() throws Exception { MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer(); - ObjectName consumerOn = new ObjectName("org.opendaylight.controller:instanceName=toaster-consumer-impl,type=RuntimeBean,moduleFactoryName=toaster-consumer-impl"); ObjectName providerOn = new ObjectName("org.opendaylight.controller:instanceName=toaster-provider-impl,type=RuntimeBean,moduleFactoryName=toaster-provider-impl"); long toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade"); assertEquals(0, toastsMade); - boolean toasts = true; + boolean success = true; // Make toasts using OSGi service - toasts &= toastConsumer.createToast(HashBrown.class, 4); - toasts &= toastConsumer.createToast(WhiteBread.class, 8); - - // Make toast using JMX/config-subsystem - toasts &= (Boolean)platformMBeanServer.invoke(consumerOn, "makeHashBrownToast", new Object[]{4}, new String[]{Integer.class.getName()}); + success &= kitchenService.makeBreakfast( EggsType.SCRAMBLED, HashBrown.class, 4).get().isSuccessful(); + success &= kitchenService.makeBreakfast( EggsType.POACHED, WhiteBread.class, 8 ).get().isSuccessful(); - Assert.assertTrue("Not all toasts done by " + toastConsumer, toasts); + Assert.assertTrue("Not all breakfasts succeeded", success); // Verify toasts made count on provider via JMX/config-subsystem toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade"); - assertEquals(3, toastsMade); + assertEquals(2, toastsMade); } }