[jboss-cvs] JBoss Messaging SVN: r4582 - in trunk: src/main/org/jboss/messaging/core/message/impl and 10 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 25 16:02:13 EDT 2008
Author: timfox
Date: 2008-06-25 16:02:13 -0400 (Wed, 25 Jun 2008)
New Revision: 4582
Added:
trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientMessageImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageImplTestBase.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java
Removed:
trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java
Modified:
trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java
trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
trunk/src/main/org/jboss/messaging/core/security/impl/SecurityActions.java
trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java
trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/MessagingCodecImplTest.java
trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/XidImplTest.java
trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
Log:
More tests
Modified: trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/src/main/org/jboss/messaging/core/client/impl/ClientMessageImpl.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -71,6 +71,11 @@
super((byte) 0, durable, 0, System.currentTimeMillis(), (byte)4, body);
}
+ /* Only used in testing */
+ public ClientMessageImpl()
+ {
+ }
+
public void setDeliveryCount(final int deliveryCount)
{
this.deliveryCount = deliveryCount;
Modified: trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/src/main/org/jboss/messaging/core/message/impl/MessageImpl.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -22,15 +22,19 @@
package org.jboss.messaging.core.message.impl;
+import static org.jboss.messaging.util.DataConstants.SIZE_BOOLEAN;
+import static org.jboss.messaging.util.DataConstants.SIZE_BYTE;
+import static org.jboss.messaging.util.DataConstants.SIZE_INT;
+import static org.jboss.messaging.util.DataConstants.SIZE_LONG;
+
+import java.util.Set;
+
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.message.Message;
-import static org.jboss.messaging.util.DataConstants.*;
import org.jboss.messaging.util.MessagingBuffer;
import org.jboss.messaging.util.SimpleString;
import org.jboss.messaging.util.TypedProperties;
-import java.util.Set;
-
/**
* A concrete implementation of a message
*
@@ -71,7 +75,6 @@
private byte priority;
-
private MessagingBuffer body;
// Constructors --------------------------------------------------
@@ -91,7 +94,7 @@
* @param body
*/
protected MessageImpl(final byte type, final boolean durable, final long expiration,
- final long timestamp, final byte priority, MessagingBuffer body)
+ final long timestamp, final byte priority, MessagingBuffer body)
{
this();
this.type = type;
@@ -207,7 +210,6 @@
{
this.timestamp = timestamp;
}
-
public byte getPriority()
{
@@ -219,7 +221,6 @@
this.priority = priority;
}
-
public boolean isExpired()
{
if (expiration == 0)
@@ -312,7 +313,7 @@
}
// Public --------------------------------------------------------
-
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
Modified: trunk/src/main/org/jboss/messaging/core/security/impl/SecurityActions.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/impl/SecurityActions.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/src/main/org/jboss/messaging/core/security/impl/SecurityActions.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -44,7 +44,7 @@
PrincipalInfoAction PRIVILEGED = new PrincipalInfoAction()
{
public void push(final Principal principal, final Object credential,
- final Subject subject)
+ final Subject subject)
{
AccessController.doPrivileged(
new PrivilegedAction()
@@ -57,19 +57,6 @@
}
);
}
- public void dup()
- {
- AccessController.doPrivileged(
- new PrivilegedAction()
- {
- public Object run()
- {
- SecurityAssociation.dupSubjectContext();
- return null;
- }
- }
- );
- }
public void pop()
{
AccessController.doPrivileged(
@@ -87,14 +74,10 @@
PrincipalInfoAction NON_PRIVILEGED = new PrincipalInfoAction()
{
- public void push(Principal principal, Object credential, Subject subject)
+ public void push(final Principal principal, final Object credential, final Subject subject)
{
SecurityAssociation.pushSubjectContext(subject, principal, credential);
}
- public void dup()
- {
- SecurityAssociation.dupSubjectContext();
- }
public void pop()
{
SecurityAssociation.popSubjectContext();
@@ -102,12 +85,11 @@
};
void push(Principal principal, Object credential, Subject subject);
- void dup();
void pop();
}
- static void pushSubjectContext(Principal principal, Object credential,
- Subject subject)
+ static void pushSubjectContext(final Principal principal, final Object credential,
+ final Subject subject)
{
if(System.getSecurityManager() == null)
{
@@ -118,9 +100,10 @@
PrincipalInfoAction.PRIVILEGED.push(principal, credential, subject);
}
}
+
static void popSubjectContext()
{
- if(System.getSecurityManager() == null)
+ if (System.getSecurityManager() == null)
{
PrincipalInfoAction.NON_PRIVILEGED.pop();
}
Modified: trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/src/main/org/jboss/messaging/core/security/impl/SecurityStoreImpl.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -152,7 +152,6 @@
invalidateCache();
}
-
// Public --------------------------------------------------------
public void setSecurityRepository(HierarchicalRepository<Set<Role>> securityRepository)
@@ -161,7 +160,6 @@
securityRepository.registerListener(this);
}
-
public void setSecurityManager(JBMSecurityManager securityManager)
{
this.securityManager = securityManager;
Modified: trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/src/main/org/jboss/messaging/core/server/impl/ServerMessageImpl.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -107,9 +107,7 @@
public MessageReference createReference(final Queue queue)
{
MessageReference ref = new MessageReferenceImpl(this, queue);
-
- //references.add(ref);
-
+
if (durable && queue.isDurable())
{
durableRefCount.incrementAndGet();
@@ -136,8 +134,6 @@
public ServerMessage copy()
{
return new ServerMessageImpl(this);
- }
-
-
+ }
}
Modified: trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java
===================================================================
--- trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/jms-tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTestBase.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -53,7 +53,7 @@
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
* @version <tt>$Revision: 2883 $</tt>
*
- * $Id: MessageTest.java 2883 2007-07-12 23:36:16Z timfox $
+ * $Id: MessageImplTestBase.java 2883 2007-07-12 23:36:16Z timfox $
*/
public class MessageHeaderTestBase extends JBMServerTestCase
{
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientConsumerImplTest.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -510,8 +510,8 @@
consumer.cleanUp();
EasyMock.verify(session, connection, rc, executor, pd);
}
+
// Private -----------------------------------------------------------------------------------------------------------
-
private void testConstructor(final long targetID, final long clientTargetID,
final int windowSize, final boolean direct) throws Exception
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientMessageImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientMessageImplTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/client/impl/ClientMessageImplTest.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -0,0 +1,142 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.unit.core.client.impl;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+
+import java.nio.ByteBuffer;
+
+import org.jboss.messaging.core.client.ClientMessage;
+import org.jboss.messaging.core.client.impl.ClientMessageImpl;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.tests.unit.core.message.impl.MessageImplTestBase;
+import org.jboss.messaging.tests.util.RandomUtil;
+import org.jboss.messaging.util.ByteBufferWrapper;
+import org.jboss.messaging.util.MessagingBuffer;
+
+
+/**
+ *
+ * A ClientMessageImplTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class ClientMessageImplTest extends MessageImplTestBase
+{
+ protected Message createMessage(final byte type, final boolean durable, final long expiration,
+ final long timestamp, final byte priority, MessagingBuffer buffer)
+ {
+ return new ClientMessageImpl(type, durable, expiration, timestamp, priority, buffer);
+ }
+
+ protected Message createMessage()
+ {
+ return new ClientMessageImpl();
+ }
+
+ public void testDeliveryCountDeliveryIDConstructor()
+ {
+ final int deliveryCount = 120982;
+ final long deliveryID = 10291029;
+ ClientMessage msg = new ClientMessageImpl(deliveryCount, deliveryID);
+ assertEquals(deliveryCount, msg.getDeliveryCount());
+ assertEquals(deliveryID, msg.getDeliveryID());
+ }
+
+ public void testSetDeliveryCount()
+ {
+ ClientMessage msg = new ClientMessageImpl();
+ final int deliveryCount = 127627;
+ msg.setDeliveryCount(deliveryCount);
+ assertEquals(deliveryCount, msg.getDeliveryCount());
+ }
+
+ public void testSetDeliveryID()
+ {
+ ClientMessage msg = new ClientMessageImpl();
+ final long deliveryID = 1029123843;
+ msg.setDeliveryID(deliveryID);
+ assertEquals(deliveryID, msg.getDeliveryID());
+ }
+
+ public void testConstructor1()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ boolean durable = RandomUtil.randomBoolean();
+ ByteBuffer bb = ByteBuffer.wrap(new byte[1000]);
+ MessagingBuffer body = new ByteBufferWrapper(bb);
+
+ ClientMessage msg = new ClientMessageImpl(durable, body);
+ assertEquals(durable, msg.isDurable());
+ assertEquals(body, msg.getBody());
+
+ assertEquals(0, msg.getType());
+ assertEquals(0, msg.getExpiration());
+ assertTrue(System.currentTimeMillis() - msg.getTimestamp() < 5);
+ assertEquals((byte)4, msg.getPriority());
+ }
+ }
+
+ public void testConstructor2()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ byte type = RandomUtil.randomByte();
+ boolean durable = RandomUtil.randomBoolean();
+ ByteBuffer bb = ByteBuffer.wrap(new byte[1000]);
+ MessagingBuffer body = new ByteBufferWrapper(bb);
+
+ ClientMessage msg = new ClientMessageImpl(type, durable, body);
+ assertEquals(type, msg.getType());
+ assertEquals(durable, msg.isDurable());
+ assertEquals(body, msg.getBody());
+
+ assertEquals(0, msg.getExpiration());
+ assertTrue(System.currentTimeMillis() - msg.getTimestamp() < 5);
+ assertEquals((byte)4, msg.getPriority());
+ }
+ }
+
+ public void testConstructor3()
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ byte type = RandomUtil.randomByte();
+ boolean durable = RandomUtil.randomBoolean();
+ ByteBuffer bb = ByteBuffer.wrap(new byte[1000]);
+ MessagingBuffer body = new ByteBufferWrapper(bb);
+ long expiration = RandomUtil.randomLong();
+ long timestamp = RandomUtil.randomLong();
+ byte priority = RandomUtil.randomByte();
+
+ ClientMessage msg = new ClientMessageImpl(type, durable, expiration, timestamp, priority, body);
+ assertEquals(type, msg.getType());
+ assertEquals(durable, msg.isDurable());
+ assertEquals(expiration, msg.getExpiration());
+ assertEquals(timestamp, msg.getTimestamp());
+ assertEquals(priority, msg.getPriority());
+ assertEquals(body, msg.getBody());
+ }
+ }
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/JournalImplTestBase.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -440,7 +440,7 @@
assertEquals("type not same", rexpected.isUpdate, ractual.isUpdate);
- assertByteArraysEquivalent(rexpected.data, ractual.data);
+ assertEqualsByteArrays(rexpected.data, ractual.data);
}
}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/journal/impl/SequentialFileFactoryTestBase.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -281,14 +281,14 @@
assertEquals(rb3.limit(), bytesRead);
rb3.rewind();
rb3.get(rbytes3);
- assertByteArraysEquivalent(bytes3, rbytes3);
+ assertEqualsByteArrays(bytes3, rbytes3);
sf.position(rb1.limit());
bytesRead = sf.read(rb2);
assertEquals(rb2.limit(), bytesRead);
rb2.get(rbytes2);
- assertByteArraysEquivalent(bytes2, rbytes2);
+ assertEqualsByteArrays(bytes2, rbytes2);
sf.position(0);
@@ -296,7 +296,7 @@
assertEquals(rb1.limit(), bytesRead);
rb1.get(rbytes1);
- assertByteArraysEquivalent(bytes1, rbytes1);
+ assertEqualsByteArrays(bytes1, rbytes1);
sf.close();
}
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageImplTestBase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageImplTestBase.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageImplTestBase.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -0,0 +1,362 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.messaging.tests.unit.core.message.impl;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+import static org.jboss.messaging.tests.util.RandomUtil.randomString;
+
+import java.nio.ByteBuffer;
+import java.util.Set;
+
+import org.jboss.messaging.core.journal.EncodingSupport;
+import org.jboss.messaging.core.logging.Logger;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+import org.jboss.messaging.tests.util.UnitTestCase;
+import org.jboss.messaging.util.ByteBufferWrapper;
+import org.jboss.messaging.util.MessagingBuffer;
+import org.jboss.messaging.util.SimpleString;
+
+import static org.jboss.messaging.tests.util.RandomUtil.*;
+
+/**
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public abstract class MessageImplTestBase extends UnitTestCase
+{
+ private static final Logger log = Logger.getLogger(MessageImplTestBase.class);
+
+ protected abstract Message createMessage(final byte type, final boolean durable, final long expiration,
+ final long timestamp, final byte priority, MessagingBuffer buffer);
+
+ protected abstract Message createMessage();
+
+ public void testEncodeDecode()
+ {
+ for (int j = 0; j < 10; j++)
+ {
+ byte[] bytes = new byte[1000];
+ for (int i = 0; i < bytes.length; i++)
+ {
+ bytes[i] = randomByte();
+ }
+ ByteBuffer bb = ByteBuffer.wrap(bytes);
+ MessagingBuffer body = new ByteBufferWrapper(bb);
+ Message message = createMessage(randomByte(), randomBoolean(), randomLong(),
+ randomLong(), randomByte(), body);
+ message.setDestination(new SimpleString("oasoas"));
+
+ message.putStringProperty(new SimpleString("prop1"), new SimpleString("blah1"));
+ message.putStringProperty(new SimpleString("prop2"), new SimpleString("blah2"));
+ ByteBuffer bbMsg = ByteBuffer.allocate(message.getEncodeSize());
+ MessagingBuffer buffer = new ByteBufferWrapper(bbMsg);
+ message.encode(buffer);
+ Message message2 = createMessage();
+ buffer.flip();
+ message2.decode(buffer);
+ assertMessagesEquivalent(message, message2);
+ }
+ }
+
+ public void getSetAttributes()
+ {
+ for (int j = 0; j < 10; j++)
+ {
+ byte[] bytes = new byte[1000];
+ for (int i = 0; i < bytes.length; i++)
+ {
+ bytes[i] = randomByte();
+ }
+ ByteBuffer bb = ByteBuffer.wrap(bytes);
+ MessagingBuffer body = new ByteBufferWrapper(bb);
+
+ final byte type = randomByte();
+ final boolean durable = randomBoolean();
+ final long expiration = randomLong();
+ final long timestamp = randomLong();
+ final byte priority = randomByte();
+
+ Message message = createMessage(type, durable, expiration,
+ timestamp, priority, body);
+
+ assertEquals(type, message.getType());
+ assertEquals(durable, message.isDurable());
+ assertEquals(expiration, message.getExpiration());
+ assertEquals(timestamp, message.getTimestamp());
+ assertEquals(priority, message.getPriority());
+
+ final SimpleString destination = new SimpleString(randomString());
+ final boolean durable2 = randomBoolean();
+ final long expiration2 = randomLong();
+ final long timestamp2 = randomLong();
+ final byte priority2 = randomByte();
+
+ message.setDestination(destination);
+ assertEquals(destination, message.getDestination());
+
+ message.setDurable(durable2);
+ assertEquals(durable2, message.isDurable());
+
+ message.setExpiration(expiration2);
+ assertEquals(expiration2, message.getExpiration());
+
+ message.setTimestamp(timestamp2);
+ assertEquals(timestamp2, message.getTimestamp());
+
+ message.setPriority(priority2);
+ assertEquals(priority2, message.getPriority());
+
+ message.setBody(body);
+ assertTrue(body == message.getBody());
+ }
+ }
+
+ public void testExpired()
+ {
+ Message message = createMessage();
+
+ assertEquals(0, message.getExpiration());
+ assertFalse(message.isExpired());
+
+ message.setExpiration(System.currentTimeMillis() + 1000);
+ assertFalse(message.isExpired());
+
+ message.setExpiration(System.currentTimeMillis() - 1);
+ assertTrue(message.isExpired());
+
+ message.setExpiration(System.currentTimeMillis() - 1000);
+ assertTrue(message.isExpired());
+
+ message.setExpiration(0);
+ assertFalse(message.isExpired());
+ }
+
+
+ public void testEncodingMessage() throws Exception
+ {
+ byte[] bytes = new byte[]{(byte)1, (byte)2, (byte)3};
+ final IoBufferWrapper bufferBody = new IoBufferWrapper(bytes.length);
+ bufferBody.putBytes(bytes);
+
+ SimpleString address = new SimpleString("Simple Destination ");
+
+ Message msg = createMessage();
+ msg.setBody(new ByteBufferWrapper(ByteBuffer.allocateDirect(1024)));
+
+ msg.setDestination(address);
+ msg.setBody(bufferBody);
+ msg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless!"));
+ msg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless and bigger!"));
+ msg.putStringProperty(new SimpleString("Key2"), new SimpleString("This String is worthless and bigger and bigger!"));
+ msg.removeProperty(new SimpleString("Key2"));
+
+ checkSizes(msg, new ServerMessageImpl());
+
+ msg.removeProperty(new SimpleString("Key"));
+
+ checkSizes(msg, new ServerMessageImpl());
+ }
+
+ public void testProperties()
+ {
+ for (int j = 0; j < 10; j++)
+ {
+ Message msg = createMessage();
+
+ SimpleString prop1 = new SimpleString("prop1");
+ boolean val1 = randomBoolean();
+ msg.putBooleanProperty(prop1, val1);
+
+ SimpleString prop2 = new SimpleString("prop2");
+ byte val2 = randomByte();
+ msg.putByteProperty(prop2, val2);
+
+ SimpleString prop3 = new SimpleString("prop3");
+ byte[] val3 = randomBytes();
+ msg.putBytesProperty(prop3, val3);
+
+ SimpleString prop4 = new SimpleString("prop4");
+ double val4 = randomDouble();
+ msg.putDoubleProperty(prop4, val4);
+
+ SimpleString prop5 = new SimpleString("prop5");
+ float val5 = randomFloat();
+ msg.putFloatProperty(prop5, val5);
+
+ SimpleString prop6 = new SimpleString("prop6");
+ int val6 = randomInt();
+ msg.putIntProperty(prop6, val6);
+
+ SimpleString prop7 = new SimpleString("prop7");
+ long val7 = randomLong();
+ msg.putLongProperty(prop7, val7);
+
+ SimpleString prop8 = new SimpleString("prop8");
+ short val8 = randomShort();
+ msg.putShortProperty(prop8, val8);
+
+ SimpleString prop9 = new SimpleString("prop9");
+ SimpleString val9 = new SimpleString(randomString());
+ msg.putStringProperty(prop9, val9);
+
+ assertEquals(9, msg.getPropertyNames().size());
+ assertTrue(msg.getPropertyNames().contains(prop1));
+ assertTrue(msg.getPropertyNames().contains(prop2));
+ assertTrue(msg.getPropertyNames().contains(prop3));
+ assertTrue(msg.getPropertyNames().contains(prop4));
+ assertTrue(msg.getPropertyNames().contains(prop5));
+ assertTrue(msg.getPropertyNames().contains(prop6));
+ assertTrue(msg.getPropertyNames().contains(prop7));
+ assertTrue(msg.getPropertyNames().contains(prop8));
+ assertTrue(msg.getPropertyNames().contains(prop9));
+
+ assertTrue(msg.containsProperty(prop1));
+ assertTrue(msg.containsProperty(prop2));
+ assertTrue(msg.containsProperty(prop3));
+ assertTrue(msg.containsProperty(prop4));
+ assertTrue(msg.containsProperty(prop5));
+ assertTrue(msg.containsProperty(prop6));
+ assertTrue(msg.containsProperty(prop7));
+ assertTrue(msg.containsProperty(prop8));
+ assertTrue(msg.containsProperty(prop9));
+
+ assertEquals(val1, msg.getProperty(prop1));
+ assertEquals(val2, msg.getProperty(prop2));
+ assertEquals(val3, msg.getProperty(prop3));
+ assertEquals(val4, msg.getProperty(prop4));
+ assertEquals(val5, msg.getProperty(prop5));
+ assertEquals(val6, msg.getProperty(prop6));
+ assertEquals(val7, msg.getProperty(prop7));
+ assertEquals(val8, msg.getProperty(prop8));
+ assertEquals(val9, msg.getProperty(prop9));
+
+ SimpleString val10 = new SimpleString(randomString());
+ //test overwrite
+ msg.putStringProperty(prop9, val10);
+ assertEquals(val10, msg.getProperty(prop9));
+
+ int val11 = randomInt();
+ msg.putIntProperty(prop9, val11);
+ assertEquals(val11, msg.getProperty(prop9));
+
+ msg.removeProperty(prop1);
+ assertEquals(8, msg.getPropertyNames().size());
+ assertTrue(msg.getPropertyNames().contains(prop2));
+ assertTrue(msg.getPropertyNames().contains(prop3));
+ assertTrue(msg.getPropertyNames().contains(prop4));
+ assertTrue(msg.getPropertyNames().contains(prop5));
+ assertTrue(msg.getPropertyNames().contains(prop6));
+ assertTrue(msg.getPropertyNames().contains(prop7));
+ assertTrue(msg.getPropertyNames().contains(prop8));
+ assertTrue(msg.getPropertyNames().contains(prop9));
+
+ msg.removeProperty(prop2);
+ assertEquals(7, msg.getPropertyNames().size());
+ assertTrue(msg.getPropertyNames().contains(prop3));
+ assertTrue(msg.getPropertyNames().contains(prop4));
+ assertTrue(msg.getPropertyNames().contains(prop5));
+ assertTrue(msg.getPropertyNames().contains(prop6));
+ assertTrue(msg.getPropertyNames().contains(prop7));
+ assertTrue(msg.getPropertyNames().contains(prop8));
+ assertTrue(msg.getPropertyNames().contains(prop9));
+
+ msg.removeProperty(prop9);
+ assertEquals(6, msg.getPropertyNames().size());
+ assertTrue(msg.getPropertyNames().contains(prop3));
+ assertTrue(msg.getPropertyNames().contains(prop4));
+ assertTrue(msg.getPropertyNames().contains(prop5));
+ assertTrue(msg.getPropertyNames().contains(prop6));
+ assertTrue(msg.getPropertyNames().contains(prop7));
+ assertTrue(msg.getPropertyNames().contains(prop8));
+
+ msg.removeProperty(prop3);
+ msg.removeProperty(prop4);
+ msg.removeProperty(prop5);
+ msg.removeProperty(prop6);
+ msg.removeProperty(prop7);
+ msg.removeProperty(prop8);
+ assertEquals(0, msg.getPropertyNames().size());
+ }
+ }
+
+ // Protected -------------------------------------------------------------------------------
+
+ protected void assertMessagesEquivalent(final Message msg1, final Message msg2)
+ {
+ assertEquals(msg1.isDurable(), msg2.isDurable());
+
+ assertEquals(msg1.getExpiration(), msg2.getExpiration());
+
+ assertEquals(msg1.getTimestamp(), msg2.getTimestamp());
+
+ assertEquals(msg1.getPriority(), msg2.getPriority());
+
+ assertEquals(msg1.getType(), msg2.getType());
+
+ assertEqualsByteArrays(msg1.getBody().array(), msg2.getBody().array());
+
+ assertEquals(msg1.getDestination(), msg2.getDestination());
+
+ Set<SimpleString> props1 = msg1.getPropertyNames();
+
+ Set<SimpleString> props2 = msg2.getPropertyNames();
+
+ assertEquals(props1.size(), props2.size());
+
+ for (SimpleString propname: props1)
+ {
+ Object val1 = msg1.getProperty(propname);
+
+ Object val2 = msg2.getProperty(propname);
+
+ assertEquals(val1, val2);
+ }
+ }
+
+ // Private ----------------------------------------------------------------------------------
+
+ private void checkSizes(final EncodingSupport obj, final EncodingSupport newObject)
+ {
+ ByteBuffer bf = ByteBuffer.allocateDirect(1024);
+ ByteBufferWrapper buffer = new ByteBufferWrapper(bf);
+ obj.encode(buffer);
+ assertEquals (buffer.position(), obj.getEncodeSize());
+ int originalSize = buffer.position();
+
+ bf.rewind();
+ newObject.decode(buffer);
+
+ bf = ByteBuffer.allocateDirect(1024 * 10);
+ buffer = new ByteBufferWrapper(bf);
+
+ newObject.encode(buffer);
+
+ assertEquals(newObject.getEncodeSize(), bf.position());
+ assertEquals(originalSize, bf.position());
+ }
+}
Deleted: trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/message/impl/MessageTest.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -1,311 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-
-package org.jboss.messaging.tests.unit.core.message.impl;
-
-import org.jboss.messaging.core.client.ClientMessage;
-import org.jboss.messaging.core.client.impl.ClientMessageImpl;
-import org.jboss.messaging.core.journal.EncodingSupport;
-import org.jboss.messaging.core.logging.Logger;
-import org.jboss.messaging.core.remoting.impl.mina.IoBufferWrapper;
-import org.jboss.messaging.core.server.MessageReference;
-import org.jboss.messaging.core.server.Queue;
-import org.jboss.messaging.core.server.QueueFactory;
-import org.jboss.messaging.core.server.ServerMessage;
-import org.jboss.messaging.core.server.impl.ServerMessageImpl;
-import org.jboss.messaging.tests.unit.core.server.impl.fakes.FakeQueueFactory;
-import org.jboss.messaging.tests.util.UnitTestCase;
-import org.jboss.messaging.util.ByteBufferWrapper;
-import org.jboss.messaging.util.SimpleString;
-
-import java.nio.ByteBuffer;
-
-/**
- *
- * Tests for Message and MessageReference
- *
- * TODO - Test streaming and destreaming
- *
- * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- *
- */
-public class MessageTest extends UnitTestCase
-{
- private static final Logger log = Logger.getLogger(MessageTest.class);
-
- private QueueFactory queueFactory = new FakeQueueFactory();
-
- public void testCreateMessageBeforeSending()
- {
- long id = 56465;
- byte type = (byte) 655;
- boolean reliable = true;
- long expiration = 6712671;
- long timestamp = 82798172;
- byte priority = 32;
-
- ClientMessage message = new ClientMessageImpl(type, reliable, expiration, timestamp, priority, new ByteBufferWrapper(ByteBuffer.allocateDirect(1024)));
-
- assertEquals(type, message.getType());
- assertEquals(reliable, message.isDurable());
- assertEquals(timestamp, message.getTimestamp());
- assertEquals(priority, message.getPriority());
-
- reliable = false;
-
- message = new ClientMessageImpl(type, reliable, expiration, timestamp, priority, new ByteBufferWrapper(ByteBuffer.allocateDirect(1024)));
-
- assertEquals(type, message.getType());
- assertEquals(reliable, message.isDurable());
- assertEquals(timestamp, message.getTimestamp());
- assertEquals(priority, message.getPriority());
- }
-
- public void testCreateMessageFromStorage() throws Exception
- {
- long id = 56465;
-
- ServerMessage message = new ServerMessageImpl(id);
-
- assertEquals(id, message.getMessageID());
- }
-
- public void testSetAndGetMessageID()
- {
- ServerMessage message = new ServerMessageImpl();
-
- assertEquals(0, message.getMessageID());
-
- message = new ServerMessageImpl(23);
-
- assertEquals(23, message.getMessageID());
-
- long id = 765432;
- message.setMessageID(id);
- assertEquals(id, message.getMessageID());
- }
-
- public void testSetAndGetReliable()
- {
- ServerMessage message = new ServerMessageImpl();
-
- boolean reliable = true;
- message.setDurable(reliable);
- assertEquals(reliable, message.isDurable());
-
- reliable = false;
- message.setDurable(reliable);
- assertEquals(reliable, message.isDurable());
- }
-
- public void testSetAndGetExpiration()
- {
- ServerMessage message = new ServerMessageImpl();
-
- long expiration = System.currentTimeMillis() + 10000;
- message.setExpiration(expiration);
- assertEquals(expiration, message.getExpiration());
- assertFalse(message.isExpired());
- message.setExpiration(System.currentTimeMillis() - 1);
- assertTrue(message.isExpired());
-
- expiration = 0; //O means never expire
- message.setExpiration(expiration);
- assertEquals(expiration, message.getExpiration());
- assertFalse(message.isExpired());
- }
-
- public void testSetAndGetTimestamp()
- {
- ServerMessage message = new ServerMessageImpl();
-
- long timestamp = System.currentTimeMillis();
- message.setTimestamp(timestamp);
- assertEquals(timestamp, message.getTimestamp());
- }
-
- public void testSetAndGetPriority()
- {
- ServerMessage message = new ServerMessageImpl();
- byte priority = 7;
- message.setPriority(priority);
- assertEquals(priority, message.getPriority());
- }
-
- public void testSetAndGetConnectionID()
- {
- ServerMessage message = new ServerMessageImpl();
-
- assertEquals(0, message.getConnectionID());
- long connectionID = 781628;
- message.setConnectionID(connectionID);
- assertEquals(connectionID, message.getConnectionID());
- }
-
- public void testMessageReference()
- {
- ServerMessage message = new ServerMessageImpl();
-
- SimpleString squeue1 = new SimpleString("queue1");
- SimpleString squeue2 = new SimpleString("queue2");
- SimpleString squeue3 = new SimpleString("queue3");
-
- Queue queue1 = queueFactory.createQueue(1, squeue1, null, false, true);
- Queue queue2 = queueFactory.createQueue(2, squeue2, null, false, true);
-
- MessageReference ref1 = message.createReference(queue1);
- MessageReference ref2 = message.createReference(queue2);
- MessageReference ref3 = message.createReference(queue1);
- MessageReference ref4 = message.createReference(queue2);
-
- assertEquals(queue1, ref1.getQueue());
- assertEquals(queue2, ref2.getQueue());
- assertEquals(queue1, ref3.getQueue());
- assertEquals(queue2, ref4.getQueue());
-
- int deliveryCount = 65235;
- ref1.setDeliveryCount(deliveryCount);
- assertEquals(deliveryCount, ref1.getDeliveryCount());
-
- long scheduledDeliveryTime = 908298123;
- ref1.setScheduledDeliveryTime(scheduledDeliveryTime);
- assertEquals(scheduledDeliveryTime, ref1.getScheduledDeliveryTime());
-
- Queue queue3 = queueFactory.createQueue(3, squeue3, null, false, true);
- MessageReference ref5 = ref1.copy(queue3);
-
- assertEquals(deliveryCount, ref5.getDeliveryCount());
- assertEquals(scheduledDeliveryTime, ref5.getScheduledDeliveryTime());
- assertEquals(queue3, ref5.getQueue());
- }
-
-
- public void testDurableReferences()
- {
- ServerMessage messageDurable = new ServerMessageImpl();
- messageDurable.setDurable(true);
-
- ServerMessage messageNonDurable = new ServerMessageImpl();
- messageNonDurable.setDurable(false);
-
- SimpleString squeue1 = new SimpleString("queue1");
- SimpleString squeue2 = new SimpleString("queue2");
-
- //Durable queue
- Queue queue1 = queueFactory.createQueue(1, squeue1, null, true, false);
-
- //Non durable queue
- Queue queue2 = queueFactory.createQueue(2, squeue2, null, false, false);
-
- assertEquals(0, messageDurable.getDurableRefCount());
-
- MessageReference ref1 = messageDurable.createReference(queue1);
-
- assertEquals(1, messageDurable.getDurableRefCount());
-
- MessageReference ref2 = messageDurable.createReference(queue2);
-
- assertEquals(1, messageDurable.getDurableRefCount());
-
- assertEquals(0, messageNonDurable.getDurableRefCount());
-
- MessageReference ref3 = messageNonDurable.createReference(queue1);
-
- assertEquals(0, messageNonDurable.getDurableRefCount());
-
- MessageReference ref4 = messageNonDurable.createReference(queue2);
-
- assertEquals(0, messageNonDurable.getDurableRefCount());
-
- MessageReference ref5 = messageDurable.createReference(queue1);
-
- assertEquals(2, messageDurable.getDurableRefCount());
-
- messageDurable.decrementDurableRefCount();
-
- assertEquals(1, messageDurable.getDurableRefCount());
-
- messageDurable.decrementDurableRefCount();
-
- assertEquals(0, messageDurable.getDurableRefCount());
-
- messageDurable.incrementDurableRefCount();
-
- assertEquals(1, messageDurable.getDurableRefCount());
- }
-
- public void testEncodingMessage() throws Exception
- {
- byte[] bytes = new byte[]{(byte)1, (byte)2, (byte)3};
- final IoBufferWrapper bufferBody = new IoBufferWrapper(bytes.length);
- bufferBody.putBytes(bytes);
-
-
- SimpleString address = new SimpleString("Simple Destination ");
-
- ServerMessageImpl implMsg = new ServerMessageImpl(/* type */ (byte)1, /* durable */ true, /* expiration */ 0,
- /* timestamp */ 0, /* priority */(byte)0, new ByteBufferWrapper(ByteBuffer.allocateDirect(1024)));
-
- implMsg.setDestination(address);
- implMsg.setBody(bufferBody);
- implMsg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless!"));
- implMsg.putStringProperty(new SimpleString("Key"), new SimpleString("This String is worthless and bigger!"));
- implMsg.putStringProperty(new SimpleString("Key2"), new SimpleString("This String is worthless and bigger and bigger!"));
- implMsg.removeProperty(new SimpleString("Key2"));
-
- checkSizes(implMsg, new ServerMessageImpl());
-
- implMsg.removeProperty(new SimpleString("Key"));
-
- checkSizes(implMsg, new ServerMessageImpl());
-
- }
-
- private void checkSizes(EncodingSupport obj, EncodingSupport newObject)
- {
- ByteBuffer bf = ByteBuffer.allocateDirect(1024);
- ByteBufferWrapper buffer = new ByteBufferWrapper(bf);
- obj.encode(buffer);
- assertEquals (buffer.position(), obj.getEncodeSize());
- int originalSize = buffer.position();
-
- bf.rewind();
- newObject.decode(buffer);
-
- log.info("Obj.size = " + obj.getEncodeSize() + " newObject.size = " + newObject.getEncodeSize());
-
- bf = ByteBuffer.allocateDirect(1024 * 10);
- buffer = new ByteBufferWrapper(bf);
-
- newObject.encode(buffer);
-
- assertEquals(newObject.getEncodeSize(), bf.position());
- assertEquals(originalSize, bf.position());
-
-
-
-
- }
-
-
-
-}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/MessagingCodecImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/MessagingCodecImplTest.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/MessagingCodecImplTest.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -349,7 +349,7 @@
assertEquals(9, copy.getServerMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getServerMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getServerMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getServerMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getServerMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getServerMessage().getProperty(intProp));
@@ -402,7 +402,7 @@
assertEquals(9, copy.getServerMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getServerMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getServerMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getServerMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getServerMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getServerMessage().getProperty(intProp));
@@ -454,7 +454,7 @@
assertEquals(9, copy.getServerMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getServerMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getServerMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getServerMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getServerMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getServerMessage().getProperty(intProp));
@@ -507,7 +507,7 @@
assertEquals(9, copy.getServerMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getServerMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getServerMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getServerMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getServerMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getServerMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getServerMessage().getProperty(intProp));
@@ -641,7 +641,7 @@
assertEquals(9, copy.getClientMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getClientMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getClientMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getClientMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getClientMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getClientMessage().getProperty(intProp));
@@ -693,7 +693,7 @@
assertEquals(9, copy.getClientMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getClientMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getClientMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getClientMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getClientMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getClientMessage().getProperty(intProp));
@@ -745,7 +745,7 @@
assertEquals(9, copy.getClientMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getClientMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getClientMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getClientMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getClientMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getClientMessage().getProperty(intProp));
@@ -798,7 +798,7 @@
assertEquals(9, copy.getClientMessage().getPropertyNames().size());
assertEquals(message1.getProperty(boolProp), copy.getClientMessage().getProperty(boolProp));
assertEquals(message1.getProperty(byteProp), copy.getClientMessage().getProperty(byteProp));
- assertByteArraysEquivalent((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
+ assertEqualsByteArrays((byte[]) message1.getProperty(byteprops), (byte[]) copy.getClientMessage().getProperty(byteprops));
assertEquals(message1.getProperty(doubleProp), copy.getClientMessage().getProperty(doubleProp));
assertEquals(message1.getProperty(floatProp), copy.getClientMessage().getProperty(floatProp));
assertEquals(message1.getProperty(intProp), copy.getClientMessage().getProperty(intProp));
@@ -1162,9 +1162,9 @@
SessionXACommitMessage copy = (SessionXACommitMessage) codec.decode(buff);
checkHeaders(message, copy);
assertEquals(message.isOnePhase(), copy.isOnePhase());
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
public void testSessionXAEndMessagePacket() throws Exception
@@ -1177,9 +1177,9 @@
SessionXAEndMessage copy = (SessionXAEndMessage) codec.decode(buff);
checkHeaders(message, copy);
assertEquals(message.isFailed(), copy.isFailed());
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
public void testSessionXAForgetMessagePacket() throws Exception
@@ -1190,9 +1190,9 @@
buff.rewind();
SessionXAForgetMessage copy = (SessionXAForgetMessage) codec.decode(buff);
checkHeaders(message, copy);
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
public void testSessionXAGetInDoubtXidsResponseMessagePacket() throws Exception
@@ -1206,9 +1206,9 @@
buff.rewind();
SessionXAGetInDoubtXidsResponseMessage copy = (SessionXAGetInDoubtXidsResponseMessage) codec.decode(buff);
checkHeaders(message, copy);
- assertByteArraysEquivalent(message.getXids().get(0).getBranchQualifier(), copy.getXids().get(0).getBranchQualifier());
+ assertEqualsByteArrays(message.getXids().get(0).getBranchQualifier(), copy.getXids().get(0).getBranchQualifier());
assertEquals(message.getXids().get(0).getFormatId(), copy.getXids().get(0).getFormatId());
- assertByteArraysEquivalent(message.getXids().get(0).getGlobalTransactionId(), copy.getXids().get(0).getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXids().get(0).getGlobalTransactionId(), copy.getXids().get(0).getGlobalTransactionId());
assertEquals(1, message.getXids().size());
}
@@ -1231,9 +1231,9 @@
buff.rewind();
SessionXAJoinMessage copy = (SessionXAJoinMessage) codec.decode(buff);
checkHeaders(message, copy);
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
public void testSessionXAPrepareMessagePacket() throws Exception
@@ -1244,9 +1244,9 @@
buff.rewind();
SessionXAPrepareMessage copy = (SessionXAPrepareMessage) codec.decode(buff);
checkHeaders(message, copy);
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
public void testSessionXAResponseMessagePacket() throws Exception
@@ -1270,9 +1270,9 @@
buff.rewind();
SessionXAResumeMessage copy = (SessionXAResumeMessage) codec.decode(buff);
checkHeaders(message, copy);
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
public void testSessionXARollbackMessagePacket() throws Exception
@@ -1283,9 +1283,9 @@
buff.rewind();
SessionXARollbackMessage copy = (SessionXARollbackMessage) codec.decode(buff);
checkHeaders(message, copy);
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
public void testSessionXASetTimeoutMessagePacket() throws Exception
@@ -1318,9 +1318,9 @@
buff.rewind();
SessionXAStartMessage copy = (SessionXAStartMessage) codec.decode(buff);
checkHeaders(message, copy);
- assertByteArraysEquivalent(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
+ assertEqualsByteArrays(message.getXid().getBranchQualifier(), copy.getXid().getBranchQualifier());
assertEquals(message.getXid().getFormatId(), copy.getXid().getFormatId());
- assertByteArraysEquivalent(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
+ assertEqualsByteArrays(message.getXid().getGlobalTransactionId(), copy.getXid().getGlobalTransactionId());
}
private void setHeaders(PacketImpl packet)
Added: trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java (rev 0)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/server/impl/ServerMessageImplTest.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -0,0 +1,203 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.messaging.tests.unit.core.server.impl;
+
+import static org.jboss.messaging.tests.util.RandomUtil.randomBoolean;
+import static org.jboss.messaging.tests.util.RandomUtil.randomByte;
+import static org.jboss.messaging.tests.util.RandomUtil.randomLong;
+
+import java.nio.ByteBuffer;
+
+import org.easymock.EasyMock;
+import org.jboss.messaging.core.message.Message;
+import org.jboss.messaging.core.server.MessageReference;
+import org.jboss.messaging.core.server.Queue;
+import org.jboss.messaging.core.server.ServerMessage;
+import org.jboss.messaging.core.server.impl.ServerMessageImpl;
+import org.jboss.messaging.tests.unit.core.message.impl.MessageImplTestBase;
+import org.jboss.messaging.util.ByteBufferWrapper;
+import org.jboss.messaging.util.MessagingBuffer;
+import org.jboss.messaging.util.SimpleString;
+
+/**
+ *
+ * A ServerMessageImplTest
+ *
+ * @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
+ *
+ */
+public class ServerMessageImplTest extends MessageImplTestBase
+{
+ protected Message createMessage(final byte type, final boolean durable, final long expiration,
+ final long timestamp, final byte priority, MessagingBuffer buffer)
+ {
+ return new ServerMessageImpl(type, durable, expiration, timestamp, priority, buffer);
+ }
+
+ protected Message createMessage()
+ {
+ return new ServerMessageImpl();
+ }
+
+ public void testMessageIDConstructor()
+ {
+ final long id = 1029812;
+ ServerMessage msg = new ServerMessageImpl(id);
+ assertEquals(id, msg.getMessageID());
+ }
+
+ public void testCopyConstructor()
+ {
+ for (int j = 0; j < 10; j++)
+ {
+ byte[] bytes = new byte[1000];
+ for (int i = 0; i < bytes.length; i++)
+ {
+ bytes[i] = randomByte();
+ }
+ ByteBuffer bb = ByteBuffer.wrap(bytes);
+ MessagingBuffer body = new ByteBufferWrapper(bb);
+ ServerMessageImpl message = new ServerMessageImpl(randomByte(), randomBoolean(), randomLong(),
+ randomLong(), randomByte(), body);
+ message.setDestination(new SimpleString("oasoas"));
+
+ message.putStringProperty(new SimpleString("prop1"), new SimpleString("blah1"));
+ message.putStringProperty(new SimpleString("prop2"), new SimpleString("blah2"));
+
+ message.setMessageID(81721872);
+ message.setConnectionID(10291092);
+
+ ServerMessage message2 = new ServerMessageImpl(message);
+
+ assertMessagesEquivalent(message, message2);
+
+ ServerMessage message3 = message2.copy();
+
+ assertMessagesEquivalent(message2, message3);
+ }
+ }
+
+ public void testGetSetMessageID()
+ {
+ ServerMessage msg = (ServerMessage)createMessage();
+ final long id = 91829182;
+ msg.setMessageID(id);
+ assertEquals(id, msg.getMessageID());
+ }
+
+ public void testGetSetConnectionID()
+ {
+ ServerMessage msg = (ServerMessage)createMessage();
+ final long id = 8172718;
+ msg.setConnectionID(id);
+ assertEquals(id, msg.getConnectionID());
+ }
+
+ public void testCreateReferencesDurable()
+ {
+ ServerMessage msg = new ServerMessageImpl();
+ msg.setDurable(true);
+
+ Queue queue1 = EasyMock.createStrictMock(Queue.class);
+ Queue queue2 = EasyMock.createStrictMock(Queue.class);
+ Queue queue3 = EasyMock.createStrictMock(Queue.class);
+
+ EasyMock.expect(queue1.isDurable()).andReturn(true);
+ EasyMock.expect(queue2.isDurable()).andReturn(true);
+ EasyMock.expect(queue3.isDurable()).andReturn(false);
+
+ EasyMock.replay(queue1, queue2, queue3);
+
+ MessageReference ref1 = msg.createReference(queue1);
+ MessageReference ref2 = msg.createReference(queue2);
+ MessageReference ref3 = msg.createReference(queue3);
+
+ assertEquals(msg, ref1.getMessage());
+ assertEquals(msg, ref2.getMessage());
+ assertEquals(msg, ref3.getMessage());
+
+ assertEquals(queue1, ref1.getQueue());
+ assertEquals(queue2, ref2.getQueue());
+ assertEquals(queue3, ref3.getQueue());
+
+ EasyMock.verify(queue1, queue2, queue3);
+
+ assertEquals(2, msg.getDurableRefCount());
+
+ msg.incrementDurableRefCount();
+ assertEquals(3, msg.getDurableRefCount());
+
+ msg.incrementDurableRefCount();
+ assertEquals(4, msg.getDurableRefCount());
+
+ msg.decrementDurableRefCount();
+ assertEquals(3, msg.getDurableRefCount());
+
+ msg.decrementDurableRefCount();
+ assertEquals(2, msg.getDurableRefCount());
+
+ msg.decrementDurableRefCount();
+ msg.decrementDurableRefCount();
+ assertEquals(0, msg.getDurableRefCount());
+ }
+
+ public void testCreateReferencesNonDurable()
+ {
+ ServerMessage msg = new ServerMessageImpl();
+ msg.setDurable(false);
+
+ Queue queue1 = EasyMock.createStrictMock(Queue.class);
+ Queue queue2 = EasyMock.createStrictMock(Queue.class);
+ Queue queue3 = EasyMock.createStrictMock(Queue.class);
+
+ EasyMock.replay(queue1, queue2, queue3);
+
+ MessageReference ref1 = msg.createReference(queue1);
+ MessageReference ref2 = msg.createReference(queue2);
+ MessageReference ref3 = msg.createReference(queue3);
+
+ assertEquals(msg, ref1.getMessage());
+ assertEquals(msg, ref2.getMessage());
+ assertEquals(msg, ref3.getMessage());
+
+ assertEquals(queue1, ref1.getQueue());
+ assertEquals(queue2, ref2.getQueue());
+ assertEquals(queue3, ref3.getQueue());
+
+ EasyMock.verify(queue1, queue2, queue3);
+
+ assertEquals(0, msg.getDurableRefCount());
+ }
+
+ // Protected -----------------------------------------------------------------------------------
+
+ protected void assertMessagesEquivalent(final Message msg1, final Message msg2)
+ {
+ super.assertMessagesEquivalent(msg1, msg2);
+
+ ServerMessage smsg1 = (ServerMessage)msg1;
+ ServerMessage smsg2 = (ServerMessage)msg2;
+
+ assertEquals(smsg1.getConnectionID(), smsg2.getConnectionID());
+ assertEquals(smsg1.getMessageID(), smsg2.getMessageID());
+ }
+}
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/XidImplTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/XidImplTest.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/transaction/impl/XidImplTest.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -78,9 +78,9 @@
XidImpl xid1 = new XidImpl(bq, formatID, globalTXID);
- assertByteArraysEquivalent(bq, xid1.getBranchQualifier());
+ assertEqualsByteArrays(bq, xid1.getBranchQualifier());
- assertByteArraysEquivalent(globalTXID, xid1.getGlobalTransactionId());
+ assertEqualsByteArrays(globalTXID, xid1.getGlobalTransactionId());
assertEquals(formatID, xid1.getFormatId());
}
@@ -117,11 +117,11 @@
private void assertXidsEquivalent(Xid xid1, Xid xid2)
{
- assertByteArraysEquivalent(xid1.getBranchQualifier(), xid2.getBranchQualifier());
+ assertEqualsByteArrays(xid1.getBranchQualifier(), xid2.getBranchQualifier());
assertEquals(xid1.getFormatId(), xid2.getFormatId());
- assertByteArraysEquivalent(xid1.getGlobalTransactionId(), xid2.getGlobalTransactionId());
+ assertEqualsByteArrays(xid1.getGlobalTransactionId(), xid2.getGlobalTransactionId());
}
// Inner classes ---------------------------------------------------------------------------
Modified: trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-06-25 16:31:42 UTC (rev 4581)
+++ trunk/tests/src/org/jboss/messaging/tests/util/UnitTestCase.java 2008-06-25 20:02:13 UTC (rev 4582)
@@ -22,21 +22,28 @@
package org.jboss.messaging.tests.util;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.ByteBuffer;
+import java.util.Iterator;
+import java.util.List;
+import java.util.UUID;
+
+import javax.transaction.xa.Xid;
+
import junit.framework.TestCase;
+
import org.jboss.messaging.core.server.MessageReference;
import org.jboss.messaging.core.server.Queue;
import org.jboss.messaging.core.server.ServerMessage;
import org.jboss.messaging.core.server.impl.ServerMessageImpl;
import org.jboss.messaging.util.ByteBufferWrapper;
-import javax.transaction.xa.Xid;
-import java.io.*;
-import java.nio.ByteBuffer;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
/**
*
* Helper base class for our unit tests
@@ -46,21 +53,21 @@
*/
public class UnitTestCase extends TestCase
{
- protected void assertByteArraysEquivalent(byte[] bytes1, byte[] bytes2)
- {
- if (bytes1.length != bytes2.length)
- {
- fail("Byte arrays different sizes bytes1: " + dumpBytes(bytes1) + " bytes2: " + dumpBytes(bytes2));
- }
-
- for (int i = 0; i < bytes1.length; i++)
- {
- if (bytes1[i] != bytes2[i])
- {
- fail("Byte arrays not equivalent: " + dumpBytes(bytes1) + " bytes2: " + dumpBytes(bytes2));
- }
- }
- }
+// protected void assertByteArraysEquivalent(byte[] bytes1, byte[] bytes2)
+// {
+// if (bytes1.length != bytes2.length)
+// {
+// fail("Byte arrays different sizes bytes1: " + dumpBytes(bytes1) + " bytes2: " + dumpBytes(bytes2));
+// }
+//
+// for (int i = 0; i < bytes1.length; i++)
+// {
+// if (bytes1[i] != bytes2[i])
+// {
+// fail("Byte arrays not equivalent: " + dumpBytes(bytes1) + " bytes2: " + dumpBytes(bytes2));
+// }
+// }
+// }
protected String dumpBytes(byte[] bytes)
{
@@ -171,29 +178,29 @@
}
}
- protected void assertRefListsEquivalent(List<MessageReference> l1, List<MessageReference> l2)
- {
- if (l1.size() != l2.size())
- {
- fail("Lists different sizes: " + l1.size() + ", " + l2.size());
- }
-
- Iterator<MessageReference> iter1 = l1.iterator();
- Iterator<MessageReference> iter2 = l2.iterator();
-
- while (iter1.hasNext())
- {
- MessageReference o1 = iter1.next();
- MessageReference o2 = iter2.next();
-
- assertEquals(o1.getMessage().getMessageID(), o2.getMessage().getMessageID());
+// protected void assertRefListsEquivalent(List<MessageReference> l1, List<MessageReference> l2)
+// {
+// if (l1.size() != l2.size())
+// {
+// fail("Lists different sizes: " + l1.size() + ", " + l2.size());
+// }
+//
+// Iterator<MessageReference> iter1 = l1.iterator();
+// Iterator<MessageReference> iter2 = l2.iterator();
+//
+// while (iter1.hasNext())
+// {
+// MessageReference o1 = iter1.next();
+// MessageReference o2 = iter2.next();
+//
+// assertEquals(o1.getMessage().getMessageID(), o2.getMessage().getMessageID());
+//
+// assertEquals(o1.getScheduledDeliveryTime(), o2.getScheduledDeliveryTime());
+//
+// assertEquals(o1.getDeliveryCount(), o2.getDeliveryCount());
+// }
+// }
- assertEquals(o1.getScheduledDeliveryTime(), o2.getScheduledDeliveryTime());
-
- assertEquals(o1.getDeliveryCount(), o2.getDeliveryCount());
- }
- }
-
protected ServerMessage generateMessage(long id)
{
ServerMessage message = new ServerMessageImpl((byte)0, true, 0, System.currentTimeMillis(), (byte)4, new ByteBufferWrapper(ByteBuffer.allocateDirect(1024)));
@@ -221,39 +228,41 @@
return message.createReference(queue);
}
- protected void assertEquivalent(ServerMessage msg1, ServerMessage msg2)
- {
- assertEquivalent(msg1, msg2, true);
- }
-
- protected void assertEquivalent(ServerMessage msg1, ServerMessage msg2, boolean exactQueue)
- {
- assertEquals(msg1.getMessageID(), msg2.getMessageID());
-
- assertEquals(msg1.isDurable(), msg2.isDurable());
-
- assertEquals(msg1.getExpiration(), msg2.getExpiration());
-
- assertEquals(msg1.getTimestamp(), msg2.getTimestamp());
-
- assertEquals(msg1.getPriority(), msg2.getPriority());
-
- assertEquals(msg1.getType(), msg2.getType());
-
- assertByteArraysEquivalent(msg1.getBody().array(), msg2.getBody().array());
-
- assertEquals(msg1.getDurableRefCount(), msg2.getDurableRefCount());
- }
-
- protected void assertMapsEquivalent(Map<String, Object> headers1, Map<String, Object> headers2)
- {
- assertEquals(headers1.size(), headers2.size());
-
- for (Map.Entry<String, Object> entry : headers1.entrySet())
- {
- assertEquals(entry.getValue(), headers2.get(entry.getKey()));
- }
- }
+// protected void assertEquivalent(ServerMessage msg1, ServerMessage msg2)
+// {
+// assertEquivalent(msg1, msg2, true);
+// }
+//
+// protected void assertEquivalent(ServerMessage msg1, ServerMessage msg2, boolean exactQueue)
+// {
+// assertEquals(msg1.getMessageID(), msg2.getMessageID());
+//
+// assertEquals(msg1.isDurable(), msg2.isDurable());
+//
+// assertEquals(msg1.getExpiration(), msg2.getExpiration());
+//
+// assertEquals(msg1.getTimestamp(), msg2.getTimestamp());
+//
+// assertEquals(msg1.getPriority(), msg2.getPriority());
+//
+// assertEquals(msg1.getType(), msg2.getType());
+//
+// assertEqualsByteArrays(msg1.getBody().array(), msg2.getBody().array());
+//
+// assertEquals(msg1.getDurableRefCount(), msg2.getDurableRefCount());
+//
+// assertEquals(msg1.getDestination(), msg2.getDestination());
+// }
+//
+// protected void assertMapsEquivalent(Map<String, Object> headers1, Map<String, Object> headers2)
+// {
+// assertEquals(headers1.size(), headers2.size());
+//
+// for (Map.Entry<String, Object> entry : headers1.entrySet())
+// {
+// assertEquals(entry.getValue(), headers2.get(entry.getKey()));
+// }
+// }
protected int calculateRecordSize(int size, int alignment)
{
More information about the jboss-cvs-commits
mailing list