// Register_Response_Success to Request Stream, when partially consumed window
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
RelayPullThread relayPuller = bldr.createRelayPullThread();
Checkpoint cp = new Checkpoint();
cp.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
cp.setWindowScn(100L);
cp.setWindowOffset(20);
cp.setPrevScn(80L);
relayPuller.getConnectionState().setCheckpoint(cp);
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
Assert.assertEquals(relayPuller.getConnectionState().getCheckpoint().getWindowScn(), 80L, "WindowSCN check");
Assert.assertEquals(relayPuller.getConnectionState().getCheckpoint().getWindowOffset(), new Long(-1), "WindowOffset check");
Assert.assertEquals(relayPuller.getConnectionState().isSCNRegress(), true, "SCN Regress check");
}
// Register_Response_Success, No PrevSCN for partially consumed window
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
RelayPullThread relayPuller = bldr.createRelayPullThread();
Checkpoint cp = new Checkpoint();
cp.setConsumptionMode(DbusClientMode.ONLINE_CONSUMPTION);
cp.setWindowScn(100L);
cp.setWindowOffset(20);
relayPuller.getConnectionState().setCheckpoint(cp);
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS,StateId.REGISTER_RESPONSE_SUCCESS, "SUSPEND_ON_ERROR");
}
// Register_Response_Success to Bootstrap ( when checkpoint is Bootstrap_SnapShot
{
//RelayPullThread relayPuller = createRelayPullThread(false, false, true);
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
Checkpoint cp = new Checkpoint();
cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_SNAPSHOT);
connState.setCheckpoint(cp);
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.BOOTSTRAP);
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
Assert.assertEquals(relayPuller.getConnectionState().isSCNRegress(), false, "SCN Regress check");
}
// Register_Response_Success to Bootstrap ( when checkpoint is Bootstrap_Catchup
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
Checkpoint cp = new Checkpoint();
cp.setConsumptionMode(DbusClientMode.BOOTSTRAP_CATCHUP);
connState.setCheckpoint(cp);
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.BOOTSTRAP);
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
Assert.assertEquals(relayPuller.getConnectionState().isSCNRegress(), false, "SCN Regress check");
}
// Request_Stream to Request_Stream_Sent
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, true);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_REQUEST_SENT, "");
List<IdNamePair> sourcesResponse = new ArrayList<IdNamePair>();
sourcesResponse.add(new IdNamePair(1L, "source1"));
connState.switchToSourcesSuccess(sourcesResponse, _HOSTNAME, _SVCNAME);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
String subsListString = "[{\"physicalSource\":{\"uri\":\"databus:physical-source:ANY\",\"role\":\"MASTER\"},\"physicalPartition\":{\"id\":-1,\"name\":\"*\"},\"logicalPartition\":{\"source\":{\"id\":0,\"name\":\"source1\"},\"id\":-1}}]";
String sourcesIdListString = "1";
connState.switchToRequestSourcesSchemas(sourcesIdListString, subsListString);
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_REQUEST_SENT,"");
relayPuller.getMessageQueue().clear();
MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
connState.switchToRegisterSuccess(conn.getRegisterResponse(), conn.getRegisterResponse(), conn.getRegisterMetadataResponse());
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SENT, "");
validateConnState(connState);
}
// Request_Stream to Stream_Response_Success
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
}
//Stream_Request_Success to Stream_Request_Done
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
}
//Stream_Request_Success : ScnNotFoundException but retries set to 5 and bootstrap enabled
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName()).setNumRetriesOnFellOff(5);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
for ( int i = 1; i <= 6 ; i++)
{
System.out.println("Iteration :" + i);
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
if ( i < 6 )
{
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 6-i ,"Retry State");
} else {
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 5 ,"Retry State"); //reset
}
relayPuller.getMessageQueue().clear();
}
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "RelayFellOff State");
}
//Stream_Request_Success : ScnNotFoundException and bootstrap enabled
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
}
//Stream_Request_Success : ScnNotFoundException but retries set to 5, bootstrap disabled and readLatestScnOnFallOff enabled.
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(true).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName()).setNumRetriesOnFellOff(5);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
for (int i=1; i<=6;i++)
{
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
if ( i < 6 )
{
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 6-i ,"Retry State");
} else {
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 5 ,"Retry State"); //reset
}
relayPuller.getMessageQueue().clear();
}
MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
Assert.assertEquals(conn.isReadFromLatestScn(),true, "ReadFromLatestScn set");
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "RelayFellOff State");
}
//Stream_Request_Success : ScnNotFoundException, bootstrap disabled and readLatestScnOnFallOff enabled.
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(true).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
MockRelayConnection conn = (MockRelayConnection)connState.getRelayConnection();
Assert.assertEquals(conn.isReadFromLatestScn(),true, "ReadFromLatestScn set");
}
//Stream_Request_Success : ScnNotFoundException but retries set to 5, bootstrap disabled and readLatestScnOnFallOff disabled.
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName()).setNumRetriesOnFellOff(5);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
for (int i = 1; i <= 6; i++)
{
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
if ( i < 6 )
{
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.PICK_SERVER);
Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 6-i ,"Retry State");
} else {
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_REQUEST_SUCCESS, "SUSPEND_ON_ERROR");
Assert.assertEquals(relayPuller.getRetryonFallOff().getRemainingRetriesNum(), 5 ,"Retry State"); //reset
}
relayPuller.getMessageQueue().clear();
}
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "RelayFellOff State");
}
//Stream_Request_Success : ScnNotFoundException, bootstrap disabled and readLatestScnOnFallOff disabled.
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(false).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_REQUEST_SUCCESS, "SUSPEND_ON_ERROR");
}
//Stream_Request_Success : Non-ScnNotFoundException
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName("DummyError");
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_ERROR);
}
//Stream_Request_Done to Request_Stream
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.STREAM_RESPONSE_DONE);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_RESPONSE_DONE,StateId.REQUEST_STREAM);
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
}
// Bootstrap to Bootstrap_Requested
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
}
//Exception while doBootstrap()
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(true)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP, "SUSPEND_ON_ERROR");
}
// Bootstrap Failed : Case 1
{
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
BootstrapResultMessage msg = BootstrapResultMessage.createBootstrapFailedMessage(new Exception("Dummy"));
doExecuteAndChangeState(relayPuller,msg);
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
Assert.assertEquals(connState.getStateId(),StateId.BOOTSTRAP, "BOOTSTRAP_REQUESTED to BOOTSTRAP");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [BOOTSTRAP]", "Queue :BOOTSTRAP_REQUESTED to BOOTSTRAP");
}
// Bootstrap Failed : Case 2
{
//RelayPullThread relayPuller = createRelayPullThread(false, false, true, false, false, true, ScnNotFoundException.class.getName());
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
BootstrapResultMessage msg = BootstrapResultMessage.createBootstrapCompleteMessage(null);
doExecuteAndChangeState(relayPuller,msg);
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
Assert.assertEquals(connState.getStateId(),StateId.BOOTSTRAP, "BOOTSTRAP_REQUESTED to BOOTSTRAP");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [BOOTSTRAP]", "Queue :BOOTSTRAP_REQUESTED to BOOTSTRAP");
}
// Bootstrap Success
{
//RelayPullThread relayPuller = createRelayPullThread(false, false, true, false, false, true, ScnNotFoundException.class.getName());
RelayPullThreadBuilder bldr = new RelayPullThreadBuilder(false, false);
bldr.setBootstrapEnabled(true).setReadLatestScnEnabled(false).setReadDataThrowException(false)
.setReadDataException(true).setExceptionName(ScnNotFoundException.class.getName());
RelayPullThread relayPuller = bldr.createRelayPullThread();
relayPuller.getComponentStatus().start();
ConnectionState connState = relayPuller.getConnectionState();
connState.switchToPickServer();
testTransitionCase(relayPuller, StateId.PICK_SERVER, StateId.REQUEST_SOURCES);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_SOURCES, StateId.SOURCES_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.SOURCES_RESPONSE_SUCCESS, StateId.REQUEST_REGISTER);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_REGISTER, StateId.REGISTER_RESPONSE_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REGISTER_RESPONSE_SUCCESS, StateId.REQUEST_STREAM);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.REQUEST_STREAM, StateId.STREAM_REQUEST_SUCCESS);
relayPuller.getMessageQueue().clear();
testTransitionCase(relayPuller, StateId.STREAM_REQUEST_SUCCESS,StateId.BOOTSTRAP);
relayPuller.getMessageQueue().clear();
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), true, "Is Relay FellOff");
testTransitionCase(relayPuller, StateId.BOOTSTRAP,StateId.BOOTSTRAP_REQUESTED,"");
BootstrapResultMessage msg = BootstrapResultMessage.createBootstrapCompleteMessage(new Checkpoint());
doExecuteAndChangeState(relayPuller,msg);
Assert.assertEquals(relayPuller.getConnectionState().isRelayFellOff(), false, "Is Relay FellOff");
Assert.assertEquals(connState.getStateId(),StateId.REQUEST_STREAM, "BOOTSTRAP_REQUESTED to REQUEST_STREAM");
Assert.assertEquals(relayPuller.getQueueListString(), "RelayPuller queue: [REQUEST_STREAM]", "Queue :BOOTSTRAP_REQUESTED to REQUEST_STREAM");
}