Package javax.jms

Examples of javax.jms.BytesMessage.readBytes()


    {
      final BytesMessage jBytes = (BytesMessage) fromJMSMessage;
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      byte[] ba = new byte[1000];
      int iQread;
      while (-1 != (iQread = jBytes.readBytes(ba)))
      {
        if (iQread > 0) out.write(ba, 0, iQread);
          out.close();
      }
      bodyAsBytes = out.toByteArray();
View Full Code Here


                return message;
            }

            public void completeCheck(BytesMessage message) throws JMSException {
                byte[] result = new byte[bytes.length];
                message.readBytes(result);
                Assert.assertArrayEquals("The returned byte array was different", bytes, result);
            }
        });
    }
View Full Code Here

    protected void dispatchMessage(TopicExpressionType topic, Message message) throws JMSException, IOException {
        if (message instanceof BytesMessage) {
            BytesMessage bm = (BytesMessage) message;
            byte data[] = new byte[(int) bm.getBodyLength()];
            bm.readBytes(data);
            dispatch(topic, createXml(data));
        }
        else if (message instanceof TextMessage) {
            TextMessage tm = (TextMessage) message;
            String text = tm.getText();
View Full Code Here

            return new StreamSource(new StringReader(textMessage.getText()));
        }
        else if (message instanceof BytesMessage) {
            BytesMessage bytesMessage = (BytesMessage) message;
            byte data[] = new byte[(int) bytesMessage.getBodyLength()];
            bytesMessage.readBytes(data);
            return new StreamSource(new ByteArrayInputStream(data));
        }
        else if (message instanceof ObjectMessage) {
            ObjectMessage objectMessage = (ObjectMessage) message;
            return createSource(topic, objectMessage);
View Full Code Here

            return new StreamSource(new StringReader(textMessage.getText()));
        }
        else if (message instanceof BytesMessage) {
            BytesMessage bytesMessage = (BytesMessage) message;
            byte data[] = new byte[(int) bytesMessage.getBodyLength()];
            bytesMessage.readBytes(data);
            return new StreamSource(new ByteArrayInputStream(data));
        }
        else if (message instanceof ObjectMessage) {
            ObjectMessage objectMessage = (ObjectMessage) message;
            return createSource(topic, objectMessage);
View Full Code Here

    protected void dispatchMessage(TopicExpressionType topic, Message message) throws JMSException, XmlException, IOException {
        if (message instanceof BytesMessage) {
            BytesMessage bm = (BytesMessage) message;
            byte data[] = new byte[(int) bm.getBodyLength()];
            bm.readBytes(data);
            XmlObject xml = XmlObject.Factory.parse(new ByteArrayInputStream(data));
            dispatch(topic, xml);
        }
        else if (message instanceof TextMessage) {
            TextMessage tm = (TextMessage) message;
View Full Code Here

      if (message instanceof BytesMessage) {
        BytesMessage bytesMsg = (BytesMessage) message;
        bytesMsg.reset();

        final byte[] decl = new byte["<?xml".length()];
        bytesMsg.readBytes(decl);

        return XmlUtils.isXML(new String(decl));
      }
    } catch (JMSException e) {
      log.error("error getting text: " + e.getMessage(), e);
View Full Code Here

    MockControl mockBytesMessage = MockControl.createControl(BytesMessage.class);
    BytesMessage bytesMessage = (BytesMessage) mockBytesMessage.getMock();
    // BytesMessage contents must be unwrapped...
    bytesMessage.getBodyLength();
    mockBytesMessage.setReturnValue(TEXT.getBytes().length);
    bytesMessage.readBytes(null);
    mockBytesMessage.setMatcher(MockControl.ALWAYS_MATCHER);
    mockBytesMessage.setReturnValue(TEXT.getBytes().length);
    mockBytesMessage.replay();

    MockControl mockDelegate = MockControl.createControl(MessageContentsDelegate.class);
View Full Code Here

      BytesMessage recv = (BytesMessage) sendRecMsg(sent);
      log.debug("recv: "+recv);
      assertTrue("Boolean == true", recv.readBoolean() == true);
      assertTrue("Byte == 1", recv.readByte() == 1);
      byte[] bytes = new byte[testBytes.length];
      recv.readBytes(bytes);
      assertTrue("Bytes == Bytes[]",
         Arrays.equals(bytes, testBytes));
      assertTrue("Char == c", recv.readChar() == 'c');
      assertTrue("Short == 314159", recv.readShort() == 31415);
      assertTrue("Int == 314159", recv.readInt() == 314159);
View Full Code Here

      assertEquals(myFloat, m2.readFloat(), 0);
      assertEquals(myDouble, m2.readDouble(), 0);
      assertEquals(myString, m2.readUTF());

      byte[] bytes = new byte[6];
      int ret = m2.readBytes(bytes);
      assertEquals(6, ret);

      assertByteArraysEqual(myBytes, bytes);

      byte[] bytes2 = new byte[3];
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.