-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JMS 3.1 spec, "A.3.13. JMSXDeliveryCount (JMS_SPEC-42)" https://jakarta.ee/specifications/messaging/3.1/jakarta-messaging-spec-3.1.html#jmsxdeliverycount-jms_spec-42 The header is set on every message: * to 1 for each message which is not redelivered * to the value of the AMQP `x-delivery-count` header + 1 for a delivered message and if the header is present (for *quorum queues* only) * to 2 for a delivered message and if the AMQP `x-delivery-count` header is not present References #180 Fixes #202
- Loading branch information
1 parent
0037dee
commit 197fddd
Showing
6 changed files
with
197 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
// | ||
// Copyright (c) 2022 VMware, Inc. or its affiliates. All rights reserved. | ||
|
||
|
||
package com.rabbitmq; | ||
|
||
import javax.jms.JMSException; | ||
import javax.jms.Message; | ||
import org.assertj.core.api.AbstractObjectAssert; | ||
|
||
public abstract class Assertions { | ||
|
||
public static JmsMessageAssert assertThat(Message message) { | ||
return new JmsMessageAssert(message); | ||
} | ||
|
||
public static class JmsMessageAssert extends AbstractObjectAssert<JmsMessageAssert, Message> { | ||
|
||
private static final String JMS_X_DELIVERY_COUNT = "JMSXDeliveryCount"; | ||
|
||
public JmsMessageAssert isRedelivered() throws JMSException { | ||
isNotNull(); | ||
if (!actual.getJMSRedelivered()) { | ||
failWithMessage("Message is expected to be redelivered"); | ||
} | ||
return this; | ||
} | ||
|
||
public JmsMessageAssert isNotRedelivered() throws JMSException { | ||
isNotNull(); | ||
if (actual.getJMSRedelivered()) { | ||
failWithMessage("Message is not expected to be redelivered"); | ||
} | ||
return this; | ||
} | ||
|
||
public JmsMessageAssert hasDeliveryCount(int expectedDeliveryCount) throws JMSException { | ||
isNotNull(); | ||
int actualDeliveryCount = this.actual.getIntProperty(JMS_X_DELIVERY_COUNT); | ||
if (actualDeliveryCount != expectedDeliveryCount) { | ||
failWithMessage("Delivery count is expected to be %d but is %d", expectedDeliveryCount, actualDeliveryCount); | ||
} | ||
return this; | ||
} | ||
|
||
public JmsMessageAssert(Message message) { | ||
super(message, JmsMessageAssert.class); | ||
} | ||
|
||
public static JmsMessageAssert assertThat(Message message) { | ||
return new JmsMessageAssert(message); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters