[hornetq-commits] JBoss hornetq SVN: r8239 - in trunk: src/main/org/hornetq/core/management/impl and 17 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Fri Nov 6 08:31:15 EST 2009
Author: jmesnil
Date: 2009-11-06 08:31:14 -0500 (Fri, 06 Nov 2009)
New Revision: 8239
Added:
trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesConversionTest.java
Removed:
trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java
Modified:
trunk/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java
trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java
trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
trunk/src/main/org/hornetq/core/postoffice/QueueInfo.java
trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
trunk/src/main/org/hornetq/core/remoting/impl/invm/InVMAcceptor.java
trunk/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java
trunk/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
trunk/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java
trunk/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
trunk/src/main/org/hornetq/core/server/group/impl/LocalGroupingHandler.java
trunk/src/main/org/hornetq/core/server/group/impl/RemoteGroupingHandler.java
trunk/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java
trunk/src/main/org/hornetq/jms/client/HornetQMapMessage.java
trunk/src/main/org/hornetq/utils/TypedProperties.java
trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java
trunk/tests/src/org/hornetq/tests/integration/discovery/DiscoveryTest.java
trunk/tests/src/org/hornetq/tests/integration/management/AcceptorControlTest.java
trunk/tests/src/org/hornetq/tests/integration/management/BridgeControlTest.java
trunk/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java
trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java
Log:
https://jira.jboss.org/jira/browse/HORNETQ-176: typed property getters on the core Message class
* moved type conversion to TypedProperties
* refactored HornetQMapMessage to used TypedProperties's typed getters
Modified: trunk/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/cluster/impl/DiscoveryGroupImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -125,7 +125,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), new SimpleString(name));
+ props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
Notification notification = new Notification(nodeID, NotificationType.DISCOVERY_GROUP_STARTED, props );
notificationService.sendNotification(notification );
}
@@ -160,7 +160,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), new SimpleString(name));
+ props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
Notification notification = new Notification(nodeID, NotificationType.DISCOVERY_GROUP_STOPPED, props );
try
{
Modified: trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/management/impl/ManagementServiceImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -720,14 +720,14 @@
notifProps = new TypedProperties();
}
- notifProps.putStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE,
+ notifProps.putSimpleStringProperty(ManagementHelper.HDR_NOTIFICATION_TYPE,
new SimpleString(notification.getType().toString()));
notifProps.putLongProperty(ManagementHelper.HDR_NOTIFICATION_TIMESTAMP, System.currentTimeMillis());
if (notification.getUID() != null)
{
- notifProps.putStringProperty(new SimpleString("foobar"), new SimpleString(notification.getUID()));
+ notifProps.putSimpleStringProperty(new SimpleString("foobar"), new SimpleString(notification.getUID()));
}
notificationMessage.putTypedProperties(notifProps);
Modified: trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/message/impl/MessageImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -398,7 +398,7 @@
public void putStringProperty(final SimpleString key, final SimpleString value)
{
- properties.putStringProperty(key, value);
+ properties.putSimpleStringProperty(key, value);
}
public void putObjectProperty(SimpleString key, Object value) throws PropertyConversionException
@@ -439,7 +439,7 @@
}
else if (value instanceof String)
{
- properties.putStringProperty(key, new SimpleString((String)value));
+ properties.putSimpleStringProperty(key, new SimpleString((String)value));
}
else
{
@@ -494,7 +494,7 @@
public void putStringProperty(final String key, final String value)
{
- properties.putStringProperty(new SimpleString(key), new SimpleString(value));
+ properties.putSimpleStringProperty(new SimpleString(key), new SimpleString(value));
}
public void putTypedProperties(TypedProperties otherProps)
@@ -509,76 +509,27 @@
public Boolean getBooleanProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
- if (value == null)
- {
- return Boolean.valueOf(null);
- }
-
- if (value instanceof Boolean)
- {
- return (Boolean)value;
- }
- else if (value instanceof SimpleString)
- {
- return Boolean.valueOf(((SimpleString)value).toString()).booleanValue();
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getBooleanProperty(key);
}
public Boolean getBooleanProperty(String key) throws PropertyConversionException
{
- return getBooleanProperty(new SimpleString(key));
+ return properties.getBooleanProperty(new SimpleString(key));
}
public Byte getByteProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
-
- if (value == null)
- {
- return Byte.valueOf(null);
- }
-
- if (value instanceof Byte)
- {
- return (Byte)value;
- }
- else if (value instanceof SimpleString)
- {
- return Byte.parseByte(((SimpleString)value).toString());
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getByteProperty(key);
}
public Byte getByteProperty(String key) throws PropertyConversionException
{
- return getByteProperty(new SimpleString(key));
+ return properties.getByteProperty(new SimpleString(key));
}
public byte[] getBytesProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
-
- if (value == null)
- {
- return null;
- }
-
- if (value instanceof byte[])
- {
- return (byte[])value;
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getBytesProperty(key);
}
public byte[] getBytesProperty(String key) throws PropertyConversionException
@@ -588,162 +539,52 @@
public Double getDoubleProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
- if (value == null)
- {
- return Double.valueOf(null);
- }
-
- if (value instanceof Float)
- {
- return ((Float)value).doubleValue();
- }
- else if (value instanceof Double)
- {
- return (Double)value;
- }
- else if (value instanceof SimpleString)
- {
- return Double.parseDouble(((SimpleString)value).toString());
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getDoubleProperty(key);
}
public Double getDoubleProperty(String key) throws PropertyConversionException
{
- return getDoubleProperty(new SimpleString(key));
+ return properties.getDoubleProperty(new SimpleString(key));
}
public Integer getIntProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
- if (value == null)
- {
- return Integer.valueOf(null);
- }
- else if (value instanceof Integer)
- {
- return (Integer)value;
- }
- else if (value instanceof Byte)
- {
- return ((Byte)value).intValue();
- }
- else if (value instanceof Short)
- {
- return ((Short)value).intValue();
- }
- else if (value instanceof SimpleString)
- {
- return Integer.parseInt(((SimpleString)value).toString());
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getIntProperty(key);
}
public Integer getIntProperty(String key) throws PropertyConversionException
{
- return getIntProperty(new SimpleString(key));
+ return properties.getIntProperty(new SimpleString(key));
}
public Long getLongProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
- if (value == null)
- {
- return Long.valueOf(null);
- }
- else if (value instanceof Long)
- {
- return (Long)value;
- }
- else if (value instanceof Byte)
- {
- return ((Byte)value).longValue();
- }
- else if (value instanceof Short)
- {
- return ((Short)value).longValue();
- }
- else if (value instanceof Integer)
- {
- return ((Integer)value).longValue();
- }
- else if (value instanceof SimpleString)
- {
- return Long.parseLong(((SimpleString)value).toString());
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getLongProperty(key);
}
public Long getLongProperty(String key) throws PropertyConversionException
{
- return getLongProperty(new SimpleString(key));
+ return properties.getLongProperty(new SimpleString(key));
}
public Short getShortProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
- if (value == null)
- {
- return Short.valueOf(null);
- }
- else if (value instanceof Byte)
- {
- return ((Byte)value).shortValue();
- }
- else if (value instanceof Short)
- {
- return (Short)value;
- }
- else if (value instanceof SimpleString)
- {
- return Short.parseShort(((SimpleString)value).toString());
- }
- else
- {
- throw new PropertyConversionException("Invalid Conversion.");
- }
+ return properties.getShortProperty(key);
}
public Short getShortProperty(String key) throws PropertyConversionException
{
- return getShortProperty(new SimpleString(key));
+ return properties.getShortProperty(new SimpleString(key));
}
public Float getFloatProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
- if (value == null)
- {
- return Float.valueOf(null);
- }
-
- if (value instanceof Float)
- {
- return ((Float)value).floatValue();
- }
- else if (value instanceof SimpleString)
- {
- return Float.parseFloat(((SimpleString)value).toString());
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getFloatProperty(key);
}
public Float getFloatProperty(String key) throws PropertyConversionException
{
- return getFloatProperty(new SimpleString(key));
+ return properties.getFloatProperty(new SimpleString(key));
}
public String getStringProperty(SimpleString key) throws PropertyConversionException
@@ -767,54 +608,12 @@
public SimpleString getSimpleStringProperty(SimpleString key) throws PropertyConversionException
{
- Object value = properties.getProperty(key);
-
- if (value == null)
- {
- return null;
- }
-
- if (value instanceof SimpleString)
- {
- return (SimpleString)value;
- }
- else if (value instanceof Boolean)
- {
- return new SimpleString(value.toString());
- }
- else if (value instanceof Byte)
- {
- return new SimpleString(value.toString());
- }
- else if (value instanceof Short)
- {
- return new SimpleString(value.toString());
- }
- else if (value instanceof Integer)
- {
- return new SimpleString(value.toString());
- }
- else if (value instanceof Long)
- {
- return new SimpleString(value.toString());
- }
- else if (value instanceof Float)
- {
- return new SimpleString(value.toString());
- }
- else if (value instanceof Double)
- {
- return new SimpleString(value.toString());
- }
- else
- {
- throw new PropertyConversionException("Invalid conversion");
- }
+ return properties.getSimpleStringProperty(key);
}
public SimpleString getSimpleStringProperty(String key) throws PropertyConversionException
{
- return getSimpleStringProperty(new SimpleString(key));
+ return properties.getSimpleStringProperty(new SimpleString(key));
}
public Object getObjectProperty(final String key)
Modified: trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java
===================================================================
--- trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/persistence/impl/journal/JournalStorageManager.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -937,11 +937,10 @@
messageEncoding.decode(buff);
- Long originalMessageID = (Long)largeMessage.getProperties().getProperty(MessageImpl.HDR_ORIG_MESSAGE_ID);
-
- // Using the linked file by the original file
- if (originalMessageID != null)
+ if (largeMessage.getProperties().containsProperty(MessageImpl.HDR_ORIG_MESSAGE_ID))
{
+ long originalMessageID = largeMessage.getProperties().getLongProperty(MessageImpl.HDR_ORIG_MESSAGE_ID);
+
LargeServerMessage originalMessage = (LargeServerMessage)messages.get(originalMessageID);
if (originalMessage == null)
Modified: trunk/src/main/org/hornetq/core/postoffice/QueueInfo.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/QueueInfo.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/postoffice/QueueInfo.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -48,8 +48,8 @@
private final int distance;
- public QueueInfo(final SimpleString routingName, final SimpleString clusterName, final SimpleString address, final SimpleString filterString, final Long id,
- final Integer distance)
+ public QueueInfo(final SimpleString routingName, final SimpleString clusterName, final SimpleString address, final SimpleString filterString, final long id,
+ final int distance)
{
if (routingName == null)
{
@@ -63,10 +63,7 @@
{
throw new IllegalArgumentException("Address is null");
}
- if (distance == null)
- {
- throw new IllegalArgumentException("Distance is null");
- }
+
this.routingName = routingName;
this.clusterName = clusterName;
this.address = address;
Modified: trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/postoffice/impl/PostOfficeImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -222,30 +222,40 @@
{
TypedProperties props = notification.getProperties();
- Integer bindingType = (Integer)props.getProperty(ManagementHelper.HDR_BINDING_TYPE);
-
- if (bindingType == null)
+ if (!props.containsProperty(ManagementHelper.HDR_BINDING_TYPE))
{
throw new IllegalArgumentException("Binding type not specified");
}
+ Integer bindingType = props.getIntProperty(ManagementHelper.HDR_BINDING_TYPE);
+
if (bindingType == BindingType.DIVERT_INDEX)
{
// We don't propagate diverts
return;
}
- SimpleString routingName = (SimpleString)props.getProperty(ManagementHelper.HDR_ROUTING_NAME);
+ SimpleString routingName = props.getSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME);
- SimpleString clusterName = (SimpleString)props.getProperty(ManagementHelper.HDR_CLUSTER_NAME);
+ SimpleString clusterName = props.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
- SimpleString address = (SimpleString)props.getProperty(ManagementHelper.HDR_ADDRESS);
+ SimpleString address = props.getSimpleStringProperty(ManagementHelper.HDR_ADDRESS);
- Long id = (Long)props.getProperty(ManagementHelper.HDR_BINDING_ID);
+ if (!props.containsProperty(ManagementHelper.HDR_BINDING_ID))
+ {
+ throw new IllegalArgumentException("ID is null");
+ }
+
+ long id = props.getLongProperty(ManagementHelper.HDR_BINDING_ID);
- SimpleString filterString = (SimpleString)props.getProperty(ManagementHelper.HDR_FILTERSTRING);
+ SimpleString filterString = props.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING);
- Integer distance = (Integer)props.getProperty(ManagementHelper.HDR_DISTANCE);
+ if (!props.containsProperty(ManagementHelper.HDR_DISTANCE))
+ {
+ throw new IllegalArgumentException("Distance is null");
+ }
+
+ int distance = props.getIntProperty(ManagementHelper.HDR_DISTANCE);
QueueInfo info = new QueueInfo(routingName, clusterName, address, filterString, id, distance);
@@ -257,12 +267,12 @@
{
TypedProperties props = notification.getProperties();
- SimpleString clusterName = (SimpleString)props.getProperty(ManagementHelper.HDR_CLUSTER_NAME);
-
- if (clusterName == null)
+ if (!props.containsProperty(ManagementHelper.HDR_CLUSTER_NAME))
{
throw new IllegalStateException("No cluster name");
}
+
+ SimpleString clusterName = props.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
QueueInfo info = queueInfos.remove(clusterName);
@@ -277,14 +287,14 @@
{
TypedProperties props = notification.getProperties();
- SimpleString clusterName = (SimpleString)props.getProperty(ManagementHelper.HDR_CLUSTER_NAME);
-
- if (clusterName == null)
+ if (!props.containsProperty(ManagementHelper.HDR_CLUSTER_NAME))
{
throw new IllegalStateException("No cluster name");
}
+
+ SimpleString clusterName = props.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
- SimpleString filterString = (SimpleString)props.getProperty(ManagementHelper.HDR_FILTERSTRING);
+ SimpleString filterString = props.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING);
QueueInfo info = queueInfos.get(clusterName);
@@ -309,16 +319,16 @@
filterStrings.add(filterString);
}
- Integer distance = (Integer)props.getProperty(ManagementHelper.HDR_DISTANCE);
-
- if (distance == null)
+ if (!props.containsProperty(ManagementHelper.HDR_DISTANCE))
{
throw new IllegalStateException("No distance");
}
+ int distance = props.getIntProperty(ManagementHelper.HDR_DISTANCE);
+
if (distance > 0)
{
- SimpleString queueName = (SimpleString)props.getProperty(ManagementHelper.HDR_ROUTING_NAME);
+ SimpleString queueName = props.getSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME);
if (queueName == null)
{
@@ -350,14 +360,14 @@
{
TypedProperties props = notification.getProperties();
- SimpleString clusterName = (SimpleString)props.getProperty(ManagementHelper.HDR_CLUSTER_NAME);
+ SimpleString clusterName = props.getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
if (clusterName == null)
{
- throw new IllegalStateException("No distance");
+ throw new IllegalStateException("No cluster name");
}
- SimpleString filterString = (SimpleString)props.getProperty(ManagementHelper.HDR_FILTERSTRING);
+ SimpleString filterString = props.getSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING);
QueueInfo info = queueInfos.get(clusterName);
@@ -377,16 +387,16 @@
if (info.getNumberOfConsumers() == 0)
{
- Integer distance = (Integer)props.getProperty(ManagementHelper.HDR_DISTANCE);
-
- if (distance == null)
+ if (!props.containsProperty(ManagementHelper.HDR_DISTANCE))
{
throw new IllegalStateException("No cluster name");
}
+ int distance = props.getIntProperty(ManagementHelper.HDR_DISTANCE);
+
if (distance == 0)
{
- SimpleString queueName = (SimpleString)props.getProperty(ManagementHelper.HDR_ROUTING_NAME);
+ SimpleString queueName = props.getSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME);
if (queueName == null)
{
@@ -439,11 +449,11 @@
props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, binding.getType().toInt());
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
- props.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
- props.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
props.putLongProperty(ManagementHelper.HDR_BINDING_ID, binding.getID());
@@ -453,7 +463,7 @@
if (filter != null)
{
- props.putStringProperty(ManagementHelper.HDR_FILTERSTRING, filter.getFilterString());
+ props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filter.getFilterString());
}
String uid = UUIDGenerator.getInstance().generateStringUUID();
@@ -491,11 +501,11 @@
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
- props.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
- props.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
Modified: trunk/src/main/org/hornetq/core/remoting/impl/invm/InVMAcceptor.java
===================================================================
--- trunk/src/main/org/hornetq/core/remoting/impl/invm/InVMAcceptor.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/remoting/impl/invm/InVMAcceptor.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -84,7 +84,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("factory"), new SimpleString(InVMAcceptorFactory.class.getName()));
+ props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(InVMAcceptorFactory.class.getName()));
props.putIntProperty(new SimpleString("id"), id);
Notification notification = new Notification(null, NotificationType.ACCEPTOR_STARTED, props);
notificationService.sendNotification(notification);
@@ -117,7 +117,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("factory"), new SimpleString(InVMAcceptorFactory.class.getName()));
+ props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(InVMAcceptorFactory.class.getName()));
props.putIntProperty(new SimpleString("id"), id);
Notification notification = new Notification(null, NotificationType.ACCEPTOR_STOPPED, props);
try
Modified: trunk/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/security/impl/SecurityStoreImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -127,7 +127,7 @@
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_USER, SimpleString.toSimpleString(user));
+ props.putSimpleStringProperty(ManagementHelper.HDR_USER, SimpleString.toSimpleString(user));
Notification notification = new Notification(null, SECURITY_AUTHENTICATION_VIOLATION, props);
@@ -168,9 +168,9 @@
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, address);
- props.putStringProperty(ManagementHelper.HDR_CHECK_TYPE, new SimpleString(checkType.toString()));
- props.putStringProperty(ManagementHelper.HDR_USER, SimpleString.toSimpleString(user));
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address);
+ props.putSimpleStringProperty(ManagementHelper.HDR_CHECK_TYPE, new SimpleString(checkType.toString()));
+ props.putSimpleStringProperty(ManagementHelper.HDR_USER, SimpleString.toSimpleString(user));
Notification notification = new Notification(null, NotificationType.SECURITY_PERMISSION_VIOLATION, props);
Modified: trunk/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/server/cluster/impl/BridgeImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -235,7 +235,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), name);
+ props.putSimpleStringProperty(new SimpleString("name"), name);
Notification notification = new Notification(nodeUUID.toString(), NotificationType.BRIDGE_STARTED, props);
notificationService.sendNotification(notification);
}
@@ -281,7 +281,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), name);
+ props.putSimpleStringProperty(new SimpleString("name"), name);
Notification notification = new Notification(nodeUUID.toString(), NotificationType.BRIDGE_STOPPED, props);
try
{
Modified: trunk/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/server/cluster/impl/BroadcastGroupImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -127,7 +127,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), new SimpleString(name));
+ props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
Notification notification = new Notification(nodeID, NotificationType.BROADCAST_GROUP_STARTED, props);
notificationService.sendNotification(notification );
}
@@ -152,7 +152,7 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), new SimpleString(name));
+ props.putSimpleStringProperty(new SimpleString("name"), new SimpleString(name));
Notification notification = new Notification(nodeID, NotificationType.BROADCAST_GROUP_STOPPED, props);
try
{
Modified: trunk/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/server/cluster/impl/ClusterConnectionImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -225,7 +225,7 @@
if (managementService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), name);
+ props.putSimpleStringProperty(new SimpleString("name"), name);
Notification notification = new Notification(nodeUUID.toString(), NotificationType.CLUSTER_CONNECTION_STARTED, props);
managementService.sendNotification(notification);
}
@@ -257,7 +257,7 @@
if (managementService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("name"), name);
+ props.putSimpleStringProperty(new SimpleString("name"), name);
Notification notification = new Notification(nodeUUID.toString(), NotificationType.CLUSTER_CONNECTION_STOPPED, props);
managementService.sendNotification(notification);
}
Modified: trunk/src/main/org/hornetq/core/server/group/impl/LocalGroupingHandler.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/group/impl/LocalGroupingHandler.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/server/group/impl/LocalGroupingHandler.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -107,11 +107,11 @@
public void send(final Response response, final int distance) throws Exception
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, response.getGroupId());
- props.putStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, response.getClusterName());
- props.putStringProperty(ManagementHelper.HDR_PROPOSAL_ALT_VALUE, response.getAlternativeClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, response.getGroupId());
+ props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, response.getClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_ALT_VALUE, response.getAlternativeClusterName());
props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, address);
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address);
props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance);
Notification notification = new Notification(null, NotificationType.PROPOSAL_RESPONSE, props);
managementService.sendNotification(notification);
@@ -145,8 +145,8 @@
{
if (notification.getType() == NotificationType.BINDING_REMOVED)
{
- SimpleString clusterName = (SimpleString)notification.getProperties()
- .getProperty(ManagementHelper.HDR_CLUSTER_NAME);
+ SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
+
List<GroupBinding> list = groupMap.remove(clusterName);
if (list != null)
{
Modified: trunk/src/main/org/hornetq/core/server/group/impl/RemoteGroupingHandler.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/group/impl/RemoteGroupingHandler.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/server/group/impl/RemoteGroupingHandler.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -89,13 +89,13 @@
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, proposal.getGroupId());
+ props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, proposal.getGroupId());
- props.putStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, proposal.getClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, proposal.getClusterName());
props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, address);
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address);
props.putIntProperty(ManagementHelper.HDR_DISTANCE, 0);
@@ -148,10 +148,10 @@
public Response receive(final Proposal proposal, final int distance) throws Exception
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, proposal.getGroupId());
- props.putStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, proposal.getClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_GROUP_ID, proposal.getGroupId());
+ props.putSimpleStringProperty(ManagementHelper.HDR_PROPOSAL_VALUE, proposal.getClusterName());
props.putIntProperty(ManagementHelper.HDR_BINDING_TYPE, BindingType.LOCAL_QUEUE_INDEX);
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, address);
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, address);
props.putIntProperty(ManagementHelper.HDR_DISTANCE, distance);
Notification notification = new Notification(null, NotificationType.PROPOSAL, props);
managementService.sendNotification(notification);
@@ -173,8 +173,7 @@
// removing the groupid if the binding has been removed
if (notification.getType() == NotificationType.BINDING_REMOVED)
{
- SimpleString clusterName = (SimpleString)notification.getProperties()
- .getProperty(ManagementHelper.HDR_CLUSTER_NAME);
+ SimpleString clusterName = notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME);
List<SimpleString> list = groupMap.remove(clusterName);
if (list != null)
{
Modified: trunk/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -308,13 +308,13 @@
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
- props.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
- props.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
- props.putStringProperty(ManagementHelper.HDR_FILTERSTRING, filter == null ? null : filter.getFilterString());
+ props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filter == null ? null : filter.getFilterString());
props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
Modified: trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/core/server/impl/ServerSessionImpl.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -388,11 +388,11 @@
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ADDRESS, binding.getAddress());
- props.putStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_CLUSTER_NAME, binding.getClusterName());
- props.putStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
+ props.putSimpleStringProperty(ManagementHelper.HDR_ROUTING_NAME, binding.getRoutingName());
props.putIntProperty(ManagementHelper.HDR_DISTANCE, binding.getDistance());
@@ -402,7 +402,7 @@
if (filterString != null)
{
- props.putStringProperty(ManagementHelper.HDR_FILTERSTRING, filterString);
+ props.putSimpleStringProperty(ManagementHelper.HDR_FILTERSTRING, filterString);
}
Notification notification = new Notification(null, CONSUMER_CREATED, props);
Modified: trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -315,8 +315,8 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName()));
- props.putStringProperty(new SimpleString("host"), new SimpleString(host));
+ props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName()));
+ props.putSimpleStringProperty(new SimpleString("host"), new SimpleString(host));
props.putIntProperty(new SimpleString("port"), port);
Notification notification = new Notification(null, NotificationType.ACCEPTOR_STARTED, props);
notificationService.sendNotification(notification);
@@ -387,8 +387,8 @@
if (notificationService != null)
{
TypedProperties props = new TypedProperties();
- props.putStringProperty(new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName()));
- props.putStringProperty(new SimpleString("host"), new SimpleString(host));
+ props.putSimpleStringProperty(new SimpleString("factory"), new SimpleString(NettyAcceptorFactory.class.getName()));
+ props.putSimpleStringProperty(new SimpleString("host"), new SimpleString(host));
props.putIntProperty(new SimpleString("port"), port);
Notification notification = new Notification(null, NotificationType.ACCEPTOR_STOPPED, props);
try
Modified: trunk/src/main/org/hornetq/jms/client/HornetQMapMessage.java
===================================================================
--- trunk/src/main/org/hornetq/jms/client/HornetQMapMessage.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/jms/client/HornetQMapMessage.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -25,6 +25,7 @@
import org.hornetq.core.client.ClientMessage;
import org.hornetq.core.client.ClientSession;
+import org.hornetq.core.message.PropertyConversionException;
import org.hornetq.utils.SimpleString;
import org.hornetq.utils.TypedProperties;
@@ -153,7 +154,7 @@
public void setString(final String name, final String value) throws JMSException
{
checkName(name);
- map.putStringProperty(new SimpleString(name), value == null ? null : new SimpleString(value));
+ map.putSimpleStringProperty(new SimpleString(name), value == null ? null : new SimpleString(value));
}
public void setBytes(final String name, final byte[] value) throws JMSException
@@ -195,7 +196,7 @@
else if (value instanceof Double)
map.putDoubleProperty(key, (Double)value);
else if (value instanceof String)
- map.putStringProperty(key, new SimpleString((String)value));
+ map.putSimpleStringProperty(key, new SimpleString((String)value));
else if (value instanceof byte[])
map.putBytesProperty(key, (byte[]) value);
else
@@ -204,197 +205,132 @@
public boolean getBoolean(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return Boolean.valueOf(null).booleanValue();
-
- if (value instanceof Boolean)
- return ((Boolean) value).booleanValue();
- else if (value instanceof SimpleString)
- return Boolean.valueOf(((SimpleString) value).toString()).booleanValue();
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getBooleanProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public byte getByte(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return Byte.parseByte(null);
-
- if (value instanceof Byte)
- return ((Byte) value).byteValue();
- else if (value instanceof SimpleString)
- return Byte.parseByte(((SimpleString) value).toString());
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getByteProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public short getShort(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return Short.parseShort(null);
-
- if (value instanceof Byte)
- return ((Byte) value).shortValue();
- else if (value instanceof Short)
- return ((Short) value).shortValue();
- else if (value instanceof SimpleString)
- return Short.parseShort(((SimpleString) value).toString());
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getShortProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public char getChar(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- throw new NullPointerException("Invalid conversion");
-
- if (value instanceof Character)
- return ((Character) value).charValue();
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getCharProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public int getInt(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return Integer.parseInt(null);
-
- if (value instanceof Byte)
- return ((Byte) value).intValue();
- else if (value instanceof Short)
- return ((Short) value).intValue();
- else if (value instanceof Integer)
- return ((Integer) value).intValue();
- else if (value instanceof SimpleString)
- return Integer.parseInt(((SimpleString) value).toString());
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getIntProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public long getLong(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return Long.parseLong(null);
-
- if (value instanceof Byte)
- return ((Byte) value).longValue();
- else if (value instanceof Short)
- return ((Short) value).longValue();
- else if (value instanceof Integer)
- return ((Integer) value).longValue();
- else if (value instanceof Long)
- return ((Long) value).longValue();
- else if (value instanceof SimpleString)
- return Long.parseLong(((SimpleString) value).toString());
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getLongProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public float getFloat(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return Float.parseFloat(null);
-
- if (value instanceof Float)
- return ((Float) value).floatValue();
- else if (value instanceof SimpleString)
- return Float.parseFloat(((SimpleString) value).toString());
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getFloatProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public double getDouble(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return Double.parseDouble(null);
-
- if (value instanceof Float)
- return ((Float) value).doubleValue();
- else if (value instanceof Double)
- return ((Double) value).doubleValue();
- else if (value instanceof SimpleString)
- return Double.parseDouble(((SimpleString) value).toString());
- else
- throw new MessageFormatException("Invalid conversion");
+ try
+ {
+ return map.getDoubleProperty(new SimpleString(name));
+ }
+ catch (PropertyConversionException e)
+ {
+ throw new MessageFormatException(e.getMessage());
+ }
}
public String getString(final String name) throws JMSException
{
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return null;
-
- if (value instanceof SimpleString)
+ try
{
- return ((SimpleString) value).toString();
- }
- else if (value instanceof Boolean)
- {
- return value.toString();
+ SimpleString str = map.getSimpleStringProperty(new SimpleString(name));
+ if (str == null)
+ {
+ return null;
+ }
+ else
+ {
+ return str.toString();
+ }
}
- else if (value instanceof Byte)
+ catch (PropertyConversionException e)
{
- return value.toString();
+ throw new MessageFormatException(e.getMessage());
}
- else if (value instanceof Short)
+ }
+
+ public byte[] getBytes(final String name) throws JMSException
+ {
+ try
{
- return value.toString();
+ return map.getBytesProperty(new SimpleString(name));
}
- else if (value instanceof Character)
+ catch (PropertyConversionException e)
{
- return value.toString();
+ throw new MessageFormatException(e.getMessage());
}
- else if (value instanceof Integer)
- {
- return value.toString();
- }
- else if (value instanceof Long)
- {
- return value.toString();
- }
- else if (value instanceof Float)
- {
- return value.toString();
- }
- else if (value instanceof Double)
- {
- return value.toString();
- }
- else
- {
- throw new MessageFormatException("Invalid conversion");
- }
}
- public byte[] getBytes(final String name) throws JMSException
- {
- Object value = map.getProperty(new SimpleString(name));
-
- if (value == null)
- return null;
- if (value instanceof byte[])
- return (byte[]) value;
- else
- throw new MessageFormatException("Invalid conversion");
- }
-
public Object getObject(final String name) throws JMSException
{
Object val = map.getProperty(new SimpleString(name));
Modified: trunk/src/main/org/hornetq/utils/TypedProperties.java
===================================================================
--- trunk/src/main/org/hornetq/utils/TypedProperties.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/src/main/org/hornetq/utils/TypedProperties.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -41,6 +41,7 @@
import java.util.Map.Entry;
import org.hornetq.core.logging.Logger;
+import org.hornetq.core.message.PropertyConversionException;
import org.hornetq.core.remoting.spi.HornetQBuffer;
/**
@@ -119,7 +120,7 @@
doPutValue(key, new DoubleValue(value));
}
- public void putStringProperty(final SimpleString key, final SimpleString value)
+ public void putSimpleStringProperty(final SimpleString key, final SimpleString value)
{
checkCreateProperties();
doPutValue(key, value == null ? new NullValue() : new StringValue(value));
@@ -151,6 +152,262 @@
return doGetProperty(key);
}
+ public Boolean getBooleanProperty(final SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return Boolean.valueOf(null);
+ }
+ else if (value instanceof Boolean)
+ {
+ return (Boolean)value;
+ }
+ else if (value instanceof SimpleString)
+ {
+ return Boolean.valueOf(((SimpleString)value).toString()).booleanValue();
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
+ public Byte getByteProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return Byte.valueOf(null);
+ }
+ else if (value instanceof Byte)
+ {
+ return (Byte)value;
+ }
+ else if (value instanceof SimpleString)
+ {
+ return Byte.parseByte(((SimpleString)value).toString());
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
+ public Character getCharProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ throw new NullPointerException("Invalid conversion");
+
+ if (value instanceof Character)
+ return ((Character) value).charValue();
+ else
+ throw new PropertyConversionException("Invalid conversion");
+ }
+
+ public byte[] getBytesProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return null;
+ }
+ else if (value instanceof byte[])
+ {
+ return (byte[])value;
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
+ public Double getDoubleProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return Double.valueOf(null);
+ }
+ else if (value instanceof Float)
+ {
+ return ((Float)value).doubleValue();
+ }
+ else if (value instanceof Double)
+ {
+ return (Double)value;
+ }
+ else if (value instanceof SimpleString)
+ {
+ return Double.parseDouble(((SimpleString)value).toString());
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
+ public Integer getIntProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return Integer.valueOf(null);
+ }
+ else if (value instanceof Integer)
+ {
+ return (Integer)value;
+ }
+ else if (value instanceof Byte)
+ {
+ return ((Byte)value).intValue();
+ }
+ else if (value instanceof Short)
+ {
+ return ((Short)value).intValue();
+ }
+ else if (value instanceof SimpleString)
+ {
+ return Integer.parseInt(((SimpleString)value).toString());
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
+ public Long getLongProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return Long.valueOf(null);
+ }
+ else if (value instanceof Long)
+ {
+ return (Long)value;
+ }
+ else if (value instanceof Byte)
+ {
+ return ((Byte)value).longValue();
+ }
+ else if (value instanceof Short)
+ {
+ return ((Short)value).longValue();
+ }
+ else if (value instanceof Integer)
+ {
+ return ((Integer)value).longValue();
+ }
+ else if (value instanceof SimpleString)
+ {
+ return Long.parseLong(((SimpleString)value).toString());
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
+ public Short getShortProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return Short.valueOf(null);
+ }
+ else if (value instanceof Byte)
+ {
+ return ((Byte)value).shortValue();
+ }
+ else if (value instanceof Short)
+ {
+ return (Short)value;
+ }
+ else if (value instanceof SimpleString)
+ {
+ return Short.parseShort(((SimpleString)value).toString());
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid Conversion.");
+ }
+ }
+
+ public Float getFloatProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+ if (value == null)
+ {
+ return Float.valueOf(null);
+ }
+
+ if (value instanceof Float)
+ {
+ return ((Float)value).floatValue();
+ }
+ else if (value instanceof SimpleString)
+ {
+ return Float.parseFloat(((SimpleString)value).toString());
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
+ public SimpleString getSimpleStringProperty(SimpleString key) throws PropertyConversionException
+ {
+ Object value = doGetProperty(key);
+
+ if (value == null)
+ {
+ return null;
+ }
+
+ if (value instanceof SimpleString)
+ {
+ return (SimpleString)value;
+ }
+ else if (value instanceof Boolean)
+ {
+ return new SimpleString(value.toString());
+ }
+ else if (value instanceof Character)
+ {
+ return new SimpleString(value.toString());
+ }
+ else if (value instanceof Byte)
+ {
+ return new SimpleString(value.toString());
+ }
+ else if (value instanceof Short)
+ {
+ return new SimpleString(value.toString());
+ }
+ else if (value instanceof Integer)
+ {
+ return new SimpleString(value.toString());
+ }
+ else if (value instanceof Long)
+ {
+ return new SimpleString(value.toString());
+ }
+ else if (value instanceof Float)
+ {
+ return new SimpleString(value.toString());
+ }
+ else if (value instanceof Double)
+ {
+ return new SimpleString(value.toString());
+ }
+ else
+ {
+ throw new PropertyConversionException("Invalid conversion");
+ }
+ }
+
public Object removeProperty(final SimpleString key)
{
return doRemoveProperty(key);
Modified: trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/tests/src/org/hornetq/tests/integration/cluster/distribution/ClusteredGroupingTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -640,14 +640,14 @@
{
if(NotificationType.BINDING_REMOVED == notification.getType())
{
- if(notification.getProperties().getProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
+ if(notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
{
latch.countDown();
}
}
else if(NotificationType.BINDING_ADDED == notification.getType())
{
- if(notification.getProperties().getProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
+ if(notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
{
latch.countDown();
}
@@ -737,14 +737,14 @@
{
if(NotificationType.BINDING_REMOVED == notification.getType())
{
- if(notification.getProperties().getProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
+ if(notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
{
latch.countDown();
}
}
else if(NotificationType.BINDING_ADDED == notification.getType())
{
- if(notification.getProperties().getProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
+ if(notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
{
latch.countDown();
}
@@ -831,14 +831,14 @@
{
if(NotificationType.BINDING_REMOVED == notification.getType())
{
- if(notification.getProperties().getProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
+ if(notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
{
latch.countDown();
}
}
else if(NotificationType.BINDING_ADDED == notification.getType())
{
- if(notification.getProperties().getProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
+ if(notification.getProperties().getSimpleStringProperty(ManagementHelper.HDR_ADDRESS).toString().equals("queues.testaddress"))
{
latch.countDown();
}
Modified: trunk/tests/src/org/hornetq/tests/integration/discovery/DiscoveryTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/discovery/DiscoveryTest.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/tests/src/org/hornetq/tests/integration/discovery/DiscoveryTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -869,14 +869,14 @@
assertEquals(1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(0);
assertEquals(NotificationType.DISCOVERY_GROUP_STARTED, notif.getType());
- assertEquals(dg.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(dg.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
dg.stop();
assertEquals(2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(1);
assertEquals(NotificationType.DISCOVERY_GROUP_STOPPED, notif.getType());
- assertEquals(dg.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(dg.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
}
public void testBroadcastGroupNotifications() throws Exception
@@ -898,14 +898,14 @@
assertEquals(1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(0);
assertEquals(NotificationType.BROADCAST_GROUP_STARTED, notif.getType());
- assertEquals(bg.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(bg.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
bg.stop();
assertEquals(2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(1);
assertEquals(NotificationType.BROADCAST_GROUP_STOPPED, notif.getType());
- assertEquals(bg.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(bg.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
}
private TransportConfiguration generateTC()
Modified: trunk/tests/src/org/hornetq/tests/integration/management/AcceptorControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/management/AcceptorControlTest.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/tests/src/org/hornetq/tests/integration/management/AcceptorControlTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -164,14 +164,14 @@
assertEquals(1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(0);
assertEquals(NotificationType.ACCEPTOR_STOPPED, notif.getType());
- assertEquals(InVMAcceptorFactory.class.getName(), (notif.getProperties().getProperty(new SimpleString("factory")).toString()));
+ assertEquals(InVMAcceptorFactory.class.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString()));
acceptorControl.start();
assertEquals(2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(1);
assertEquals(NotificationType.ACCEPTOR_STARTED, notif.getType());
- assertEquals(InVMAcceptorFactory.class.getName(), (notif.getProperties().getProperty(new SimpleString("factory")).toString()));
+ assertEquals(InVMAcceptorFactory.class.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("factory")).toString()));
}
// Package protected ---------------------------------------------
Modified: trunk/tests/src/org/hornetq/tests/integration/management/BridgeControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/management/BridgeControlTest.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/tests/src/org/hornetq/tests/integration/management/BridgeControlTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -120,14 +120,14 @@
assertEquals(1, notifListener.getNotifications().size());
Notification notif = notifListener.getNotifications().get(0);
assertEquals(NotificationType.BRIDGE_STOPPED, notif.getType());
- assertEquals(bridgeControl.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(bridgeControl.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
bridgeControl.start();
assertEquals(2, notifListener.getNotifications().size());
notif = notifListener.getNotifications().get(1);
assertEquals(NotificationType.BRIDGE_STARTED, notif.getType());
- assertEquals(bridgeControl.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(bridgeControl.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
}
// Package protected ---------------------------------------------
Modified: trunk/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/tests/src/org/hornetq/tests/integration/management/ClusterConnectionControlTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -163,14 +163,14 @@
assertTrue(notifListener.getNotifications().size() > 0);
Notification notif = notifListener.getNotifications().get(notifListener.getNotifications().size() - 1);
assertEquals(NotificationType.CLUSTER_CONNECTION_STOPPED, notif.getType());
- assertEquals(clusterConnectionControl.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(clusterConnectionControl.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
clusterConnectionControl.start();
assertTrue(notifListener.getNotifications().size() > 0);
notif = notifListener.getNotifications().get(notifListener.getNotifications().size() - 1);
assertEquals(NotificationType.CLUSTER_CONNECTION_STARTED, notif.getType());
- assertEquals(clusterConnectionControl.getName(), (notif.getProperties().getProperty(new SimpleString("name")).toString()));
+ assertEquals(clusterConnectionControl.getName(), (notif.getProperties().getSimpleStringProperty(new SimpleString("name")).toString()));
}
// Package protected ---------------------------------------------
Deleted: trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -1,343 +0,0 @@
-/*
- * Copyright 2009 Red Hat, Inc.
- * Red Hat 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.hornetq.tests.unit.core.message.impl;
-
-import static org.hornetq.tests.util.RandomUtil.randomBoolean;
-import static org.hornetq.tests.util.RandomUtil.randomByte;
-import static org.hornetq.tests.util.RandomUtil.randomDouble;
-import static org.hornetq.tests.util.RandomUtil.randomFloat;
-import static org.hornetq.tests.util.RandomUtil.randomInt;
-import static org.hornetq.tests.util.RandomUtil.randomShort;
-import static org.hornetq.tests.util.RandomUtil.randomSimpleString;
-import static org.hornetq.tests.util.UnitTestCase.assertEqualsByteArrays;
-import junit.framework.TestCase;
-
-import org.hornetq.core.client.impl.ClientMessageImpl;
-import org.hornetq.core.message.Message;
-import org.hornetq.core.message.PropertyConversionException;
-import org.hornetq.tests.util.RandomUtil;
-import org.hornetq.utils.SimpleString;
-
-/**
- * A MessagePropertyConversionTest
- *
- * @author jmesnil
- *
- *
- */
-public class MessagePropertyConversionTest extends TestCase
-{
-
- // Constants -----------------------------------------------------
-
- // Attributes ----------------------------------------------------
-
- private Message msg;
-
- private SimpleString key;
-
- private SimpleString unknownKey = new SimpleString("this.key.is.never.used");
-
- // Static --------------------------------------------------------
-
- // Constructors --------------------------------------------------
-
- // Public --------------------------------------------------------
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- key = randomSimpleString();
- msg = new ClientMessageImpl(false);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- key = null;
- msg = null;
-
- super.tearDown();
- }
-
- public void testBooleanProperty() throws Exception
- {
- Boolean val = randomBoolean();
- msg.putBooleanProperty(key, val);
-
- assertEquals(val, msg.getBooleanProperty(key));
- assertEquals(Boolean.toString(val), msg.getStringProperty(key));
-
- msg.putStringProperty(key, new SimpleString(Boolean.toString(val)));
- assertEquals(val, msg.getBooleanProperty(key));
-
- try
- {
- msg.putByteProperty(key, randomByte());
- msg.getBooleanProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- assertFalse(msg.getBooleanProperty(unknownKey));
- }
-
- public void testByteProperty() throws Exception
- {
- Byte val = randomByte();
- msg.putByteProperty(key, val);
-
- assertEquals(val, msg.getByteProperty(key));
- assertEquals(Byte.toString(val), msg.getStringProperty(key));
-
- msg.putStringProperty(key, new SimpleString(Byte.toString(val)));
- assertEquals(val, msg.getByteProperty(key));
-
- try
- {
- msg.putBooleanProperty(key, randomBoolean());
- msg.getByteProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- try
- {
- msg.getByteProperty(unknownKey);
- fail();
- }
- catch (NumberFormatException e)
- {
- }
- }
-
- public void testIntProperty() throws Exception
- {
- Integer val = randomInt();
- msg.putIntProperty(key, val);
-
- assertEquals(val, msg.getIntProperty(key));
- assertEquals(Integer.toString(val), msg.getStringProperty(key));
-
- msg.putStringProperty(key, new SimpleString(Integer.toString(val)));
- assertEquals(val, msg.getIntProperty(key));
-
- Byte byteVal = randomByte();
- msg.putByteProperty(key, byteVal);
- assertEquals(Integer.valueOf(byteVal), msg.getIntProperty(key));
-
- try
- {
- msg.putBooleanProperty(key, randomBoolean());
- msg.getIntProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- try
- {
- msg.getIntProperty(unknownKey);
- fail();
- }
- catch (NumberFormatException e)
- {
- }
- }
-
- public void testLongProperty() throws Exception
- {
- Long val = RandomUtil.randomLong();
- msg.putLongProperty(key, val);
-
- assertEquals(val, msg.getLongProperty(key));
- assertEquals(Long.toString(val), msg.getStringProperty(key));
-
- msg.putStringProperty(key, new SimpleString(Long.toString(val)));
- assertEquals(val, msg.getLongProperty(key));
-
- Byte byteVal = randomByte();
- msg.putByteProperty(key, byteVal);
- assertEquals(Long.valueOf(byteVal), msg.getLongProperty(key));
-
- Short shortVal = randomShort();
- msg.putShortProperty(key, shortVal);
- assertEquals(Long.valueOf(shortVal), msg.getLongProperty(key));
-
- Integer intVal = randomInt();
- msg.putIntProperty(key, intVal);
- assertEquals(Long.valueOf(intVal), msg.getLongProperty(key));
-
- try
- {
- msg.putBooleanProperty(key, randomBoolean());
- msg.getLongProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- try
- {
- msg.getLongProperty(unknownKey);
- fail();
- }
- catch (NumberFormatException e)
- {
- }
- }
-
- public void testDoubleProperty() throws Exception
- {
- Double val = randomDouble();
- msg.putDoubleProperty(key, val);
-
- assertEquals(val, msg.getDoubleProperty(key));
- assertEquals(Double.toString(val), msg.getStringProperty(key));
-
- msg.putStringProperty(key, new SimpleString(Double.toString(val)));
- assertEquals(val, msg.getDoubleProperty(key));
-
- try
- {
- msg.putBooleanProperty(key, randomBoolean());
- msg.getDoubleProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- try
- {
- msg.getDoubleProperty(unknownKey);
- fail();
- }
- catch (Exception e)
- {
- }
- }
-
- public void testFloatProperty() throws Exception
- {
- Float val = randomFloat();
- msg.putFloatProperty(key, val);
-
- assertEquals(val, msg.getFloatProperty(key));
- assertEquals(Double.valueOf(val), msg.getDoubleProperty(key));
- assertEquals(Float.toString(val), msg.getStringProperty(key));
-
- msg.putStringProperty(key, new SimpleString(Float.toString(val)));
- assertEquals(val, msg.getFloatProperty(key));
-
- try
- {
- msg.putBooleanProperty(key, randomBoolean());
- msg.getFloatProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- try
- {
- msg.getFloatProperty(unknownKey);
- fail();
- }
- catch (Exception e)
- {
- }
- }
-
- public void testShortProperty() throws Exception
- {
- Short val = randomShort();
- msg.putShortProperty(key, val);
-
- assertEquals(val, msg.getShortProperty(key));
- assertEquals(Integer.valueOf(val), msg.getIntProperty(key));
- assertEquals(Short.toString(val), msg.getStringProperty(key));
-
- msg.putStringProperty(key, new SimpleString(Short.toString(val)));
- assertEquals(val, msg.getShortProperty(key));
-
- Byte byteVal = randomByte();
- msg.putByteProperty(key, byteVal);
- assertEquals(Short.valueOf(byteVal), msg.getShortProperty(key));
-
- try
- {
- msg.putBooleanProperty(key, randomBoolean());
- msg.getShortProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- try
- {
- msg.getShortProperty(unknownKey);
- fail();
- }
- catch (NumberFormatException e)
- {
- }
- }
-
- public void testStringProperty() throws Exception
- {
- SimpleString strVal = randomSimpleString();
- msg.putStringProperty(key, strVal);
- assertEquals(strVal.toString(), msg.getStringProperty(key));
- }
-
- public void testBytesProperty() throws Exception
- {
- byte[] val = RandomUtil.randomBytes();
- msg.putBytesProperty(key, val);
-
- assertEqualsByteArrays(val, msg.getBytesProperty(key));
-
- try
- {
- msg.putBooleanProperty(key, randomBoolean());
- msg.getBytesProperty(key);
- fail();
- }
- catch (PropertyConversionException e)
- {
- }
-
- assertNull(msg.getBytesProperty(unknownKey));
- }
-
- // Package protected ---------------------------------------------
-
- // Protected -----------------------------------------------------
-
- // Private -------------------------------------------------------
-
- // Inner classes -------------------------------------------------
-
-}
Copied: trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesConversionTest.java (from rev 8234, trunk/tests/src/org/hornetq/tests/unit/core/message/impl/MessagePropertyConversionTest.java)
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesConversionTest.java (rev 0)
+++ trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesConversionTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -0,0 +1,370 @@
+/*
+ * Copyright 2009 Red Hat, Inc.
+ * Red Hat 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.hornetq.tests.unit.util;
+
+import static org.hornetq.tests.util.RandomUtil.randomBoolean;
+import static org.hornetq.tests.util.RandomUtil.randomByte;
+import static org.hornetq.tests.util.RandomUtil.randomDouble;
+import static org.hornetq.tests.util.RandomUtil.randomFloat;
+import static org.hornetq.tests.util.RandomUtil.randomInt;
+import static org.hornetq.tests.util.RandomUtil.randomShort;
+import static org.hornetq.tests.util.RandomUtil.randomSimpleString;
+import static org.hornetq.tests.util.UnitTestCase.assertEqualsByteArrays;
+import junit.framework.TestCase;
+
+import org.hornetq.core.message.PropertyConversionException;
+import org.hornetq.tests.util.RandomUtil;
+import org.hornetq.utils.SimpleString;
+import org.hornetq.utils.TypedProperties;
+
+/**
+ * A TypedPropertiesConversionTest
+ *
+ * @author jmesnil
+ *
+ *
+ */
+public class TypedPropertiesConversionTest extends TestCase
+{
+
+ // Constants -----------------------------------------------------
+
+ // Attributes ----------------------------------------------------
+
+ private TypedProperties props;
+
+ private SimpleString key;
+
+ private SimpleString unknownKey = new SimpleString("this.key.is.never.used");
+
+ // Static --------------------------------------------------------
+
+ // Constructors --------------------------------------------------
+
+ // Public --------------------------------------------------------
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ key = randomSimpleString();
+ props = new TypedProperties();
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ key = null;
+ props = null;
+
+ super.tearDown();
+ }
+
+ public void testBooleanProperty() throws Exception
+ {
+ Boolean val = randomBoolean();
+ props.putBooleanProperty(key, val);
+
+ assertEquals(val, props.getBooleanProperty(key));
+ assertEquals(new SimpleString(Boolean.toString(val)), props.getSimpleStringProperty(key));
+
+ props.putSimpleStringProperty(key, new SimpleString(Boolean.toString(val)));
+ assertEquals(val, props.getBooleanProperty(key));
+
+ try
+ {
+ props.putByteProperty(key, randomByte());
+ props.getBooleanProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ assertFalse(props.getBooleanProperty(unknownKey));
+ }
+
+ public void testCharProperty() throws Exception
+ {
+ Character val = RandomUtil.randomChar();
+ props.putCharProperty(key, val);
+
+ assertEquals(val, props.getCharProperty(key));
+ assertEquals(new SimpleString(Character.toString(val)), props.getSimpleStringProperty(key));
+
+ try
+ {
+ props.putByteProperty(key, randomByte());
+ props.getCharProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ try
+ {
+ props.getCharProperty(unknownKey);
+ fail();
+ }
+ catch (NullPointerException e)
+ {
+ }
+ }
+
+ public void testByteProperty() throws Exception
+ {
+ Byte val = randomByte();
+ props.putByteProperty(key, val);
+
+ assertEquals(val, props.getByteProperty(key));
+ assertEquals(new SimpleString(Byte.toString(val)), props.getSimpleStringProperty(key));
+
+ props.putSimpleStringProperty(key, new SimpleString(Byte.toString(val)));
+ assertEquals(val, props.getByteProperty(key));
+
+ try
+ {
+ props.putBooleanProperty(key, randomBoolean());
+ props.getByteProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ try
+ {
+ props.getByteProperty(unknownKey);
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
+
+ public void testIntProperty() throws Exception
+ {
+ Integer val = randomInt();
+ props.putIntProperty(key, val);
+
+ assertEquals(val, props.getIntProperty(key));
+ assertEquals(new SimpleString(Integer.toString(val)), props.getSimpleStringProperty(key));
+
+ props.putSimpleStringProperty(key, new SimpleString(Integer.toString(val)));
+ assertEquals(val, props.getIntProperty(key));
+
+ Byte byteVal = randomByte();
+ props.putByteProperty(key, byteVal);
+ assertEquals(Integer.valueOf(byteVal), props.getIntProperty(key));
+
+ try
+ {
+ props.putBooleanProperty(key, randomBoolean());
+ props.getIntProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ try
+ {
+ props.getIntProperty(unknownKey);
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
+
+ public void testLongProperty() throws Exception
+ {
+ Long val = RandomUtil.randomLong();
+ props.putLongProperty(key, val);
+
+ assertEquals(val, props.getLongProperty(key));
+ assertEquals(new SimpleString(Long.toString(val)), props.getSimpleStringProperty(key));
+
+ props.putSimpleStringProperty(key, new SimpleString(Long.toString(val)));
+ assertEquals(val, props.getLongProperty(key));
+
+ Byte byteVal = randomByte();
+ props.putByteProperty(key, byteVal);
+ assertEquals(Long.valueOf(byteVal), props.getLongProperty(key));
+
+ Short shortVal = randomShort();
+ props.putShortProperty(key, shortVal);
+ assertEquals(Long.valueOf(shortVal), props.getLongProperty(key));
+
+ Integer intVal = randomInt();
+ props.putIntProperty(key, intVal);
+ assertEquals(Long.valueOf(intVal), props.getLongProperty(key));
+
+ try
+ {
+ props.putBooleanProperty(key, randomBoolean());
+ props.getLongProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ try
+ {
+ props.getLongProperty(unknownKey);
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
+
+ public void testDoubleProperty() throws Exception
+ {
+ Double val = randomDouble();
+ props.putDoubleProperty(key, val);
+
+ assertEquals(val, props.getDoubleProperty(key));
+ assertEquals(new SimpleString(Double.toString(val)), props.getSimpleStringProperty(key));
+
+ props.putSimpleStringProperty(key, new SimpleString(Double.toString(val)));
+ assertEquals(val, props.getDoubleProperty(key));
+
+ try
+ {
+ props.putBooleanProperty(key, randomBoolean());
+ props.getDoubleProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ try
+ {
+ props.getDoubleProperty(unknownKey);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void testFloatProperty() throws Exception
+ {
+ Float val = randomFloat();
+ props.putFloatProperty(key, val);
+
+ assertEquals(val, props.getFloatProperty(key));
+ assertEquals(Double.valueOf(val), props.getDoubleProperty(key));
+ assertEquals(new SimpleString(Float.toString(val)), props.getSimpleStringProperty(key));
+
+ props.putSimpleStringProperty(key, new SimpleString(Float.toString(val)));
+ assertEquals(val, props.getFloatProperty(key));
+
+ try
+ {
+ props.putBooleanProperty(key, randomBoolean());
+ props.getFloatProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ try
+ {
+ props.getFloatProperty(unknownKey);
+ fail();
+ }
+ catch (Exception e)
+ {
+ }
+ }
+
+ public void testShortProperty() throws Exception
+ {
+ Short val = randomShort();
+ props.putShortProperty(key, val);
+
+ assertEquals(val, props.getShortProperty(key));
+ assertEquals(Integer.valueOf(val), props.getIntProperty(key));
+ assertEquals(new SimpleString(Short.toString(val)), props.getSimpleStringProperty(key));
+
+ props.putSimpleStringProperty(key, new SimpleString(Short.toString(val)));
+ assertEquals(val, props.getShortProperty(key));
+
+ Byte byteVal = randomByte();
+ props.putByteProperty(key, byteVal);
+ assertEquals(Short.valueOf(byteVal), props.getShortProperty(key));
+
+ try
+ {
+ props.putBooleanProperty(key, randomBoolean());
+ props.getShortProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ try
+ {
+ props.getShortProperty(unknownKey);
+ fail();
+ }
+ catch (NumberFormatException e)
+ {
+ }
+ }
+
+ public void testSimpleStringProperty() throws Exception
+ {
+ SimpleString strVal = randomSimpleString();
+ props.putSimpleStringProperty(key, strVal);
+ assertEquals(strVal, props.getSimpleStringProperty(key));
+ }
+
+ public void testBytesProperty() throws Exception
+ {
+ byte[] val = RandomUtil.randomBytes();
+ props.putBytesProperty(key, val);
+
+ assertEqualsByteArrays(val, props.getBytesProperty(key));
+
+ try
+ {
+ props.putBooleanProperty(key, randomBoolean());
+ props.getBytesProperty(key);
+ fail();
+ }
+ catch (PropertyConversionException e)
+ {
+ }
+
+ assertNull(props.getBytesProperty(unknownKey));
+ }
+
+ // Package protected ---------------------------------------------
+
+ // Protected -----------------------------------------------------
+
+ // Private -------------------------------------------------------
+
+ // Inner classes -------------------------------------------------
+
+}
Modified: trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java
===================================================================
--- trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java 2009-11-06 12:02:52 UTC (rev 8238)
+++ trunk/tests/src/org/hornetq/tests/unit/util/TypedPropertiesTest.java 2009-11-06 13:31:14 UTC (rev 8239)
@@ -81,7 +81,7 @@
public void testCopyContructor() throws Exception
{
- props.putStringProperty(key, randomSimpleString());
+ props.putSimpleStringProperty(key, randomSimpleString());
TypedProperties copy = new TypedProperties(props);
@@ -94,7 +94,7 @@
public void testRemove() throws Exception
{
- props.putStringProperty(key, randomSimpleString());
+ props.putSimpleStringProperty(key, randomSimpleString());
assertTrue(props.containsProperty(key));
assertNotNull(props.getProperty(key));
@@ -107,7 +107,7 @@
public void testClear() throws Exception
{
- props.putStringProperty(key, randomSimpleString());
+ props.putSimpleStringProperty(key, randomSimpleString());
assertTrue(props.containsProperty(key));
assertNotNull(props.getProperty(key));
@@ -143,38 +143,11 @@
public void testNullProperty() throws Exception
{
- props.putStringProperty(key, null);
+ props.putSimpleStringProperty(key, null);
assertTrue(props.containsProperty(key));
assertNull(props.getProperty(key));
}
- public void testBooleanProperty() throws Exception
- {
- props.putBooleanProperty(key, true);
- boolean bool = (Boolean) props.getProperty(key);
- assertEquals(true, bool);
-
- props.putBooleanProperty(key, false);
- bool = (Boolean) props.getProperty(key);
- assertEquals(false, bool);
- }
-
- public void testByteProperty() throws Exception
- {
- byte b = randomByte();
- props.putByteProperty(key, b);
- byte bb = (Byte) props.getProperty(key);
- assertEquals(b, bb);
- }
-
- public void testBytesProperty() throws Exception
- {
- byte[] b = randomBytes();
- props.putBytesProperty(key, b);
- byte[] bb = (byte[]) props.getProperty(key);
- assertEqualsByteArrays(b, bb);
- }
-
public void testBytesPropertyWithNull() throws Exception
{
props.putBytesProperty(key, null);
@@ -184,63 +157,6 @@
assertNull(bb);
}
- public void testFloatProperty() throws Exception
- {
- float f = randomFloat();
- props.putFloatProperty(key, f);
- float ff = (Float) props.getProperty(key);
- assertEquals(f, ff);
- }
-
- public void testDoubleProperty() throws Exception
- {
- double d = randomDouble();
- props.putDoubleProperty(key, d);
- double dd = (Double) props.getProperty(key);
- assertEquals(d, dd);
- }
-
- public void testShortProperty() throws Exception
- {
- short s = randomShort();
- props.putShortProperty(key, s);
- short ss = (Short) props.getProperty(key);
- assertEquals(s, ss);
- }
-
- public void testIntProperty() throws Exception
- {
- int i = randomInt();
- props.putIntProperty(key, i);
- int ii = (Integer) props.getProperty(key);
- assertEquals(i, ii);
- }
-
- public void testLongProperty() throws Exception
- {
- long l = randomLong();
- props.putLongProperty(key, l);
- long ll = (Long) props.getProperty(key);
- assertEquals(l, ll);
- }
-
- public void testCharProperty() throws Exception
- {
- char c = randomChar();
- props.putCharProperty(key, c);
- char cc = (Character) props.getProperty(key);
- assertEquals(c, cc);
- }
-
- public void testSimpleString() throws Exception
- {
- props = new TypedProperties();
- SimpleString value = randomSimpleString();
- props.putStringProperty(key, value);
- SimpleString vv = (SimpleString)props.getProperty(key);
- assertEquals(value, vv);
- }
-
public void testTypedProperties() throws Exception
{
SimpleString longKey = randomSimpleString();
@@ -249,13 +165,13 @@
SimpleString simpleStringValue = randomSimpleString();
TypedProperties otherProps = new TypedProperties();
otherProps.putLongProperty(longKey, longValue);
- otherProps.putStringProperty(simpleStringKey, simpleStringValue);
+ otherProps.putSimpleStringProperty(simpleStringKey, simpleStringValue);
props.putTypedProperties(otherProps);
- long ll = (Long) props.getProperty(longKey);
+ long ll = props.getLongProperty(longKey);
assertEquals(longValue, ll);
- SimpleString ss = (SimpleString) props.getProperty(simpleStringKey);
+ SimpleString ss = props.getSimpleStringProperty(simpleStringKey);
assertEquals(simpleStringValue, ss);
}
@@ -289,10 +205,10 @@
props.putFloatProperty(randomSimpleString(), randomFloat());
props.putDoubleProperty(randomSimpleString(), randomDouble());
props.putCharProperty(randomSimpleString(), randomChar());
- props.putStringProperty(randomSimpleString(), randomSimpleString());
- props.putStringProperty(randomSimpleString(), null);
+ props.putSimpleStringProperty(randomSimpleString(), randomSimpleString());
+ props.putSimpleStringProperty(randomSimpleString(), null);
SimpleString keyToRemove = randomSimpleString();
- props.putStringProperty(keyToRemove, randomSimpleString());
+ props.putSimpleStringProperty(keyToRemove, randomSimpleString());
HornetQBuffer buffer = ChannelBuffers.dynamicBuffer(1024);
props.encode(buffer);
More information about the hornetq-commits
mailing list