Adding missing boolean type support in Message properties. (#252)
This commit is contained in:
Родитель
9c16ab3419
Коммит
31f21a05cb
|
@ -16,6 +16,7 @@ public final class AmqpErrorCode
|
||||||
public static final Symbol InternalError = Symbol.getSymbol("amqp:internal-error");
|
public static final Symbol InternalError = Symbol.getSymbol("amqp:internal-error");
|
||||||
public static final Symbol IllegalState = Symbol.getSymbol("amqp:illegal-state");
|
public static final Symbol IllegalState = Symbol.getSymbol("amqp:illegal-state");
|
||||||
public static final Symbol NotImplemented = Symbol.getSymbol("amqp:not-implemented");
|
public static final Symbol NotImplemented = Symbol.getSymbol("amqp:not-implemented");
|
||||||
|
public static final Symbol DecodeError = Symbol.getSymbol("amqp:decode-error");
|
||||||
|
|
||||||
// link errors
|
// link errors
|
||||||
public static final Symbol Stolen = Symbol.getSymbol("amqp:link:stolen");
|
public static final Symbol Stolen = Symbol.getSymbol("amqp:link:stolen");
|
||||||
|
|
|
@ -109,6 +109,10 @@ public final class ExceptionUtil
|
||||||
{
|
{
|
||||||
return new MessagingEntityAlreadyExistsException(errorCondition.getDescription());
|
return new MessagingEntityAlreadyExistsException(errorCondition.getDescription());
|
||||||
}
|
}
|
||||||
|
else if (errorCondition.getCondition() == AmqpErrorCode.DecodeError)
|
||||||
|
{
|
||||||
|
return new ServiceBusException(false, new AmqpException(errorCondition));
|
||||||
|
}
|
||||||
|
|
||||||
return new ServiceBusException(ClientConstants.DEFAULT_IS_TRANSIENT, errorCondition.toString());
|
return new ServiceBusException(ClientConstants.DEFAULT_IS_TRANSIENT, errorCondition.toString());
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,11 @@ public class Util
|
||||||
return Short.BYTES;
|
return Short.BYTES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (obj instanceof Boolean)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (obj instanceof Character)
|
if (obj instanceof Character)
|
||||||
{
|
{
|
||||||
return 4;
|
return 4;
|
||||||
|
|
|
@ -222,6 +222,13 @@ public abstract class SendReceiveTests extends Tests {
|
||||||
TestCommons.testReceiveBySequenceNumberAndDeadletter(this.sender, this.sessionId, this.receiver);
|
TestCommons.testReceiveBySequenceNumberAndDeadletter(this.sender, this.sessionId, this.receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSendReceiveMessageWithVariousPropertyTypes() throws InterruptedException, ServiceBusException
|
||||||
|
{
|
||||||
|
this.receiver = ClientFactory.createMessageReceiverFromEntityPath(factory, this.receiveEntityPath, ReceiveMode.RECEIVEANDDELETE);
|
||||||
|
TestCommons.testSendReceiveMessageWithVariousPropertyTypes(this.sender, this.sessionId, this.receiver);
|
||||||
|
}
|
||||||
|
|
||||||
private void drainAllMessages() throws InterruptedException, ServiceBusException
|
private void drainAllMessages() throws InterruptedException, ServiceBusException
|
||||||
{
|
{
|
||||||
if(this.receiver != null)
|
if(this.receiver != null)
|
||||||
|
|
|
@ -229,6 +229,14 @@ public abstract class SessionTests extends Tests {
|
||||||
TestCommons.testReceiveBySequenceNumberAndDeadletter(this.sender, sessionId, this.session);
|
TestCommons.testReceiveBySequenceNumberAndDeadletter(this.sender, sessionId, this.session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testSendReceiveMessageWithVariousPropertyTypes() throws InterruptedException, ServiceBusException
|
||||||
|
{
|
||||||
|
String sessionId = TestUtils.getRandomString();
|
||||||
|
this.session = ClientFactory.acceptSessionFromEntityPath(this.factory, this.receiveEntityPath, sessionId, ReceiveMode.RECEIVEANDDELETE);
|
||||||
|
TestCommons.testSendReceiveMessageWithVariousPropertyTypes(this.sender, sessionId, this.session);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAcceptAnySession() throws InterruptedException, ServiceBusException
|
public void testAcceptAnySession() throws InterruptedException, ServiceBusException
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,6 +9,7 @@ import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
@ -507,6 +508,59 @@ public class TestCommons {
|
||||||
// Expected
|
// Expected
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void testSendReceiveMessageWithVariousPropertyTypes(IMessageSender sender, String sessionId, IMessageReceiver receiver) throws InterruptedException, ServiceBusException
|
||||||
|
{
|
||||||
|
Map<String, Object> sentProperties = new HashMap<>();
|
||||||
|
sentProperties.put("NullProperty", null);
|
||||||
|
sentProperties.put("BooleanProperty", true);
|
||||||
|
sentProperties.put("ByteProperty", (byte)1);
|
||||||
|
sentProperties.put("ShortProperty", (short)2);
|
||||||
|
sentProperties.put("IntProperty", 3);
|
||||||
|
sentProperties.put("LongProperty", 4l);
|
||||||
|
sentProperties.put("FloatProperty", 5.5f);
|
||||||
|
sentProperties.put("DoubleProperty", 6.6f);
|
||||||
|
sentProperties.put("CharProperty", 'z');
|
||||||
|
sentProperties.put("UUIDProperty", UUID.randomUUID());
|
||||||
|
sentProperties.put("StringProperty", "string");
|
||||||
|
|
||||||
|
// These additional types are not supported in message properties by Azure Service Bus
|
||||||
|
// sentProperties.put("ArrayProperty", new Object[]{1, 2, 3, 4, 5});
|
||||||
|
// List<Integer> list = new ArrayList<>();
|
||||||
|
// list.add(10);
|
||||||
|
// list.add(11);
|
||||||
|
// sentProperties.put("ListProperty", list);
|
||||||
|
// Map<String, Object> map = new HashMap<>();
|
||||||
|
// map.put("key1", 20);
|
||||||
|
// map.put("key2", "thirty");
|
||||||
|
// sentProperties.put("MapProperty", map);
|
||||||
|
|
||||||
|
String messageId = UUID.randomUUID().toString();
|
||||||
|
Message message = new Message("AMQP message");
|
||||||
|
message.setMessageId(messageId);
|
||||||
|
if(sessionId != null)
|
||||||
|
{
|
||||||
|
message.setSessionId(sessionId);
|
||||||
|
}
|
||||||
|
message.getProperties().putAll(sentProperties);
|
||||||
|
sender.send(message);
|
||||||
|
|
||||||
|
IMessage receivedMessage = receiver.receive();
|
||||||
|
Assert.assertNotNull("Message not received", receivedMessage);
|
||||||
|
Assert.assertEquals("Message Id did not match", messageId, receivedMessage.getMessageId());
|
||||||
|
Map<String, Object> receivedProperties = receivedMessage.getProperties();
|
||||||
|
for(Map.Entry<String, Object> sentEntry : sentProperties.entrySet())
|
||||||
|
{
|
||||||
|
if(sentEntry.getValue() != null && sentEntry.getValue().getClass().isArray())
|
||||||
|
{
|
||||||
|
Assert.assertArrayEquals("Sent property didn't match with received property", (Object[])sentEntry.getValue(), (Object[])receivedProperties.get(sentEntry.getKey()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.assertEquals("Sent property didn't match with received property", sentEntry.getValue(), receivedProperties.get(sentEntry.getKey()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void testGetMessageSessions(IMessageSender sender, Object sessionsClient) throws InterruptedException, ServiceBusException
|
public static void testGetMessageSessions(IMessageSender sender, Object sessionsClient) throws InterruptedException, ServiceBusException
|
||||||
{
|
{
|
||||||
|
|
Загрузка…
Ссылка в новой задаче