[jboss-cvs] JBoss Messaging SVN: r4380 - trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 4 10:39:05 EDT 2008
Author: jmesnil
Date: 2008-06-04 10:39:04 -0400 (Wed, 04 Jun 2008)
New Revision: 4380
Modified:
trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java
Log:
added testMessagingExceptionMessage()
renamed testConsumerFlowTokenMessage() to testConsumerFlowCreditMessage()
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java 2008-06-04 14:36:48 UTC (rev 4379)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/remoting/impl/wireformat/PacketTypeTest.java 2008-06-04 14:39:04 UTC (rev 4380)
@@ -14,6 +14,7 @@
import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.CONS_FLOWTOKEN;
import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.CREATECONNECTION;
import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.CREATECONNECTION_RESP;
+import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.EXCEPTION;
import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.NULL;
import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.PING;
import static org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket.PONG;
@@ -74,6 +75,7 @@
import org.apache.mina.common.IoBuffer;
import org.apache.mina.filter.codec.ProtocolDecoderOutput;
+import org.jboss.messaging.core.exception.MessagingException;
import org.jboss.messaging.core.logging.Logger;
import org.jboss.messaging.core.remoting.Packet;
import org.jboss.messaging.core.remoting.impl.mina.BufferWrapper;
@@ -84,6 +86,7 @@
import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionRequest;
import org.jboss.messaging.core.remoting.impl.wireformat.CreateConnectionResponse;
import org.jboss.messaging.core.remoting.impl.wireformat.EmptyPacket;
+import org.jboss.messaging.core.remoting.impl.wireformat.MessagingExceptionMessage;
import org.jboss.messaging.core.remoting.impl.wireformat.Ping;
import org.jboss.messaging.core.remoting.impl.wireformat.Pong;
import org.jboss.messaging.core.remoting.impl.wireformat.ProducerFlowCreditMessage;
@@ -197,6 +200,11 @@
{
Xid xid = (Xid) arg;
XidCodecSupport.encodeXid(xid, buffer);
+ } else if (arg instanceof MessagingException)
+ {
+ MessagingException exception = (MessagingException) arg;
+ buffer.putInt(exception.getCode());
+ buffer.putNullableString(exception.getMessage());
} else
{
fail("no encoding defined for " + arg);
@@ -240,13 +248,15 @@
int bodyLength = packetLength - (SIZE_BYTE + 3 * SIZE_LONG);
checkBody(buffer, bodyLength, bodyObjects);
buffer.rewind();
-
+
SimpleProtocolDecoderOutput out = new SimpleProtocolDecoderOutput();
MessagingCodec codec = new MessagingCodec();
codec.doDecode(null, IoBuffer.wrap(buffer.array()), out);
Object message = out.getMessage();
assertTrue(message instanceof Packet);
+ log.info("encoded and decoded " + packet);
+
return (Packet) message;
}
@@ -311,6 +321,18 @@
assertEquals(pong.isSessionFailed(), decodedPong.isSessionFailed());
}
+ public void testMessagingExceptionMessage() throws Exception
+ {
+ MessagingExceptionMessage message = new MessagingExceptionMessage(new MessagingException(MessagingException.ILLEGAL_STATE));
+
+ Packet decodedPacket = encodeAndCheckBytesAndDecode(message, message.getException());
+
+ assertTrue(decodedPacket instanceof MessagingExceptionMessage);
+ MessagingExceptionMessage decodedMessage = (MessagingExceptionMessage) decodedPacket;
+ assertEquals(EXCEPTION, decodedMessage.getType());
+ assertEquals(message.getException().getCode(), decodedMessage.getException().getCode());
+ }
+
public void testCreateConnectionRequest() throws Exception
{
int version = randomInt();
@@ -516,7 +538,7 @@
assertEquals(CONN_STOP, decodedPacket.getType());
}
- public void testConsumerFlowTokenMessage() throws Exception
+ public void testConsumerFlowCreditMessage() throws Exception
{
ConsumerFlowCreditMessage message = new ConsumerFlowCreditMessage(
randomInt());
More information about the jboss-cvs-commits
mailing list