* Description: receive 2x100 messages in two subscriptions of the same client<br>
* Expectation: passes
*/
@Test
public void t10_receiveTwoSubscriptions() throws Exception {
SCPublishService service1 = client.newPublishService(TestConstants.pubServiceName1);
SCPublishService service2 = client.newPublishService(TestConstants.pubServiceName1);
int nrMessages = 100;
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();
Assert.assertEquals("message body is empty", true, response.getDataLength() > 0);
cbk2.waitForMessage(200);
Assert.assertEquals("Nr messages does not match", nrMessages, cbk2.getMessageCount());
response = cbk2.getMessage();
Assert.assertEquals("message body is empty", true, response.getDataLength() > 0);
service1.unsubscribe(4);
Assert.assertNull("the session ID is not null)", service1.getSessionId());
service2.unsubscribe(4);
Assert.assertNull("the session ID is not null)", service2.getSessionId());
}