From d0998f88315c3978e375c5493078fdc50f65712b Mon Sep 17 00:00:00 2001 From: Piotrek Zygielo Date: Mon, 18 Nov 2024 11:55:50 +0100 Subject: [PATCH] Test SysMessageID.toString --- .../jmq/io/SysMessageID_toString_Test.java | 52 +++++++++++++++++++ mq/main/comm-io/src/test/needs.assertj-core | 0 .../comm-io/src/test/needs.junit-jupiter-api | 0 3 files changed, 52 insertions(+) create mode 100644 mq/main/comm-io/src/test/java/com/sun/messaging/jmq/io/SysMessageID_toString_Test.java create mode 100644 mq/main/comm-io/src/test/needs.assertj-core create mode 100644 mq/main/comm-io/src/test/needs.junit-jupiter-api diff --git a/mq/main/comm-io/src/test/java/com/sun/messaging/jmq/io/SysMessageID_toString_Test.java b/mq/main/comm-io/src/test/java/com/sun/messaging/jmq/io/SysMessageID_toString_Test.java new file mode 100644 index 000000000..77f9b594a --- /dev/null +++ b/mq/main/comm-io/src/test/java/com/sun/messaging/jmq/io/SysMessageID_toString_Test.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2024 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package com.sun.messaging.jmq.io; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class SysMessageID_toString_Test { + @Test + void testToStringOfUninitialized() { + var sysMessageId = new SysMessageID(); + + assertThat(sysMessageId.toString()).isEqualTo("0-0.0.0.0-0-0"); + } + + @Test + void testToStringOfManuallyInitialized() { + var sysMessageId = new SysMessageID(); + sysMessageId.setSequence(10); + sysMessageId.setIPAddress(new byte [] { 127, 76, 76, 0 }); + sysMessageId.setPort(8076); + sysMessageId.setTimestamp(500300400); + + assertThat(sysMessageId.toString()).isEqualTo("10-127.76.76.0-8076-500300400"); + } + + @Test + void testToStringOfManuallyInitializedToMaxLength() { + var sysMessageId = new SysMessageID(); + sysMessageId.setSequence(2147483647); + sysMessageId.setIPAddress(new byte [] { 127, -100, 100, 100 }); + sysMessageId.setPort(2147483647); + sysMessageId.setTimestamp(9223372036854775807L); + + assertThat(sysMessageId.toString()).isEqualTo("2147483647-127.156.100.100-2147483647-9223372036854775807"); + } +} diff --git a/mq/main/comm-io/src/test/needs.assertj-core b/mq/main/comm-io/src/test/needs.assertj-core new file mode 100644 index 000000000..e69de29bb diff --git a/mq/main/comm-io/src/test/needs.junit-jupiter-api b/mq/main/comm-io/src/test/needs.junit-jupiter-api new file mode 100644 index 000000000..e69de29bb