Java 类net.floodlightcontroller.core.internal.OFSwitchHandshakeHandler.WaitAppHandshakeState 实例源码

项目:fresco_floodlight    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:fresco_floodlight    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:iTAP-controller    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:SDN-Multicast    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:SDN-Multicast    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:arscheduler    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:arscheduler    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:arscheduler    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight1.2-delay    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:floodlight1.2-delay    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight-hardware    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:floodlight-hardware    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:ACAMPController    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:ACAMPController    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:ACAMPController    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:fast-failover-demo    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:fast-failover-demo    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlightLB    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlightLB    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:floodlightLB    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:DSC    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole(null)).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:DSC    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:DSC    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole(null)).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Override
@Test
public void moveToWaitInitialRole() throws Exception {
    moveToWaitAppHandshakeState();
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    roleManager.notifyControllerConnectionUpdate();
    expectLastCall().once();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    state.enterNextPlugin();

    // Expect wait initial role's enterState message to be written
    OFMessage msg = connection.retrieveMessage();
    assertThat(msg, CoreMatchers.instanceOf(OFRoleRequest.class));
    verifyUniqueXids(msg);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:floodlight    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a plugin returns a DISCONNECT result. This means
 * we should disconnect the connection and the state should not change.
 *
 * @throws Exception
 */
@Test
public void failedAppHandshake() throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    PluginResult result = new PluginResult(PluginResultType.DISCONNECT);
    handshakePlugin.exitPlugin(result);

    assertThat(connection.isConnected(), equalTo(false));
}
项目:floodlight    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Override
@Test
public void moveToWaitInitialRole()
        throws Exception {
    moveToWaitAppHandshakeState();

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));

    reset(sw);
    expect(sw.getAttribute(IOFSwitchBackend.SWITCH_SUPPORTS_NX_ROLE)).andReturn(true).anyTimes();
    replay(sw);

    reset(roleManager);
    expect(roleManager.getOFControllerRole()).andReturn(OFControllerRole.ROLE_MASTER).anyTimes();
    replay(roleManager);

    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    PluginResult result = new PluginResult(PluginResultType.CONTINUE);
    state.exitPlugin(result);

    assertThat(connection.retrieveMessage(), instanceOf(getRoleRequestClass()));
    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitInitialRoleState.class));
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Test
@Override
public void moveToWaitAppHandshakeState() throws Exception {
    moveToWaitTableFeaturesReplyState();
    handleTableFeatures(true);

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));
}
项目:fresco_floodlight    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a switch returns a QUARANTINE result. This means
 * we should move the handshake handler to a quarantine state and also
 * quarantine the switch in the controller.
 *
 * @throws Exception
 */
@Test
public void moveQuarantine() throws Exception {
    moveToWaitAppHandshakeState();

    reset(switchManager);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.QUARANTINED);
    expectLastCall().once();
    replay(switchManager);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));
    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    reset(sw);
    expect(sw.getStatus()).andReturn(SwitchStatus.HANDSHAKE);
    sw.setStatus(SwitchStatus.QUARANTINED);
    expectLastCall().once();
    replay(sw);

    PluginResult result = new PluginResult(PluginResultType.QUARANTINE, "test quarantine");
    handshakePlugin.exitPlugin(result);

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(QuarantineState.class));
    verify(switchManager);
}
项目:fresco_floodlight    文件:OFSwitchHandlerTestBase.java   
/**
 * Move the channel from scratch to WAIT_INITIAL_ROLE state via
 * WAIT_SWITCH_DRIVER_SUB_HANDSHAKE
 * Does extensive testing for the WAIT_SWITCH_DRIVER_SUB_HANDSHAKE state
 *
 */
