qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject [2/2] git commit: remove test-only getBody method, update testClearBody
Date Thu, 09 Oct 2014 16:48:32 GMT
remove test-only getBody method, update testClearBody


Project: http://git-wip-us.apache.org/repos/asf/qpid-jms/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-jms/commit/97912261
Tree: http://git-wip-us.apache.org/repos/asf/qpid-jms/tree/97912261
Diff: http://git-wip-us.apache.org/repos/asf/qpid-jms/diff/97912261

Branch: refs/heads/master
Commit: 97912261f6912d9b3a9abc177a5297d024d02702
Parents: d5ef8fb
Author: Robert Gemmell <robbie@apache.org>
Authored: Thu Oct 9 17:17:33 2014 +0100
Committer: Robert Gemmell <robbie@apache.org>
Committed: Thu Oct 9 17:48:13 2014 +0100

----------------------------------------------------------------------
 .../message/facade/JmsBytesMessageFacade.java   | 10 --------
 .../amqp/message/AmqpJmsBytesMessageFacade.java | 16 ------------
 .../qpid/jms/message/JmsBytesMessageTest.java   | 27 +++++++++-----------
 .../defaults/JmsDefaultBytesMessageFacade.java  |  8 ------
 4 files changed, 12 insertions(+), 49 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/97912261/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsBytesMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsBytesMessageFacade.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsBytesMessageFacade.java
index fd3adde..b5ee153 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsBytesMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/message/facade/JmsBytesMessageFacade.java
@@ -88,16 +88,6 @@ public interface JmsBytesMessageFacade extends JmsMessageFacade {
     int getBodyLength();
 
     /**
-     * Returns a copy of the body of the message in a new byte[] instance.  If the
-     * message body is empty an empty byte[] will be returned.
-     *
-     * @returns a new byte[] that contains a copy of the contents of this message.
-     *
-     * @throws JMSException if an error occurs accessing the message body.
-     */
-    byte[] getBody() throws JMSException;
-
-    /**
      * Sets the contents of the message from the given byte[] the given bytes are
      * copied into the body of the message.  Any previous message body content is
      * discarded.

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/97912261/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsBytesMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsBytesMessageFacade.java
b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsBytesMessageFacade.java
index 854ccec..4207439 100644
--- a/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsBytesMessageFacade.java
+++ b/qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/amqp/message/AmqpJmsBytesMessageFacade.java
@@ -129,22 +129,6 @@ public class AmqpJmsBytesMessageFacade extends AmqpJmsMessageFacade implements
J
     }
 
     @Override
-    public byte[] getBody() throws JMSException {
-        if (bytesIn != null || bytesOut != null) {
-            throw new JMSException("Body cannot be read until message is reset()");
-        }
-
-        byte[] result = new byte[0];
-        Binary payload = getBinaryFromBody();
-        if (payload != null && payload.getLength() > 0) {
-            result = new byte[payload.getLength()];
-            System.arraycopy(payload.getArray(), payload.getArrayOffset(), result, 0, payload.getLength());
-        }
-
-        return result;
-    }
-
-    @Override
     public void setBody(byte[] content) throws JMSException {
         if (bytesIn != null || bytesOut != null) {
             throw new JMSException("Body cannot be read until message is reset()");

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/97912261/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsBytesMessageTest.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsBytesMessageTest.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsBytesMessageTest.java
index acb8ffa..00c49e3 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsBytesMessageTest.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/JmsBytesMessageTest.java
@@ -139,10 +139,10 @@ public class JmsBytesMessageTest {
 
     /**
      * Test that calling {@link BytesMessage#clearBody()} of a received message
-     * causes the body of the underlying {@link AmqpBytesMessage} to be emptied.
+     * causes the facade input stream to be empty and body length to return 0.
      */
     @Test
-    public void testClearBodyOnReceivedBytesMessageClearsUnderlyingMessageBody() throws Exception
{
+    public void testClearBodyOnReceivedBytesMessageClearsFacadeInputStream() throws Exception
{
         byte[] content = "myBytesData".getBytes();
         JmsDefaultBytesMessageFacade facade = new JmsDefaultBytesMessageFacade();
         facade.setBody(content);
@@ -150,9 +150,11 @@ public class JmsBytesMessageTest {
         JmsBytesMessage bytesMessage = new JmsBytesMessage(facade);
         bytesMessage.onDispatch();
 
-        assertTrue("Expected message content but none was present", facade.getBody().length
> 0);
+        assertTrue("Expected message content but none was present", facade.getBodyLength()
> 0);
+        assertEquals("Expected data from facade", 1, facade.getInputStream().read(new byte[1]));
         bytesMessage.clearBody();
-        assertTrue("Expected no message content but was present", facade.getBody().length
== 0);
+        assertTrue("Expected no message content from facade", facade.getBodyLength() == 0);
+        assertEquals("Expected no data from facade, but got some", END_OF_STREAM, facade.getInputStream().read(new
byte[1]));
     }
 
     /**
@@ -425,18 +427,13 @@ public class JmsBytesMessageTest {
     }
 
     @Test
-    public void testClearBody() throws JMSException {
+    public void testClearBodyOnNewMessage() throws JMSException {
         JmsBytesMessage bytesMessage = factory.createBytesMessage();
-        try {
-            bytesMessage.writeInt(1);
-            bytesMessage.clearBody();
-            assertFalse(bytesMessage.isReadOnlyBody());
-            bytesMessage.writeInt(1);
-            bytesMessage.readInt();
-        } catch (MessageNotReadableException mnwe) {
-        } catch (MessageNotWriteableException mnwe) {
-            assertTrue(false);
-        }
+        bytesMessage.writeInt(1);
+        bytesMessage.clearBody();
+        assertFalse(bytesMessage.isReadOnlyBody());
+        bytesMessage.reset();
+        assertEquals(0, bytesMessage.getBodyLength());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/qpid-jms/blob/97912261/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultBytesMessageFacade.java
----------------------------------------------------------------------
diff --git a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultBytesMessageFacade.java
b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultBytesMessageFacade.java
index 04b949c..7783c3f 100644
--- a/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultBytesMessageFacade.java
+++ b/qpid-jms-client/src/test/java/org/apache/qpid/jms/message/facade/defaults/JmsDefaultBytesMessageFacade.java
@@ -137,14 +137,6 @@ public final class JmsDefaultBytesMessageFacade extends JmsDefaultMessageFacade
     }
 
     @Override
-    public byte[] getBody() throws JMSException {
-        if (bytesIn != null || bytesOut != null) {
-            throw new JMSException("Body is in use, call reset before attempting to access
it.");
-        }
-        return content.copy().array();
-    }
-
-    @Override
     public void setBody(byte[] content) throws JMSException {
         if (bytesIn != null || bytesOut != null) {
             throw new JMSException("Body is in use, call reset before attempting to access
it.");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message