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.MakeToast;
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 // proxy for the entire toaster, nothing else
41 public MavenUrlReference getFeatureRepo() {
42 return maven().groupId("org.opendaylight.controller").artifactId("features-controller-experimental")
43 .classifier("features").type("xml").versionAsInProject();
47 public String getFeatureName() {
52 public void testToaster() throws Exception {
53 MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
54 ObjectName providerOn = new ObjectName(
55 "org.opendaylight.controller:name=OpendaylightToaster,type=toaster-provider");
57 long toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
58 assertEquals(0, toastsMade);
60 boolean success = true;
62 // Make toasts using OSGi service
63 success &= kitchenService.makeBreakfast(EggsType.SCRAMBLED, HashBrown.VALUE, 4).get().isSuccessful();
64 success &= kitchenService.makeBreakfast(EggsType.POACHED, WhiteBread.VALUE, 8).get().isSuccessful();
66 assertTrue("Not all breakfasts succeeded", success);
68 // Verify toasts made count on provider via JMX/config-subsystem
69 toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
70 assertEquals(2, toastsMade);