use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class TypedPropertiesConversionTest method testLongProperty.
@Test
public void testLongProperty() throws Exception {
Long val = RandomUtil.randomLong();
props.putLongProperty(key, val);
Assert.assertEquals(val, props.getLongProperty(key));
Assert.assertEquals(new SimpleString(Long.toString(val)), props.getSimpleStringProperty(key));
props.putSimpleStringProperty(key, new SimpleString(Long.toString(val)));
Assert.assertEquals(val, props.getLongProperty(key));
Byte byteVal = RandomUtil.randomByte();
props.putByteProperty(key, byteVal);
Assert.assertEquals(Long.valueOf(byteVal), props.getLongProperty(key));
Short shortVal = RandomUtil.randomShort();
props.putShortProperty(key, shortVal);
Assert.assertEquals(Long.valueOf(shortVal), props.getLongProperty(key));
Integer intVal = RandomUtil.randomInt();
props.putIntProperty(key, intVal);
Assert.assertEquals(Long.valueOf(intVal), props.getLongProperty(key));
try {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getLongProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getLongProperty(unknownKey);
Assert.fail();
} catch (NumberFormatException e) {
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class TypedPropertiesConversionTest method testIntProperty.
@Test
public void testIntProperty() throws Exception {
Integer val = RandomUtil.randomInt();
props.putIntProperty(key, val);
Assert.assertEquals(val, props.getIntProperty(key));
Assert.assertEquals(new SimpleString(Integer.toString(val)), props.getSimpleStringProperty(key));
props.putSimpleStringProperty(key, new SimpleString(Integer.toString(val)));
Assert.assertEquals(val, props.getIntProperty(key));
Byte byteVal = RandomUtil.randomByte();
props.putByteProperty(key, byteVal);
Assert.assertEquals(Integer.valueOf(byteVal), props.getIntProperty(key));
try {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getIntProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getIntProperty(unknownKey);
Assert.fail();
} catch (NumberFormatException e) {
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class TypedPropertiesConversionTest method testByteProperty.
@Test
public void testByteProperty() throws Exception {
Byte val = RandomUtil.randomByte();
props.putByteProperty(key, val);
Assert.assertEquals(val, props.getByteProperty(key));
Assert.assertEquals(new SimpleString(Byte.toString(val)), props.getSimpleStringProperty(key));
props.putSimpleStringProperty(key, new SimpleString(Byte.toString(val)));
Assert.assertEquals(val, props.getByteProperty(key));
try {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getByteProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getByteProperty(unknownKey);
Assert.fail();
} catch (NumberFormatException e) {
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class ActiveMQJMSProducer method getPropertyNames.
@Override
public Set<String> getPropertyNames() {
try {
Set<SimpleString> simplePropNames = properties.getPropertyNames();
Set<String> propNames = new HashSet<>(simplePropNames.size());
for (SimpleString str : simplePropNames) {
propNames.add(str.toString());
}
return propNames;
} catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
} catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class ActiveMQJMSProducer method getObjectProperty.
@Override
public Object getObjectProperty(String name) {
try {
SimpleString key = new SimpleString(name);
Object property = properties.getProperty(key);
if (stringPropertyNames.contains(key)) {
property = property.toString();
}
return property;
} catch (ActiveMQPropertyConversionException ce) {
throw new MessageFormatRuntimeException(ce.getMessage());
} catch (RuntimeException e) {
throw new JMSRuntimeException(e.getMessage());
}
}
Aggregations