类javax.jms.MessageEOFException源码实例Demo

下面列出了怎么用javax.jms.MessageEOFException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public byte readByte() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }

   try {
      Object value = content.get(position);
      offset = 0;
      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).byteValue();
      } else if (value instanceof String) {
         byte result = Byte.parseByte((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码2 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public char readChar() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Character) {
         position++;
         return ((Character) value).charValue();
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码3 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public float readFloat() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Float) {
         position++;
         return ((Float) value).floatValue();
      } else if (value instanceof String) {
         float result = Float.parseFloat((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码4 项目: qpid-jms   文件: JmsStreamMessageTest.java
@Test
public void testClearBodyOnNewMessageRemovesExistingValues() throws Exception {
    JmsStreamMessage streamMessage = factory.createStreamMessage();
    streamMessage.writeBoolean(true);

    streamMessage.clearBody();

    streamMessage.writeBoolean(false);
    streamMessage.reset();

    // check we get only the value added after the clear
    assertFalse("expected value added after the clear", streamMessage.readBoolean());

    try {
        streamMessage.readBoolean();
        fail("Expected exception to be thrown");
    } catch (MessageEOFException meofe) {
        // expected
    }
}
 
源代码5 项目: qpid-jms   文件: AmqpJmsStreamMessageFacadeTest.java
@Test
public void testPopFullyReadListThrowsMEOFE() throws Exception {
    Message message = Message.Factory.create();
    List<Object> list = new ArrayList<Object>();
    list.add(Boolean.FALSE);
    message.setBody(new AmqpSequence(list));

    AmqpJmsStreamMessageFacade amqpStreamMessageFacade = createReceivedStreamMessageFacade(createMockAmqpConsumer(), message);

    assertEquals("Unexpected value retrieved", Boolean.FALSE, amqpStreamMessageFacade.peek());
    amqpStreamMessageFacade.pop();

    try {
        amqpStreamMessageFacade.pop();
        fail("expected exception to be thrown");
    } catch (MessageEOFException meofe) {
        // expected
    }
}
 
源代码6 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public boolean readBoolean() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }

   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Boolean) {
         position++;
         return ((Boolean) value).booleanValue();
      } else if (value instanceof String) {
         boolean result = Boolean.valueOf((String) value).booleanValue();
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }

}
 
源代码7 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public short readShort() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).shortValue();
      } else if (value instanceof Short) {
         position++;
         return ((Short) value).shortValue();
      } else if (value instanceof String) {
         short result = Short.parseShort((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码8 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public int readInt() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).intValue();
      } else if (value instanceof Short) {
         position++;
         return ((Short) value).intValue();
      } else if (value instanceof Integer) {
         position++;
         return ((Integer) value).intValue();
      } else if (value instanceof String) {
         int result = Integer.parseInt((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码9 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public long readLong() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Byte) {
         position++;
         return ((Byte) value).longValue();
      } else if (value instanceof Short) {
         position++;
         return ((Short) value).longValue();
      } else if (value instanceof Integer) {
         position++;
         return ((Integer) value).longValue();
      } else if (value instanceof Long) {
         position++;
         return ((Long) value).longValue();
      } else if (value instanceof String) {
         long result = Long.parseLong((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码10 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public double readDouble() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      offset = 0;

      if (value == null) {
         throw new NullPointerException("Value is null");
      } else if (value instanceof Float) {
         position++;
         return ((Float) value).doubleValue();
      } else if (value instanceof Double) {
         position++;
         return ((Double) value).doubleValue();
      } else if (value instanceof String) {
         double result = Double.parseDouble((String) value);
         position++;
         return result;
      } else {
         throw new MessageFormatException("Invalid conversion");
      }
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码11 项目: activemq-artemis   文件: SimpleJMSStreamMessage.java
@Override
public Object readObject() throws JMSException {
   if (bodyWriteOnly) {
      throw new MessageNotReadableException("The message body is writeonly");
   }
   try {
      Object value = content.get(position);
      position++;
      offset = 0;

      return value;
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
private void doReadTypeFromEmptyMessage(final TypeReader reader) throws Exception {
   ActiveMQStreamMessage message = new ActiveMQStreamMessage();
   message.reset();

   try {
      reader.readType(message);
      Assert.fail("MessageEOFException");
   } catch (MessageEOFException e) {
   }
}
 
源代码13 项目: activemq-artemis   文件: ActiveMQStreamMessage.java
public ActiveMQStreamMessage(final StreamMessage foreign, final ClientSession session) throws JMSException {
   super(foreign, ActiveMQStreamMessage.TYPE, session);

   foreign.reset();

   try {
      while (true) {
         Object obj = foreign.readObject();
         writeObject(obj);
      }
   } catch (MessageEOFException e) {
      // Ignore
   }
}
 
源代码14 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public boolean readBoolean() throws JMSException {
   checkRead();
   try {
      return bytesReadBoolean(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码15 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public byte readByte() throws JMSException {
   checkRead();
   try {
      return bytesReadByte(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码16 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public int readUnsignedByte() throws JMSException {
   checkRead();
   try {
      return bytesReadUnsignedByte(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码17 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public short readShort() throws JMSException {
   checkRead();
   try {
      return bytesReadShort(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码18 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public int readUnsignedShort() throws JMSException {
   checkRead();
   try {
      return bytesReadUnsignedShort(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码19 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public char readChar() throws JMSException {
   checkRead();
   try {
      return bytesReadChar(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码20 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public int readInt() throws JMSException {
   checkRead();
   try {
      return bytesReadInt(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码21 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public long readLong() throws JMSException {
   checkRead();
   try {
      return bytesReadLong(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码22 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public float readFloat() throws JMSException {
   checkRead();
   try {
      return bytesReadFloat(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码23 项目: activemq-artemis   文件: ActiveMQBytesMessage.java
@Override
public double readDouble() throws JMSException {
   checkRead();
   try {
      return bytesReadDouble(message.getBodyBuffer());
   } catch (IndexOutOfBoundsException e) {
      throw new MessageEOFException("");
   }
}
 
源代码24 项目: qpid-jms   文件: AmqpJmsStreamMessageFacade.java
@Override
public Object peek() throws MessageEOFException {
    if (list.isEmpty() || position >= list.size()) {
        throw new MessageEOFException("Attempt to read past end of stream");
    }

    Object object = list.get(position);
    if (object instanceof Binary) {
        // Copy to a byte[], ensure we copy only the required portion.
        Binary bin = ((Binary) object);
        object = Arrays.copyOfRange(bin.getArray(), bin.getArrayOffset(), bin.getLength());
    }

    return object;
}
 
源代码25 项目: qpid-jms   文件: AmqpJmsStreamMessageFacade.java
@Override
public void pop() throws MessageEOFException {
    if (list.isEmpty() || position >= list.size()) {
        throw new MessageEOFException("Attempt to read past end of stream");
    }

    position++;
}
 
源代码26 项目: qpid-jms   文件: JmsMessageTransformationTest.java
@Test
public void testEmptyForeignStreamMessageTransformCreateNewMessage() throws JMSException {
    ForeignJmsStreamMessage foreignMessage = new ForeignJmsStreamMessage();

    JmsMessage transformed = JmsMessageTransformation.transformMessage(createMockJmsConnection(), foreignMessage);
    assertNotSame(foreignMessage, transformed);
    assertFalse(transformed.equals(foreignMessage));

    assertTrue(transformed instanceof JmsStreamMessage);
    JmsStreamMessage message = (JmsStreamMessage) transformed;
    message.reset();
    try {
        message.readBoolean();
    } catch (MessageEOFException ex) {}
}
 
源代码27 项目: qpid-jms   文件: JmsMessageTransformationTest.java
@Test
public void tesAbnormalForeignStreamMessageTransformCreateNewMessage() throws JMSException {
    ForeignJmsStreamMessage foreignMessage = new ForeignJmsStreamMessage();
    foreignMessage.writeObject(true);
    foreignMessage.reset();
    foreignMessage = Mockito.spy(foreignMessage);

    // Test for an odd StreamMessage that return null instead of throwing a MessageEOFException
    Mockito.when(foreignMessage.readObject()).thenReturn(true).
                                              thenReturn(false).
                                              thenReturn(true).
                                              thenReturn(null);

    JmsMessage transformed = JmsMessageTransformation.transformMessage(createMockJmsConnection(), foreignMessage);
    assertNotSame(foreignMessage, transformed);
    assertFalse(transformed.equals(foreignMessage));

    assertTrue(transformed instanceof JmsStreamMessage);
    JmsStreamMessage message = (JmsStreamMessage) transformed;
    message.reset();

    assertTrue(message.readBoolean());
    assertFalse(message.readBoolean());
    assertTrue(message.readBoolean());
    try {
        message.readBoolean();
    } catch (MessageEOFException ex) {}
}
 
源代码28 项目: qpid-jms   文件: JmsStreamMessageTest.java
@Test
public void testReadWithEmptyStreamThrowsMEOFE() throws Exception {
    JmsStreamMessage streamMessage = factory.createStreamMessage();
    streamMessage.reset();

    try {
        streamMessage.readBoolean();
        fail("Expected exception to be thrown as message has no content");
    } catch (MessageEOFException meofe) {
        // expected
    }
}
 
源代码29 项目: qpid-jms   文件: JmsTestStreamMessageFacade.java
@Override
public Object peek() throws MessageEOFException {
    if (stream.isEmpty() || index + 1 >= stream.size()) {
        throw new MessageEOFException("Attempted to read past the end of the stream");
    }

    return stream.get(index + 1);
}
 
源代码30 项目: qpid-jms   文件: JmsTestStreamMessageFacade.java
@Override
public void pop() throws MessageEOFException {
    if (stream.isEmpty() || index + 1 >= stream.size()) {
        throw new MessageEOFException("Attempted to read past the end of the stream");
    }

    index++;
}
 
 类所在包
 同包方法