/** * Test dispatch of messages while in Complete state */ @Test public void testMessageDispatchComplete() throws Exception { moveToComplete(); newConnection.getValue().setListener(connectionListener); resetChannel(); expect(channel.writeAndFlush(capture(writeCapture))).andReturn(null).once(); replay(channel); // Send echo request. expect reply OFMessage echoRequest = factory.buildEchoRequest().build(); sendMessageToHandlerWithControllerReset(ImmutableList.<OFMessage>of(echoRequest)); List<OFMessage> msgs = getMessagesFromCapture(); assertEquals(1, msgs.size()); assertEquals(OFType.ECHO_REPLY, msgs.get(0).getType()); // Send barrier reply. expect dispatch OFBarrierReply barrierReply = factory.buildBarrierReply() .build(); resetAndExpectConnectionListener(barrierReply); // Send packet in. expect dispatch OFFlowRemoved flowRemoved = factory.buildFlowRemoved() .build(); resetAndExpectConnectionListener(flowRemoved); // Send get config reply. expect dispatch OFGetConfigReply getConfigReply = factory.buildGetConfigReply() .build(); resetAndExpectConnectionListener(getConfigReply); // Send packet in. expect dispatch OFPacketIn pi = factory.buildPacketIn() .setReason(OFPacketInReason.NO_MATCH) .build(); resetAndExpectConnectionListener(pi); // Send port status. expect dispatch OFPortStatus portStatus = factory.buildPortStatus() .setReason(OFPortReason.DELETE) .setDesc(portDesc) .build(); resetAndExpectConnectionListener(portStatus); // Send queue reply. expect dispatch OFQueueGetConfigReply queueReply = factory.buildQueueGetConfigReply() .build(); resetAndExpectConnectionListener(queueReply); // Send stat reply. expect dispatch OFFlowStatsReply statReply = factory.buildFlowStatsReply() .build(); resetAndExpectConnectionListener(statReply); // Send role reply. expect dispatch OFRoleReply roleReply = factory.buildRoleReply() .setRole(OFControllerRole.ROLE_MASTER) .build(); resetAndExpectConnectionListener(roleReply); // Send experimenter. expect dispatch OFBsnSetAuxCxnsReply auxReply = factory.buildBsnSetAuxCxnsReply() .build(); resetAndExpectConnectionListener(auxReply); }