summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Greig <rgreig@apache.org>2006-12-21 17:41:00 +0000
committerRobert Greig <rgreig@apache.org>2006-12-21 17:41:00 +0000
commitc8150aa5966cc3283b84ac842c4e502fcaf35877 (patch)
tree6ad7275ba4316743054a6e18e6a253b6f5d9bd1a
parent6d5154b0d5ad1fb32aadda06801c5dc8fdc958eb (diff)
downloadqpid-python-c8150aa5966cc3283b84ac842c4e502fcaf35877.tar.gz
Merge from trunk up to revision 486610
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/new_persistence@489417 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--java/broker/pom.xml3
-rw-r--r--java/broker/src/main/java/log4j.properties24
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/AMQSession.java26
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java11
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java9
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java177
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java2
-rw-r--r--java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java20
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java1126
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java23
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java14
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java70
-rw-r--r--java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java136
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java23
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java2
-rw-r--r--java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java265
-rw-r--r--java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java2
-rw-r--r--java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java146
-rw-r--r--java/common/src/test/java/org/apache/qpid/pool/PoolingFilterTest.java104
-rw-r--r--java/common/src/test/java/org/apache/qpid/session/TestSession.java273
20 files changed, 2184 insertions, 272 deletions
diff --git a/java/broker/pom.xml b/java/broker/pom.xml
index 5a2c699cc1..aea2d5878a 100644
--- a/java/broker/pom.xml
+++ b/java/broker/pom.xml
@@ -34,6 +34,7 @@
<properties>
<topDirectoryLocation>..</topDirectoryLocation>
+ <amqj.logging.level>warn</amqj.logging.level>
</properties>
<dependencies>
@@ -92,7 +93,7 @@
</property>
<property>
<name>amqj.logging.level</name>
- <value>WARN</value>
+ <value>${amqj.logging.level}</value>
</property>
<property>
<name>log4j.configuration</name>
diff --git a/java/broker/src/main/java/log4j.properties b/java/broker/src/main/java/log4j.properties
new file mode 100644
index 0000000000..87f04f4991
--- /dev/null
+++ b/java/broker/src/main/java/log4j.properties
@@ -0,0 +1,24 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+log4j.rootCategory=${amqj.logging.level}, console
+
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.Threshold=info
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%t %d %p [%c{4}] %m%n
diff --git a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
index 03c18903e4..5a16a148cb 100644
--- a/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
+++ b/java/client/src/main/java/org/apache/qpid/client/AMQSession.java
@@ -7,9 +7,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -728,10 +728,12 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
public Object operation() throws JMSException
{
checkNotClosed();
-
- return new BasicMessageProducer(_connection, (AMQDestination) destination, _transacted, _channelId,
- AMQSession.this, _connection.getProtocolHandler(),
- getNextProducerId(), immediate, mandatory, waitUntilSent);
+ long producerId = getNextProducerId();
+ BasicMessageProducer producer = new BasicMessageProducer(_connection, (AMQDestination) destination, _transacted, _channelId,
+ AMQSession.this, _connection.getProtocolHandler(),
+ producerId, immediate, mandatory, waitUntilSent);
+ registerProducer(producerId, producer);
+ return producer;
}
}.execute(_connection);
}
@@ -745,7 +747,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
*/
public QueueReceiver createQueueReceiver(Destination destination) throws JMSException
{
- checkValidDestination(destination);
+ checkValidDestination(destination);
AMQQueue dest = (AMQQueue) destination;
BasicMessageConsumer consumer = (BasicMessageConsumer) createConsumer(destination);
return new QueueReceiverAdaptor(dest, consumer);
@@ -1024,7 +1026,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
public Topic createTopic(String topicName) throws JMSException
{
checkNotClosed();
-
+
if (topicName.indexOf('/') == -1)
{
return new AMQTopic(topicName);
@@ -1142,7 +1144,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
public void unsubscribe(String name) throws JMSException
{
checkNotClosed();
-
+
//send a queue.delete for the subscription
String queue = _connection.getClientID() + ":" + name;
AMQFrame frame = QueueDeleteBody.createAMQFrame(_channelId, 0, queue, false, false, true);
@@ -1344,7 +1346,7 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
AMQFrame channelFlowFrame = ChannelFlowBody.createAMQFrame(_channelId, true);
_connection.getProtocolHandler().writeFrame(channelFlowFrame);
}
-
+
/*
* I could have combined the last 3 methods, but this way it improves readability
*/
@@ -1353,13 +1355,13 @@ public class AMQSession extends Closeable implements Session, QueueSession, Topi
throw new javax.jms.InvalidDestinationException("Invalid Topic");
}
}
-
+
private void checkValidQueue(Queue queue) throws InvalidDestinationException{
if (queue == null){
throw new javax.jms.InvalidDestinationException("Invalid Queue");
}
}
-
+
private void checkValidDestination(Destination destination) throws InvalidDestinationException{
if (destination == null){
throw new javax.jms.InvalidDestinationException("Invalid Queue");
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
index bec0686ce4..6935cde491 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractBytesMessage.java
@@ -59,11 +59,16 @@ public abstract class AbstractBytesMessage extends AbstractJMSMessage
if (_data == null)
{
- _data = ByteBuffer.allocate(DEFAULT_BUFFER_INITIAL_SIZE);
- _data.setAutoExpand(true);
+ allocateInitialBuffer();
}
}
+ private void allocateInitialBuffer()
+ {
+ _data = ByteBuffer.allocate(DEFAULT_BUFFER_INITIAL_SIZE);
+ _data.setAutoExpand(true);
+ }
+
AbstractBytesMessage(long messageNbr, ContentHeaderBody contentHeader, ByteBuffer data)
throws AMQException
{
@@ -74,7 +79,7 @@ public abstract class AbstractBytesMessage extends AbstractJMSMessage
public void clearBodyImpl() throws JMSException
{
- _data.clear();
+ allocateInitialBuffer();
}
public String toBodyString() throws JMSException
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
index 6bd4fd0297..279d861cc2 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
@@ -505,7 +505,14 @@ public abstract class AbstractJMSMessage extends AMQMessage implements javax.jms
// position beyond the start
if (_data != null)
{
- _data.rewind();
+ if (!_readableMessage)
+ {
+ _data.flip();
+ }
+ else
+ {
+ _data.rewind();
+ }
}
return _data;
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
index 5282dce4c9..85d434e4eb 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
@@ -21,16 +21,21 @@
package org.apache.qpid.client.message;
import org.apache.mina.common.ByteBuffer;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.PropertyFieldTable;
import org.apache.qpid.framing.FieldTableFactory;
+import org.apache.qpid.framing.ContentHeaderBody;
+import org.apache.qpid.framing.EncodingUtils;
import org.apache.qpid.AMQException;
+import org.apache.log4j.Logger;
import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
import java.util.Enumeration;
-public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessage
+public class JMSMapMessage extends JMSBytesMessage implements javax.jms.MapMessage
{
+ private static final Logger _logger = Logger.getLogger(JMSMapMessage.class);
+
public static final String MIME_TYPE = "jms/map-message";
@@ -38,48 +43,38 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
JMSMapMessage() throws JMSException
{
- this(null, null);
+ this(null);
}
- JMSMapMessage(ByteBuffer data, String encoding) throws JMSException
+ JMSMapMessage(ByteBuffer data) throws JMSException
{
super(data); // this instantiates a content header
- getJmsContentHeaderProperties().setContentType(MIME_TYPE);
- getJmsContentHeaderProperties().setEncoding(encoding);
_map = new PropertyFieldTable();
}
- JMSMapMessage(long deliveryTag, BasicContentHeaderProperties contentHeader, ByteBuffer data)
+ JMSMapMessage(long messageNbr, ContentHeaderBody contentHeader, ByteBuffer data)
throws AMQException
{
- super(deliveryTag, contentHeader, data);
- contentHeader.setContentType(MIME_TYPE);
+ super(messageNbr, contentHeader, data);
- try
- {
- _map = FieldTableFactory.newFieldTable(getText());
- }
- catch (JMSException e)
+ if (data != null)
{
- throw new AMQException(e.getMessage(), e);
- }
- }
- // AbstractJMSMessage Interface
+ long tableSize = EncodingUtils.readInteger(_data);
+ _map = (PropertyFieldTable) FieldTableFactory.newFieldTable(_data, tableSize);
- public void clearBodyImpl() throws JMSException
- {
- if (_data != null)
+ }
+ else
{
- _data.release();
+ _map = (PropertyFieldTable) FieldTableFactory.newFieldTable();
}
- _data = null;
}
+
public String toBodyString() throws JMSException
{
- return _map.toString();
+ return "MapSize:" + _map.getEncodedSize() + "\nMapData:\n" + _map.toString();
}
public String getMimeType()
@@ -95,7 +90,23 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
if (b == null)
{
- b = Boolean.valueOf(_map.getString(string));
+ if (_map.containsKey(string))
+ {
+ Object str = _map.getObject(string);
+
+ if (str == null || !(str instanceof String))
+ {
+ throw new MessageFormatException("getBoolean can't use " + string + " item.");
+ }
+ else
+ {
+ return Boolean.valueOf((String) str);
+ }
+ }
+ else
+ {
+ b = Boolean.valueOf(null);
+ }
}
return b;
@@ -106,26 +117,55 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
Byte b = _map.getByte(string);
if (b == null)
{
- b = Byte.valueOf(_map.getString(string));
+ if (_map.containsKey(string))
+ {
+ Object str = _map.getObject(string);
+
+ if (str == null || !(str instanceof String))
+ {
+ throw new MessageFormatException("getByte can't use " + string + " item.");
+ }
+ else
+ {
+ return Byte.valueOf((String) str);
+ }
+ }
+ else
+ {
+ b = Byte.valueOf(null);
+ }
}
+
return b;
}
public short getShort(String string) throws JMSException
{
- Short s = _map.getShort(string);
-
- if (s == null)
{
- s = Short.valueOf(getByte(string));
- }
+ Short s = _map.getShort(string);
- return s;
+ if (s == null)
+ {
+ s = Short.valueOf(getByte(string));
+ }
+
+ return s;
+ }
}
public char getChar(String string) throws JMSException
{
- return _map.getCharacter(string);
+
+ Character result = _map.getCharacter(string);
+
+ if (result == null)
+ {
+ throw new MessageFormatException("getChar couldn't find " + string + " item.");
+ }
+ else
+ {
+ return result;
+ }
}
public int getInt(String string) throws JMSException
@@ -142,6 +182,7 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
public long getLong(String string) throws JMSException
{
+
Long l = _map.getLong(string);
if (l == null)
@@ -150,18 +191,38 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
}
return l;
+
}
public float getFloat(String string) throws JMSException
{
+
Float f = _map.getFloat(string);
if (f == null)
{
- f = Float.valueOf(_map.getString(string));
+ if (_map.containsKey(string))
+ {
+ Object str = _map.getObject(string);
+
+ if (str == null || !(str instanceof String))
+ {
+ throw new MessageFormatException("getFloat can't use " + string + " item.");
+ }
+ else
+ {
+ return Float.valueOf((String) str);
+ }
+ }
+ else
+ {
+ f = Float.valueOf(null);
+ }
+
}
return f;
+
}
public double getDouble(String string) throws JMSException
@@ -182,8 +243,25 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
if (s == null)
{
- Object o = _map.getObject(string);
- s = o.toString();
+ if (_map.containsKey(string))
+ {
+ Object o = _map.getObject(string);
+ if (o instanceof byte[])
+ {
+ throw new MessageFormatException("getObject couldn't find " + string + " item.");
+ }
+ else
+ {
+ if (o == null)
+ {
+ return null;
+ }
+ else
+ {
+ s = String.valueOf(o);
+ }
+ }
+ }
}
return s;
@@ -191,7 +269,16 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
public byte[] getBytes(String string) throws JMSException
{
- return _map.getBytes(string);
+
+ byte[] result = _map.getBytes(string);
+
+ if (result == null)
+ {
+ throw new MessageFormatException("getBytes couldn't find " + string + " item.");
+ }
+
+ return result;
+
}
public Object getObject(String string) throws JMSException
@@ -282,19 +369,9 @@ public class JMSMapMessage extends JMSTextMessage implements javax.jms.MapMessag
public ByteBuffer getData()
{
-
- try
- {
- setText(toString());
- return super.getData();
- }
- catch (JMSException e)
- {
- // should never occur according to setText
- //fixme -- what to do if it does occur.
- }
-
- return ByteBuffer.allocate(0);
+ //What if _data is null?
+ _map.writeToBuffer(_data);
+ return super.getData();
}
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java
index 8d17f2bbf0..38b8b67ff9 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessageFactory.java
@@ -36,6 +36,6 @@ public class JMSMapMessageFactory extends AbstractJMSMessageFactory
protected AbstractJMSMessage createMessage(long deliveryTag, ByteBuffer data, ContentHeaderBody contentHeader) throws AMQException
{
- return new JMSMapMessage(deliveryTag, (BasicContentHeaderProperties) contentHeader.properties, data);
+ return new JMSMapMessage(deliveryTag, contentHeader, data);
}
}
diff --git a/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java b/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
index 61f326d52b..7393cea714 100644
--- a/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
+++ b/java/client/src/main/java/org/apache/qpid/client/message/JMSObjectMessage.java
@@ -7,9 +7,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,18 +20,17 @@
*/
package org.apache.qpid.client.message;
-import org.apache.qpid.framing.ContentHeaderBody;
-import org.apache.qpid.framing.BasicContentHeaderProperties;
-import org.apache.qpid.AMQException;
import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.AMQException;
+import org.apache.qpid.framing.BasicContentHeaderProperties;
+import org.apache.qpid.framing.ContentHeaderBody;
-import javax.jms.ObjectMessage;
import javax.jms.JMSException;
import javax.jms.MessageFormatException;
-import javax.jms.MessageNotWriteableException;
+import javax.jms.ObjectMessage;
import java.io.*;
-import java.nio.charset.Charset;
import java.nio.charset.CharacterCodingException;
+import java.nio.charset.Charset;
public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessage
{
@@ -94,13 +93,16 @@ public class JMSObjectMessage extends AbstractJMSMessage implements ObjectMessag
_data = ByteBuffer.allocate(DEFAULT_BUFFER_SIZE);
_data.setAutoExpand(true);
}
+ else
+ {
+ _data.rewind();
+ }
try
{
ObjectOutputStream out = new ObjectOutputStream(_data.asOutputStream());
out.writeObject(serializable);
out.flush();
out.close();
- _data.rewind();
}
catch (IOException e)
{
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
index 6fbc4809eb..1a469c1d12 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
@@ -21,14 +21,11 @@
package org.apache.qpid.test.unit.basic;
import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.client.transport.TransportConnection;
-import org.apache.qpid.client.message.JMSTextMessage;
import org.apache.qpid.client.message.JMSMapMessage;
import org.apache.qpid.testutil.VMBrokerSetup;
+import org.apache.log4j.Logger;
import java.util.ArrayList;
import java.util.Iterator;
@@ -40,20 +37,26 @@ import junit.framework.Assert;
public class MapMessageTest extends TestCase implements MessageListener
{
+
+ private static final Logger _logger = Logger.getLogger(MapMessageTest.class);
+
private AMQConnection _connection;
private Destination _destination;
private AMQSession _session;
private final List<JMSMapMessage> received = new ArrayList<JMSMapMessage>();
- private final List<String> messages = new ArrayList<String>();
+
+ private static final String MESSAGE = "Message ";
private int _count = 100;
public String _connectionString = "vm://:1";
private byte[] _bytes = {99, 98, 97, 96, 95};
+ private static final float _smallfloat = 100.0f;
protected void setUp() throws Exception
{
super.setUp();
try
{
+ //TransportConnection.createVMBroker(1);
init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
}
catch (Exception e)
@@ -64,7 +67,9 @@ public class MapMessageTest extends TestCase implements MessageListener
protected void tearDown() throws Exception
{
+ _logger.info("Tearing Down unit.basic.MapMessageTest");
super.tearDown();
+ //TransportConnection.killAllVMBrokers();
}
private void init(AMQConnection connection) throws Exception
@@ -90,7 +95,6 @@ public class MapMessageTest extends TestCase implements MessageListener
send(count);
waitFor(count);
check();
- System.out.println("Completed without failure");
_connection.close();
}
@@ -100,38 +104,45 @@ public class MapMessageTest extends TestCase implements MessageListener
MessageProducer producer = _session.createProducer(_destination);
for (int i = 0; i < count; i++)
{
- String text = "Message " + i;
- messages.add(text);
MapMessage message = _session.createMapMessage();
- message.setBoolean("odd", i / 2 == 0);
- message.setByte("byte", (byte) Byte.MAX_VALUE);
+ setMapValues(message, i);
- message.setBytes("bytes", _bytes);
- message.setChar("char", (char) 'c');
- message.setDouble("double", (double) Double.MAX_VALUE);
- message.setFloat("float", (float) Float.MAX_VALUE);
-
- message.setInt("messageNumber", i);
- message.setInt("int", (int) Integer.MAX_VALUE);
+ producer.send(message);
+ }
+ }
- message.setLong("long", (long) Long.MAX_VALUE);
- message.setShort("short", (short) Short.MAX_VALUE);
- message.setString("message", text);
+ private void setMapValues(MapMessage message, int i) throws JMSException
+ {
+ message.setBoolean("odd", i / 2 == 0);
+ message.setByte("byte", (byte) Byte.MAX_VALUE);
+ message.setBytes("bytes", _bytes);
+ message.setChar("char", (char) 'c');
+ message.setDouble("double", (double) Double.MAX_VALUE);
+ message.setFloat("float", (float) Float.MAX_VALUE);
+ message.setFloat("smallfloat", 100);
+ message.setInt("messageNumber", i);
+ message.setInt("int", (int) Integer.MAX_VALUE);
+ message.setLong("long", (long) Long.MAX_VALUE);
+ message.setShort("short", (short) Short.MAX_VALUE);
+ message.setString("message", MESSAGE + i);
+ //Test Setting Object Values
+ message.setObject("object-bool", true);
+ message.setObject("object-byte", Byte.MAX_VALUE);
+ message.setObject("object-bytes", _bytes);
+ message.setObject("object-char", 'c');
+ message.setObject("object-double", Double.MAX_VALUE);
+ message.setObject("object-float", Float.MAX_VALUE);
+ message.setObject("object-int", Integer.MAX_VALUE);
+ message.setObject("object-long", Long.MAX_VALUE);
+ message.setObject("object-short", Short.MAX_VALUE);
- message.setObject("object-bool", true);
- message.setObject("object-byte", Byte.MAX_VALUE);
- message.setObject("object-bytes", _bytes);
- message.setObject("object-char", 'c');
- message.setObject("object-double", Double.MAX_VALUE);
- message.setObject("object-float", Float.MAX_VALUE);
- message.setObject("object-int", Integer.MAX_VALUE);
- message.setObject("object-long", Long.MAX_VALUE);
- message.setObject("object-short", Short.MAX_VALUE);
+ //Set a null String value
+ message.setString("nullString", null);
+ // Highlight protocol problem
+ message.setString("emptyString", "");
- producer.send(message);
- }
}
void waitFor(int count) throws InterruptedException
@@ -152,80 +163,1014 @@ public class MapMessageTest extends TestCase implements MessageListener
for (JMSMapMessage m : received)
{
actual.add(m.getString("message"));
- assertEqual(m.getInt("messageNumber"), count);
+ testMapValues(m, count);
- assertEqual(count / 2 == 0, m.getBoolean("odd"));
- assertEqual((byte) Byte.MAX_VALUE, m.getByte("byte"));
+ testMessageWriteStatus(m);
- assertBytesEqual(_bytes, m.getBytes("bytes"));
- assertEqual((char) 'c', m.getChar("char"));
- assertEqual((double) Double.MAX_VALUE, m.getDouble("double"));
- assertEqual((float) Float.MAX_VALUE, m.getFloat("float"));
+ testPropertyWriteStatus(m);
- assertEqual(count, m.getInt("messageNumber"));
- assertEqual((int) Integer.MAX_VALUE, m.getInt("int"));
- assertEqual((long) Long.MAX_VALUE, m.getLong("long"));
- assertEqual((short) Short.MAX_VALUE, m.getShort("short"));
+ testCorrectExceptions(m);
- assertEqual(true, m.getObject("object-bool"));
- assertEqual(Byte.MAX_VALUE, m.getObject("object-byte"));
- assertBytesEqual(_bytes, (byte[]) m.getObject("object-bytes"));
- assertEqual('c', m.getObject("object-char"));
- assertEqual(Double.MAX_VALUE, m.getObject("object-double"));
- assertEqual(Float.MAX_VALUE, m.getObject("object-float"));
- assertEqual(Integer.MAX_VALUE, m.getObject("object-int"));
- assertEqual(Long.MAX_VALUE, m.getObject("object-long"));
- assertEqual(Short.MAX_VALUE, m.getObject("object-short"));
+ count++;
+ }
+ }
+ private void testCorrectExceptions(JMSMapMessage m) throws JMSException
+ {
+ testBoolean(m);
- try
- {
- m.setInt("testint", 3);
- fail("Message should not be writeable");
- }
- catch (MessageNotWriteableException mnwe)
- {
- //normal execution
- }
+ testByte(m);
- m.clearBody();
+ testBytes(m);
- try
- {
- m.setInt("testint", 3);
- }
- catch (MessageNotWriteableException mnwe)
- {
- Assert.fail("Message should be writeable");
- }
+ testChar(m);
- //Check property write status
- try
- {
- m.setStringProperty("test", "test");
- Assert.fail("Message should not be writeable");
- }
- catch (MessageNotWriteableException mnwe)
- {
- //normal execution
- }
+ testDouble(m);
- m.clearProperties();
+ testFloat(m);
- try
- {
- m.setStringProperty("test", "test");
- }
- catch (MessageNotWriteableException mnwe)
- {
- Assert.fail("Message should be writeable");
- }
+ testInt(m);
- count++;
+ testLong(m);
+
+ testShort(m);
+
+ testString(m);
+ }
+
+ private void testString(JMSMapMessage m) throws JMSException
+ {
+
+ Assert.assertFalse(m.getBoolean("message"));
+
+ try
+ {
+ m.getByte("message");
+ fail("Exception Expected.");
+ }
+ catch (NumberFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getShort("message");
+ fail("Exception Expected.");
+ }
+ catch (NumberFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getChar("message");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getInt("message");
+ fail("Exception Expected.");
+ }
+ catch (NumberFormatException nfe)
+ {
+ //normal execution
+ }
+ try
+ {
+ m.getLong("message");
+ fail("Exception Expected.");
+ }
+ catch (NumberFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("message");
+ fail("Exception Expected.");
+ }
+ catch (NumberFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("message");
+ fail("Exception Expected.");
+ }
+ catch (NumberFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getBytes("message");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals(MESSAGE + m.getInt("messageNumber"), m.getString("message"));
+ }
+
+ private void testShort(JMSMapMessage m) throws JMSException
+ {
+
+ //Try bad reads
+ try
+ {
+ m.getBoolean("short");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getByte("short");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals(Short.MAX_VALUE, m.getShort("short"));
+
+ //Try bad reads
+ try
+ {
+ m.getChar("short");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals(Short.MAX_VALUE, m.getInt("short"));
+
+ Assert.assertEquals(Short.MAX_VALUE, m.getLong("short"));
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("short");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("short");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getBytes("short");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + Short.MAX_VALUE, m.getString("short"));
+ }
+
+ private void testLong(JMSMapMessage m) throws JMSException
+ {
+
+ //Try bad reads
+ try
+ {
+ m.getBoolean("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getByte("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
}
- assertEqual(messages.iterator(), actual.iterator());
+ try
+ {
+ m.getShort("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getChar("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getInt("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals(Long.MAX_VALUE, m.getLong("long"));
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getBytes("long");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + Long.MAX_VALUE, m.getString("long"));
+ }
+
+ private void testDouble(JMSMapMessage m) throws JMSException
+ {
+
+ //Try bad reads
+ try
+ {
+ m.getBoolean("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getByte("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getShort("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getChar("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getInt("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ try
+ {
+ m.getLong("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+
+ Assert.assertEquals(Double.MAX_VALUE, m.getDouble("double"));
+
+ //Try bad reads
+ try
+ {
+ m.getBytes("double");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + Double.MAX_VALUE, m.getString("double"));
+ }
+
+
+ private void testFloat(JMSMapMessage m) throws JMSException
+ {
+
+ //Try bad reads
+ try
+ {
+ m.getBoolean("float");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getByte("float");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getShort("float");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getChar("float");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getInt("float");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ try
+ {
+ m.getLong("float");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+
+ Assert.assertEquals(Float.MAX_VALUE, m.getFloat("float"));
+
+ Assert.assertEquals(_smallfloat, (float) m.getDouble("smallfloat"));
+
+ //Try bad reads
+ try
+ {
+ m.getBytes("float");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + Float.MAX_VALUE, m.getString("float"));
+ }
+
+
+ private void testInt(JMSMapMessage m) throws JMSException
+ {
+
+ //Try bad reads
+ try
+ {
+ m.getBoolean("int");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getByte("int");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getShort("int");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getChar("int");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals(Integer.MAX_VALUE, m.getInt("int"));
+
+ Assert.assertEquals(Integer.MAX_VALUE, (int) m.getLong("int"));
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("int");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("int");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getBytes("int");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + Integer.MAX_VALUE, m.getString("int"));
+ }
+
+
+ private void testChar(JMSMapMessage m) throws JMSException
+ {
+
+ //Try bad reads
+ try
+ {
+ m.getBoolean("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getByte("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getShort("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals('c', m.getChar("char"));
+
+ try
+ {
+ m.getInt("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ try
+ {
+ m.getLong("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getBytes("char");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + 'c', m.getString("char"));
+ }
+
+ private void testBytes(JMSMapMessage m) throws JMSException
+ {
+ //Try bad reads
+ try
+ {
+ m.getBoolean("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getByte("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getShort("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getChar("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getInt("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ try
+ {
+ m.getLong("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+
+ assertBytesEqual(_bytes, m.getBytes("bytes"));
+
+ try
+ {
+ m.getString("bytes");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+
+ }
+
+ private void testByte(JMSMapMessage m) throws JMSException
+ {
+ //Try bad reads
+ try
+ {
+ m.getBoolean("byte");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals(Byte.MAX_VALUE, m.getByte("byte"));
+
+ Assert.assertEquals((short) Byte.MAX_VALUE, m.getShort("byte"));
+
+ //Try bad reads
+ try
+ {
+ m.getChar("byte");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Reading a byte as an int is ok
+ Assert.assertEquals((short) Byte.MAX_VALUE, m.getInt("byte"));
+
+ Assert.assertEquals((short) Byte.MAX_VALUE, m.getLong("byte"));
+
+ //Try bad reads
+ try
+ {
+ m.getFloat("byte");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("byte");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getBytes("byte");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + Byte.MAX_VALUE, m.getString("byte"));
+
+ }
+
+ private void testBoolean(JMSMapMessage m) throws JMSException
+ {
+
+ Assert.assertEquals((m.getInt("messageNumber") / 2) == 0, m.getBoolean("odd"));
+
+ //Try bad reads
+ try
+ {
+ m.getByte("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ //Try bad reads
+ try
+ {
+ m.getShort("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getChar("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getInt("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getLong("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getFloat("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getDouble("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+ //Try bad reads
+ try
+ {
+ m.getBytes("odd");
+ fail("Exception Expected.");
+ }
+ catch (MessageFormatException nfe)
+ {
+ //normal execution
+ }
+
+ Assert.assertEquals("" + ((m.getInt("messageNumber") / 2) == 0), m.getString("odd"));
+ }
+
+
+ private void testPropertyWriteStatus(JMSMapMessage m) throws JMSException
+ {
+ //Check property write status
+ try
+ {
+ m.setStringProperty("test", "test");
+ Assert.fail("Message should not be writeable");
+ }
+ catch (MessageNotWriteableException mnwe)
+ {
+ //normal execution
+ }
+
+ m.clearProperties();
+
+ try
+ {
+ m.setStringProperty("test", "test");
+ }
+ catch (MessageNotWriteableException mnwe)
+ {
+ Assert.fail("Message should be writeable");
+ }
+ }
+
+ private void testMessageWriteStatus(JMSMapMessage m) throws JMSException
+ {
+ try
+ {
+ m.setInt("testint", 3);
+ fail("Message should not be writeable");
+ }
+ catch (MessageNotWriteableException mnwe)
+ {
+ //normal execution
+ }
+
+ m.clearBody();
+
+ try
+ {
+ m.setInt("testint", 3);
+ }
+ catch (MessageNotWriteableException mnwe)
+ {
+ Assert.fail("Message should be writeable");
+ }
+ }
+
+ private void testMapValues(JMSMapMessage m, int count) throws JMSException
+ {
+ //Test get<Primiative>
+
+ //Boolean
+ assertEqual(count / 2 == 0, m.getBoolean("odd"));
+ assertEqual("" + (count / 2 == 0), m.getString("odd"));
+
+ //Byte
+ assertEqual(Byte.MAX_VALUE, m.getByte("byte"));
+ assertEqual("" + Byte.MAX_VALUE, m.getString("byte"));
+
+ //Bytes
+ assertBytesEqual(_bytes, m.getBytes("bytes"));
+
+ //Char
+ assertEqual('c', m.getChar("char"));
+
+ //Double
+ assertEqual(Double.MAX_VALUE, m.getDouble("double"));
+ assertEqual("" + Double.MAX_VALUE, m.getString("double"));
+
+ //Float
+ assertEqual(Float.MAX_VALUE, m.getFloat("float"));
+ assertEqual(_smallfloat, (float) m.getDouble("smallfloat"));
+ assertEqual("" + Float.MAX_VALUE, m.getString("float"));
+
+ //Integer
+ assertEqual(Integer.MAX_VALUE, m.getInt("int"));
+ assertEqual("" + Integer.MAX_VALUE, m.getString("int"));
+ assertEqual(count, m.getInt("messageNumber"));
+
+ //long
+ assertEqual(Long.MAX_VALUE, m.getLong("long"));
+ assertEqual("" + Long.MAX_VALUE, m.getString("long"));
+
+ //Short
+ assertEqual(Short.MAX_VALUE, m.getShort("short"));
+ assertEqual("" + Short.MAX_VALUE, m.getString("short"));
+ assertEqual((int) Short.MAX_VALUE, m.getInt("short"));
+
+ //String
+ assertEqual(MESSAGE + count, m.getString("message"));
+
+ //Test getObjects
+ assertEqual(true, m.getObject("object-bool"));
+ assertEqual(Byte.MAX_VALUE, m.getObject("object-byte"));
+ assertBytesEqual(_bytes, (byte[]) m.getObject("object-bytes"));
+ assertEqual('c', m.getObject("object-char"));
+ assertEqual(Double.MAX_VALUE, m.getObject("object-double"));
+ assertEqual(Float.MAX_VALUE, m.getObject("object-float"));
+ assertEqual(Integer.MAX_VALUE, m.getObject("object-int"));
+ assertEqual(Long.MAX_VALUE, m.getObject("object-long"));
+ assertEqual(Short.MAX_VALUE, m.getObject("object-short"));
+
+ //Check Special values
+ assertTrue(m.getString("nullString") == null);
+ assertEqual("", m.getString("emptyString"));
}
private void assertBytesEqual(byte[] expected, byte[] actual)
@@ -279,6 +1224,7 @@ public class MapMessageTest extends TestCase implements MessageListener
{
synchronized(received)
{
+ _logger.info("****************** Recevied Messgage:" + (JMSMapMessage) message);
received.add((JMSMapMessage) message);
received.notify();
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
index 9b1637058d..3f726ae5ab 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/basic/ObjectMessageTest.java
@@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -19,28 +19,21 @@
*/
package org.apache.qpid.test.unit.basic;
+import junit.framework.Assert;
+import junit.framework.TestCase;
import org.apache.qpid.client.AMQConnection;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.vmbroker.AMQVMBrokerCreationException;
-import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.client.message.JMSObjectMessage;
-import org.apache.qpid.testutil.VMBrokerSetup;
+import org.apache.qpid.client.transport.TransportConnection;
-import javax.jms.JMSException;
-import javax.jms.Message;
-import javax.jms.MessageListener;
-import javax.jms.MessageProducer;
-import javax.jms.MessageNotWriteableException;
+import javax.jms.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import junit.framework.TestCase;
-import junit.framework.Assert;
-
public class ObjectMessageTest extends TestCase implements MessageListener
{
private AMQConnection _connection;
@@ -54,6 +47,7 @@ public class ObjectMessageTest extends TestCase implements MessageListener
protected void setUp() throws Exception
{
super.setUp();
+ TransportConnection.createVMBroker(1);
try
{
init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
@@ -67,6 +61,7 @@ public class ObjectMessageTest extends TestCase implements MessageListener
protected void tearDown() throws Exception
{
super.tearDown();
+ TransportConnection.killAllVMBrokers();
}
private void init(AMQConnection connection) throws Exception
@@ -263,6 +258,6 @@ public class ObjectMessageTest extends TestCase implements MessageListener
public static junit.framework.Test suite()
{
- return new VMBrokerSetup(new junit.framework.TestSuite(ObjectMessageTest.class));
+ return new junit.framework.TestSuite(ObjectMessageTest.class);
}
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
index f55f2428ce..e5458fd89e 100644
--- a/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
@@ -25,6 +25,7 @@ import junit.framework.Assert;
import org.apache.qpid.framing.PropertyFieldTable;
import org.apache.qpid.client.message.JMSMapMessage;
import org.apache.qpid.client.message.TestMessageHelper;
+import org.apache.log4j.Logger;
import javax.jms.JMSException;
import javax.jms.MessageFormatException;
@@ -203,7 +204,7 @@ public class MapMessageTest extends TestCase
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getByte("random");
- Assert.fail("NumberFormatException should be received.");
+ Assert.fail("MessageFormatException expected");
}
catch (NumberFormatException e)
{
@@ -221,7 +222,12 @@ public class MapMessageTest extends TestCase
try
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
- Assert.assertEquals(null, mm.getBytes("random"));
+ mm.getBytes("random");
+ Assert.fail("MessageFormatException expected");
+ }
+ catch (MessageFormatException mfe)
+ {
+ //normal path
}
catch (JMSException e)
{
@@ -235,9 +241,9 @@ public class MapMessageTest extends TestCase
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getChar("random");
- Assert.fail("NullPointerException should be received.");
+ Assert.fail("MessageFormatException expected");
}
- catch (NullPointerException e)
+ catch (MessageFormatException e)
{
//normal execution
}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
new file mode 100644
index 0000000000..c9240e9be7
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/close/TopicPublisherCloseTest.java
@@ -0,0 +1,70 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */package org.apache.qpid.test.unit.close;
+
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.client.*;
+import junit.framework.TestCase;
+
+import javax.jms.Session;
+import javax.jms.TopicPublisher;
+import javax.jms.TopicSession;
+import javax.jms.Topic;
+
+/**
+ * @author Apache Software Foundation
+ */
+public class TopicPublisherCloseTest extends TestCase
+{
+
+ public String _connectionString = "vm://:1";
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ TransportConnection.createVMBroker(1);
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ TransportConnection.killAllVMBrokers();
+ }
+
+ public void testAllMethodsThrowAfterConnectionClose() throws Exception
+ {
+ AMQConnection connection = new AMQConnection(_connectionString, "guest", "guest", "Client", "/test_path");
+
+ Topic destination1 = new AMQTopic("t1");
+ TopicSession session1 = connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
+ TopicPublisher pub = session1.createPublisher(destination1);
+ connection.close();
+ try
+ {
+ pub.getDeliveryMode();
+ fail("Expected exception not thrown");
+ }
+ catch (javax.jms.IllegalStateException e)
+ {
+ // PASS
+ }
+ }
+}
diff --git a/java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java b/java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
new file mode 100644
index 0000000000..50944730c3
--- /dev/null
+++ b/java/client/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
@@ -0,0 +1,136 @@
+/**
+ * User: Robert Greig
+ * Date: 12-Dec-2006
+ ******************************************************************************
+ * (c) Copyright JP Morgan Chase Ltd 2006. All rights reserved. No part of
+ * this program may be photocopied reproduced or translated to another
+ * program language without prior written consent of JP Morgan Chase Ltd
+ ******************************************************************************/
+package org.apache.qpid.test.unit.message;
+
+import junit.framework.TestCase;
+import org.apache.log4j.Logger;
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQHeadersExchange;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.exchange.ExchangeDefaults;
+import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.PropertyFieldTable;
+import org.apache.qpid.url.AMQBindingURL;
+import org.apache.qpid.url.BindingURL;
+
+import javax.jms.*;
+
+/**
+ * @author Apache Software Foundation
+ */
+public class StreamMessageTest extends TestCase
+{
+
+ private static final Logger _logger = Logger.getLogger(StreamMessageTest.class);
+
+ public String _connectionString = "vm://:1";
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ TransportConnection.createVMBroker(1);
+ }
+
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ TransportConnection.killAllVMBrokers();
+ }
+
+ public void testStreamMessageEOF() throws Exception
+ {
+ Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
+ AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+
+
+ AMQHeadersExchange queue = new AMQHeadersExchange(new AMQBindingURL(ExchangeDefaults.HEADERS_EXCHANGE_CLASS+"://"+ExchangeDefaults.HEADERS_EXCHANGE_NAME+"/test/queue1?"+ BindingURL.OPTION_ROUTING_KEY+"='F0000=1'"));
+ FieldTable ft = new PropertyFieldTable();
+ ft.setString("F1000","1");
+ MessageConsumer consumer = consumerSession.createConsumer(queue, AMQSession.DEFAULT_PREFETCH_LOW_MARK, AMQSession.DEFAULT_PREFETCH_HIGH_MARK, false, false, (String)null, ft);
+
+
+ //force synch to ensure the consumer has resulted in a bound queue
+ ((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME, ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
+
+ Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
+
+ AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+
+ // Need to start the "producer" connection in order to receive bounced messages
+ _logger.info("Starting producer connection");
+ con2.start();
+
+
+ MessageProducer mandatoryProducer = producerSession.createProducer(queue);
+
+ // Third test - should be routed
+ _logger.info("Sending routable message");
+ StreamMessage msg = producerSession.createStreamMessage();
+
+ msg.setStringProperty("F1000","1");
+
+ msg.writeByte((byte)42);
+
+ mandatoryProducer.send(msg);
+
+
+
+ _logger.info("Starting consumer connection");
+ con.start();
+
+ StreamMessage msg2 = (StreamMessage) consumer.receive();
+
+ byte b1 = msg2.readByte();
+ try
+ {
+ byte b2 = msg2.readByte();
+ }
+ catch (Exception e)
+ {
+ assertTrue("Expected MessageEOFException: " + e, e instanceof MessageEOFException);
+ }
+ }
+
+ public void testModifyReceivedMessageExpandsBuffer() throws Exception
+ {
+ Connection con = new AMQConnection("vm://:1", "guest", "guest", "consumer1", "/test");
+ AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ AMQQueue queue = new AMQQueue("testQ");
+ MessageConsumer consumer = consumerSession.createConsumer(queue);
+ consumer.setMessageListener(new MessageListener()
+ {
+
+ public void onMessage(Message message)
+ {
+ StreamMessage sm = (StreamMessage) message;
+ try
+ {
+ sm.clearBody();
+ sm.writeString("dfgjshfslfjshflsjfdlsjfhdsljkfhdsljkfhsd");
+ }
+ catch (JMSException e)
+ {
+ _logger.error("Error when writing large string to received msg: " + e, e);
+ fail("Error when writing large string to received msg" + e);
+ }
+ }
+ });
+ Connection con2 = new AMQConnection("vm://:1", "guest", "guest", "producer1", "/test");
+ AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+ MessageProducer mandatoryProducer = producerSession.createProducer(queue);
+ con.start();
+ StreamMessage sm = producerSession.createStreamMessage();
+ sm.writeInt(42);
+ mandatoryProducer.send(sm);
+ Thread.sleep(2000);
+ }
+}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java b/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
index 2f791ea541..2efdb88fd9 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
@@ -100,7 +100,7 @@ public class EncodingUtils
public static int encodedContentLength(Content table)
{
- // TODO: New Content class required for AMQP 0-9.
+ // TODO: New Content class required for AMQP 0-9.
return 0;
}
@@ -114,7 +114,7 @@ public class EncodingUtils
{
encodedString[i] = (byte) cha[i];
}
- writeBytes(buffer,encodedString);
+ writeBytes(buffer, encodedString);
}
else
{
@@ -199,6 +199,12 @@ public class EncodingUtils
}
}
+
+ public static long unsignedIntegerLength()
+ {
+ return 4;
+ }
+
public static void writeUnsignedInteger(ByteBuffer buffer, long l)
{
// TODO: Is this comparison safe? Do I need to cast RHS to long?
@@ -233,7 +239,7 @@ public class EncodingUtils
public static void writeContentBytes(ByteBuffer buffer, Content content)
{
- // TODO: New Content class required for AMQP 0-9.
+ // TODO: New Content class required for AMQP 0-9.
}
public static void writeBooleans(ByteBuffer buffer, boolean[] values)
@@ -302,8 +308,8 @@ public class EncodingUtils
public static Content readContent(ByteBuffer buffer) throws AMQFrameDecodingException
{
- // TODO: New Content class required for AMQP 0-9.
- return null;
+ // TODO: New Content class required for AMQP 0-9.
+ return null;
}
public static String readShortString(ByteBuffer buffer)
@@ -337,7 +343,7 @@ public class EncodingUtils
long length = buffer.getUnsignedInt();
if (length == 0)
{
- return null;
+ return "";
}
else
{
@@ -602,4 +608,9 @@ public class EncodingUtils
buffer.put((byte) 0);
}
}
+
+ public static long encodedCharacterLength()
+ {
+ return encodedShortStringLength("c");
+ }
}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java b/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java
index 1ec57da35b..b1fcd8a20b 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/FieldTableFactory.java
@@ -34,7 +34,7 @@ public class FieldTableFactory
return new PropertyFieldTable(byteBuffer, length);
}
- public static PropertyFieldTable newFieldTable(String text)
+ public static FieldTable newFieldTable(String text)
{
return new PropertyFieldTable(text);
}
diff --git a/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java b/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
index 48ca34abfe..e6f5196434 100644
--- a/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
+++ b/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
@@ -52,6 +52,7 @@ public class PropertyFieldTable implements FieldTable, Map
public static final char LONG_PROPERTY_PREFIX = 'l';
public static final char FLOAT_PROPERTY_PREFIX = 'f';
public static final char DOUBLE_PROPERTY_PREFIX = 'd';
+ public static final char NULL_STRING_PROPERTY_PREFIX = 'n';
public static final char STRING_PROPERTY_PREFIX = AMQP_STRING_PROPERTY_PREFIX;
public static final char CHAR_PROPERTY_PREFIX = AMQP_ASCII_STRING_PROPERTY_PREFIX;
@@ -79,7 +80,7 @@ public class PropertyFieldTable implements FieldTable, Map
private LinkedHashMap<String, Object> _properties;
private LinkedHashMap<String, String> _propertyNamesTypeMap;
- private long _encodedSize = 0;
+ private long _encodedSize = 0;//EncodingUtils.unsignedIntegerLength();
public PropertyFieldTable()
{
@@ -138,7 +139,7 @@ public class PropertyFieldTable implements FieldTable, Map
public Boolean getBoolean(String string)
{
Object o = get(string, BOOLEAN_PROPERTY_PREFIX);
- if (o != null)
+ if (o != null && o instanceof Boolean)
{
return (Boolean) o;
}
@@ -209,7 +210,7 @@ public class PropertyFieldTable implements FieldTable, Map
}
else
{
- return null;
+ return null; //Float.valueOf(null); ???
}
}
@@ -235,7 +236,45 @@ public class PropertyFieldTable implements FieldTable, Map
}
else
{
- return null;
+
+
+ String type = _propertyNamesTypeMap.get(string);
+
+ if (type == null || type.equals("" + NULL_STRING_PROPERTY_PREFIX))
+ {
+ return null;
+ }
+ else
+ {
+ char itype = type.charAt(0);
+
+ Object value = _properties.get(string);
+
+ switch (itype)
+ {
+ case STRING_PROPERTY_PREFIX:
+ case BYTES_PROPERTY_PREFIX:
+ return null;
+ default:
+ case BYTE_PROPERTY_PREFIX:
+ case BOOLEAN_PROPERTY_PREFIX:
+ case SHORT_PROPERTY_PREFIX:
+ case INT_PROPERTY_PREFIX:
+ case LONG_PROPERTY_PREFIX:
+ case FLOAT_PROPERTY_PREFIX:
+ case DOUBLE_PROPERTY_PREFIX:
+ return String.valueOf(value);
+ case CHAR_PROPERTY_PREFIX:
+ if (value == null)
+ {
+ throw new NullPointerException("null char cannot be converted to String");
+ }
+ else
+ {
+ return String.valueOf(value);
+ }
+ }
+ }
}
}
@@ -309,7 +348,14 @@ public class PropertyFieldTable implements FieldTable, Map
public Object setString(String string, String string1)
{
- return put(STRING_PROPERTY_PREFIX + string, string1);
+ if (string1 == null)
+ {
+ return put(NULL_STRING_PROPERTY_PREFIX + string, null);
+ }
+ else
+ {
+ return put(STRING_PROPERTY_PREFIX + string, string1);
+ }
}
public Object setChar(String string, char c)
@@ -902,6 +948,8 @@ public class PropertyFieldTable implements FieldTable, Map
}
EncodingUtils.writeUnsignedInteger(buffer, _encodedSize);
+ //EncodingUtils.writeLong(buffer, _encodedSize);
+
putDataInBuffer(buffer);
}
@@ -959,7 +1007,17 @@ public class PropertyFieldTable implements FieldTable, Map
String propertyName = key.substring(1);
char propertyPrefix = _propertyNamesTypeMap.get(propertyName).charAt(0);
- if (value != null)
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("Put:" + propertyName +
+ " encoding Now:" + _encodedSize +
+ " name size= " + EncodingUtils.encodedShortStringLength(propertyName) +
+ " value size= " + getEncodingSize(key, value));
+ }
+
+ // This prevents the item from being sent.
+ // JMS needs these propertyNames for lookups.
+ //if (value != null)
{
//Add the size of the propertyName
_encodedSize += EncodingUtils.encodedShortStringLength(propertyName);
@@ -972,6 +1030,11 @@ public class PropertyFieldTable implements FieldTable, Map
_encodedSize += getEncodingSize(key, value);
}
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("Put: new encodingSize " + _encodedSize);
+ }
+
_properties.put((String) propertyName, value);
return previous;
@@ -1046,6 +1109,7 @@ public class PropertyFieldTable implements FieldTable, Map
private void putDataInBuffer(ByteBuffer buffer)
{
+
final Iterator it = _properties.entrySet().iterator();
//If there are values then write out the encoded Size... could check _encodedSize != 0
@@ -1054,84 +1118,115 @@ public class PropertyFieldTable implements FieldTable, Map
while (it.hasNext())
{
+
Map.Entry me = (Map.Entry) it.next();
String propertyName = (String) me.getKey();
//The type value
char propertyPrefix = _propertyNamesTypeMap.get(propertyName).charAt(0);
- //The actual param name skipping type
- EncodingUtils.writeShortStringBytes(buffer, propertyName);
Object value = me.getValue();
-
- switch (propertyPrefix)
+ try
{
- case BOOLEAN_PROPERTY_PREFIX:
- buffer.put((byte) BOOLEAN_PROPERTY_PREFIX);
- EncodingUtils.writeBoolean(buffer, (Boolean) value);
- break;
- case BYTE_PROPERTY_PREFIX:
- buffer.put((byte) BYTE_PROPERTY_PREFIX);
- EncodingUtils.writeByte(buffer, (Byte) value);
- break;
- case SHORT_PROPERTY_PREFIX:
- buffer.put((byte) SHORT_PROPERTY_PREFIX);
- EncodingUtils.writeShort(buffer, (Short) value);
- break;
- case INT_PROPERTY_PREFIX:
- buffer.put((byte) INT_PROPERTY_PREFIX);
- EncodingUtils.writeInteger(buffer, (Integer) value);
- break;
- case AMQP_UNSIGNEDINT_PROPERTY_PREFIX: // Currently we don't create these
- buffer.put((byte) AMQP_UNSIGNEDINT_PROPERTY_PREFIX);
- EncodingUtils.writeUnsignedInteger(buffer, (Long) value);
- break;
- case LONG_PROPERTY_PREFIX:
- buffer.put((byte) LONG_PROPERTY_PREFIX);
- EncodingUtils.writeLong(buffer, (Long) value);
- break;
- case FLOAT_PROPERTY_PREFIX:
- buffer.put((byte) FLOAT_PROPERTY_PREFIX);
- EncodingUtils.writeFloat(buffer, (Float) value);
- break;
- case DOUBLE_PROPERTY_PREFIX:
- buffer.put((byte) DOUBLE_PROPERTY_PREFIX);
- EncodingUtils.writeDouble(buffer, (Double) value);
- break;
+ if (_logger.isDebugEnabled())
+ {
+ _logger.debug("Writing Property:" + propertyName +
+ " Type:" + propertyPrefix +
+ " Value:" + value);
+ _logger.debug("Buffer Position:" + buffer.position() +
+ " Remaining:" + buffer.remaining());
+ }
- case AMQP_WIDE_STRING_PROPERTY_PREFIX:
- //case AMQP_STRING_PROPERTY_PREFIX:
- case STRING_PROPERTY_PREFIX:
- // TODO: look at using proper charset encoder
- buffer.put((byte) STRING_PROPERTY_PREFIX);
- EncodingUtils.writeLongStringBytes(buffer, (String) value);
- break;
+ //The actual param name skipping type
+ EncodingUtils.writeShortStringBytes(buffer, propertyName);
- //case AMQP_ASCII_STRING_PROPERTY_PREFIX:
- case CHAR_PROPERTY_PREFIX:
- // TODO: look at using proper charset encoder
- buffer.put((byte) CHAR_PROPERTY_PREFIX);
- EncodingUtils.writeShortStringBytes(buffer, "" + (Character) value);
- break;
- case BYTES_PROPERTY_PREFIX:
- buffer.put((byte) BYTES_PROPERTY_PREFIX);
- EncodingUtils.writeBytes(buffer, (byte[]) value);
- break;
+ switch (propertyPrefix)
+ {
- case XML_PROPERTY_PREFIX:
- // Encode as XML
- buffer.put((byte) XML_PROPERTY_PREFIX);
- EncodingUtils.writeLongStringBytes(buffer, valueAsXML(propertyPrefix + propertyName, value));
- break;
- default:
+ case BOOLEAN_PROPERTY_PREFIX:
+ buffer.put((byte) BOOLEAN_PROPERTY_PREFIX);
+ EncodingUtils.writeBoolean(buffer, (Boolean) value);
+ break;
+ case BYTE_PROPERTY_PREFIX:
+ buffer.put((byte) BYTE_PROPERTY_PREFIX);
+ EncodingUtils.writeByte(buffer, (Byte) value);
+ break;
+ case SHORT_PROPERTY_PREFIX:
+ buffer.put((byte) SHORT_PROPERTY_PREFIX);
+ EncodingUtils.writeShort(buffer, (Short) value);
+ break;
+ case INT_PROPERTY_PREFIX:
+ buffer.put((byte) INT_PROPERTY_PREFIX);
+ EncodingUtils.writeInteger(buffer, (Integer) value);
+ break;
+ case AMQP_UNSIGNEDINT_PROPERTY_PREFIX: // Currently we don't create these
+ buffer.put((byte) AMQP_UNSIGNEDINT_PROPERTY_PREFIX);
+ EncodingUtils.writeUnsignedInteger(buffer, (Long) value);
+ break;
+ case LONG_PROPERTY_PREFIX:
+ buffer.put((byte) LONG_PROPERTY_PREFIX);
+ EncodingUtils.writeLong(buffer, (Long) value);
+ break;
+ case FLOAT_PROPERTY_PREFIX:
+ buffer.put((byte) FLOAT_PROPERTY_PREFIX);
+ EncodingUtils.writeFloat(buffer, (Float) value);
+ break;
+ case DOUBLE_PROPERTY_PREFIX:
+ buffer.put((byte) DOUBLE_PROPERTY_PREFIX);
+ EncodingUtils.writeDouble(buffer, (Double) value);
+ break;
+ case NULL_STRING_PROPERTY_PREFIX:
+ buffer.put((byte) NULL_STRING_PROPERTY_PREFIX);
+ break;
+ case AMQP_WIDE_STRING_PROPERTY_PREFIX:
+ //case AMQP_STRING_PROPERTY_PREFIX:
+ case STRING_PROPERTY_PREFIX:
+ // TODO: look at using proper charset encoder
+ buffer.put((byte) STRING_PROPERTY_PREFIX);
+ EncodingUtils.writeLongStringBytes(buffer, (String) value);
+ break;
+
+ //case AMQP_ASCII_STRING_PROPERTY_PREFIX:
+ case CHAR_PROPERTY_PREFIX:
+ // TODO: look at using proper charset encoder
+ buffer.put((byte) CHAR_PROPERTY_PREFIX);
+ EncodingUtils.writeShortStringBytes(buffer, "" + (Character) value);
+ break;
+
+ case BYTES_PROPERTY_PREFIX:
+ buffer.put((byte) BYTES_PROPERTY_PREFIX);
+ EncodingUtils.writeBytes(buffer, (byte[]) value);
+ break;
+
+ case XML_PROPERTY_PREFIX:
+ // Encode as XML
+ buffer.put((byte) XML_PROPERTY_PREFIX);
+ EncodingUtils.writeLongStringBytes(buffer, valueAsXML(propertyPrefix + propertyName, value));
+ break;
+ default:
+ {
+ // Should never get here
+ throw new IllegalArgumentException("Key '" + propertyName + "': Unsupported type in field table, type: " + ((value == null) ? "null-object" : value.getClass()));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ if (_logger.isDebugEnabled())
{
- // Should never get here
- throw new IllegalArgumentException("Key '" + propertyName + "': Unsupported type in field table, type: " + ((value == null) ? "null-object" : value.getClass()));
+ _logger.debug("Exception thrown:" + e);
+ _logger.debug("Writing Property:" + propertyName +
+ " Type:" + propertyPrefix +
+ " Value:" + value);
+ _logger.debug("Buffer Position:" + buffer.position() +
+ " Remaining:" + buffer.remaining());
}
+ throw new RuntimeException(e);
}
}
+
}
@@ -1180,6 +1275,9 @@ public class PropertyFieldTable implements FieldTable, Map
case STRING_PROPERTY_PREFIX:
value = EncodingUtils.readLongString(buffer);
break;
+ case NULL_STRING_PROPERTY_PREFIX:
+ value = null;
+ break;
//case AMQP_ASCII_STRING_PROPERTY_PREFIX:
case CHAR_PROPERTY_PREFIX:
value = EncodingUtils.readShortString(buffer).charAt(0);
@@ -1207,6 +1305,12 @@ public class PropertyFieldTable implements FieldTable, Map
if (type != XML_PROPERTY_PREFIX)
{
setObject(key, value);
+ if (value == null)
+ {
+ _logger.debug("setFromBuffer: value is null for key:" + key);
+ _propertyNamesTypeMap.put(key, "" + type);
+ _properties.put(key, null);
+ }
}
}
@@ -1224,47 +1328,50 @@ public class PropertyFieldTable implements FieldTable, Map
*/
private static int getEncodingSize(String name, Object value)
{
- int encodingSize;
+ int encodingSize = 1; // Initialy 1 to cover the char prefix
char propertyPrefix = name.charAt(0);
switch (propertyPrefix)
{
case BOOLEAN_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedBooleanLength();
+ encodingSize += EncodingUtils.encodedBooleanLength();
break;
case BYTE_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedByteLength();
+ encodingSize += EncodingUtils.encodedByteLength();
break;
case SHORT_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedShortLength();
+ encodingSize += EncodingUtils.encodedShortLength();
break;
case INT_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedIntegerLength();
+ encodingSize += EncodingUtils.encodedIntegerLength();
break;
case LONG_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedLongLength();
+ encodingSize += EncodingUtils.encodedLongLength();
break;
case FLOAT_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedFloatLength();
+ encodingSize += EncodingUtils.encodedFloatLength();
break;
case DOUBLE_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedDoubleLength();
+ encodingSize += EncodingUtils.encodedDoubleLength();
break;
case AMQP_WIDE_STRING_PROPERTY_PREFIX:
//case AMQP_STRING_PROPERTY_PREFIX:
case STRING_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedLongStringLength((String) value);
+ encodingSize += EncodingUtils.encodedLongStringLength((String) value);
+ break;
+ case NULL_STRING_PROPERTY_PREFIX:
+ // There is no need for additiona size beyond the prefix
break;
//case AMQP_ASCII_STRING_PROPERTY_PREFIX:
case CHAR_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedShortStringLength("" + (Character) value);
+ encodingSize += EncodingUtils.encodedShortStringLength("" + (Character) value);
break;
case BYTES_PROPERTY_PREFIX:
- encodingSize = 1 + ((byte[]) value).length;
+ encodingSize += 1 + ((byte[]) value).length;
break;
case XML_PROPERTY_PREFIX:
- encodingSize = 1 + EncodingUtils.encodedLongStringLength(valueAsXML(name, value));
+ encodingSize += EncodingUtils.encodedLongStringLength(valueAsXML(name, value));
break;
default:
//encodingSize = 1 + EncodingUtils.encodedLongStringLength(String.valueOf(value));
diff --git a/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java b/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java
index ba614a26c2..2ace2b8348 100644
--- a/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java
+++ b/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java
@@ -58,7 +58,7 @@ public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionH
Job job = getJobForSession(session);
job.acquire(); //prevents this job being removed from _jobs
job.add(event);
- if (job.activate())
+ if (job.activate() && _poolReference.getPool() != null && !_poolReference.getPool().isShutdown())
{
_poolReference.getPool().execute(job);
}
diff --git a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
index 5166168b04..e41487ba4b 100644
--- a/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
+++ b/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
@@ -65,7 +65,14 @@ public class PropertyFieldTableTest extends TestCase
{
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setBoolean("value", true);
+ //Test Getting right value back
Assert.assertEquals((Boolean) true, table1.getBoolean("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getBoolean("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("true", table1.getString("value"));
}
public void testByteLookup()
@@ -73,6 +80,12 @@ public class PropertyFieldTableTest extends TestCase
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setByte("value", (byte) 1);
Assert.assertEquals((Byte) (byte) 1, table1.getByte("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getByte("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("1", table1.getString("value"));
}
public void testShortLookup()
@@ -80,6 +93,12 @@ public class PropertyFieldTableTest extends TestCase
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setShort("value", Short.MAX_VALUE);
Assert.assertEquals((Short) Short.MAX_VALUE, table1.getShort("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getShort("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("" + Short.MAX_VALUE, table1.getString("value"));
}
@@ -88,6 +107,12 @@ public class PropertyFieldTableTest extends TestCase
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setChar("value", 'b');
Assert.assertEquals((Character) 'b', table1.getCharacter("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getCharacter("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("b", table1.getString("value"));
}
public void testDoubleLookup()
@@ -95,6 +120,13 @@ public class PropertyFieldTableTest extends TestCase
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setDouble("value", Double.MAX_VALUE);
Assert.assertEquals(Double.MAX_VALUE, table1.getDouble("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getDouble("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("" + Double.MAX_VALUE, table1.getString("value"));
+
}
public void testFloatLookup()
@@ -102,6 +134,13 @@ public class PropertyFieldTableTest extends TestCase
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setFloat("value", Float.MAX_VALUE);
Assert.assertEquals(Float.MAX_VALUE, table1.getFloat("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getFloat("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("" + Float.MAX_VALUE, table1.getString("value"));
+
}
public void testIntLookup()
@@ -109,6 +148,13 @@ public class PropertyFieldTableTest extends TestCase
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setInteger("value", Integer.MAX_VALUE);
Assert.assertEquals((Integer) Integer.MAX_VALUE, table1.getInteger("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getInteger("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("" + Integer.MAX_VALUE, table1.getString("value"));
+
}
public void testLongLookup()
@@ -116,6 +162,13 @@ public class PropertyFieldTableTest extends TestCase
PropertyFieldTable table1 = new PropertyFieldTable();
table1.setLong("value", Long.MAX_VALUE);
Assert.assertEquals((Long) Long.MAX_VALUE, table1.getLong("value"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getLong("Rubbish") == null);
+
+ //Try reading value as a string
+ Assert.assertEquals("" + Long.MAX_VALUE, table1.getString("value"));
+
}
public void testBytesLookup()
@@ -124,6 +177,9 @@ public class PropertyFieldTableTest extends TestCase
byte[] bytes = {99, 98, 97, 96, 95};
table1.setBytes("bytes", bytes);
assertBytesEqual(bytes, table1.getBytes("bytes"));
+
+ //Looking up an invalid value returns null
+ Assert.assertTrue(table1.getBytes("Rubbish") == null);
}
// Failed Lookups
@@ -328,6 +384,96 @@ public class PropertyFieldTableTest extends TestCase
{
FieldTable result = FieldTableFactory.newFieldTable();
int size = 0;
+
+ result.setBoolean("boolean", true);
+ size += 1 + EncodingUtils.encodedShortStringLength("boolean") + EncodingUtils.encodedBooleanLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+
+ result.setByte("byte", (byte) Byte.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("byte") + EncodingUtils.encodedByteLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+
+ byte[] _bytes = {99, 98, 97, 96, 95};
+
+ result.setBytes("bytes", _bytes);
+ size += 1 + EncodingUtils.encodedShortStringLength("bytes") + 1 + EncodingUtils.encodedByteLength() * _bytes.length;
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setChar("char", (char) 'c');
+ size += 1 + EncodingUtils.encodedShortStringLength("char") + EncodingUtils.encodedCharacterLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setDouble("double", (double) Double.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("double") + EncodingUtils.encodedDoubleLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setFloat("float", (float) Float.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("float") + EncodingUtils.encodedFloatLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setInteger("int", (int) Integer.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("int") + EncodingUtils.encodedIntegerLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+
+ result.setLong("long", (long) Long.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("long") + EncodingUtils.encodedLongLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setShort("short", (short) Short.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("short") + EncodingUtils.encodedShortLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setString("result", "Hello");
+ size += 1 + EncodingUtils.encodedShortStringLength("result") + EncodingUtils.encodedLongStringLength("Hello");
+ Assert.assertEquals(size, result.getEncodedSize());
+
+
+ result.setObject("object-bool", true);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-bool") + EncodingUtils.encodedBooleanLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setObject("object-byte", Byte.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-byte") + EncodingUtils.encodedByteLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setObject("object-bytes", _bytes);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-bytes") + 1 + EncodingUtils.encodedByteLength() * _bytes.length;
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setObject("object-char", 'c');
+ size += 1 + EncodingUtils.encodedShortStringLength("object-char") + EncodingUtils.encodedCharacterLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setObject("object-double", Double.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-double") + EncodingUtils.encodedDoubleLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setObject("object-float", Float.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-float") + EncodingUtils.encodedFloatLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setObject("object-int", Integer.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-int") + EncodingUtils.encodedIntegerLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+
+ result.setObject("object-long", Long.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-long") + EncodingUtils.encodedLongLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ result.setObject("object-short", Short.MAX_VALUE);
+ size += 1 + EncodingUtils.encodedShortStringLength("object-short") + EncodingUtils.encodedShortLength();
+ Assert.assertEquals(size, result.getEncodedSize());
+
+ }
+
+ public void testEncodingSize1()
+ {
+ FieldTable result = FieldTableFactory.newFieldTable();
+ int size = 0;
result.put("one", 1L);
size = EncodingUtils.encodedShortStringLength("one");
size += 1 + EncodingUtils.encodedLongLength();
diff --git a/java/common/src/test/java/org/apache/qpid/pool/PoolingFilterTest.java b/java/common/src/test/java/org/apache/qpid/pool/PoolingFilterTest.java
new file mode 100644
index 0000000000..972a935257
--- /dev/null
+++ b/java/common/src/test/java/org/apache/qpid/pool/PoolingFilterTest.java
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *
+ */
+package org.apache.qpid.pool;
+
+import junit.framework.TestCase;
+import junit.framework.Assert;
+import org.apache.qpid.session.TestSession;
+import org.apache.mina.common.IoFilter;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.common.IdleStatus;
+
+import java.util.concurrent.RejectedExecutionException;
+
+public class PoolingFilterTest extends TestCase
+{
+ private PoolingFilter _pool;
+ ReferenceCountingExecutorService _executorService;
+
+ public void setUp()
+ {
+ //Create Pool
+ _executorService = ReferenceCountingExecutorService.getInstance();
+ _executorService.acquireExecutorService();
+ _pool = new PoolingFilter(_executorService, PoolingFilter.WRITE_EVENTS,
+ "AsynchronousWriteFilter");
+
+ }
+
+ public void testRejectedExecution() throws Exception
+ {
+ _pool.filterWrite(new NoOpFilter(), new TestSession(), new IoFilter.WriteRequest("Message"));
+
+ //Shutdown the pool
+ _executorService.getPool().shutdownNow();
+
+ try
+ {
+ //prior to fix for QPID-172 this would throw RejectedExecutionException
+ _pool.filterWrite(null, new TestSession(), null);
+ }
+ catch (RejectedExecutionException rje)
+ {
+ Assert.fail("RejectedExecutionException should not occur after pool has shutdown:" + rje);
+ }
+ }
+
+ private static class NoOpFilter implements IoFilter.NextFilter
+ {
+
+ public void sessionOpened(IoSession session)
+ {
+ }
+
+ public void sessionClosed(IoSession session)
+ {
+ }
+
+ public void sessionIdle(IoSession session, IdleStatus status)
+ {
+ }
+
+ public void exceptionCaught(IoSession session, Throwable cause)
+ {
+ }
+
+ public void messageReceived(IoSession session, Object message)
+ {
+ }
+
+ public void messageSent(IoSession session, Object message)
+ {
+ }
+
+ public void filterWrite(IoSession session, IoFilter.WriteRequest writeRequest)
+ {
+ }
+
+ public void filterClose(IoSession session)
+ {
+ }
+
+ public void sessionCreated(IoSession session)
+ {
+ }
+ }
+}
diff --git a/java/common/src/test/java/org/apache/qpid/session/TestSession.java b/java/common/src/test/java/org/apache/qpid/session/TestSession.java
new file mode 100644
index 0000000000..f10d55e9d0
--- /dev/null
+++ b/java/common/src/test/java/org/apache/qpid/session/TestSession.java
@@ -0,0 +1,273 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.qpid.session;
+
+import org.apache.mina.common.*;
+
+import java.net.SocketAddress;
+import java.util.Set;
+
+public class TestSession implements IoSession
+{
+ public TestSession()
+ {
+ }
+
+ public IoService getService()
+ {
+ return null; //TODO
+ }
+
+ public IoServiceConfig getServiceConfig()
+ {
+ return null; //TODO
+ }
+
+ public IoHandler getHandler()
+ {
+ return null; //TODO
+ }
+
+ public IoSessionConfig getConfig()
+ {
+ return null; //TODO
+ }
+
+ public IoFilterChain getFilterChain()
+ {
+ return null; //TODO
+ }
+
+ public WriteFuture write(Object message)
+ {
+ return null; //TODO
+ }
+
+ public CloseFuture close()
+ {
+ return null; //TODO
+ }
+
+ public Object getAttachment()
+ {
+ return null; //TODO
+ }
+
+ public Object setAttachment(Object attachment)
+ {
+ return null; //TODO
+ }
+
+ public Object getAttribute(String key)
+ {
+ return null; //TODO
+ }
+
+ public Object setAttribute(String key, Object value)
+ {
+ return null; //TODO
+ }
+
+ public Object setAttribute(String key)
+ {
+ return null; //TODO
+ }
+
+ public Object removeAttribute(String key)
+ {
+ return null; //TODO
+ }
+
+ public boolean containsAttribute(String key)
+ {
+ return false; //TODO
+ }
+
+ public Set getAttributeKeys()
+ {
+ return null; //TODO
+ }
+
+ public TransportType getTransportType()
+ {
+ return null; //TODO
+ }
+
+ public boolean isConnected()
+ {
+ return false; //TODO
+ }
+
+ public boolean isClosing()
+ {
+ return false; //TODO
+ }
+
+ public CloseFuture getCloseFuture()
+ {
+ return null; //TODO
+ }
+
+ public SocketAddress getRemoteAddress()
+ {
+ return null; //TODO
+ }
+
+ public SocketAddress getLocalAddress()
+ {
+ return null; //TODO
+ }
+
+ public SocketAddress getServiceAddress()
+ {
+ return null; //TODO
+ }
+
+ public int getIdleTime(IdleStatus status)
+ {
+ return 0; //TODO
+ }
+
+ public long getIdleTimeInMillis(IdleStatus status)
+ {
+ return 0; //TODO
+ }
+
+ public void setIdleTime(IdleStatus status, int idleTime)
+ {
+ //TODO
+ }
+
+ public int getWriteTimeout()
+ {
+ return 0; //TODO
+ }
+
+ public long getWriteTimeoutInMillis()
+ {
+ return 0; //TODO
+ }
+
+ public void setWriteTimeout(int writeTimeout)
+ {
+ //TODO
+ }
+
+ public TrafficMask getTrafficMask()
+ {
+ return null; //TODO
+ }
+
+ public void setTrafficMask(TrafficMask trafficMask)
+ {
+ //TODO
+ }
+
+ public void suspendRead()
+ {
+ //TODO
+ }
+
+ public void suspendWrite()
+ {
+ //TODO
+ }
+
+ public void resumeRead()
+ {
+ //TODO
+ }
+
+ public void resumeWrite()
+ {
+ //TODO
+ }
+
+ public long getReadBytes()
+ {
+ return 0; //TODO
+ }
+
+ public long getWrittenBytes()
+ {
+ return 0; //TODO
+ }
+
+ public long getReadMessages()
+ {
+ return 0;
+ }
+
+ public long getWrittenMessages()
+ {
+ return 0;
+ }
+
+ public long getWrittenWriteRequests()
+ {
+ return 0; //TODO
+ }
+
+ public int getScheduledWriteRequests()
+ {
+ return 0; //TODO
+ }
+
+ public int getScheduledWriteBytes()
+ {
+ return 0; //TODO
+ }
+
+ public long getCreationTime()
+ {
+ return 0; //TODO
+ }
+
+ public long getLastIoTime()
+ {
+ return 0; //TODO
+ }
+
+ public long getLastReadTime()
+ {
+ return 0; //TODO
+ }
+
+ public long getLastWriteTime()
+ {
+ return 0; //TODO
+ }
+
+ public boolean isIdle(IdleStatus status)
+ {
+ return false; //TODO
+ }
+
+ public int getIdleCount(IdleStatus status)
+ {
+ return 0; //TODO
+ }
+
+ public long getLastIdleTime(IdleStatus status)
+ {
+ return 0; //TODO
+ }
+}