X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=openstack%2Fnet-virt%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fovsdb%2Fopenstack%2Fnetvirt%2FPortSecurityHandlerTest.java;h=bb975af41eb30744d96849e064143a66cc8fc7cb;hb=8c25485f297283f1dd337d5c45272598a2d3cc5e;hp=5668c06283cca8f2ce92d21ab248df5f45a8a55e;hpb=3a01b2e8c2e1023ed71b7b4c2b28a95d783b4a03;p=ovsdb.git diff --git a/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/PortSecurityHandlerTest.java b/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/PortSecurityHandlerTest.java index 5668c0628..bb975af41 100644 --- a/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/PortSecurityHandlerTest.java +++ b/openstack/net-virt/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/PortSecurityHandlerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Inocybe and others. All rights reserved. + * Copyright (c) 2015, 2016 Inocybe 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, @@ -21,26 +21,24 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; +import org.mockito.Mock; import org.mockito.Mockito; -import org.opendaylight.neutron.spi.NeutronSecurityGroup; -import org.opendaylight.neutron.spi.NeutronSecurityRule; +import org.mockito.runners.MockitoJUnitRunner; import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher; +import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityGroup; +import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronSecurityRule; import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper; -import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceReference; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; /** * Unit test {@link PortSecurityHandler} */ -@RunWith(PowerMockRunner.class) -@PrepareForTest(ServiceHelper.class) +@RunWith(MockitoJUnitRunner.class) public class PortSecurityHandlerTest { @InjectMocks private PortSecurityHandler portSecurityHandler; private PortSecurityHandler posrtSecurityHandlerSpy; + @Mock EventDispatcher eventDispatcher; @Before public void setUp() { @@ -73,7 +71,7 @@ public class PortSecurityHandlerTest { assertEquals("Error, did not return the correct HTTP flag", HttpURLConnection.HTTP_CREATED, portSecurityHandler.canCreateNeutronSecurityRule(mock(NeutronSecurityRule.class))); posrtSecurityHandlerSpy.neutronSecurityRuleCreated(any(NeutronSecurityRule.class)); - verify(posrtSecurityHandlerSpy, times(1)).canCreateNeutronSecurityRule(any(NeutronSecurityRule.class)); + verify(posrtSecurityHandlerSpy, times(1)).enqueueEvent(any(AbstractEvent.class)); } @Test @@ -86,7 +84,7 @@ public class PortSecurityHandlerTest { assertEquals("Error, did not return the correct HTTP flag", HttpURLConnection.HTTP_OK, portSecurityHandler.canDeleteNeutronSecurityRule(mock(NeutronSecurityRule.class))); posrtSecurityHandlerSpy.neutronSecurityRuleDeleted(any(NeutronSecurityRule.class)); - verify(posrtSecurityHandlerSpy, times(1)).canDeleteNeutronSecurityRule(any(NeutronSecurityRule.class)); + verify(posrtSecurityHandlerSpy, times(1)).enqueueEvent(any(AbstractEvent.class)); } @Test @@ -98,10 +96,9 @@ public class PortSecurityHandlerTest { public void testSetDependencies() throws Exception { EventDispatcher eventDispatcher = mock(EventDispatcher.class); - PowerMockito.mockStatic(ServiceHelper.class); - PowerMockito.when(ServiceHelper.getGlobalInstance(EventDispatcher.class, portSecurityHandler)).thenReturn(eventDispatcher); + ServiceHelper.overrideGlobalInstance(EventDispatcher.class, eventDispatcher); - portSecurityHandler.setDependencies(mock(BundleContext.class), mock(ServiceReference.class)); + portSecurityHandler.setDependencies(mock(ServiceReference.class)); assertEquals("Error, did not return the correct object", portSecurityHandler.eventDispatcher, eventDispatcher); }