Skip to content

Commit 46a4c37

Browse files
committed
Test publish/consume message with float and double values
1 parent 31d9749 commit 46a4c37

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/test/java/com/rabbitmq/client/amqp/impl/AmqpTest.java

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
import java.util.concurrent.atomic.AtomicReference;
5555
import java.util.function.BiConsumer;
5656
import java.util.stream.IntStream;
57+
import net.jqwik.api.Arbitraries;
5758
import org.junit.jupiter.api.*;
5859
import org.junit.jupiter.params.ParameterizedTest;
5960
import org.junit.jupiter.params.provider.CsvSource;
@@ -785,8 +786,24 @@ void types(TestInfo info) {
785786
publishSync.down();
786787
}
787788
};
789+
float fValue = Arbitraries.floats().sample();
790+
double dValue = Arbitraries.doubles().sample();
788791
Publisher publisher = connection.publisherBuilder().queue(q).build();
789-
publisher.publish(publisher.message().property("key1", -1L), callback);
792+
publisher.publish(
793+
publisher
794+
.message()
795+
.property("key1", -1L)
796+
.property("float", fValue)
797+
.property("fMin", Float.MIN_VALUE)
798+
.property("fMax", Float.MAX_VALUE)
799+
.property("fNegInf", Float.NEGATIVE_INFINITY)
800+
.property("fPosInf", Float.POSITIVE_INFINITY)
801+
.property("double", dValue)
802+
.property("dMin", Double.MIN_VALUE)
803+
.property("dMax", Double.MAX_VALUE)
804+
.property("dNegInf", Double.NEGATIVE_INFINITY)
805+
.property("dPosInf", Double.POSITIVE_INFINITY),
806+
callback);
790807
assertThat(publishSync).completes();
791808
AtomicReference<Message> message = new AtomicReference<>();
792809
Sync consumeSync = sync();
@@ -801,7 +818,18 @@ void types(TestInfo info) {
801818
})
802819
.build();
803820
assertThat(consumeSync).completes();
804-
assertThat(message.get()).hasProperty("key1", -1L);
821+
assertThat(message.get())
822+
.hasProperty("key1", -1L)
823+
.hasProperty("float", fValue)
824+
.hasProperty("fMin", Float.MIN_VALUE)
825+
.hasProperty("fMax", Float.MAX_VALUE)
826+
.hasProperty("fNegInf", Float.NEGATIVE_INFINITY)
827+
.hasProperty("fPosInf", Float.POSITIVE_INFINITY)
828+
.hasProperty("double", dValue)
829+
.hasProperty("dMin", Double.MIN_VALUE)
830+
.hasProperty("dMax", Double.MAX_VALUE)
831+
.hasProperty("dNegInf", Double.NEGATIVE_INFINITY)
832+
.hasProperty("dPosInf", Double.POSITIVE_INFINITY);
805833
}
806834

807835
@Test

0 commit comments

Comments
 (0)