Fix checkstyle in toaster-it
[controller.git] / opendaylight / md-sal / samples / toaster-it / src / test / java / org / opendaylight / controller / sample / toaster / it / ToasterTest.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sample.toaster.it;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.ops4j.pax.exam.CoreOptions.maven;
13
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;
28
29 @RunWith(PaxExam.class)
30 public class ToasterTest extends AbstractMdsalTestBase {
31     @Inject
32     @Filter(timeout = 60*1000)
33     KitchenService kitchenService;
34
35     @Override
36     public MavenUrlReference getFeatureRepo() {
37         return maven().groupId("org.opendaylight.controller").artifactId("features-mdsal").classifier("features")
38                 .type("xml").versionAsInProject();
39     }
40
41     @Override
42     public String getFeatureName() {
43         return "odl-toaster";
44     }
45
46     @Test
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");
51
52         long toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
53         assertEquals(0, toastsMade);
54
55         boolean success = true;
56
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();
60
61         assertTrue("Not all breakfasts succeeded", success);
62
63         // Verify toasts made count on provider via JMX/config-subsystem
64         toastsMade = (long) platformMBeanServer.getAttribute(providerOn, "ToastsMade");
65         assertEquals(2, toastsMade);
66     }
67 }