@Test
public void testSwitchDriverSubHandshake()
        throws Exception {
    moveToWaitSwitchDriverSubHandshake();

    //-------------------------------------------------
    //-------------------------------------------------
    // Send a message to the handler, it should be passed to the
    // switch's sub-handshake handling. After this message the
    // sub-handshake will be complete
    // FIXME:LOJI: With Andi's fix for a default Match object we won't
    // need to build/set this match object

    Match match = factory.buildMatch().build();
    OFMessage m = factory.buildFlowRemoved().setMatch(match).build();
    resetToStrict(sw);
    sw.processDriverHandshakeMessage(m);
    expectLastCall().once();
    expect(sw.isDriverHandshakeComplete()).andReturn(true).once();
    replay(sw);

    switchHandler.processOFMessage(m);

    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitAppHandshakeState.class));
    assertThat("Unexpected message captured", connection.getMessages(), Matchers.empty());
    verify(sw);
}
项目:fresco_floodlight    文件:OFSwitchHandshakeHandlerVer10Test.java   
@Test
@Override
public void moveToWaitAppHandshakeState() throws Exception {
    moveToWaitDescriptionStatReply();
    handleDescStatsAndCreateSwitch(true);
    assertThat(switchHandler.getStateForTesting(),
            CoreMatchers.instanceOf(WaitAppHandshakeState.class));
}
项目:iTAP-controller    文件:OFSwitchHandshakeHandlerVer13Test.java   
@Test
@Override
public void moveToWaitAppHandshakeState() throws Exception {
    moveToWaitDescriptionStatReply();
    handleDescStatsAndCreateSwitch(true);

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(WaitAppHandshakeState.class));
}
项目:iTAP-controller    文件:OFSwitchHandlerTestBase.java   
/**
 * Tests a situation where a switch returns a QUARANTINE result. This means
 * we should move the handshake handler to a quarantine state and also
 * quarantine the switch in the controller.
 *
 * @throws Exception
 */
@Test
public void moveQuarantine() throws Exception {
    moveToWaitAppHandshakeState();

    reset(switchManager);
    switchManager.switchStatusChanged(sw, SwitchStatus.HANDSHAKE, SwitchStatus.QUARANTINED);
    expectLastCall().once();
    replay(switchManager);

    assertThat(switchHandler.getStateForTesting(), CoreMatchers.instanceOf(WaitAppHandshakeState.class));
    WaitAppHandshakeState state = (WaitAppHandshakeState) switchHandler.getStateForTesting();
    assertThat(state.getCurrentPlugin(), CoreMatchers.<OFSwitchAppHandshakePlugin>equalTo(handshakePlugin));

    reset(sw);
    expect(sw.getStatus()).andReturn(SwitchStatus.HANDSHAKE);
    sw.setStatus(SwitchStatus.QUARANTINED);
    expectLastCall().once();
    replay(sw);

    PluginResult result = new PluginResult(PluginResultType.QUARANTINE, "test quarantine");
    handshakePlugin.exitPlugin(result);

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(QuarantineState.class));
    verify(switchManager);
}
项目:iTAP-controller    文件:OFSwitchHandlerTestBase.java   
/**
 * Move the channel from scratch to WAIT_INITIAL_ROLE state via
 * WAIT_SWITCH_DRIVER_SUB_HANDSHAKE
 * Does extensive testing for the WAIT_SWITCH_DRIVER_SUB_HANDSHAKE state
 *
 */
@Test
public void testSwitchDriverSubHandshake()
        throws Exception {
    moveToWaitSwitchDriverSubHandshake();

    //-------------------------------------------------
    //-------------------------------------------------
    // Send a message to the handler, it should be passed to the
    // switch's sub-handshake handling. After this message the
    // sub-handshake will be complete
    // FIXME:LOJI: With Andi's fix for a default Match object we won't
    // need to build/set this match object

    Match match = factory.buildMatch().build();
    OFMessage m = factory.buildFlowRemoved().setMatch(match).build();
    resetToStrict(sw);
    sw.processDriverHandshakeMessage(m);
    expectLastCall().once();
    expect(sw.isDriverHandshakeComplete()).andReturn(true).once();
    replay(sw);

    switchHandler.processOFMessage(m);

    assertThat(switchHandler.getStateForTesting(),
               CoreMatchers.instanceOf(OFSwitchHandshakeHandler.WaitAppHandshakeState.class));
    assertThat("Unexpected message captured", connection.getMessages(), Matchers.empty());
    verify(sw);
}