X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflowplugin-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fopenflowplugin%2Fimpl%2Fservices%2Fsal%2FSalRoleServiceImplTest.java;h=91e3eb8063fca0f165bc8b9bb80ce3ec7ff56de8;hb=cd2ee9a2cc640746835fe585cf1a45b1d33b423f;hp=20f26350002ead576f5c7125fec4fb7d99f9a0e4;hpb=e1ffb3c68e930c693d6c03f656d01d8c8b502754;p=openflowplugin.git diff --git a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java index 20f2635000..91e3eb8063 100644 --- a/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java +++ b/openflowplugin-impl/src/test/java/org/opendaylight/openflowplugin/impl/services/sal/SalRoleServiceImplTest.java @@ -8,7 +8,6 @@ package org.opendaylight.openflowplugin.impl.services.sal; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -21,7 +20,6 @@ import org.junit.Test; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter; import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue; import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext; import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext; @@ -47,13 +45,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetR import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleInputBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.role.service.rev150727.SetRoleOutput; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; -/** - * Created by kramesha on 8/27/15. - */ public class SalRoleServiceImplTest { @Mock @@ -62,9 +56,6 @@ public class SalRoleServiceImplTest { @Mock private DeviceContext mockDeviceContext; - @Mock - private ConnectionAdapter mockConnectionAdapter; - @Mock private FeaturesReply mockFeaturesReply; @@ -91,14 +82,12 @@ public class SalRoleServiceImplTest { private NodeId testNodeId = new NodeId(Uri.getDefaultInstance("openflow:1")); - private static short testVersion = 4; - private static long testXid = 100L; - private static final String ROLEREQUESTFAILED = - org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ErrorType.ROLEREQUESTFAILED.name(); + private static final String ROLEREQUESTFAILED = org.opendaylight.yang.gen.v1.urn + .opendaylight.openflow.common.types.rev130731.ErrorType.ROLEREQUESTFAILED.name(); - private static final String ROLES_UNSUPPORTED = "Device reported error type "+ ROLEREQUESTFAILED +" code UNSUP"; + private static final String ROLES_UNSUPPORTED = "Device reported error type " + ROLEREQUESTFAILED + " code UNSUP"; private NodeRef nodeRef; @@ -107,6 +96,7 @@ public class SalRoleServiceImplTest { MockitoAnnotations.initMocks(this); Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId); Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN); + short testVersion = 4; Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion); Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState); Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo); @@ -118,7 +108,8 @@ public class SalRoleServiceImplTest { Mockito.when(mockRequestContextStack.createRequestContext()).thenReturn(mockRequestContext); Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(testXid)); Mockito.when(mockConnectionContext.getOutboundQueueProvider()).thenReturn(mockOutboundQueue); - Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING); + Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState()) + .thenReturn(ConnectionContext.CONNECTION_STATE.WORKING); NodeKey key = new NodeKey(testNodeId); InstanceIdentifier path = InstanceIdentifier.builder(Nodes.class) @@ -157,31 +148,6 @@ public class SalRoleServiceImplTest { } - @Test - public void testSetRoleUnsupported() throws Exception { - ListenableFuture> futureOutput = - RpcResultBuilder.failed() - .withError(ErrorType.APPLICATION, ROLES_UNSUPPORTED) - .buildFuture(); - - Mockito.when(mockRequestContext.getFuture()).thenReturn(futureOutput); - - SalRoleService salRoleService = new SalRoleServiceImpl(mockRequestContextStack, mockDeviceContext); - - SetRoleInput setRoleInput = new SetRoleInputBuilder() - .setControllerRole(OfpRole.BECOMESLAVE) - .setNode(nodeRef) - .build(); - - Future> future = salRoleService.setRole(setRoleInput); - - RpcResult roleOutputRpcResult = future.get(5, TimeUnit.SECONDS); - assertNotNull("RpcResult from future cannot be null.", roleOutputRpcResult); - assertFalse("RpcResult from future is successful.", roleOutputRpcResult.isSuccessful()); - assertEquals(ROLES_UNSUPPORTED, roleOutputRpcResult - .getErrors().iterator().next().getMessage()); - } - @Test public void testDuplicateRoles() throws Exception { // set role to slave