当前位置: 首页>>代码示例>>Java>>正文


Java StreamMessage.readBytes方法代码示例

本文整理汇总了Java中javax.jms.StreamMessage.readBytes方法的典型用法代码示例。如果您正苦于以下问题:Java StreamMessage.readBytes方法的具体用法?Java StreamMessage.readBytes怎么用?Java StreamMessage.readBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jms.StreamMessage的用法示例。


在下文中一共展示了StreamMessage.readBytes方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: assertEquivalent

import javax.jms.StreamMessage; //导入方法依赖的package包/类
@Override
protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException {
   super.assertEquivalent(m, mode, redelivery);

   StreamMessage sm = (StreamMessage) m;

   ProxyAssertSupport.assertTrue(sm.readBoolean());

   byte[] bytes = new byte[5];
   sm.readBytes(bytes);
   String s = new String(bytes);
   ProxyAssertSupport.assertEquals("jboss", s);
   ProxyAssertSupport.assertEquals(-1, sm.readBytes(bytes));

   ProxyAssertSupport.assertEquals(sm.readChar(), 'c');
   ProxyAssertSupport.assertEquals(sm.readDouble(), 1.0D, 0.0D);
   ProxyAssertSupport.assertEquals(sm.readFloat(), 2.0F, 0.0F);
   ProxyAssertSupport.assertEquals(sm.readInt(), 3);
   ProxyAssertSupport.assertEquals(sm.readLong(), 4L);
   ProxyAssertSupport.assertEquals(sm.readObject(), "object");
   ProxyAssertSupport.assertEquals(sm.readShort(), (short) 5);
   ProxyAssertSupport.assertEquals(sm.readString(), "stringvalue");
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:24,代码来源:ForeignStreamMessageTest.java

示例2: assertEquivalent

import javax.jms.StreamMessage; //导入方法依赖的package包/类
@Override
protected void assertEquivalent(final Message m, final int mode, final boolean redelivery) throws JMSException {
   super.assertEquivalent(m, mode, redelivery);

   StreamMessage sm = (StreamMessage) m;

   sm.reset();

   ProxyAssertSupport.assertEquals(true, sm.readBoolean());
   ProxyAssertSupport.assertEquals((byte) 3, sm.readByte());
   byte[] bytes = new byte[3];
   sm.readBytes(bytes);
   ProxyAssertSupport.assertEquals((byte) 4, bytes[0]);
   ProxyAssertSupport.assertEquals((byte) 5, bytes[1]);
   ProxyAssertSupport.assertEquals((byte) 6, bytes[2]);
   ProxyAssertSupport.assertEquals(-1, sm.readBytes(bytes));
   ProxyAssertSupport.assertEquals((char) 7, sm.readChar());
   ProxyAssertSupport.assertEquals(new Double(8.0), new Double(sm.readDouble()));
   ProxyAssertSupport.assertEquals(new Float(9.0), new Float(sm.readFloat()));
   ProxyAssertSupport.assertEquals(10, sm.readInt());
   ProxyAssertSupport.assertEquals(11L, sm.readLong());
   ProxyAssertSupport.assertEquals("this is an object", sm.readObject());
   ProxyAssertSupport.assertEquals((short) 12, sm.readShort());
   ProxyAssertSupport.assertEquals("this is a String", sm.readString());
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:26,代码来源:StreamMessageTest.java

示例3: extractByteArrayFromMessage

import javax.jms.StreamMessage; //导入方法依赖的package包/类
private static byte[] extractByteArrayFromMessage(StreamMessage message) throws JMSException {

        ByteArrayOutputStream oStream = new ByteArrayOutputStream(BUFFER_CAPACITY_BYTES);

        byte[] buffer = new byte[BUFFER_CAPACITY_BYTES];

        int bufferCount = -1;

        while ((bufferCount = message.readBytes(buffer)) >= 0) {
            oStream.write(buffer, 0, bufferCount);
            if (bufferCount < BUFFER_CAPACITY_BYTES) {
                break;
            }
        }

        return oStream.toByteArray();
    }
 
开发者ID:JadiraOrg,项目名称:jadira,代码行数:18,代码来源:FatalJmsExceptionMessageCreator.java

示例4: receiveStreamMessage

import javax.jms.StreamMessage; //导入方法依赖的package包/类
private void receiveStreamMessage(boolean useCore) throws Exception {
   StreamMessage streamMessage = (StreamMessage) receiveMessage(useCore);
   boolean booleanVal = streamMessage.readBoolean();
   assertTrue(booleanVal);
   byte byteVal = streamMessage.readByte();
   assertEquals((byte) 10, byteVal);
   byte[] originVal = TEXT.getBytes();
   byte[] bytesVal = new byte[originVal.length];
   streamMessage.readBytes(bytesVal);
   for (int i = 0; i < bytesVal.length; i++) {
      assertTrue(bytesVal[i] == originVal[i]);
   }
   char charVal = streamMessage.readChar();
   assertEquals('A', charVal);
   double doubleVal = streamMessage.readDouble();
   assertEquals(55.3D, doubleVal, 0.1D);
   float floatVal = streamMessage.readFloat();
   assertEquals(79.1F, floatVal, 0.1F);
   int intVal = streamMessage.readInt();
   assertEquals(37, intVal);
   long longVal = streamMessage.readLong();
   assertEquals(56652L, longVal);
   Object objectVal = streamMessage.readObject();
   Object origVal = new String("VVVV");
   assertTrue(objectVal.equals(origVal));
   short shortVal = streamMessage.readShort();
   assertEquals((short) 333, shortVal);
   String strVal = streamMessage.readString();
   assertEquals(TEXT, strVal);
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:31,代码来源:CompressedInteropTest.java

示例5: checkConversionsFail

import javax.jms.StreamMessage; //导入方法依赖的package包/类
private void checkConversionsFail(StreamMessage sm, int[] conversions) throws JMSException
{
    for (int conversion : conversions)
    {
        try
        {
            switch (conversion)
            {
                case 0:
                    sm.readBoolean();
                    break;
                case 1:
                    sm.readByte();
                    break;
                case 2:
                    sm.readShort();
                    break;
                case 3:
                    sm.readChar();
                    break;
                case 4:
                    sm.readInt();
                    break;
                case 5:
                    sm.readLong();
                    break;
                case 6:
                    sm.readFloat();
                    break;
                case 7:
                    sm.readDouble();
                    break;
                case 8:
                    sm.readString();
                    break;
                case 9:
                    sm.readBytes(new byte[3]);
                    break;
            }
            fail("MessageFormatException was not thrown");
        }
        catch (MessageFormatException e)
        {
            // PASS
        }
        sm.reset();
    }
}
 
开发者ID:wso2,项目名称:andes,代码行数:49,代码来源:StreamMessageTest.java


注:本文中的javax.jms.StreamMessage.readBytes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。