You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2006/12/15 09:33:11 UTC
svn commit: r487481 [1/3] - in /incubator/qpid/trunk/qpid/java:
client/src/main/java/org/apache/qpid/client/message/
client/src/test/java/org/apache/qpid/test/unit/basic/
client/src/test/java/org/apache/qpid/test/unit/client/message/ common/
common/src...
Author: ritchiem
Date: Fri Dec 15 00:33:10 2006
New Revision: 487481
URL: http://svn.apache.org/viewvc?view=rev&rev=487481
Log:
QPID-181 QPID-180
AbstractJMSMessage.java - updated to use getJMSHeaders
JMSMapMessage.java - JMSPropertyFieldTable.java - Moved functionality of setting and retrieving a JMS property. Now shared by the Headers and MapMessageTest.java
MapMessageTest.java - Updated the exceptions that are caught as all methods should throw a JMSException i.e. MessageFormatException
TextMessageTest.java - Added tests for the Message Properties
common/pom.xml - Added JMS dependency for the JMSPropertyFieldTable.java and associated tests
EncodingUtils.java - changed comments and changed getencodedCharLength return to an int
PropertyFieldTable.java - Cleaned up and now uses enum for prefixs. Created comprehensive test of both PropertyFieldTable classes.
AMQPInvalidClassException.java - created to throw a runtime exception when trying to add a non-primative value. Forcing clients to handle this would break the Map usage of the FieldTable.
Added:
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java (with props)
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java (with props)
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/JMSPropertyFieldTableTest.java (with props)
Modified:
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
incubator/qpid/trunk/qpid/java/common/pom.xml
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/PropertyFieldTable.java
incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java
incubator/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/framing/PropertyFieldTableTest.java
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/AbstractJMSMessage.java Fri Dec 15 00:33:10 2006
@@ -32,11 +32,13 @@
import org.apache.qpid.client.JmsNotImplementedException;
import org.apache.qpid.framing.BasicContentHeaderProperties;
import org.apache.qpid.framing.FieldTable;
+import org.apache.qpid.framing.JMSPropertyFieldTable;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageNotReadableException;
import javax.jms.MessageNotWriteableException;
+import javax.jms.MessageFormatException;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Map;
@@ -234,7 +236,7 @@
public void clearProperties() throws JMSException
{
- getJmsContentHeaderProperties().getHeaders().clear();
+ getJmsContentHeaderProperties().getJMSHeaders().clear();
_readableProperties = false;
}
@@ -249,135 +251,136 @@
public boolean propertyExists(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().propertyExists(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().propertyExists(propertyName);
}
public boolean getBooleanProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getBoolean(propertyName);
+
+ return getJmsContentHeaderProperties().getJMSHeaders().getBoolean(propertyName);
}
public byte getByteProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getByte(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getByte(propertyName);
}
public short getShortProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getShort(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getShort(propertyName);
}
public int getIntProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getInteger(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getInteger(propertyName);
}
public long getLongProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getLong(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getLong(propertyName);
}
public float getFloatProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getFloat(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getFloat(propertyName);
}
public double getDoubleProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getDouble(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getDouble(propertyName);
}
public String getStringProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getString(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getString(propertyName);
}
public Object getObjectProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- return getJmsContentHeaderProperties().getHeaders().getObject(propertyName);
+ return getJmsContentHeaderProperties().getJMSHeaders().getObject(propertyName);
}
public Enumeration getPropertyNames() throws JMSException
{
- return getJmsContentHeaderProperties().getHeaders().getPropertyNames();
+ return getJmsContentHeaderProperties().getJMSHeaders().getPropertyNames();
}
public void setBooleanProperty(String propertyName, boolean b) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setBoolean(propertyName, b);
+ getJmsContentHeaderProperties().getJMSHeaders().setBoolean(propertyName, b);
}
public void setByteProperty(String propertyName, byte b) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setByte(propertyName, new Byte(b));
+ getJmsContentHeaderProperties().getJMSHeaders().setByte(propertyName, new Byte(b));
}
public void setShortProperty(String propertyName, short i) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setShort(propertyName, new Short(i));
+ getJmsContentHeaderProperties().getJMSHeaders().setShort(propertyName, new Short(i));
}
public void setIntProperty(String propertyName, int i) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setInteger(propertyName, new Integer(i));
+ getJmsContentHeaderProperties().getJMSHeaders().setInteger(propertyName, new Integer(i));
}
public void setLongProperty(String propertyName, long l) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setLong(propertyName, new Long(l));
+ getJmsContentHeaderProperties().getJMSHeaders().setLong(propertyName, new Long(l));
}
public void setFloatProperty(String propertyName, float f) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setFloat(propertyName, new Float(f));
+ getJmsContentHeaderProperties().getJMSHeaders().setFloat(propertyName, new Float(f));
}
public void setDoubleProperty(String propertyName, double v) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setDouble(propertyName, new Double(v));
+ getJmsContentHeaderProperties().getJMSHeaders().setDouble(propertyName, new Double(v));
}
public void setStringProperty(String propertyName, String value) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setString(propertyName, value);
+ getJmsContentHeaderProperties().getJMSHeaders().setString(propertyName, value);
}
public void setObjectProperty(String propertyName, Object object) throws JMSException
{
checkWritableProperties();
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().setObject(propertyName, object);
+ getJmsContentHeaderProperties().getJMSHeaders().setObject(propertyName, object);
}
protected void removeProperty(String propertyName) throws JMSException
{
checkPropertyName(propertyName);
- getJmsContentHeaderProperties().getHeaders().remove(propertyName);
+ getJmsContentHeaderProperties().getJMSHeaders().remove(propertyName);
}
public void acknowledge() throws JMSException
@@ -426,13 +429,13 @@
buf.append("\nJMS reply to: ").append(String.valueOf(getJMSReplyTo()));
buf.append("\nAMQ message number: ").append(_deliveryTag);
buf.append("\nProperties:");
- if (getJmsContentHeaderProperties().getHeaders().isEmpty())
+ if (getJmsContentHeaderProperties().getJMSHeaders().isEmpty())
{
buf.append("<NONE>");
}
else
{
- buf.append('\n').append(getJmsContentHeaderProperties().getHeaders());
+ buf.append('\n').append(getJmsContentHeaderProperties().getJMSHeaders());
}
return buf.toString();
}
@@ -462,9 +465,6 @@
{
throw new IllegalArgumentException("Property name must not be the empty string");
}
-
- // Call to ensure that the it has been set.
- getJmsContentHeaderProperties().getHeaders();
}
public BasicContentHeaderProperties getJmsContentHeaderProperties()
Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/message/JMSMapMessage.java Fri Dec 15 00:33:10 2006
@@ -25,6 +25,8 @@
import org.apache.qpid.framing.FieldTableFactory;
import org.apache.qpid.framing.ContentHeaderBody;
import org.apache.qpid.framing.EncodingUtils;
+import org.apache.qpid.framing.JMSPropertyFieldTable;
+import org.apache.qpid.framing.AMQFrameDecodingException;
import org.apache.qpid.AMQException;
import org.apache.log4j.Logger;
@@ -39,7 +41,7 @@
public static final String MIME_TYPE = "jms/map-message";
- private PropertyFieldTable _map;
+ private JMSPropertyFieldTable _properties;
JMSMapMessage() throws JMSException
{
@@ -49,16 +51,9 @@
JMSMapMessage(ByteBuffer data) throws JMSException
{
super(data); // this instantiates a content header
- _map = new PropertyFieldTable();
+ _properties = new JMSPropertyFieldTable();
}
-
- @Override
- public void clearBodyImpl() throws JMSException {
- super.clearBodyImpl();
- _map = new PropertyFieldTable();
- }
-
JMSMapMessage(long messageNbr, ContentHeaderBody contentHeader, ByteBuffer data)
throws AMQException
{
@@ -68,19 +63,33 @@
{
long tableSize = EncodingUtils.readInteger(_data);
- _map = (PropertyFieldTable) FieldTableFactory.newFieldTable(_data, tableSize);
-
+ try
+ {
+ _properties = new JMSPropertyFieldTable(_data, tableSize);
+ }
+ catch (JMSException e)
+ {
+ Exception error = e.getLinkedException();
+ if (error instanceof AMQFrameDecodingException)
+ {
+ throw(AMQFrameDecodingException) error;
+ }
+ else
+ {
+ throw new AMQException(e.getMessage(), e);
+ }
+ }
}
else
{
- _map = (PropertyFieldTable) FieldTableFactory.newFieldTable();
+ _properties = new JMSPropertyFieldTable();
}
}
public String toBodyString() throws JMSException
{
- return "MapSize:" + _map.getEncodedSize() + "\nMapData:\n" + _map.toString();
+ return _properties.toString();
}
public String getMimeType()
@@ -88,81 +97,40 @@
return MIME_TYPE;
}
- // MapMessage Interface
- public boolean getBoolean(String string) throws JMSException
+ public ByteBuffer getData()
{
- Boolean b = _map.getBoolean(string);
-
- if (b == null)
- {
- if (_map.containsKey(string))
- {
- Object str = _map.getObject(string);
+ //What if _data is null?
+ _properties.writeToBuffer(_data);
+ return super.getData();
+ }
- 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);
- }
- }
+ @Override
+ public void clearBodyImpl() throws JMSException
+ {
+ super.clearBodyImpl();
+ _properties.clear();
+ }
- return b;
+ public boolean getBoolean(String string) throws JMSException
+ {
+ return _properties.getBoolean(string);
}
public byte getByte(String string) throws JMSException
{
- Byte b = _map.getByte(string);
- if (b == null)
- {
- 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;
+ return _properties.getByte(string);
}
public short getShort(String string) throws JMSException
{
- {
- Short s = _map.getShort(string);
-
- if (s == null)
- {
- s = Short.valueOf(getByte(string));
- }
-
- return s;
- }
+ return _properties.getShort(string);
}
public char getChar(String string) throws JMSException
{
- Character result = _map.getCharacter(string);
+ Character result = _properties.getCharacter(string);
if (result == null)
{
@@ -176,179 +144,97 @@
public int getInt(String string) throws JMSException
{
- Integer i = _map.getInteger(string);
-
- if (i == null)
- {
- i = Integer.valueOf(getShort(string));
- }
-
- return i;
+ return _properties.getInteger(string);
}
public long getLong(String string) throws JMSException
{
-
- Long l = _map.getLong(string);
-
- if (l == null)
- {
- l = Long.valueOf(getInt(string));
- }
-
- return l;
-
+ return _properties.getLong(string);
}
public float getFloat(String string) throws JMSException
{
-
- Float f = _map.getFloat(string);
-
- if (f == null)
- {
- 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;
-
+ return _properties.getFloat(string);
}
public double getDouble(String string) throws JMSException
{
- Double d = _map.getDouble(string);
-
- if (d == null)
- {
- d = Double.valueOf(getFloat(string));
- }
-
- return d;
+ return _properties.getDouble(string);
}
public String getString(String string) throws JMSException
{
- String s = _map.getString(string);
-
- if (s == null)
- {
- 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;
+ return _properties.getString(string);
}
public byte[] getBytes(String string) throws JMSException
{
-
- byte[] result = _map.getBytes(string);
-
- if (result == null)
- {
- throw new MessageFormatException("getBytes couldn't find " + string + " item.");
- }
-
- return result;
-
+ return _properties.getBytes(string);
}
public Object getObject(String string) throws JMSException
{
- return _map.getObject(string);
+ return _properties.getObject(string);
}
public Enumeration getMapNames() throws JMSException
{
- return _map.getPropertyNames();
+ return _properties.getMapNames();
}
+
public void setBoolean(String string, boolean b) throws JMSException
{
checkWritable();
- _map.setBoolean(string, b);
+ _properties.setBoolean(string, b);
}
public void setByte(String string, byte b) throws JMSException
{
checkWritable();
- _map.setByte(string, b);
+ _properties.setByte(string, b);
}
public void setShort(String string, short i) throws JMSException
{
checkWritable();
- _map.setShort(string, i);
+ _properties.setShort(string, i);
}
public void setChar(String string, char c) throws JMSException
{
checkWritable();
- _map.setChar(string, c);
+ _properties.setChar(string, c);
}
public void setInt(String string, int i) throws JMSException
{
checkWritable();
- _map.setInteger(string, i);
+ _properties.setInteger(string, i);
}
public void setLong(String string, long l) throws JMSException
{
checkWritable();
- _map.setLong(string, l);
+ _properties.setLong(string, l);
}
public void setFloat(String string, float v) throws JMSException
{
checkWritable();
- _map.setFloat(string, v);
+ _properties.setFloat(string, v);
}
public void setDouble(String string, double v) throws JMSException
{
checkWritable();
- _map.setDouble(string, v);
+ _properties.setDouble(string, v);
}
public void setString(String string, String string1) throws JMSException
{
checkWritable();
- _map.setString(string, string1);
+ _properties.setString(string, string1);
}
public void setBytes(String string, byte[] bytes) throws JMSException
@@ -359,25 +245,18 @@
public void setBytes(String string, byte[] bytes, int i, int i1) throws JMSException
{
checkWritable();
- _map.setBytes(string, bytes, i, i1);
+ _properties.setBytes(string, bytes, i, i1);
}
public void setObject(String string, Object object) throws JMSException
{
checkWritable();
- _map.setObject(string, object);
+ _properties.setObject(string, object);
}
public boolean itemExists(String string) throws JMSException
{
- return _map.itemExists(string);
- }
-
- public ByteBuffer getData()
- {
- //What if _data is null?
- _map.writeToBuffer(_data);
- return super.getData();
+ return _properties.itemExists(string);
}
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java Fri Dec 15 00:33:10 2006
@@ -166,12 +166,12 @@
testMapValues(m, count);
- testMessageWriteStatus(m);
-
testPropertyWriteStatus(m);
testCorrectExceptions(m);
+ testMessageWriteStatus(m);
+
count++;
}
}
@@ -207,9 +207,9 @@
try
{
m.getByte("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -217,9 +217,9 @@
try
{
m.getShort("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -228,7 +228,7 @@
try
{
m.getChar("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -238,18 +238,18 @@
try
{
m.getInt("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
try
{
m.getLong("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -258,9 +258,9 @@
try
{
m.getFloat("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -268,9 +268,9 @@
try
{
m.getDouble("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (NumberFormatException nfe)
+ catch (MessageFormatException nfe)
{
//normal execution
}
@@ -278,7 +278,7 @@
try
{
m.getBytes("message");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -295,7 +295,7 @@
try
{
m.getBoolean("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -305,7 +305,7 @@
try
{
m.getByte("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -318,7 +318,7 @@
try
{
m.getChar("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -333,7 +333,7 @@
try
{
m.getFloat("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -343,7 +343,7 @@
try
{
m.getDouble("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -353,7 +353,7 @@
try
{
m.getBytes("short");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -370,7 +370,7 @@
try
{
m.getBoolean("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -380,7 +380,7 @@
try
{
m.getByte("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -390,7 +390,7 @@
try
{
m.getShort("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -401,7 +401,7 @@
try
{
m.getChar("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -411,7 +411,7 @@
try
{
m.getInt("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -424,7 +424,7 @@
try
{
m.getFloat("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -434,7 +434,7 @@
try
{
m.getDouble("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -444,7 +444,7 @@
try
{
m.getBytes("long");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -461,7 +461,7 @@
try
{
m.getBoolean("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -471,7 +471,7 @@
try
{
m.getByte("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -481,7 +481,7 @@
try
{
m.getShort("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -492,7 +492,7 @@
try
{
m.getChar("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -502,7 +502,7 @@
try
{
m.getInt("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -511,7 +511,7 @@
try
{
m.getLong("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -522,7 +522,7 @@
try
{
m.getFloat("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -536,7 +536,7 @@
try
{
m.getBytes("double");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -554,7 +554,7 @@
try
{
m.getBoolean("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -564,7 +564,7 @@
try
{
m.getByte("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -574,7 +574,7 @@
try
{
m.getShort("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -585,7 +585,7 @@
try
{
m.getChar("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -595,7 +595,7 @@
try
{
m.getInt("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -604,7 +604,7 @@
try
{
m.getLong("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -620,7 +620,7 @@
try
{
m.getBytes("float");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -638,7 +638,7 @@
try
{
m.getBoolean("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -648,7 +648,7 @@
try
{
m.getByte("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -658,7 +658,7 @@
try
{
m.getShort("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -669,7 +669,7 @@
try
{
m.getChar("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -684,7 +684,7 @@
try
{
m.getFloat("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -694,7 +694,7 @@
try
{
m.getDouble("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -704,7 +704,7 @@
try
{
m.getBytes("int");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -722,7 +722,7 @@
try
{
m.getBoolean("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -732,7 +732,7 @@
try
{
m.getByte("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -742,7 +742,7 @@
try
{
m.getShort("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -754,7 +754,7 @@
try
{
m.getInt("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -763,7 +763,7 @@
try
{
m.getLong("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -774,7 +774,7 @@
try
{
m.getFloat("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -784,7 +784,7 @@
try
{
m.getDouble("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -794,7 +794,7 @@
try
{
m.getBytes("char");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -810,7 +810,7 @@
try
{
m.getBoolean("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -820,7 +820,7 @@
try
{
m.getByte("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -830,7 +830,7 @@
try
{
m.getShort("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -841,7 +841,7 @@
try
{
m.getChar("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -851,7 +851,7 @@
try
{
m.getInt("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -861,7 +861,7 @@
try
{
m.getLong("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -872,7 +872,7 @@
try
{
m.getFloat("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -882,7 +882,7 @@
try
{
m.getDouble("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -895,7 +895,7 @@
try
{
m.getString("bytes");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -911,7 +911,7 @@
try
{
m.getBoolean("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -926,7 +926,7 @@
try
{
m.getChar("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -942,7 +942,7 @@
try
{
m.getFloat("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -952,7 +952,7 @@
try
{
m.getDouble("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -962,7 +962,7 @@
try
{
m.getBytes("byte");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -982,7 +982,7 @@
try
{
m.getByte("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -993,7 +993,7 @@
try
{
m.getShort("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1003,9 +1003,9 @@
try
{
m.getChar("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
- catch (MessageFormatException nfe)
+ catch (MessageFormatException npe)
{
//normal execution
}
@@ -1013,7 +1013,7 @@
try
{
m.getInt("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1023,7 +1023,7 @@
try
{
m.getLong("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1033,7 +1033,7 @@
try
{
m.getFloat("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1043,7 +1043,7 @@
try
{
m.getDouble("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1053,7 +1053,7 @@
try
{
m.getBytes("odd");
- fail("Exception Expected.");
+ fail("MessageFormatException expected as value doesn't exist.");
}
catch (MessageFormatException nfe)
{
@@ -1224,7 +1224,6 @@
{
synchronized(received)
{
- _logger.info("****************** Recevied Messgage:" + (JMSMapMessage) message);
received.add((JMSMapMessage) message);
received.notify();
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/MapMessageTest.java Fri Dec 15 00:33:10 2006
@@ -206,7 +206,7 @@
mm.getByte("random");
Assert.fail("MessageFormatException expected");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException e)
{
//normal execution
}
@@ -295,9 +295,9 @@
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getInt("random");
- Assert.fail("NumberFormatException should be received.");
+ Assert.fail("MessageFormatException should be received.");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException e)
{
//normal execution
}
@@ -313,9 +313,9 @@
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getLong("random");
- Assert.fail("NumberFormatException should be received.");
+ Assert.fail("MessageFormatException should be received.");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException e)
{
//normal execution
}
@@ -331,9 +331,9 @@
{
JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
mm.getShort("random");
- Assert.fail("NumberFormatException should be received.");
+ Assert.fail("MessageFormatException should be received.");
}
- catch (NumberFormatException e)
+ catch (MessageFormatException e)
{
//normal execution
}
Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java (original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/test/unit/client/message/TextMessageTest.java Fri Dec 15 00:33:10 2006
@@ -22,8 +22,13 @@
import org.apache.qpid.client.message.TestMessageHelper;
import org.apache.qpid.client.message.JMSTextMessage;
+import org.apache.qpid.client.message.JMSMapMessage;
import junit.framework.TestCase;
+import junit.framework.Assert;
+
+import javax.jms.JMSException;
+import javax.jms.MessageFormatException;
public class TextMessageTest extends TestCase
{
@@ -46,6 +51,248 @@
val = tm.getText();
assertEquals(val, "Banana");
}
+
+
+ public void testBooleanPropertyLookup()
+ {
+ try
+ {
+ JMSTextMessage tm = TestMessageHelper.newJMSTextMessage();
+
+ tm.setBooleanProperty("value", true);
+ Assert.assertEquals(true, tm.getBooleanProperty("value"));
+ Assert.assertEquals("true", tm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testBytePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setByteProperty("value", Byte.MAX_VALUE);
+
+ Assert.assertEquals(Byte.MAX_VALUE, mm.getByteProperty("value"));
+ Assert.assertEquals((short) Byte.MAX_VALUE, mm.getShortProperty("value"));
+ Assert.assertEquals(Byte.MAX_VALUE, mm.getIntProperty("value"));
+ Assert.assertEquals((long) Byte.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Byte.MAX_VALUE, mm.getStringProperty("value"));
+
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testShortPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setShortProperty("value", Short.MAX_VALUE);
+ Assert.assertEquals(Short.MAX_VALUE, mm.getShortProperty("value"));
+ Assert.assertEquals((int) Short.MAX_VALUE, mm.getIntProperty("value"));
+ Assert.assertEquals((long) Short.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Short.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testDoublePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setDoubleProperty("value", Double.MAX_VALUE);
+ Assert.assertEquals(Double.MAX_VALUE, mm.getDoubleProperty("value"));
+ Assert.assertEquals("" + Double.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testFloatPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setFloatProperty("value", Float.MAX_VALUE);
+ Assert.assertEquals(Float.MAX_VALUE, mm.getFloatProperty("value"));
+ Assert.assertEquals((double) Float.MAX_VALUE, mm.getDoubleProperty("value"));
+ Assert.assertEquals("" + Float.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testIntPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setIntProperty("value", Integer.MAX_VALUE);
+ Assert.assertEquals(Integer.MAX_VALUE, mm.getIntProperty("value"));
+ Assert.assertEquals((long) Integer.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Integer.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testLongPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.setLongProperty("value", Long.MAX_VALUE);
+ Assert.assertEquals(Long.MAX_VALUE, mm.getLongProperty("value"));
+ Assert.assertEquals("" + Long.MAX_VALUE, mm.getStringProperty("value"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+
+ // Failed Lookups
+
+ public void testFailedBooleanPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ Assert.assertEquals(false, mm.getBooleanProperty("int"));
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received." + e);
+ }
+ }
+
+ public void testFailedBytePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getByteProperty("random");
+ Assert.fail("MessageFormatException expected");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+
+ }
+
+ public void testFailedDoublePropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getDoubleProperty("random");
+ Assert.fail("NullPointerException should be received.");
+ }
+ catch (NullPointerException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedFloatPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getFloatProperty("random");
+ Assert.fail("NullPointerException should be received.");
+ }
+ catch (NullPointerException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedIntPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getIntProperty("random");
+ Assert.fail("MessageFormatException should be received.");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedLongPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getLongProperty("random");
+ Assert.fail("MessageFormatException should be received.");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
+ public void testFailedShortPropertyLookup()
+ {
+ try
+ {
+ JMSMapMessage mm = TestMessageHelper.newJMSMapMessage();
+ mm.getShortProperty("random");
+ Assert.fail("MessageFormatException should be received.");
+ }
+ catch (MessageFormatException e)
+ {
+ //normal execution
+ }
+ catch (JMSException e)
+ {
+ Assert.fail("JMSException received:" + e);
+ }
+ }
+
public static junit.framework.Test suite()
{
Modified: incubator/qpid/trunk/qpid/java/common/pom.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/pom.xml?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/pom.xml (original)
+++ incubator/qpid/trunk/qpid/java/common/pom.xml Fri Dec 15 00:33:10 2006
@@ -90,5 +90,9 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ </dependency>
</dependencies>
</project>
Added: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java?view=auto&rev=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java (added)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java Fri Dec 15 00:33:10 2006
@@ -0,0 +1,30 @@
+/*
+ * 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;
+
+
+public class AMQPInvalidClassException extends RuntimeException
+{
+ public AMQPInvalidClassException(String s)
+ {
+ super(s);
+ }
+}
Propchange: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/AMQPInvalidClassException.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java Fri Dec 15 00:33:10 2006
@@ -57,6 +57,8 @@
private FieldTable _headers;
+ private JMSPropertyFieldTable _jmsHeaders;
+
private byte _deliveryMode;
private byte _priority;
@@ -276,6 +278,7 @@
if ((_propertyFlags & (1 << 13)) > 0)
{
_headers = EncodingUtils.readFieldTable(buffer);
+ setJMSHeaders();
}
if ((_propertyFlags & (1 << 12)) > 0)
{
@@ -358,6 +361,8 @@
if ((_propertyFlags & (1 << 13)) > 0)
{
_headers = EncodingUtils.readFieldTable(buffer);
+ setJMSHeaders();
+
}
_decodedHeaders = true;
}
@@ -446,6 +451,26 @@
clearEncodedForm();
_propertyFlags |= (1 << 13);
_headers = headers;
+ setJMSHeaders();
+ }
+
+ private void setJMSHeaders()
+ {
+ if (_jmsHeaders == null)
+ {
+ _jmsHeaders = new JMSPropertyFieldTable(_headers);
+ }
+ else
+ {
+ _jmsHeaders.setFieldTable(_headers);
+ }
+ }
+
+ public JMSPropertyFieldTable getJMSHeaders()
+ {
+ //This will ensure we have a blank header
+ getHeaders();
+ return _jmsHeaders;
}
public byte getDeliveryMode()
Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java?view=diff&rev=487481&r1=487480&r2=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java Fri Dec 15 00:33:10 2006
@@ -461,7 +461,7 @@
//**** new methods
- // BOOLEAN_PROPERTY_PREFIX
+ // AMQP_BOOLEAN_PROPERTY_PREFIX
public static void writeBoolean(ByteBuffer buffer, Boolean aBoolean)
{
@@ -479,7 +479,7 @@
return 1;
}
- // BYTE_PROPERTY_PREFIX
+ // AMQP_BYTE_PROPERTY_PREFIX
public static void writeByte(ByteBuffer buffer, Byte aByte)
{
buffer.put(aByte);
@@ -496,7 +496,7 @@
}
- // SHORT_PROPERTY_PREFIX
+ // AMQP_SHORT_PROPERTY_PREFIX
public static void writeShort(ByteBuffer buffer, Short aShort)
{
buffer.putShort(aShort);
@@ -528,7 +528,7 @@
return 4;
}
- // LONG_PROPERTY_PREFIX
+ // AMQP_LONG_PROPERTY_PREFIX
public static void writeLong(ByteBuffer buffer, Long aLong)
{
buffer.putLong(aLong);
@@ -610,7 +610,7 @@
}
//CHAR_PROPERTY
- public static long encodedCharLength()
+ public static int encodedCharLength()
{
return encodedByteLength();
}
Added: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java?view=auto&rev=487481
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java (added)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java Fri Dec 15 00:33:10 2006
@@ -0,0 +1,514 @@
+/*
+ * 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.framing;
+
+import org.apache.mina.common.ByteBuffer;
+import org.apache.qpid.AMQPInvalidClassException;
+
+import javax.jms.MessageFormatException;
+import javax.jms.JMSException;
+import java.util.Enumeration;
+
+
+public class JMSPropertyFieldTable
+{
+ private FieldTable _fieldtable;
+
+ public JMSPropertyFieldTable()
+ {
+ _fieldtable = new PropertyFieldTable();
+ }
+
+ public JMSPropertyFieldTable(FieldTable table)
+ {
+ _fieldtable = table;
+ }
+
+ public JMSPropertyFieldTable(ByteBuffer buffer, long length) throws JMSException
+ {
+ try
+ {
+ _fieldtable = new PropertyFieldTable(buffer, length);
+ }
+ catch (AMQFrameDecodingException e)
+ {
+ JMSException error = new JMSException(e.getMessage());
+ error.setLinkedException(e);
+ throw error;
+ }
+ }
+
+ private void checkPropertyName(String propertyName)
+ {
+ if (propertyName == null)
+ {
+ throw new IllegalArgumentException("Property name must not be null");
+ }
+ else if ("".equals(propertyName))
+ {
+ throw new IllegalArgumentException("Property name must not be the empty string");
+ }
+
+ checkIdentiferFormat(propertyName);
+ }
+
+ protected static void checkIdentiferFormat(String propertyName)
+ {
+// JMS requirements 3.5.1 Property Names
+// Identifiers:
+// - An identifier is an unlimited-length character sequence that must begin
+// with a Java identifier start character; all following characters must be Java
+// identifier part characters. An identifier start character is any character for
+// which the method Character.isJavaIdentifierStart returns true. This includes
+// '_' and '$'. An identifier part character is any character for which the
+// method Character.isJavaIdentifierPart returns true.
+// - Identifiers cannot be the names NULL, TRUE, or FALSE.
+// Identifiers cannot be NOT, AND, OR, BETWEEN, LIKE, IN, IS, or
+// ESCAPE.
+// Identifiers are either header field references or property references. The
+// type of a property value in a message selector corresponds to the type
+// used to set the property. If a property that does not exist in a message is
+// referenced, its value is NULL. The semantics of evaluating NULL values
+// in a selector are described in Section 3.8.1.2, Null Values.
+// The conversions that apply to the get methods for properties do not
+// apply when a property is used in a message selector expression. For
+// example, suppose you set a property as a string value, as in the
+// following:
+// myMessage.setStringProperty("NumberOfOrders", "2");
+// The following expression in a message selector would evaluate to false,
+// because a string cannot be used in an arithmetic expression:
+// "NumberOfOrders > 1"
+// Identifiers are case sensitive.
+// Message header field references are restricted to JMSDeliveryMode,
+// JMSPriority, JMSMessageID, JMSTimestamp, JMSCorrelationID, and
+// JMSType. JMSMessageID, JMSCorrelationID, and JMSType values may be
+// null and if so are treated as a NULL value.
+
+ if (Boolean.getBoolean("strict-jms"))
+ {
+ // JMS start character
+ if (!(Character.isJavaIdentifierStart(propertyName.charAt(0))))
+ {
+ throw new IllegalArgumentException("Identifier '" + propertyName + "' does not start with a valid JMS identifier start character");
+ }
+
+ // JMS part character
+ int length = propertyName.length();
+ for (int c = 1; c < length; c++)
+ {
+ if (!(Character.isJavaIdentifierPart(propertyName.charAt(c))))
+ {
+ throw new IllegalArgumentException("Identifier '" + propertyName + "' contains an invalid JMS identifier character");
+ }
+ }
+
+ // JMS invalid names
+ if ((propertyName.equals("NULL")
+ || propertyName.equals("TRUE")
+ || propertyName.equals("FALSE")
+ || propertyName.equals("NOT")
+ || propertyName.equals("AND")
+ || propertyName.equals("OR")
+ || propertyName.equals("BETWEEN")
+ || propertyName.equals("LIKE")
+ || propertyName.equals("IN")
+ || propertyName.equals("IS")
+ || propertyName.equals("ESCAPE")))
+ {
+ throw new IllegalArgumentException("Identifier '" + propertyName + "' is not allowed in JMS");
+ }
+ }
+
+ }
+
+ // MapMessage Interface
+ public boolean getBoolean(String string) throws JMSException
+ {
+ Boolean b = _fieldtable.getBoolean(string);
+
+ if (b == null)
+ {
+ if (_fieldtable.containsKey(string))
+ {
+ Object str = _fieldtable.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;
+ }
+
+ public char getCharacter(String string) throws JMSException
+ {
+ Character c = _fieldtable.getCharacter(string);
+
+ if (c == null)
+ {
+ if (_fieldtable.get(string) instanceof Character)
+ {
+ throw new NullPointerException("Cannot convert null char");
+ }
+ else
+ {
+ throw new MessageFormatException("getChar can't use " + string + " item.");
+ }
+ }
+ else
+ {
+ return (char) c;
+ }
+ }
+
+ public byte[] getBytes(String string) throws JMSException
+ {
+ byte[] bs = _fieldtable.getBytes(string);
+
+ if (bs == null)
+ {
+ throw new MessageFormatException("getBytes can't use " + string + " item.");
+ }
+ else
+ {
+ return bs;
+ }
+ }
+
+ public byte getByte(String string) throws JMSException
+ {
+ try
+ {
+ Byte b = _fieldtable.getByte(string);
+ if (b == null)
+ {
+ if (_fieldtable.containsKey(string))
+ {
+ Object str = _fieldtable.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;
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new MessageFormatException(nfe.getMessage());
+ }
+ }
+
+ public short getShort(String string) throws JMSException
+ {
+ try
+ {
+ Short s = _fieldtable.getShort(string);
+
+ if (s == null)
+ {
+ s = Short.valueOf(getByte(string));
+ }
+
+ return s;
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new MessageFormatException(nfe.getMessage());
+ }
+ }
+
+ public int getInteger(String string) throws JMSException
+ {
+ try
+ {
+ Integer i = _fieldtable.getInteger(string);
+
+ if (i == null)
+ {
+ i = Integer.valueOf(getShort(string));
+ }
+
+ return i;
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new MessageFormatException(nfe.getMessage());
+ }
+ }
+
+ public long getLong(String string) throws JMSException
+ {
+ try
+ {
+ Long l = _fieldtable.getLong(string);
+
+ if (l == null)
+ {
+ l = Long.valueOf(getInteger(string));
+ }
+
+ return l;
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new MessageFormatException(nfe.getMessage());
+ }
+
+ }
+
+ public float getFloat(String string) throws JMSException
+ {
+ try
+ {
+ Float f = _fieldtable.getFloat(string);
+
+ if (f == null)
+ {
+ if (_fieldtable.containsKey(string))
+ {
+ Object str = _fieldtable.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;
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new MessageFormatException(nfe.getMessage());
+ }
+ }
+
+ public double getDouble(String string) throws JMSException
+ {
+ try
+ {
+ Double d = _fieldtable.getDouble(string);
+
+ if (d == null)
+ {
+ d = Double.valueOf(getFloat(string));
+ }
+
+ return d;
+ }
+ catch (NumberFormatException nfe)
+ {
+ throw new MessageFormatException(nfe.getMessage());
+ }
+ }
+
+ public String getString(String string) throws JMSException
+ {
+ String s = _fieldtable.getString(string);
+
+ if (s == null)
+ {
+ if (_fieldtable.containsKey(string))
+ {
+ Object o = _fieldtable.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;
+ }
+
+ public Object getObject(String string) throws JMSException
+ {
+ return _fieldtable.getObject(string);
+ }
+
+ public void setBoolean(String string, boolean b) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setBoolean(string, b);
+ }
+
+ public void setChar(String string, char c) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setChar(string, c);
+ }
+
+ public Object setBytes(String string, byte[] bytes)
+ {
+ return _fieldtable.setBytes(string, bytes, 0, bytes.length);
+ }
+
+ public Object setBytes(String string, byte[] bytes, int start, int length)
+ {
+ return _fieldtable.setBytes(string, bytes, start, length);
+ }
+
+ public void setByte(String string, byte b) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setByte(string, b);
+ }
+
+ public void setShort(String string, short i) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setShort(string, i);
+ }
+
+ public void setInteger(String string, int i) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setInteger(string, i);
+ }
+
+ public void setLong(String string, long l) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setLong(string, l);
+ }
+
+ public void setFloat(String string, float v) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setFloat(string, v);
+ }
+
+ public void setDouble(String string, double v) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setDouble(string, v);
+ }
+
+ public void setString(String string, String string1) throws JMSException
+ {
+ checkPropertyName(string);
+ _fieldtable.setString(string, string1);
+ }
+
+ public void setObject(String string, Object object) throws JMSException
+ {
+ checkPropertyName(string);
+ try
+ {
+ _fieldtable.setObject(string, object);
+ }
+ catch (AMQPInvalidClassException aice)
+ {
+ throw new JMSException("Only primatives are allowed object is:" + object.getClass());
+ }
+ }
+
+ public boolean itemExists(String string) throws JMSException
+ {
+ return _fieldtable.containsKey(string);
+ }
+
+ public void setFieldTable(FieldTable headers)
+ {
+ _fieldtable = headers;
+ }
+
+ public Enumeration getPropertyNames()
+ {
+ return _fieldtable.getPropertyNames();
+ }
+
+ public void clear()
+ {
+ _fieldtable.clear();
+ }
+
+ public boolean propertyExists(String propertyName)
+ {
+ return _fieldtable.propertyExists(propertyName);
+ }
+
+ public Object put(Object key, Object value)
+ {
+ return _fieldtable.put(key, value);
+ }
+
+ public Object remove(String propertyName)
+ {
+ return _fieldtable.remove(propertyName);
+ }
+
+ public boolean isEmpty()
+ {
+ return _fieldtable.isEmpty();
+ }
+
+ public void writeToBuffer(ByteBuffer data)
+ {
+ _fieldtable.writeToBuffer(data);
+ }
+
+ public Enumeration getMapNames()
+ {
+ return getPropertyNames();
+ }
+}
Propchange: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/framing/JMSPropertyFieldTable.java
------------------------------------------------------------------------------
svn:keywords = Rev Date