From cebde5f199ed78e9b3f9e218da5a64e3ab724556 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Fri, 5 Jan 2024 19:00:04 +0000 Subject: [PATCH] Merge changes from develop --- .../chronicle/wire/VanillaMessageHistory.java | 4 +++ .../chronicle/wire/LongConversionTest.java | 32 +------------------ .../marshallable/IAEOnMissingClassTest.java | 30 ----------------- 3 files changed, 5 insertions(+), 61 deletions(-) delete mode 100644 src/test/java/net/openhft/chronicle/wire/marshallable/IAEOnMissingClassTest.java diff --git a/src/main/java/net/openhft/chronicle/wire/VanillaMessageHistory.java b/src/main/java/net/openhft/chronicle/wire/VanillaMessageHistory.java index 8f21e8d48..3fce952ce 100644 --- a/src/main/java/net/openhft/chronicle/wire/VanillaMessageHistory.java +++ b/src/main/java/net/openhft/chronicle/wire/VanillaMessageHistory.java @@ -20,11 +20,15 @@ import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.io.IORuntimeException; import net.openhft.chronicle.core.io.InvalidMarshallableException; +import net.openhft.chronicle.core.time.SystemTimeProvider; import net.openhft.chronicle.wire.converter.NanoTime; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.util.function.BiConsumer; + +import static net.openhft.chronicle.core.time.SystemTimeProvider.CLOCK; + /** * The {@code VanillaMessageHistory} class is an implementation of {@link MessageHistory} that * provides an array-backed history of messages. diff --git a/src/test/java/net/openhft/chronicle/wire/LongConversionTest.java b/src/test/java/net/openhft/chronicle/wire/LongConversionTest.java index d4e24ec3b..233dd150d 100644 --- a/src/test/java/net/openhft/chronicle/wire/LongConversionTest.java +++ b/src/test/java/net/openhft/chronicle/wire/LongConversionTest.java @@ -83,44 +83,14 @@ public void method() { assertEquals("to[74565]\n", sw.toString().replaceAll("\r", "")); } - - // Test case to check the method using OxHexadecimalLongConverter - @Test - public void oxmethod() { - - // Initializing a new Wire instance with an elastic heap-allocated buffer - Wire wire = new TextWire(Bytes.allocateElasticOnHeap(64)) - .useTextDocuments(); - - // Creating a method writer for the OxWriteWithLong interface - LongConversionTest.OxWriteWithLong write = wire.methodWriter(LongConversionTest.OxWriteWithLong.class); - assertSame(write, write.to(0x12345)); - - // Asserting the wire's string representation - assertEquals("to: 0x12345\n", wire.toString()); - - // Setting up a StringWriter to capture logging output - StringWriter sw = new StringWriter(); - LongConversionTest.OxWriteWithLong read = Mocker.logging(LongConversionTest.OxWriteWithLong.class, "", sw); - wire.methodReader(read).readOne(); - - // NOTE: Mocker which is in Core, ignores the LongConverter - assertEquals("to[74565]\n", sw.toString().replaceAll("\r", "")); - } - // Interface for method writers that use HexadecimalLongConverter interface WriteWithLong { LongConversionTest.WriteWithLong to(@LongConversion(HexadecimalLongConverter.class) int x); } - // Interface for method writers that use OxHexadecimalLongConverter - interface OxWriteWithLong { - LongConversionTest.OxWriteWithLong to(@LongConversion(OxHexadecimalLongConverter.class) int x); - } - // Static class representing a holder for various types of Long values static class LongHolder extends SelfDescribingMarshallable { - @LongConversion(UnsignedLongConverter.class) + @LongConversion(Base32LongConverter.class) long unsigned; // Represents unsigned long value @LongConversion(HexadecimalLongConverter.class) long hex; // Represents a hexadecimal long value diff --git a/src/test/java/net/openhft/chronicle/wire/marshallable/IAEOnMissingClassTest.java b/src/test/java/net/openhft/chronicle/wire/marshallable/IAEOnMissingClassTest.java deleted file mode 100644 index 18feff180..000000000 --- a/src/test/java/net/openhft/chronicle/wire/marshallable/IAEOnMissingClassTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package net.openhft.chronicle.wire.marshallable; - -import net.openhft.chronicle.bytes.Bytes; -import net.openhft.chronicle.wire.TextWire; -import net.openhft.chronicle.wire.Wire; -import org.junit.Test; - -import static org.junit.Assert.assertNotNull; - -// Class to test behavior when a missing class alias is encountered -public class IAEOnMissingClassTest { - - // Test to ensure that a missing class alias results in an IllegalArgumentException - @Test(expected = IllegalArgumentException.class) - public void throwIllegalArgumentExceptionOnMissingClassAlias() { - - // Create a wire object with a missing class alias 'Aaa' - Wire wire = new TextWire(Bytes.from("" + - "a: !Aaa { hi: bye }")); - - // Attempt to read the object from the wire - Object object = wire.read("a").object(); - - // Print the resulting object for debug purposes - System.out.println(object); - - // Ensure that an object is returned (this check might be redundant given the expected exception) - assertNotNull(object); - } -}