X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Ftest%2Fsal%2Fbinding%2Fit%2FNoficationTest.java;h=b23ceaaf15b69c0bed04977b97e3bcefb7eab50a;hp=fdae91670c74ccd4ac5498f5bc4cd45ce2582e17;hb=c31af714994cbaed40299758460916b2c7101158;hpb=6b5e1e50d209999f53a32ae44e9a7c03a79e499c diff --git a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NoficationTest.java b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NoficationTest.java index fdae91670c..b23ceaaf15 100644 --- a/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NoficationTest.java +++ b/opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NoficationTest.java @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.test.sal.binding.it; import static org.junit.Assert.assertEquals; @@ -5,21 +12,33 @@ import static org.junit.Assert.assertNotNull; import java.math.BigInteger; import java.util.ArrayList; +import java.util.Collection; import java.util.List; import org.junit.Before; import org.junit.Test; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; -import org.opendaylight.controller.sal.binding.api.*; -import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.*; +import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer; +import org.opendaylight.controller.sal.binding.api.BindingAwareProvider; +import org.opendaylight.controller.sal.binding.api.NotificationProviderService; +import org.opendaylight.controller.sal.binding.api.NotificationService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAdded; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowAddedBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemoved; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowUpdated; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeErrorNotification; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.NodeExperimenterErrorNotification; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SwitchFlowRemoved; import org.opendaylight.yangtools.concepts.Registration; import org.opendaylight.yangtools.yang.binding.NotificationListener; +import org.opendaylight.yangtools.yang.binding.RpcService; public class NoficationTest extends AbstractTest { - private FlowListener listener1 = new FlowListener(); - private FlowListener listener2 = new FlowListener(); + private final FlowListener listener1 = new FlowListener(); + private final FlowListener listener2 = new FlowListener(); private Registration listener1Reg; private Registration listener2Reg; @@ -33,9 +52,9 @@ public class NoficationTest extends AbstractTest { @Test public void notificationTest() throws Exception { /** - * + * * The registration of the Provider 1. - * + * */ AbstractTestProvider provider1 = new AbstractTestProvider() { @Override @@ -49,10 +68,10 @@ public class NoficationTest extends AbstractTest { assertNotNull(notifyProviderService); /** - * + * * The registration of the Consumer 1. It retrieves Notification Service * from MD-SAL and registers SalFlowListener as notification listener - * + * */ BindingAwareConsumer consumer1 = new BindingAwareConsumer() { @Override @@ -77,7 +96,7 @@ public class NoficationTest extends AbstractTest { /** * Check that one notification was delivered and has correct cookie. - * + * */ assertEquals(1, listener1.addedFlows.size()); assertEquals(0, listener1.addedFlows.get(0).getCookie().intValue()); @@ -86,16 +105,36 @@ public class NoficationTest extends AbstractTest { * The registration of the Consumer 2. SalFlowListener is registered * registered as notification listener. */ - BindingAwareConsumer consumer2 = new BindingAwareConsumer() { + BindingAwareProvider provider = new BindingAwareProvider() { + @Override - public void onSessionInitialized(ConsumerContext session) { + public void onSessionInitiated(ProviderContext session) { listener2Reg = session.getSALService(NotificationProviderService.class).registerNotificationListener( listener2); } + + @Override + public void onSessionInitialized(ConsumerContext session) { + // TODO Auto-generated method stub + + } + + @Override + public Collection getImplementations() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Collection getFunctionality() { + // TODO Auto-generated method stub + return null; + } + }; // registerConsumer method calls onSessionInitialized method above - broker.registerConsumer(consumer2, getBundleContext()); + broker.registerProvider(provider, getBundleContext()); /** * 3 notifications are published @@ -113,19 +152,19 @@ public class NoficationTest extends AbstractTest { /** * Check that 3 notification was delivered to both listeners (first one * received 4 in total, second 3 in total). - * + * */ assertEquals(4, listener1.addedFlows.size()); assertEquals(3, listener2.addedFlows.size()); /** * The second listener is closed (unregistered) - * + * */ listener2Reg.close(); /** - * + * * The notification 5 is published */ notifyProviderService.publish(flowAdded(10)); @@ -140,7 +179,7 @@ public class NoficationTest extends AbstractTest { * Check that first consumer received 5 notifications in total, second * consumer received only three. Last notification was never received by * second consumer because its listener was unregistered. - * + * */ assertEquals(5, listener1.addedFlows.size()); assertEquals(3, listener2.addedFlows.size()); @@ -150,7 +189,7 @@ public class NoficationTest extends AbstractTest { /** * Creates instance of the type FlowAdded. Only cookie value is set. It is * used only for testing purpose. - * + * * @param i * cookie value * @return instance of the type FlowAdded @@ -162,7 +201,7 @@ public class NoficationTest extends AbstractTest { } /** - * + * * Implements * {@link org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.SalFlowListener * SalFlowListener} and contains attributes which keep lists of objects of @@ -192,5 +231,24 @@ public class NoficationTest extends AbstractTest { updatedFlows.add(notification); } + @Override + public void onSwitchFlowRemoved(SwitchFlowRemoved notification) { + // TODO Auto-generated method stub + + } + + @Override + public void onNodeErrorNotification(NodeErrorNotification notification) { + // TODO Auto-generated method stub + + } + + @Override + public void onNodeExperimenterErrorNotification( + NodeExperimenterErrorNotification notification) { + // TODO Auto-generated method stub + + } + } }