MsgCallback cbk1 = new MsgCallback(service1);
cbk1.setExpectedMessages(nrMessages);
MsgCallback cbk2 = new MsgCallback(service2);
cbk2.setExpectedMessages(nrMessages);
SCSubscribeMessage subMsgRequest = new SCSubscribeMessage();
SCSubscribeMessage subMsgResponse = null;
subMsgRequest.setMask(TestConstants.mask);
subMsgRequest.setData(Integer.toString(nrMessages));
subMsgRequest.setDataLength(((String) subMsgRequest.getData()).length());
subMsgResponse = service1.subscribe(subMsgRequest, cbk1);
Assert.assertNotNull("the session ID is null", service1.getSessionId());
Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
Assert.assertTrue("is not subscribed", service1.isSubscribed());
subMsgRequest.setSessionInfo(TestConstants.publishCompressedMsgCmd);
subMsgResponse = service2.subscribe(subMsgRequest, cbk2);
Assert.assertNotNull("the session ID is null", service2.getSessionId());
Assert.assertEquals("message body is not the same length", subMsgRequest.getDataLength(), subMsgResponse.getDataLength());
Assert.assertEquals("compression is not the same", subMsgRequest.isCompressed(), subMsgResponse.isCompressed());
Assert.assertTrue("is not subscribed", service2.isSubscribed());
cbk1.waitForMessage(200);
Assert.assertEquals("Nr messages does not match", nrMessages, cbk1.getMessageCount());
SCMessage response = cbk1.getMessage();