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.WhiteBread;
25 import org.ops4j.pax.exam.junit.PaxExam;
26 import org.ops4j.pax.exam.options.MavenUrlReference;
27 import org.ops4j.pax.exam.util.Filter;
29 @RunWith(PaxExam.class)
30 public class ToasterTest extends AbstractMdsalTestBase {
32 @Filter(timeout = 60 * 1000)
33 KitchenService kitchenService;
36 public MavenUrlReference getFeatureRepo() {
37 return maven().groupId("org.opendaylight.controller").artifactId("features-controller-experimental")
38 .classifier("features").type("xml").versionAsInProject();
42 public String getFeatureName() {
47 public void testToaster() throws Exception {
48 MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
49 ObjectName providerOn = new ObjectName(
50 "org.opendaylight.controller:name=OpendaylightToaster,type=toaster-provider");
52 long toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
53 assertEquals(0, toastsMade);
55 boolean success = true;
57 // Make toasts using OSGi service
58 success &= kitchenService.makeBreakfast(EggsType.SCRAMBLED, HashBrown.class, 4).get().isSuccessful();
59 success &= kitchenService.makeBreakfast(EggsType.POACHED, WhiteBread.class, 8).get().isSuccessful();
61 assertTrue("Not all breakfasts succeeded", success);
63 // Verify toasts made count on provider via JMX/config-subsystem
64 toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
65 assertEquals(2, toastsMade);