/** * Sets the channel pipeline's handshake timeout to a more appropriate value * for the remaining part of the switch handshake. */ private void setSwitchHandshakeTimeout() { HandshakeTimeoutHandler handler = new HandshakeTimeoutHandler( this, this.timer, PipelineHandshakeTimeout.SWITCH); pipeline.replace(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT, PipelineHandler.SWITCH_HANDSHAKE_TIMEOUT, handler); }
/** Move the channel from scratch to WAIT_FEATURES_REPLY state * Builds on moveToWaitHello() * adds testing for WAIT_HELLO state */ @Test public void moveToComplete() throws Exception { moveToWaitFeaturesReply(); reset(pipeline); HandshakeTimeoutHandler newHandler = new HandshakeTimeoutHandler( handler, timer, PipelineHandshakeTimeout.SWITCH); expect( pipeline.replace(EasyMock.eq(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT), EasyMock.eq(PipelineHandler.SWITCH_HANDSHAKE_TIMEOUT), EasyMock.anyObject(HandshakeTimeoutHandler.class))).andReturn(newHandler) .once(); replay(pipeline); newConnectionListener.connectionOpened(capture(newConnection), capture(newFeaturesReply)); expectLastCall().once(); replay(newConnectionListener); sendMessageToHandlerWithControllerReset(Collections.<OFMessage>singletonList(featuresReply)); assertThat(handler.getStateForTesting(), CoreMatchers.instanceOf(OFChannelHandler.CompleteState.class)); assertTrue("A connection has been created and set", handler.getConnectionForTesting() != null); verify(newConnectionListener); assertTrue(newConnection.hasCaptured()); assertThat(newFeaturesReply.getValue(), equalTo(featuresReply)); }
/** Move the channel from scratch to WAIT_FEATURES_REPLY state * Builds on moveToWaitHello() * adds testing for WAIT_HELLO state */ @Test public void moveToComplete() throws Exception { moveToWaitFeaturesReply(); reset(pipeline); HandshakeTimeoutHandler newHandler = new HandshakeTimeoutHandler( handler, timer, PipelineHandshakeTimeout.SWITCH); expect( pipeline.replace(EasyMock.eq(PipelineHandler.CHANNEL_HANDSHAKE_TIMEOUT), EasyMock.eq(PipelineHandler.SWITCH_HANDSHAKE_TIMEOUT), EasyMock.anyObject(HandshakeTimeoutHandler.class))).andReturn(newHandler) .once(); replay(pipeline); reset(newConnectionListener); newConnectionListener.connectionOpened(capture(newConnection), capture(newFeaturesReply)); expectLastCall().once(); replay(newConnectionListener); sendMessageToHandlerWithControllerReset(Collections.<OFMessage>singletonList(featuresReply)); assertThat(handler.getStateForTesting(), CoreMatchers.instanceOf(OFChannelHandler.CompleteState.class)); assertTrue("A connection has been created and set", handler.getConnectionForTesting() != null); }