use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class TypedPropertiesConversionTest method testShortProperty.
@Test
public void testShortProperty() throws Exception {
Short val = RandomUtil.randomShort();
props.putShortProperty(key, val);
Assert.assertEquals(val, props.getShortProperty(key));
Assert.assertEquals(Integer.valueOf(val), props.getIntProperty(key));
Assert.assertEquals(new SimpleString(Short.toString(val)), props.getSimpleStringProperty(key));
props.putSimpleStringProperty(key, new SimpleString(Short.toString(val)));
Assert.assertEquals(val, props.getShortProperty(key));
Byte byteVal = RandomUtil.randomByte();
props.putByteProperty(key, byteVal);
Assert.assertEquals(Short.valueOf(byteVal), props.getShortProperty(key));
try {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getShortProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getShortProperty(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 testDoubleProperty.
@Test
public void testDoubleProperty() throws Exception {
Double val = RandomUtil.randomDouble();
props.putDoubleProperty(key, val);
Assert.assertEquals(val, props.getDoubleProperty(key));
Assert.assertEquals(new SimpleString(Double.toString(val)), props.getSimpleStringProperty(key));
props.putSimpleStringProperty(key, new SimpleString(Double.toString(val)));
Assert.assertEquals(val, props.getDoubleProperty(key));
try {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getDoubleProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getDoubleProperty(unknownKey);
Assert.fail();
} catch (Exception e) {
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class TypedPropertiesConversionTest method testBooleanProperty.
@Test
public void testBooleanProperty() throws Exception {
Boolean val = RandomUtil.randomBoolean();
props.putBooleanProperty(key, val);
Assert.assertEquals(val, props.getBooleanProperty(key));
Assert.assertEquals(new SimpleString(Boolean.toString(val)), props.getSimpleStringProperty(key));
props.putSimpleStringProperty(key, new SimpleString(Boolean.toString(val)));
Assert.assertEquals(val, props.getBooleanProperty(key));
try {
props.putByteProperty(key, RandomUtil.randomByte());
props.getBooleanProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
Assert.assertFalse(props.getBooleanProperty(unknownKey));
}
use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class TypedPropertiesConversionTest method testCharProperty.
@Test
public void testCharProperty() throws Exception {
Character val = RandomUtil.randomChar();
props.putCharProperty(key, val);
Assert.assertEquals(val, props.getCharProperty(key));
Assert.assertEquals(new SimpleString(Character.toString(val)), props.getSimpleStringProperty(key));
try {
props.putByteProperty(key, RandomUtil.randomByte());
props.getCharProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getCharProperty(unknownKey);
Assert.fail();
} catch (NullPointerException e) {
}
}
use of org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException in project activemq-artemis by apache.
the class TypedPropertiesConversionTest method testFloatProperty.
@Test
public void testFloatProperty() throws Exception {
Float val = RandomUtil.randomFloat();
props.putFloatProperty(key, val);
Assert.assertEquals(val, props.getFloatProperty(key));
Assert.assertEquals(Double.valueOf(val), props.getDoubleProperty(key));
Assert.assertEquals(new SimpleString(Float.toString(val)), props.getSimpleStringProperty(key));
props.putSimpleStringProperty(key, new SimpleString(Float.toString(val)));
Assert.assertEquals(val, props.getFloatProperty(key));
try {
props.putBooleanProperty(key, RandomUtil.randomBoolean());
props.getFloatProperty(key);
Assert.fail();
} catch (ActiveMQPropertyConversionException e) {
}
try {
props.getFloatProperty(unknownKey);
Assert.fail();
} catch (Exception e) {
}
}
Aggregations