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 org.opendaylight.controller.sample.toaster.it;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.ops4j.pax.exam.CoreOptions.maven;
14 import java.lang.management.ManagementFactory;
15 import javax.inject.Inject;
16 import javax.management.MBeanServer;
17 import javax.management.ObjectName;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
21 import org.opendaylight.controller.sample.kitchen.api.EggsType;
22 import org.opendaylight.controller.sample.kitchen.api.KitchenService;
23 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.HashBrown;
24 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.ToasterService;
25 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WhiteBread;
26 import org.ops4j.pax.exam.junit.PaxExam;
27 import org.ops4j.pax.exam.options.MavenUrlReference;
28 import org.ops4j.pax.exam.util.Filter;
30 @RunWith(PaxExam.class)
31 public class ToasterTest extends AbstractMdsalTestBase {
33 @Filter(timeout = 60 * 1000)
34 KitchenService kitchenService;
36 @Filter(timeout = 60 * 1000)
37 ToasterService toasterService;
40 public MavenUrlReference getFeatureRepo() {
41 return maven().groupId("org.opendaylight.controller").artifactId("features-controller-experimental")
42 .classifier("features").type("xml").versionAsInProject();
46 public String getFeatureName() {
51 public void testToaster() throws Exception {
52 MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
53 ObjectName providerOn = new ObjectName(
54 "org.opendaylight.controller:name=OpendaylightToaster,type=toaster-provider");
56 long toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
57 assertEquals(0, toastsMade);
59 boolean success = true;
61 // Make toasts using OSGi service
62 success &= kitchenService.makeBreakfast(EggsType.SCRAMBLED, HashBrown.VALUE, 4).get().isSuccessful();
63 success &= kitchenService.makeBreakfast(EggsType.POACHED, WhiteBread.VALUE, 8).get().isSuccessful();
65 assertTrue("Not all breakfasts succeeded", success);
67 // Verify toasts made count on provider via JMX/config-subsystem
68 toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
69 assertEquals(2, toastsMade);