Esempio n. 1
0
 @Test
 public void testSendStreamMessage() throws JMSException, InterruptedException {
   JmsProducerCompletionListenerTest.CountingCompletionListener cl =
       new JmsProducerCompletionListenerTest.CountingCompletionListener(1);
   JMSProducer producer = context.createProducer();
   producer.setAsync(cl);
   StreamMessage msg = context.createStreamMessage();
   msg.setStringProperty("name", name.getMethodName());
   String bprop = "booleanProp";
   String iprop = "intProp";
   msg.setBooleanProperty(bprop, true);
   msg.setIntProperty(iprop, 42);
   msg.writeBoolean(true);
   msg.writeInt(67);
   producer.send(queue1, msg);
   JMSConsumer consumer = context.createConsumer(queue1);
   Message msg2 = consumer.receive(100);
   Assert.assertNotNull(msg2);
   Assert.assertTrue(cl.completionLatch.await(1, TimeUnit.SECONDS));
   StreamMessage sm = (StreamMessage) cl.lastMessage;
   Assert.assertEquals(true, sm.getBooleanProperty(bprop));
   Assert.assertEquals(42, sm.getIntProperty(iprop));
   Assert.assertEquals(true, sm.readBoolean());
   Assert.assertEquals(67, sm.readInt());
 }
Esempio n. 2
0
 @Test
 public void bytesMessage() throws Exception {
   context = cf.createContext();
   try {
     JMSProducer producer = context.createProducer();
     BytesMessage bMsg = context.createBytesMessage();
     bMsg.setStringProperty("COM_SUN_JMS_TESTNAME", "sendAndRecvMsgOfEachTypeCLTest");
     bMsg.writeByte((byte) 1);
     bMsg.writeInt((int) 22);
     CountDownLatch latch = new CountDownLatch(1);
     SimpleCompletionListener listener = new SimpleCompletionListener(latch);
     producer.setAsync(listener);
     producer.send(queue1, bMsg);
     assertTrue(latch.await(5, TimeUnit.SECONDS));
     assertEquals(listener.message.readByte(), (byte) 1);
     assertEquals(listener.message.readInt(), (int) 22);
   } finally {
     context.close();
   }
 }