use of org.apache.activemq.artemis.api.core.ActiveMQIncompatibleClientServerException in project activemq-artemis by apache.
the class IncompatibleVersionTest method doTestClientVersionCompatibility.
private void doTestClientVersionCompatibility(boolean compatible) throws Exception {
Channel channel1 = connection.getChannel(1, -1);
long sessionChannelID = connection.generateChannelID();
int version = VersionLoader.getVersion().getIncrementingVersion();
if (!compatible) {
version = -1;
}
Packet request = new CreateSessionMessage(randomString(), sessionChannelID, version, null, null, ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE, false, true, true, false, ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE, null);
if (compatible) {
CreateSessionResponseMessage packet = (CreateSessionResponseMessage) channel1.sendBlocking(request, PacketImpl.CREATESESSION_RESP);
assertNotNull(packet);
// 1 connection on the server
assertEquals(1, server.getConnectionCount());
} else {
try {
channel1.sendBlocking(request, PacketImpl.CREATESESSION_RESP);
fail();
} catch (ActiveMQIncompatibleClientServerException icsv) {
// ok
} catch (ActiveMQException e) {
fail("Invalid Exception type:" + e.getType());
}
long start = System.currentTimeMillis();
while (System.currentTimeMillis() < start + 3 * server.getConfiguration().getConnectionTtlCheckInterval()) {
if (server.getConnectionCount() == 0) {
break;
}
}
// no connection on the server
assertEquals(0, server.getConnectionCount());
}
}
Aggregations