--- /dev/null
+/*
+ * Copyright (c) 2015 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.openflowplugin.impl.services;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.SendBarrierInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+
+/**
+ * Test for {@link FlowCapableTransactionServiceImpl}.
+ */
+public class FlowCapableTransactionServiceImplTest extends ServiceMocking {
+
+ private static final Long DUMMY_XID_VALUE = 100L;
+ FlowCapableTransactionServiceImpl flowCapableTransactionService;
+
+ @Override
+ protected void setup() {
+ flowCapableTransactionService = new FlowCapableTransactionServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+ }
+
+ @Test
+ public void testBuildRequest() throws Exception {
+ SendBarrierInput sendBarrierInput = buildSendBarrierInput();
+
+ final OfHeader request = flowCapableTransactionService.buildRequest(new Xid(DUMMY_XID_VALUE), sendBarrierInput);
+ assertEquals(DUMMY_XID_VALUE, request.getXid());
+ assertTrue(request instanceof BarrierInput);
+ }
+
+ @Test
+ public void testSendBarrier() throws Exception {
+ SendBarrierInput sendBarrierInput = buildSendBarrierInput();
+ flowCapableTransactionService.sendBarrier(sendBarrierInput);
+ verify(mockedRequestContextStack).createRequestContext();
+ }
+
+ private SendBarrierInput buildSendBarrierInput() {
+ return new SendBarrierInputBuilder()
+ .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier())).build();
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2015 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.openflowplugin.impl.services;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.verify;
+
+import org.junit.Test;
+import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
+import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.action.grouping.action.choice.OutputActionCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
+import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
+
+/**
+ * Test for {@link PacketProcessingServiceImpl}.
+ */
+public class PacketProcessingServiceImplTest extends ServiceMocking {
+
+ private static final Long DUMMY_XID_VALUE = 100L;
+ public static final String ULTIMATE_PAYLOAD = "What do you get when you multiply six by nine?";
+
+ private PacketProcessingServiceImpl packetProcessingService;
+ private KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> pathToNodeconnector;
+
+ @Override
+ protected void setup() {
+ packetProcessingService = new PacketProcessingServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+ pathToNodeconnector = KeyedInstanceIdentifier.create(Nodes.class)
+ .child(Node.class, new NodeKey(new NodeId("ofp-ut:123")))
+ .child(NodeConnector.class, new NodeConnectorKey(new NodeConnectorId("ofp-ut:123:1")));
+ OpenflowPortsUtil.init();
+ }
+
+ @Test
+ public void testTransmitPacket() throws Exception {
+ TransmitPacketInput transmitPacketInput = buildTransmitPacketInput();
+ packetProcessingService.transmitPacket(transmitPacketInput);
+ verify(mockedRequestContextStack).createRequestContext();
+ }
+
+ @Test
+ public void testBuildRequest() throws Exception {
+ TransmitPacketInput transmitPacketInput = buildTransmitPacketInput();
+
+ final OfHeader request = packetProcessingService.buildRequest(new Xid(DUMMY_XID_VALUE), transmitPacketInput);
+ assertEquals(DUMMY_XID_VALUE, request.getXid());
+ assertTrue(request instanceof PacketOutInput);
+ final PacketOutInput input = (PacketOutInput) request;
+ assertEquals(OFConstants.OFP_NO_BUFFER, input.getBufferId());
+ assertEquals(1, input.getAction().size());
+ assertEquals(OutputActionCase.class, input.getAction().get(0).getActionChoice().getImplementedInterface());
+
+ final OutputActionCase actionChoice = (OutputActionCase) input.getAction().get(0).getActionChoice();
+ assertEquals(1, actionChoice.getOutputAction().getPort().getValue().intValue());
+ assertEquals(ULTIMATE_PAYLOAD, new String(input.getData()));
+ }
+
+ private TransmitPacketInput buildTransmitPacketInput() {
+ TransmitPacketInputBuilder transmitPacketInputBld = new TransmitPacketInputBuilder()
+ .setBufferId(OFConstants.OFP_NO_BUFFER)
+ .setNode(new NodeRef(mockedDeviceState.getNodeInstanceIdentifier()))
+ .setPayload(ULTIMATE_PAYLOAD.getBytes())
+ .setEgress(new NodeConnectorRef(pathToNodeconnector));
+ return transmitPacketInputBld.build();
+ }
+}
\ No newline at end of file
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import com.google.common.util.concurrent.Futures;
import java.math.BigInteger;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.UpdateFlowInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.OriginalFlow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.flow.update.UpdatedFlow;
addFlow(null);
}
+ @Test
+ public void testAddFlowFailCallback() throws Exception {
+ AddFlowInput mockedAddFlowInput = createFlowMock(AddFlowInput.class);
+ Mockito.doReturn(Futures.<RequestContext<Object>>immediateFailedFuture(new Exception("ut-failed-response")))
+ .when(requestContext).getFuture();
+
+ final Future<RpcResult<AddFlowOutput>> rpcResultFuture = salFlowService.addFlow(mockedAddFlowInput);
+
+ assertNotNull(rpcResultFuture);
+ final RpcResult<?> addFlowOutputRpcResult = rpcResultFuture.get();
+ assertNotNull(addFlowOutputRpcResult);
+ assertFalse(addFlowOutputRpcResult.isSuccessful());
+ }
+
+ @Test
+ public void testRemoveFlowFailCallback() throws Exception {
+ RemoveFlowInput mockedRemoveFlowInput = createFlowMock(RemoveFlowInput.class);
+ Mockito.doReturn(Futures.<RequestContext<Object>>immediateFailedFuture(new Exception("ut-failed-response")))
+ .when(requestContext).getFuture();
+
+ final Future<RpcResult<RemoveFlowOutput>> rpcResultFuture = salFlowService.removeFlow(mockedRemoveFlowInput);
+
+ assertNotNull(rpcResultFuture);
+ final RpcResult<?> removeFlowOutputRpcResult = rpcResultFuture.get();
+ assertNotNull(removeFlowOutputRpcResult);
+ assertFalse(removeFlowOutputRpcResult.isSuccessful());
+ }
+
@Test
public void testAddFlowWithItemLifecycle() throws Exception {
addFlow(mock(ItemLifecycleListener.class));
package org.opendaylight.openflowplugin.impl.services;
-import junit.framework.TestCase;
-import org.junit.Before;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.SettableFuture;
+import java.math.BigInteger;
+import java.util.Collections;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import org.junit.Assert;
import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.mockito.Matchers;
import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.Mockito;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
-import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.OFConstants;
-import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
-import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
-import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
-import org.opendaylight.openflowplugin.api.openflow.rpc.RpcContext;
-import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
-import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
-import org.opendaylight.openflowplugin.impl.rpc.RpcContextImpl;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableFeaturesCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.MultipartReplyTableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table.features._case.multipart.reply.table.features.TableFeaturesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.table.features.properties.grouping.TableFeatureProperties;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.UpdateTableOutput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTable;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.service.rev131026.table.update.UpdatedTableBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.table.features.TableFeatures;
import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import java.math.BigInteger;
-import java.util.Collections;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-
-import static org.mockito.Mockito.when;
-
-@RunWith(MockitoJUnitRunner.class)
-public class SalTableServiceImplTest extends TestCase {
+public class SalTableServiceImplTest extends ServiceMocking {
private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444");
private static final Short DUMMY_VERSION = OFConstants.OFP_VERSION_1_3;
private static final int DUMMY_MAX_REQUEST = 88;
- @Mock
- RequestContextStack mockedRequestContextStack;
- @Mock
- DeviceContext mockedDeviceContext;
- @Mock
- ConnectionContext mockedPrimConnectionContext;
- @Mock
- FeaturesReply mockedFeatures;
- @Mock
- ConnectionAdapter mockedConnectionAdapter;
- @Mock
- MessageSpy mockedMessagSpy;
@Mock
RpcProviderRegistry mockedRpcProviderRegistry;
- @Mock
- OutboundQueue mockedOutboundQueue;
- @Before
- public void initialization() {
- when(mockedFeatures.getDatapathId()).thenReturn(DUMMY_DATAPATH_ID);
- when(mockedFeatures.getVersion()).thenReturn(DUMMY_VERSION);
+ private SettableFuture<Object> handleResultFuture;
+ private SalTableServiceImpl salTableService;
+
+ @Override
+ public void setup() {
+ handleResultFuture = SettableFuture.create();
+ when(mockedRequestContext.getFuture()).thenReturn(handleResultFuture);
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ final FutureCallback<OfHeader> callback = (FutureCallback<OfHeader>) invocation.getArguments()[2];
+ callback.onSuccess(null);
+ return null;
+ }
+ })
+ .when(mockedOutboundQueue).commitEntry(
+ Matchers.anyLong(), Matchers.<OfHeader>any(), Matchers.<FutureCallback<OfHeader>>any());
- when(mockedPrimConnectionContext.getFeatures()).thenReturn(mockedFeatures);
- when(mockedPrimConnectionContext.getConnectionAdapter()).thenReturn(mockedConnectionAdapter);
- when(mockedPrimConnectionContext.getOutboundQueueProvider()).thenReturn(mockedOutboundQueue);
+ salTableService = new SalTableServiceImpl(mockedRequestContextStack, mockedDeviceContext);
+ }
- when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
+ @Test
+ public void testUpdateTableFail1() throws ExecutionException, InterruptedException {
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.<List<MultipartReply>>failed().build();
+ handleResultFuture.set(rpcResult);
+ return null;
+ }
+ }).when(multiMessageCollector).endCollecting(Matchers.<EventIdentifier>any());
- when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
- when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl());
+ final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = salTableService.updateTable(prepareUpdateTable());
+ Assert.assertNotNull(rpcResultFuture);
+ verify(mockedRequestContextStack).createRequestContext();
}
@Test
- public void testUpdateTable() throws ExecutionException, InterruptedException {
- final RpcContextImpl rpcContext = new RpcContextImpl(mockedMessagSpy,
- mockedRpcProviderRegistry, mockedDeviceContext, DUMMY_MAX_REQUEST);
- final SalTableServiceImpl salTableService = new SalTableServiceImpl(rpcContext, mockedDeviceContext);
+ public void testUpdateTableFail2() throws ExecutionException, InterruptedException {
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder.success(Collections.<MultipartReply>emptyList())
+ .build();
+ handleResultFuture.set(rpcResult);
+ return null;
+ }
+ }).when(multiMessageCollector).endCollecting(Matchers.<EventIdentifier>any());
+
+ final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = salTableService.updateTable(prepareUpdateTable());
+ Assert.assertNotNull(rpcResultFuture);
+ verify(mockedRequestContextStack).createRequestContext();
+ }
+
+ @Test
+ public void testUpdateTableSuccess() throws ExecutionException, InterruptedException {
+ Mockito.doAnswer(new Answer<Void>() {
+ @Override
+ public Void answer(InvocationOnMock invocation) throws Throwable {
+ TableFeaturesBuilder tableFeaturesBld = new TableFeaturesBuilder()
+ .setTableId((short) 0)
+ .setName("Zafod")
+ .setMaxEntries(42L)
+ .setTableFeatureProperties(Collections.<TableFeatureProperties>emptyList());
+ MultipartReplyTableFeaturesBuilder mpTableFeaturesBld = new MultipartReplyTableFeaturesBuilder()
+ .setTableFeatures(Collections.singletonList(tableFeaturesBld.build()));
+ MultipartReplyTableFeaturesCaseBuilder mpBodyBld = new MultipartReplyTableFeaturesCaseBuilder()
+ .setMultipartReplyTableFeatures(mpTableFeaturesBld.build());
+ MultipartReplyMessageBuilder mpResultBld = new MultipartReplyMessageBuilder()
+ .setType(MultipartType.OFPMPTABLEFEATURES)
+ .setMultipartReplyBody(mpBodyBld.build())
+ .setXid(21L);
+ final RpcResult<List<MultipartReply>> rpcResult = RpcResultBuilder
+ .success(Collections.singletonList((MultipartReply) mpResultBld.build()))
+ .build();
+ handleResultFuture.set(rpcResult);
+ return null;
+ }
+ }).when(multiMessageCollector).endCollecting(Matchers.<EventIdentifier>any());
+
final Future<RpcResult<UpdateTableOutput>> rpcResultFuture = salTableService.updateTable(prepareUpdateTable());
- assertNotNull(rpcResultFuture);
+ Assert.assertNotNull(rpcResultFuture);
+ verify(mockedRequestContextStack).createRequestContext();
}
private UpdateTableInput prepareUpdateTable() {
package org.opendaylight.openflowplugin.impl.services;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import io.netty.util.HashedWheelTimer;
+import java.math.BigInteger;
+import java.util.List;
import org.junit.Before;
import org.junit.runner.RunWith;
+import org.mockito.Matchers;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.opendaylight.openflowjava.protocol.api.connection.ConnectionAdapter;
import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueue;
import org.opendaylight.openflowplugin.api.OFConstants;
import org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext;
-import org.opendaylight.openflowplugin.api.openflow.device.*;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceContext;
+import org.opendaylight.openflowplugin.api.openflow.device.DeviceState;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
+import org.opendaylight.openflowplugin.api.openflow.device.RequestContextStack;
+import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.api.openflow.device.handlers.DeviceInitializationPhaseHandler;
+import org.opendaylight.openflowplugin.api.openflow.device.handlers.MultiMsgCollector;
import org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.MessageSpy;
import org.opendaylight.openflowplugin.impl.registry.flow.DeviceFlowRegistryImpl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.service.rev130918.AddMeterOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FeaturesReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import java.math.BigInteger;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
@RunWith(MockitoJUnitRunner.class)
public abstract class ServiceMocking {
private static final BigInteger DUMMY_DATAPATH_ID = new BigInteger("444");
private static final Long DUMMY_XID_VALUE = 2121L;
private static final Xid DUMMY_XID = new Xid(DUMMY_XID_VALUE);
- private static final String DUMMY_NODE_ID = "dummyNodeID";
+ protected static final String DUMMY_NODE_ID = "dummyNodeID";
private static final KeyedInstanceIdentifier<Node, NodeKey> NODE_II
= InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(DUMMY_NODE_ID)));
@Mock
- RequestContextStack mockedRequestContextStack;
+ protected RequestContextStack mockedRequestContextStack;
@Mock
- ConnectionContext mockedPrimConnectionContext;
+ protected ConnectionContext mockedPrimConnectionContext;
@Mock
- FeaturesReply mockedFeatures;
+ protected FeaturesReply mockedFeatures;
@Mock
- ConnectionAdapter mockedConnectionAdapter;
+ protected ConnectionAdapter mockedConnectionAdapter;
@Mock
- MessageSpy mockedMessagSpy;
+ protected MessageSpy mockedMessagSpy;
@Mock
- DeviceContext mockedDeviceContext;
+ protected DeviceContext mockedDeviceContext;
@Mock
- DeviceState mockedDeviceState;
+ protected DeviceState mockedDeviceState;
@Mock
- DeviceInitializationPhaseHandler mockedDevicePhaseHandler;
+ protected DeviceInitializationPhaseHandler mockedDevicePhaseHandler;
@Mock
- RequestContext mockedRequestContext;
+ protected RequestContext mockedRequestContext;
@Mock
- OutboundQueue mockedOutboundQueue;
+ protected OutboundQueue mockedOutboundQueue;
+ @Mock
+ protected MultiMsgCollector multiMessageCollector;
@Before
public void initialization() {
when(mockedDeviceState.getNodeInstanceIdentifier()).thenReturn(NODE_II);
+
when(mockedDeviceContext.getPrimaryConnectionContext()).thenReturn(mockedPrimConnectionContext);
when(mockedDeviceContext.getMessageSpy()).thenReturn(mockedMessagSpy);
when(mockedDeviceContext.getDeviceFlowRegistry()).thenReturn(new DeviceFlowRegistryImpl());
when(mockedDeviceContext.getDeviceState()).thenReturn(mockedDeviceState);
when(mockedDeviceContext.getTimer()).thenReturn(mock(HashedWheelTimer.class));
+ when(mockedDeviceContext.getMultiMsgCollector(Matchers.<RequestContext<List<MultipartReply>>>any())).thenReturn(multiMessageCollector);
+
+ setup();
+ }
+
+ protected void setup() {
+ //NOOP - to be overloaded
}