Search in sources :

Example 6 with ActiveMQPropertyConversionException

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) {
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQPropertyConversionException(org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException) Test(org.junit.Test)

Example 7 with ActiveMQPropertyConversionException

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) {
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQPropertyConversionException(org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException) ActiveMQPropertyConversionException(org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException) Test(org.junit.Test)

Example 8 with ActiveMQPropertyConversionException

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));
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQPropertyConversionException(org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException) Test(org.junit.Test)

Example 9 with ActiveMQPropertyConversionException

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) {
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQPropertyConversionException(org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException) Test(org.junit.Test)

Example 10 with ActiveMQPropertyConversionException

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) {
    }
}
Also used : SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQPropertyConversionException(org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException) ActiveMQPropertyConversionException(org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException) Test(org.junit.Test)

Aggregations

ActiveMQPropertyConversionException (org.apache.activemq.artemis.api.core.ActiveMQPropertyConversionException)12 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)12 Test (org.junit.Test)8 JMSRuntimeException (javax.jms.JMSRuntimeException)2 MessageFormatException (javax.jms.MessageFormatException)2 MessageFormatRuntimeException (javax.jms.MessageFormatRuntimeException)2 HashSet (java.util.HashSet)1 UnsignedByte (org.apache.qpid.proton.amqp.UnsignedByte)1 UnsignedInteger (org.apache.qpid.proton.amqp.UnsignedInteger)1 UnsignedLong (org.apache.qpid.proton.amqp.UnsignedLong)1 UnsignedShort (org.apache.qpid.proton.amqp.UnsignedShort)1