本文整理汇总了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");
}
示例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());
}
示例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();
}
示例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);
}
示例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();
}
}