T readResolve(Object o) {
// Pattern matching
if (o instanceof ReadResolvable) {
- return (T) ((ReadResolvable) o).readResolve();
+ return (T) ((ReadResolvable>) o).readResolve();
} else if (o instanceof Serializable) {
return (T) ObjectUtils.readResolve(o);
} else {
diff --git a/src/main/java/net/openhft/chronicle/core/util/ShortConsumer.java b/src/main/java/net/openhft/chronicle/core/util/ShortConsumer.java
index c329fa8bab1..0d3a11bbc2f 100644
--- a/src/main/java/net/openhft/chronicle/core/util/ShortConsumer.java
+++ b/src/main/java/net/openhft/chronicle/core/util/ShortConsumer.java
@@ -17,10 +17,6 @@
*/
package net.openhft.chronicle.core.util;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.Objects;
-
/**
* Represents an operation that accepts a single {@code short}-valued argument and returns no result. This is the
* primitive type specialization of {@link java.util.function.Consumer} for {@code short}. Unlike most other functional
@@ -41,23 +37,4 @@ public interface ShortConsumer {
*/
void accept(short value);
- /**
- * Returns a composed {@code ShortConsumer} that performs, in sequence, this operation followed by the {@code after}
- * operation. If performing either operation throws an exception, it is relayed to the caller of the composed
- * operation. If performing this operation throws an exception, the {@code after} operation will not be performed.
- *
- * @param after the operation to perform after this operation
- * @return a composed {@code ShortConsumer} that performs in sequence this operation followed by the {@code after}
- * operation
- * @throws NullPointerException If {@code after} is null
- */
- @Deprecated(/* to be removed in x.26 */)
- @NotNull
- default ShortConsumer andThen(@NotNull ShortConsumer after) {
- Objects.requireNonNull(after);
- return (short t) -> {
- accept(t);
- after.accept(t);
- };
- }
}
diff --git a/src/main/java/net/openhft/chronicle/core/util/ThreadConfinementAsserter.java b/src/main/java/net/openhft/chronicle/core/util/ThreadConfinementAsserter.java
index 47b55789ab8..06a3a4dc052 100644
--- a/src/main/java/net/openhft/chronicle/core/util/ThreadConfinementAsserter.java
+++ b/src/main/java/net/openhft/chronicle/core/util/ThreadConfinementAsserter.java
@@ -49,5 +49,4 @@ static ThreadConfinementAsserter create() {
static ThreadConfinementAsserter createEnabled() {
return ThreadConfinementLifecycle.createEnabled();
}
-
}
diff --git a/src/main/java/net/openhft/chronicle/core/util/ThrowingBiConsumer.java b/src/main/java/net/openhft/chronicle/core/util/ThrowingBiConsumer.java
index 1c1af11f8a9..bdc7c04c9d4 100644
--- a/src/main/java/net/openhft/chronicle/core/util/ThrowingBiConsumer.java
+++ b/src/main/java/net/openhft/chronicle/core/util/ThrowingBiConsumer.java
@@ -18,11 +18,7 @@
package net.openhft.chronicle.core.util;
-import net.openhft.chronicle.core.Jvm;
import net.openhft.chronicle.core.io.IORuntimeException;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.BiConsumer;
/**
* Represents an operation that accepts two input arguments and returns no
@@ -36,16 +32,6 @@
*/
@FunctionalInterface
public interface ThrowingBiConsumer {
- @Deprecated(/* to be removed in x.26 */)
- static BiConsumer asConsumer(@NotNull ThrowingBiConsumer function) {
- return (in, i2) -> {
- try {
- function.accept(in, i2);
- } catch (Throwable t) {
- throw Jvm.rethrow(t);
- }
- };
- }
/**
* Performs this operation on the given arguments.
diff --git a/src/main/java/net/openhft/chronicle/core/util/ThrowingBiFunction.java b/src/main/java/net/openhft/chronicle/core/util/ThrowingBiFunction.java
index 3f200a1737a..074581c6dc3 100644
--- a/src/main/java/net/openhft/chronicle/core/util/ThrowingBiFunction.java
+++ b/src/main/java/net/openhft/chronicle/core/util/ThrowingBiFunction.java
@@ -18,11 +18,8 @@
package net.openhft.chronicle.core.util;
-import net.openhft.chronicle.core.Jvm;
import org.jetbrains.annotations.NotNull;
-import java.util.function.BiFunction;
-
/**
* Represents a function that accepts two arguments and produces a result.
* This is the two-arity specialization of {@link ThrowingFunction}.
@@ -37,16 +34,6 @@
*/
@FunctionalInterface
public interface ThrowingBiFunction {
- @Deprecated(/* to be removed in x.26 */)
- static BiFunction asBiFunction(@NotNull ThrowingBiFunction function) {
- return (in, i2) -> {
- try {
- return function.apply(in, i2);
- } catch (Throwable t) {
- throw Jvm.rethrow(t);
- }
- };
- }
/**
* Applies this function to the given arguments.
diff --git a/src/main/java/net/openhft/chronicle/core/util/ThrowingConsumer.java b/src/main/java/net/openhft/chronicle/core/util/ThrowingConsumer.java
index dca6c20f4f3..20fafed7e78 100644
--- a/src/main/java/net/openhft/chronicle/core/util/ThrowingConsumer.java
+++ b/src/main/java/net/openhft/chronicle/core/util/ThrowingConsumer.java
@@ -18,11 +18,6 @@
package net.openhft.chronicle.core.util;
-import net.openhft.chronicle.core.Jvm;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.Consumer;
-
/**
*
* Represents an operation that accepts a single input argument and returns no
@@ -38,16 +33,6 @@
*/
@FunctionalInterface
public interface ThrowingConsumer {
- @Deprecated(/* to be removed in x.26 */)
- static Consumer asConsumer(@NotNull ThrowingConsumer function) {
- return in -> {
- try {
- function.accept(in);
- } catch (Throwable t) {
- throw Jvm.rethrow(t);
- }
- };
- }
/**
* Performs this operation on the given argument.
diff --git a/src/main/java/net/openhft/chronicle/core/util/ThrowingIntSupplier.java b/src/main/java/net/openhft/chronicle/core/util/ThrowingIntSupplier.java
index d1bbf126f99..c548cf3f5e5 100644
--- a/src/main/java/net/openhft/chronicle/core/util/ThrowingIntSupplier.java
+++ b/src/main/java/net/openhft/chronicle/core/util/ThrowingIntSupplier.java
@@ -19,11 +19,6 @@
package net.openhft.chronicle.core.util;
-import net.openhft.chronicle.core.Jvm;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.IntSupplier;
-
/**
*
* Represents a supplier of results which might throw an Exception
@@ -39,17 +34,6 @@
*/
@FunctionalInterface
public interface ThrowingIntSupplier {
- @Deprecated(/* to be removed in x.26 */)
- static IntSupplier asSupplier(@NotNull ThrowingIntSupplier throwingSupplier) {
- return () -> {
- try {
- return throwingSupplier.getAsInt();
-
- } catch (Throwable t) {
- throw Jvm.rethrow(t);
- }
- };
- }
/**
* Gets a result.
diff --git a/src/main/java/net/openhft/chronicle/core/util/ThrowingLongSupplier.java b/src/main/java/net/openhft/chronicle/core/util/ThrowingLongSupplier.java
index 10e6f4df99f..72952b5acc4 100644
--- a/src/main/java/net/openhft/chronicle/core/util/ThrowingLongSupplier.java
+++ b/src/main/java/net/openhft/chronicle/core/util/ThrowingLongSupplier.java
@@ -19,11 +19,6 @@
package net.openhft.chronicle.core.util;
-import net.openhft.chronicle.core.Jvm;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.LongSupplier;
-
/**
*
* Represents a supplier of results which might throw an Exception
@@ -39,17 +34,6 @@
*/
@FunctionalInterface
public interface ThrowingLongSupplier {
- @Deprecated(/* to be removed in x.26 */)
- static LongSupplier asSupplier(@NotNull ThrowingLongSupplier throwingSupplier) {
- return () -> {
- try {
- return throwingSupplier.getAsLong();
-
- } catch (Throwable t) {
- throw Jvm.rethrow(t);
- }
- };
- }
/**
* Gets a result.
diff --git a/src/main/java/net/openhft/chronicle/core/util/Time.java b/src/main/java/net/openhft/chronicle/core/util/Time.java
index 23cf3a88035..e6fa058774b 100644
--- a/src/main/java/net/openhft/chronicle/core/util/Time.java
+++ b/src/main/java/net/openhft/chronicle/core/util/Time.java
@@ -41,5 +41,4 @@ public static String uniqueId() {
}
return Long.toString(l, 36);
}
-
}
diff --git a/src/main/java/net/openhft/chronicle/core/util/TypeOf.java b/src/main/java/net/openhft/chronicle/core/util/TypeOf.java
index ab01a5f4e82..9779dc205c0 100644
--- a/src/main/java/net/openhft/chronicle/core/util/TypeOf.java
+++ b/src/main/java/net/openhft/chronicle/core/util/TypeOf.java
@@ -64,4 +64,3 @@ private Type extractType() {
return pt.getActualTypeArguments()[0];
}
}
-
diff --git a/src/main/java/net/openhft/chronicle/core/util/URIEncoder.java b/src/main/java/net/openhft/chronicle/core/util/URIEncoder.java
deleted file mode 100644
index d6bf9af3bbb..00000000000
--- a/src/main/java/net/openhft/chronicle/core/util/URIEncoder.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package net.openhft.chronicle.core.util;
-
-import org.jetbrains.annotations.NotNull;
-
-/**
- * simple uri encoder, made from the spec at ...
- * Feel free to copy this. I'm not responsible for this code in any way, ever.
- * Thanks to Marco and Thomas
- *
- * @author Daniel Murphy
- */
-@Deprecated(/* to be removed in x.26 */)
-public final class URIEncoder {
- private static final String MARK = "-_.!~*'()\"";
- private static final char[] HEX = "0123456789ABCDEF".toCharArray();
-
- // Suppresses default constructor, ensuring non-instantiability.
- private URIEncoder() {
- }
-
- public static String encodeURI(@NotNull String argString) {
- @NotNull StringBuilder uri = new StringBuilder();
-
- for (char c : argString.toCharArray()) {
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z') || MARK.indexOf(c) != -1) {
- uri.append(c);
- } else {
- appendEscaped(uri, c);
- }
- }
- return uri.toString();
- }
-
- private static void appendEscaped(@NotNull StringBuilder uri, char c) {
- if (c <= 0xFF) {
- uri.append("%");
- uri.append(HEX[(c >> 4) & 0xF]);
- uri.append(HEX[c & 0xF]);
- return;
- }
- // unicode
- uri.append('\\');
- uri.append('u');
- uri.append(HEX[(c >> 12) & 0xF]);
- uri.append(HEX[(c >> 8) & 0xF]);
- uri.append(HEX[(c >> 4) & 0xF]);
- uri.append(HEX[c & 0xF]);
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/core/values/BooleanValue.java b/src/main/java/net/openhft/chronicle/core/values/BooleanValue.java
index c499f401827..7bc49de278e 100644
--- a/src/main/java/net/openhft/chronicle/core/values/BooleanValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/BooleanValue.java
@@ -48,7 +48,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface BooleanValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/ByteValue.java b/src/main/java/net/openhft/chronicle/core/values/ByteValue.java
index 944e6c6a9bc..2760ed68b0d 100644
--- a/src/main/java/net/openhft/chronicle/core/values/ByteValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/ByteValue.java
@@ -39,7 +39,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface ByteValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/CharValue.java b/src/main/java/net/openhft/chronicle/core/values/CharValue.java
index e652fd720fb..3b89c10acd0 100644
--- a/src/main/java/net/openhft/chronicle/core/values/CharValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/CharValue.java
@@ -39,7 +39,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface CharValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/DoubleValue.java b/src/main/java/net/openhft/chronicle/core/values/DoubleValue.java
index 67e37b9418a..6307d38d7a9 100644
--- a/src/main/java/net/openhft/chronicle/core/values/DoubleValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/DoubleValue.java
@@ -48,7 +48,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface DoubleValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/FloatValue.java b/src/main/java/net/openhft/chronicle/core/values/FloatValue.java
index e289548be04..7e48f19d5ed 100644
--- a/src/main/java/net/openhft/chronicle/core/values/FloatValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/FloatValue.java
@@ -48,7 +48,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface FloatValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/IntArrayValues.java b/src/main/java/net/openhft/chronicle/core/values/IntArrayValues.java
index 0dc31425e58..f16827ea552 100644
--- a/src/main/java/net/openhft/chronicle/core/values/IntArrayValues.java
+++ b/src/main/java/net/openhft/chronicle/core/values/IntArrayValues.java
@@ -56,7 +56,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface IntArrayValues extends Closeable {
diff --git a/src/main/java/net/openhft/chronicle/core/values/IntValue.java b/src/main/java/net/openhft/chronicle/core/values/IntValue.java
index 8eb9e96cb2f..dca6ca0415c 100644
--- a/src/main/java/net/openhft/chronicle/core/values/IntValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/IntValue.java
@@ -46,7 +46,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface IntValue extends Closeable {
diff --git a/src/main/java/net/openhft/chronicle/core/values/LongArrayValues.java b/src/main/java/net/openhft/chronicle/core/values/LongArrayValues.java
index bf448b44af1..9d1a4de13a7 100644
--- a/src/main/java/net/openhft/chronicle/core/values/LongArrayValues.java
+++ b/src/main/java/net/openhft/chronicle/core/values/LongArrayValues.java
@@ -55,7 +55,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface LongArrayValues extends Closeable {
diff --git a/src/main/java/net/openhft/chronicle/core/values/LongValue.java b/src/main/java/net/openhft/chronicle/core/values/LongValue.java
index 448a8fbe40a..54197b2c866 100644
--- a/src/main/java/net/openhft/chronicle/core/values/LongValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/LongValue.java
@@ -44,7 +44,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface LongValue extends Closeable {
diff --git a/src/main/java/net/openhft/chronicle/core/values/ShortValue.java b/src/main/java/net/openhft/chronicle/core/values/ShortValue.java
index c51b9a0cd4d..9828192cd7f 100644
--- a/src/main/java/net/openhft/chronicle/core/values/ShortValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/ShortValue.java
@@ -45,7 +45,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface ShortValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/StringValue.java b/src/main/java/net/openhft/chronicle/core/values/StringValue.java
index a661ad6f817..7e30b3e5fd9 100644
--- a/src/main/java/net/openhft/chronicle/core/values/StringValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/StringValue.java
@@ -44,7 +44,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
*/
public interface StringValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/TwoLongValue.java b/src/main/java/net/openhft/chronicle/core/values/TwoLongValue.java
index 96d74dcc944..9504cc2d1b4 100644
--- a/src/main/java/net/openhft/chronicle/core/values/TwoLongValue.java
+++ b/src/main/java/net/openhft/chronicle/core/values/TwoLongValue.java
@@ -61,7 +61,6 @@
* @see net.openhft.chronicle.core.values.StringValue
* @see net.openhft.chronicle.core.values.LongArrayValues
* @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
* @since 10/10/13
*/
public interface TwoLongValue extends LongValue {
diff --git a/src/main/java/net/openhft/chronicle/core/values/UnsetLongValue.java b/src/main/java/net/openhft/chronicle/core/values/UnsetLongValue.java
deleted file mode 100644
index 31a33b7cbb1..00000000000
--- a/src/main/java/net/openhft/chronicle/core/values/UnsetLongValue.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright 2016-2022 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.values;
-
-import net.openhft.chronicle.core.io.ClosedIllegalStateException;
-import net.openhft.chronicle.core.io.ThreadingIllegalStateException;
-
-/**
- * Represents a long value that ignores attempts to modify it, and always returns the same value.
- *
- * This class is useful in scenarios where a LongValue is expected, but modifications should be ignored,
- * and a fixed or default value should be returned. This is akin to making the value 'immutable'.
- *
- * The value returned by this class is set at construction and cannot be changed thereafter.
- *
- * @see net.openhft.chronicle.core.values.BooleanValue
- * @see net.openhft.chronicle.core.values.ByteValue
- * @see net.openhft.chronicle.core.values.CharValue
- * @see net.openhft.chronicle.core.values.DoubleValue
- * @see net.openhft.chronicle.core.values.FloatValue
- * @see net.openhft.chronicle.core.values.IntValue
- * @see net.openhft.chronicle.core.values.LongValue
- * @see net.openhft.chronicle.core.values.ShortValue
- * @see net.openhft.chronicle.core.values.StringValue
- * @see net.openhft.chronicle.core.values.LongArrayValues
- * @see net.openhft.chronicle.core.values.IntArrayValues
- * @see net.openhft.chronicle.core.values.UnsetLongValue
- */
-@Deprecated(/* to be removed in x.26 */)
-public class UnsetLongValue implements LongValue {
- private final long value;
-
- /**
- * Constructs an UnsetLongValue with the specified value.
- *
- * @param value the value to be set
- */
- public UnsetLongValue(long value) {
- this.value = value;
- }
-
- /**
- * Retrieves the value set at construction.
- *
- * @return the long value
- * @throws ClosedIllegalStateException If the resource has been released or closed.
- * @throws ThreadingIllegalStateException If this resource was accessed by multiple threads in an unsafe way
- */
- @Override
- public long getValue() throws IllegalStateException {
- return value;
- }
-
- /**
- * This method does not change the value. It is here to fulfill the LongValue interface but has no effect.
- *
- * @param value the value to set (ignored)
- * @throws ClosedIllegalStateException If the resource has been released or closed.
- * @throws ThreadingIllegalStateException If this resource was accessed by multiple threads in an unsafe way
- */
- @Override
- public void setValue(long value) throws IllegalStateException {
- // ignored
- }
-
- /**
- * Retrieves the volatile value provided as a parameter since internal value modification is ignored.
- *
- * @param closedValue the volatile value to be retrieved
- * @return the closedValue parameter passed to this method
- * @throws ClosedIllegalStateException If the resource has been released or closed.
- * @throws ThreadingIllegalStateException If this resource was accessed by multiple threads in an unsafe way
- */
- @Override
- public long getVolatileValue(long closedValue) throws IllegalStateException {
- return closedValue;
- }
-
- /**
- * Ignores the addition and simply returns the value set at construction.
- *
- * @param delta the value to be added (ignored)
- * @return the long value set at construction
- * @throws ClosedIllegalStateException If the resource has been released or closed.
- * @throws ThreadingIllegalStateException If this resource was accessed by multiple threads in an unsafe way
- */
- @Override
- public long addValue(long delta) throws IllegalStateException {
- return value;
- }
-
- /**
- * Ignores the compare and swap, and simply returns true.
- *
- * @param expected the expected value (ignored)
- * @param value the new value (ignored)
- * @return true
- * @throws ClosedIllegalStateException If the resource has been released or closed.
- * @throws ThreadingIllegalStateException If this resource was accessed by multiple threads in an unsafe way
- */
- @Override
- public boolean compareAndSwapValue(long expected, long value) throws IllegalStateException {
- return true;
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/core/values/package-info.java b/src/main/java/net/openhft/chronicle/core/values/package-info.java
index 36d6800d120..36f4a0b38f6 100644
--- a/src/main/java/net/openhft/chronicle/core/values/package-info.java
+++ b/src/main/java/net/openhft/chronicle/core/values/package-info.java
@@ -29,7 +29,6 @@
*
{@link net.openhft.chronicle.core.values.ShortValue} - Represents a reference to a 16-bit short value.
* {@link net.openhft.chronicle.core.values.StringValue} - Represents a reference to a String value.
* {@link net.openhft.chronicle.core.values.TwoLongValue} - Represents a reference to two long values.
- * {@link net.openhft.chronicle.core.values.UnsetLongValue} - Represents a long value that ignores attempts to modify it.
*
*
* @since 10/10/13
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/ClassifyingWatcherListener.java b/src/main/java/net/openhft/chronicle/core/watcher/ClassifyingWatcherListener.java
deleted file mode 100644
index a7d2ed56609..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/ClassifyingWatcherListener.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-import net.openhft.chronicle.core.Jvm;
-
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-
-@Deprecated(/* to be removed x.26 */)
-public class ClassifyingWatcherListener implements WatcherListener {
- final Set classifiers = new CopyOnWriteArraySet<>();
- final Map fileManagerMap = new TreeMap<>();
-
- @Override
- public void onExists(String base, String filename, Boolean modified) {
- Path path = Paths.get(base, filename);
- if (fileManagerMap.containsKey(path))
- return;
- for (FileClassifier classifier : classifiers) {
- FileManager manager = classifier.classify(base, filename);
- if (manager != null) {
- Jvm.warn().on(getClass(), "File " + base + " " + filename + " classified as " + manager);
- fileManagerMap.put(path, manager);
- manager.start();
- }
- }
- }
-
- @Override
- public void onRemoved(String base, String filename) {
- Path path = Paths.get(base, filename);
- FileManager info = fileManagerMap.remove(path);
- if (info != null)
- info.stop();
- }
-
- public void addClassifier(FileClassifier fileClassifier) {
- classifiers.add(fileClassifier);
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/FileClassifier.java b/src/main/java/net/openhft/chronicle/core/watcher/FileClassifier.java
deleted file mode 100644
index ac1049d5824..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/FileClassifier.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-@Deprecated(/* to be removed x.26 */)
-public interface FileClassifier {
- FileManager classify(String base, String relative);
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/FileManager.java b/src/main/java/net/openhft/chronicle/core/watcher/FileManager.java
deleted file mode 100644
index 459c26b0faf..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/FileManager.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-@Deprecated(/* to be removed x.26 */)
-public interface FileManager {
- void start();
-
- void stop();
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/FileSystemWatcher.java b/src/main/java/net/openhft/chronicle/core/watcher/FileSystemWatcher.java
deleted file mode 100644
index c88d54ec661..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/FileSystemWatcher.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-import net.openhft.chronicle.core.Jvm;
-import net.openhft.chronicle.core.OS;
-import net.openhft.chronicle.core.io.Closeable;
-
-import java.io.IOException;
-import java.nio.file.*;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.*;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArraySet;
-import java.util.concurrent.LinkedBlockingQueue;
-
-import static java.nio.file.StandardWatchEventKinds.*;
-
-@Deprecated(/* to be removed x.26 */)
-public class FileSystemWatcher {
- private final WatchService watchService;
- // shared
- private final Map watchKeyToPathMap = new ConcurrentHashMap<>();
- private final Set watchKeysToRemove = new CopyOnWriteArraySet<>();
- private final BlockingQueue listenersToAdd = new LinkedBlockingQueue<>();
- private volatile boolean running = true;
- // only used by the watcher thread.
- private final List listeners = new ArrayList<>();
- private final Thread thread = new Thread(this::run, "watcher");
-
- public FileSystemWatcher() throws IOException {
- watchService = FileSystems.getDefault().newWatchService();
- }
-
- private static String p(String path) {
- return OS.isWindows() ? path.replace('\\', '/') : path;
- }
-
- public void addPath(String directory) {
- addPath(directory, "");
- }
-
- public void addPath(String base, String relative) {
- Path base0 = Paths.get(base);
- Path base2 = base0.resolve(relative);
- if (Files.isDirectory(base2)) {
- try {
- Files.walkFileTree(base2, Collections.singleton(FileVisitOption.FOLLOW_LINKS), 8, new FileVisitor() {
- @Override
- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
- return visitFile(dir, attrs);
- }
-
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- addPath0(base0, file);
-
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult visitFileFailed(Path file, IOException exc) {
- warnOnException(exc, base);
-
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
- warnOnException(exc, base);
-
- return FileVisitResult.CONTINUE;
- }
- });
- } catch (IOException e) {
- warnOnException(e, base);
- }
- try {
- bootstrapPath(listeners, base, relative);
- } catch (IOException e) {
- warnOnException(e, base);
- }
- }
- }
-
- void addPath0(Path base, Path full) {
- if (Files.isDirectory(full)) {
- try {
- String basePath = base.toString();
- watchKeyToPathMap.put(full.register(
- watchService,
- StandardWatchEventKinds.ENTRY_CREATE,
- StandardWatchEventKinds.ENTRY_DELETE,
- StandardWatchEventKinds.ENTRY_MODIFY),
- new PathInfo(basePath, full.toString()));
- } catch (IOException e) {
- Jvm.warn().on(FileSystemWatcher.class, "Couldn't add path " + full, e);
- }
- }
- }
-
- public void addListener(WatcherListener listener) {
- listenersToAdd.add(listener);
- thread.interrupt();
- }
-
- private void removePath(String filename) {
- watchKeyToPathMap.keySet().stream()
- .filter(k -> matches(watchKeyToPathMap.get(k), filename))
- .forEach(wk -> {
- watchKeysToRemove.add(wk);
- wk.cancel();
- });
- }
-
- private boolean matches(PathInfo path, String filename) {
- String s = path.full;
- return s.equals(filename) || s.startsWith(filename + "/");
- }
-
- void run() {
- WatchKey key;
- while (running) {
- List list = new ArrayList<>();
- listenersToAdd.drainTo(list);
- bootstrap(list);
- listeners.addAll(list);
-
- try {
- if ((key = watchService.take()) == null)
- break;
- PathInfo base = watchKeyToPathMap.get(key);
- for (WatchEvent> event : key.pollEvents()) {
- for (Iterator iterator = listeners.iterator(); iterator.hasNext(); ) {
- WatcherListener listener = iterator.next();
- try {
- if (event.kind() == OVERFLOW) {
- Jvm.warn().on(getClass(), "Overflow on watcher events for " + base);
- bootstrap(listeners);
- continue;
- }
-
- @SuppressWarnings("unchecked")
- WatchEvent event2 = (WatchEvent) event;
- String fullRelative = (base.relativePath.isEmpty() ? "" : base.relativePath + "/") + event2.context();
- String filename = base.basePath + "/" + fullRelative;
- if (event.kind() == ENTRY_CREATE) {
- listener.onExists(p(base.basePath), p(fullRelative), false);
- addPath(base.basePath, fullRelative);
- } else if (event.kind() == ENTRY_MODIFY) {
- listener.onExists(p(base.basePath), p(fullRelative), true);
- } else if (event.kind() == ENTRY_DELETE) {
- listener.onRemoved(p(base.basePath), p(fullRelative));
- removePath(filename);
- }
- } catch (IllegalStateException ise) {
- iterator.remove();
- }
- }
- }
- key.reset();
- if (watchKeysToRemove.contains(key)) {
- watchKeyToPathMap.remove(key);
- watchKeysToRemove.remove(key);
- }
- } catch (InterruptedException expected) {
- Thread.currentThread().interrupt();
- }
- }
- }
-
- private void bootstrap(List list) {
- for (PathInfo pathInfo : watchKeyToPathMap.values()) {
- try {
- bootstrapPath(list, pathInfo.basePath, "");
- } catch (IOException e) {
- Jvm.warn().on(getClass(), "Failed to walk " + pathInfo, e);
- }
- }
- }
-
- private void bootstrapPath(List list, String base, String relative) throws IOException {
- Path full = Paths.get(base).resolve(relative);
-
- Files.walkFileTree(full, Collections.singleton(FileVisitOption.FOLLOW_LINKS), 8, new FileVisitor() {
- @Override
- public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException {
- return visitFile(dir, attrs);
- }
-
- @Override
- public FileVisitResult visitFile(Path p, BasicFileAttributes attrs) throws IOException {
- for (Iterator iterator = list.iterator(); iterator.hasNext(); ) {
- WatcherListener listener = iterator.next();
- String pToString = p.toString();
- if (pToString.equals(full.toString()))
- continue;
- String filename = pToString.substring(base.length() + 1);
- try {
- listener.onExists(p(base), p(filename), null);
- } catch (IllegalStateException ise) {
- iterator.remove();
- }
- }
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
- warnOnException(exc, base);
-
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
- warnOnException(exc, base);
-
- return FileVisitResult.CONTINUE;
- }
- });
- }
-
- public void start() {
- thread.start();
- }
-
- public void stop() {
- running = false;
- thread.interrupt();
- try {
- thread.join(1000);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- Closeable.closeQuietly(watchService);
- }
-
- private void warnOnException(IOException exc, String base) {
- if (exc != null) {
- Jvm.warn().on(FileSystemWatcher.class, "Couldn't walk path " + base, exc);
- }
- }
-
- static class PathInfo {
- final String basePath;
- final String full;
- final String relativePath;
-
- public PathInfo(String basePath, String full) {
- this.basePath = basePath;
- this.full = full;
- this.relativePath = basePath.equals(full) ? "" : full.substring(basePath.length() + 1);
- }
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/JMXFileManager.java b/src/main/java/net/openhft/chronicle/core/watcher/JMXFileManager.java
deleted file mode 100644
index f718d2e79c9..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/JMXFileManager.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-import net.openhft.chronicle.core.Jvm;
-
-import javax.management.*;
-import java.lang.management.ManagementFactory;
-
-@Deprecated(/* to be removed x.26 */)
-public abstract class JMXFileManager implements FileManager, JMXFileManagerMBean {
- protected static final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
- protected final String basePath;
- protected final String relativePath;
- private final ObjectName objectName;
-
- protected JMXFileManager(String basePath, String relativePath) {
- this.basePath = basePath;
- this.relativePath = relativePath;
- try {
- objectName = new ObjectName(jmxPath() + ":type=" + type() + ",name=" + relativePath);
- } catch (MalformedObjectNameException e) {
- throw new AssertionError(e);
- }
- }
-
- protected String type() {
- return "basic";
- }
-
- protected String jmxPath() {
- return "chronicle";
- }
-
- public String getBasePath() {
- return basePath;
- }
-
- public String getRelativePath() {
- return relativePath;
- }
-
- @Override
- public void start() {
- try {
- mbs.registerMBean(this, objectName);
- } catch (Exception e) {
- Jvm.warn().on(getClass(), "Unable to register " + this, e);
- }
- }
-
- @Override
- public void stop() {
- try {
- mbs.unregisterMBean(objectName);
- } catch (InstanceNotFoundException | MBeanRegistrationException e) {
- Jvm.warn().on(getClass(), "Unable to unregister " + this, e);
- }
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/JMXFileManagerMBean.java b/src/main/java/net/openhft/chronicle/core/watcher/JMXFileManagerMBean.java
deleted file mode 100644
index 7a137ec9fb5..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/JMXFileManagerMBean.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-@Deprecated(/* to be removed x.26 */)
-public interface JMXFileManagerMBean {
- String getBasePath();
-
- String getRelativePath();
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/PlainFileClassifier.java b/src/main/java/net/openhft/chronicle/core/watcher/PlainFileClassifier.java
deleted file mode 100644
index dd5f3083276..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/PlainFileClassifier.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-@Deprecated(/* to be removed x.26 */)
-public class PlainFileClassifier implements FileClassifier {
- @Override
- public FileManager classify(String base, String relative) {
- Path path = Paths.get(base, relative);
- if (Files.isRegularFile(path)) {
- return new PlainFileManager(base, relative, path);
- }
- return null;
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/PlainFileManager.java b/src/main/java/net/openhft/chronicle/core/watcher/PlainFileManager.java
deleted file mode 100644
index 90539699ae3..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/PlainFileManager.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-
-@Deprecated(/* to be removed x.26 */)
-class PlainFileManager extends JMXFileManager implements PlainFileManagerMBean {
- private final Path path;
-
- public PlainFileManager(String base, String relative, Path path) {
- super(base, relative);
- this.path = path;
- }
-
- @Override
- protected String type() {
- return "files";
- }
-
- @Override
- public String getFileSize() {
- try {
- long size = Files.size(path);
- if (size < 2 << 10)
- return size + " B";
- if (size < 2 << 20)
- return (size * 10L >> 10) / 10.0 + " KiB";
- return (size * 10L >> 20) / 10.0 + " MiB";
- } catch (IOException e) {
- return e.toString();
- }
- }
-
- @Override
- public String getContentType() {
- try {
- return Files.probeContentType(path);
- } catch (IOException e) {
- return "Unknown";
- }
- }
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/PlainFileManagerMBean.java b/src/main/java/net/openhft/chronicle/core/watcher/PlainFileManagerMBean.java
deleted file mode 100644
index 0a159112249..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/PlainFileManagerMBean.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-@SuppressWarnings("unused")
-@Deprecated(/* to be removed x.26 */)
-public interface PlainFileManagerMBean {
- String getFileSize();
-
- String getContentType();
-}
diff --git a/src/main/java/net/openhft/chronicle/core/watcher/WatcherListener.java b/src/main/java/net/openhft/chronicle/core/watcher/WatcherListener.java
deleted file mode 100644
index 2916408e1aa..00000000000
--- a/src/main/java/net/openhft/chronicle/core/watcher/WatcherListener.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package net.openhft.chronicle.core.watcher;
-
-@Deprecated(/* to be removed x.26 */)
-public interface WatcherListener {
- /**
- * When a file or directory is added or modified.
- *
- * @param filename of the
- * @param modified false is created, true if modified, null if bootstrapping.
- * @throws IllegalStateException when this listener is no longer valid
- */
- void onExists(String base, String filename, Boolean modified) throws IllegalStateException;
-
- /**
- * Notify that a file or directory was removed.
- *
- * @param filename removed.
- * @throws IllegalStateException when this listener is no longer valid
- */
- void onRemoved(String base, String filename) throws IllegalStateException;
-}
diff --git a/src/test/java/net/openhft/chronicle/core/CoreTestCommon.java b/src/test/java/net/openhft/chronicle/core/CoreTestCommon.java
index 63ed04ec930..be6111a25ea 100644
--- a/src/test/java/net/openhft/chronicle/core/CoreTestCommon.java
+++ b/src/test/java/net/openhft/chronicle/core/CoreTestCommon.java
@@ -78,5 +78,4 @@ public void afterChecks() {
protected void assertReferencesReleased() {
ReferenceCountedUtils.assertReferencesReleased();
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/JvmMain.java b/src/test/java/net/openhft/chronicle/core/JvmMain.java
index a0099c866db..6584188d96c 100644
--- a/src/test/java/net/openhft/chronicle/core/JvmMain.java
+++ b/src/test/java/net/openhft/chronicle/core/JvmMain.java
@@ -24,4 +24,3 @@ public static void main(String[] args) {
assertTrue(!isWarn.isInfoEnabled() && isWarn.isWarnEnabled());
}
}
-
diff --git a/src/test/java/net/openhft/chronicle/core/JvmParseSizeTest.java b/src/test/java/net/openhft/chronicle/core/JvmParseSizeTest.java
index cf27d475271..bf206d67d4f 100644
--- a/src/test/java/net/openhft/chronicle/core/JvmParseSizeTest.java
+++ b/src/test/java/net/openhft/chronicle/core/JvmParseSizeTest.java
@@ -53,7 +53,7 @@ public static Collection data() {
{" 2 M", 2L << 20},
{"0.75GiB", 768L << 20},
{"1.5 GiB", 1536L << 20},
- {"0.001TiB", (1L << 40) / 1000}
+ {"0.001TiB", Math.round((1L << 40) / 1000.0)}
});
}
diff --git a/src/test/java/net/openhft/chronicle/core/MemoryTest.java b/src/test/java/net/openhft/chronicle/core/MemoryTest.java
index ea799de6c02..02e70b0e08b 100644
--- a/src/test/java/net/openhft/chronicle/core/MemoryTest.java
+++ b/src/test/java/net/openhft/chronicle/core/MemoryTest.java
@@ -27,13 +27,6 @@
public class MemoryTest extends CoreTestCommon {
- @Test
- public void testHeapUsed() {
- final long heapUsed = OS.memory().heapUsed();
- System.out.println("heap used: " + heapUsed);
- assertTrue(heapUsed > 0);
- }
-
@Test
public void testReadme() {
@Nullable Memory memory = OS.memory();
diff --git a/src/test/java/net/openhft/chronicle/core/OSTest.java b/src/test/java/net/openhft/chronicle/core/OSTest.java
index 3366e98bb9a..53e5c738c95 100644
--- a/src/test/java/net/openhft/chronicle/core/OSTest.java
+++ b/src/test/java/net/openhft/chronicle/core/OSTest.java
@@ -25,23 +25,22 @@
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
-import org.mockito.*;
+import org.mockito.MockitoAnnotations;
-import java.io.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.nio.ByteOrder;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
-import java.nio.file.Files;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Stream;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.mockito.Mockito.*;
import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;
diff --git a/src/test/java/net/openhft/chronicle/core/UnsafeMemory2Test.java b/src/test/java/net/openhft/chronicle/core/UnsafeMemory2Test.java
index bdca4fbaf65..e32c6e4bc79 100644
--- a/src/test/java/net/openhft/chronicle/core/UnsafeMemory2Test.java
+++ b/src/test/java/net/openhft/chronicle/core/UnsafeMemory2Test.java
@@ -392,7 +392,9 @@ public void copyMemoryEachWayByteArrayHeapObject() throws NoSuchFieldException {
final byte[] data = new byte[Integer.BYTES];
data[0] = 98;
MyDTO to = new MyDTO();
+
memory.copyMemory(data, 0, to, offset, Integer.BYTES);
+
assertEquals(data[0], to.num);
to.num = 77;
memory.copyMemory(to, offset, data, memory.arrayBaseOffset(data.getClass()), Integer.BYTES);
@@ -614,5 +616,4 @@ public void directMemoryVolatileDouble() {
static class MyDTO {
int num;
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryIntTest.java b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryIntTest.java
index 9945efe29ed..850788c7a83 100644
--- a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryIntTest.java
+++ b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryIntTest.java
@@ -36,7 +36,7 @@ public Class type() {
@Override
public IntPredicate alignedToType() {
- return Ints.intAligned();
+ return x -> x % 4 == 0;
}
@Override
diff --git a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryLongTest.java b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryLongTest.java
index c78cba12309..fd628da705a 100644
--- a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryLongTest.java
+++ b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryLongTest.java
@@ -36,7 +36,7 @@ public Class type() {
@Override
public IntPredicate alignedToType() {
- return Ints.longAligned();
+ return x -> x % 8 == 0;
}
@Override
diff --git a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryShortTest.java b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryShortTest.java
index 9e11bc36f37..c1d4c205e68 100644
--- a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryShortTest.java
+++ b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryShortTest.java
@@ -36,7 +36,7 @@ public Class type() {
@Override
public IntPredicate alignedToType() {
- return Ints.shortAligned();
+ return x -> x % 2 == 0;
}
@Override
diff --git a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTest.java b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTest.java
index 5943fa81aa5..61641cc43d0 100644
--- a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTest.java
+++ b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTest.java
@@ -32,7 +32,6 @@
import static net.openhft.chronicle.core.UnsafeMemory.UNSAFE;
import static org.junit.Assert.*;
-
@RunWith(Parameterized.class)
public class UnsafeMemoryTest extends CoreTestCommon {
diff --git a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTestMixin.java b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTestMixin.java
index 6b581de8252..28969c6baba 100644
--- a/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTestMixin.java
+++ b/src/test/java/net/openhft/chronicle/core/UnsafeMemoryTestMixin.java
@@ -242,7 +242,6 @@ String name() {
T operation() {
return operation;
}
-
}
@FunctionalInterface
@@ -368,7 +367,6 @@ public long addr() {
public void close() {
closer.run();
}
-
}
static Mode mode(Arguments args) {
@@ -401,7 +399,5 @@ enum Mode {
public boolean isDirectAddressing() {
return this == NATIVE_ADDRESS;
}
-
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/ZeroCostAssertionStatusTest.java b/src/test/java/net/openhft/chronicle/core/ZeroCostAssertionStatusTest.java
index 52a7cddb520..f0bf311ec91 100644
--- a/src/test/java/net/openhft/chronicle/core/ZeroCostAssertionStatusTest.java
+++ b/src/test/java/net/openhft/chronicle/core/ZeroCostAssertionStatusTest.java
@@ -42,5 +42,4 @@ void show() {
System.out.println("Normal assertions are " + (ae ? "ON" : "OFF"));
System.out.println("Zero-cost assertions are " + (zcae ? "ON" : "OFF"));
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/annotation/ScopeConfinedTest.java b/src/test/java/net/openhft/chronicle/core/annotation/ScopeConfinedTest.java
index c35d2b775cd..d08e131156a 100644
--- a/src/test/java/net/openhft/chronicle/core/annotation/ScopeConfinedTest.java
+++ b/src/test/java/net/openhft/chronicle/core/annotation/ScopeConfinedTest.java
@@ -48,5 +48,4 @@ interface Foo {
Stream<@ScopeConfined T> stream();
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/announcer/AnnouncerTest.java b/src/test/java/net/openhft/chronicle/core/announcer/AnnouncerTest.java
index 3455ee7b566..cb8be18660e 100644
--- a/src/test/java/net/openhft/chronicle/core/announcer/AnnouncerTest.java
+++ b/src/test/java/net/openhft/chronicle/core/announcer/AnnouncerTest.java
@@ -1,8 +1,9 @@
package net.openhft.chronicle.core.announcer;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
+import static org.junit.jupiter.api.Assertions.assertThrows;
class AnnouncerTest {
diff --git a/src/test/java/net/openhft/chronicle/core/benchmarks/CoolerAppendBase10.java b/src/test/java/net/openhft/chronicle/core/benchmarks/CoolerAppendBase10.java
deleted file mode 100644
index 25f8d7740a9..00000000000
--- a/src/test/java/net/openhft/chronicle/core/benchmarks/CoolerAppendBase10.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2016-2022 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.benchmarks;
-
-import net.openhft.chronicle.core.cooler.CoolerTester;
-import net.openhft.chronicle.core.cooler.CpuCoolers;
-import net.openhft.chronicle.core.io.UnsafeText;
-
-import static net.openhft.chronicle.core.UnsafeMemory.UNSAFE;
-
-public class CoolerAppendBase10 {
-
- static long blackhole;
-
- public static void main(String[] args) {
- long address = UNSAFE.allocateMemory(32);
- new CoolerTester(CpuCoolers.PAUSE1, CpuCoolers.BUSY100)
-// .add("noop", () -> null)
- .add("20d", () -> {
- blackhole = UnsafeText.appendFixed(address, -Integer.MAX_VALUE);
- return null;
- })
- .runTimeMS(10000)
- .repeat(6)
- .run();
-
- UNSAFE.freeMemory(address);
- }
-
-}
diff --git a/src/test/java/net/openhft/chronicle/core/benchmarks/Randomness.java b/src/test/java/net/openhft/chronicle/core/benchmarks/Randomness.java
index 20eaf00961f..75906aa7c97 100644
--- a/src/test/java/net/openhft/chronicle/core/benchmarks/Randomness.java
+++ b/src/test/java/net/openhft/chronicle/core/benchmarks/Randomness.java
@@ -58,5 +58,4 @@ public static void main(String[] args) {
System.out.println("Average score: " + scoreSum / 500);
System.out.printf("Average time %.3f us%n", time / timeCount / 1e3);
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/cleaner/impl/CleanerTestUtil.java b/src/test/java/net/openhft/chronicle/core/cleaner/impl/CleanerTestUtil.java
index 671c52baeea..a3e1c9d0ebc 100644
--- a/src/test/java/net/openhft/chronicle/core/cleaner/impl/CleanerTestUtil.java
+++ b/src/test/java/net/openhft/chronicle/core/cleaner/impl/CleanerTestUtil.java
@@ -66,5 +66,4 @@ public static void test(final Consumer cleaner) {
fail(e);
}
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/internal/CloseableUtilsTest.java b/src/test/java/net/openhft/chronicle/core/internal/CloseableUtilsTest.java
index ecdc7de66d4..7a6f49219d2 100644
--- a/src/test/java/net/openhft/chronicle/core/internal/CloseableUtilsTest.java
+++ b/src/test/java/net/openhft/chronicle/core/internal/CloseableUtilsTest.java
@@ -151,4 +151,4 @@ public void testCloseQuietlyHttpURLConnection() {
verify(mockHttpURLConnection, times(1)).disconnect();
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/net/openhft/chronicle/core/io/IOToolsTest.java b/src/test/java/net/openhft/chronicle/core/io/IOToolsTest.java
index 3227815d805..9bb2d3a638e 100644
--- a/src/test/java/net/openhft/chronicle/core/io/IOToolsTest.java
+++ b/src/test/java/net/openhft/chronicle/core/io/IOToolsTest.java
@@ -136,8 +136,6 @@ public void testReadAsBytes() throws IOException {
assertArrayEquals(testData.getBytes(), bytes);
}
-
-
@Test
public void readFileManyTimesByPath() {
final int iterations = 3_000;
diff --git a/src/test/java/net/openhft/chronicle/core/io/UnsafeTextTest.java b/src/test/java/net/openhft/chronicle/core/io/UnsafeTextTest.java
deleted file mode 100644
index 10bd2425208..00000000000
--- a/src/test/java/net/openhft/chronicle/core/io/UnsafeTextTest.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright 2016-2022 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.io;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import net.openhft.chronicle.core.cooler.CoolerTester;
-import net.openhft.chronicle.core.cooler.CpuCoolers;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.util.Random;
-import java.util.stream.IntStream;
-import java.util.stream.LongStream;
-
-import static net.openhft.chronicle.core.UnsafeMemory.UNSAFE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-public class UnsafeTextTest extends CoreTestCommon {
-
- static long blackhole;
-
- @Override
- @Before
- public void threadDump() {
- super.threadDump();
- }
-
- @Test
- public void coolerAppendBase10quick() {
- long address = UNSAFE.allocateMemory(32);
-
- try {
-
- new CoolerTester(CpuCoolers.PAUSE1, CpuCoolers.BUSY1)
-// .add("noop", () -> null)
- .add("20d", () -> {
- blackhole = UnsafeText.appendFixed(address, -Integer.MAX_VALUE);
- return null;
- })
- .runTimeMS(100)
- .repeat(3)
- .run();
-
- final String memVal = LongStream.range(address, blackhole)
- .mapToInt(addr -> UNSAFE.getByte(null, addr))
- .mapToObj(c -> (char) c)
- .reduce(new StringBuilder(), StringBuilder::append, StringBuilder::append)
- .toString();
-
- assertEquals(Long.toString(-Integer.MAX_VALUE), memVal);
- } finally {
- UNSAFE.freeMemory(address);
- }
-
- }
-
- @Test
- public void testAppendDouble() {
- // TODO FIX
- // Examples for https://github.com/OpenHFT/Chronicle-Core/issues/493
- testAppendDoubleOnce(5.959231521092378E-8, "5.959231521092378E-8");
- testAppendDoubleOnce(5.954710747053357E-8, "5.954710747053357E-8");
- testAppendDoubleOnce(-4.3723721608241563E-8, "-4.3723721608241563E-8");
- testAppendDoubleOnce(3.5645738448792343E-8, "3.5645738448792343E-8");
- testAppendDoubleOnce(1.1914579369762811E-8, "1.1914579369762811E-8");
-
- // FIXED
- testAppendDoubleOnce(-1.4778838950354771E-9, "-1.4778838950354771E-9");
- testAppendDoubleOnce(-145344868913.80003, "-145344868913.80003");
-
- testAppendDoubleOnce(1.4753448053710411E-8, "1.4753448053710411E-8");
- testAppendDoubleOnce(4.731428525883379E-10, "4.731428525883379E-10");
- testAppendDoubleOnce(1e-5, "0.00001");
-
- testAppendDoubleOnce(5.7270847085938394E-9, "5.7270847085938394E-9");
- testAppendDoubleOnce(-3.5627763205104632E-9, "-3.5627763205104632E-9");
- testAppendDoubleOnce(3.4363211797092447E-10, "3.4363211797092447E-10");
-
- testAppendDoubleOnce(0.91234567890123456789, "0.9123456789012345");
- testAppendDoubleOnce(0.7205789375929972, "0.7205789375929972");
- testAppendDoubleOnce(1.7205789375929972E-8, "1.7205789375929972E-8");
- testAppendDoubleOnce(1.000000459754255, "1.000000459754255");
-// testAppendDoubleOnce(1.0000004597542552, "1.0000004597542552");
- testAppendDoubleOnce(-0.0042633243189823394, "-0.0042633243189823394");
- // too high
- testAppendDoubleOnce(4.3634067645459027E-4, "0.00043634067645459027");
- testAppendDoubleOnce(-4.8378951079402273E-4, "-0.00048378951079402273");
- testAppendDoubleOnce(3.8098893793449994E-4, "0.00038098893793449994");
- testAppendDoubleOnce(-0.0036980489197619678, "-0.0036980489197619678");
-
- // FIXED
- testAppendDoubleOnce(1.1777536373898703E-7, "0.00000011777536373898703");
- testAppendDoubleOnce(8.577881719106565E-8, "0.00000008577881719106565");
- testAppendDoubleOnce(1.1709707236415293E-7, "0.00000011709707236415293");
- testAppendDoubleOnce(1.0272238286878982E-7, "0.00000010272238286878982");
- testAppendDoubleOnce(9.077547054210796E-8, "0.00000009077547054210796");
- testAppendDoubleOnce(-1.1914407211387385E-7, "-0.00000011914407211387385");
-// testAppendDoubleOnce(1.0626477603237785E-10, "0.00000000010626477603237785");
- testAppendDoubleOnce(8.871684275243539E-4, "0.0008871684275243539");
- testAppendDoubleOnce(8.807878708605213E-4, "0.0008807878708605213");
- testAppendDoubleOnce(8.417670165790972E-4, "0.0008417670165790972");
- testAppendDoubleOnce(0.0013292726996348332, "0.0013292726996348332");
- testAppendDoubleOnce(2.4192540417349368E-4, "0.00024192540417349368");
- testAppendDoubleOnce(1.9283711356548258E-4, "0.00019283711356548258");
- testAppendDoubleOnce(-8.299137873077923E-5, "-0.00008299137873077923");
-
- // OK
- testAppendDoubleOnce(0, "0.0");
- testAppendDoubleOnce(0.001, "0.001");
- testAppendDoubleOnce(0.0001, "0.0001");
- testAppendDoubleOnce(0.000001, "0.000001");
- testAppendDoubleOnce(0.0000001, "0.0000001");
- testAppendDoubleOnce(1.0E-8, "1.0E-8");
- testAppendDoubleOnce(1.0E-9, "1.0E-9");
- testAppendDoubleOnce(0.009, "0.009");
- testAppendDoubleOnce(0.0009, "0.0009");
- testAppendDoubleOnce(0.00009, "0.00009");
- testAppendDoubleOnce(0.000009, "0.000009");
- testAppendDoubleOnce(0.0000009, "0.0000009");
- testAppendDoubleOnce(0.00000009, "0.00000009");
- testAppendDoubleOnce(9.0E-9, "9.0E-9");
- testAppendDoubleOnce(Double.NaN, "NaN");
- testAppendDoubleOnce(Double.POSITIVE_INFINITY, "Infinity");
- testAppendDoubleOnce(Double.NEGATIVE_INFINITY, "-Infinity");
- testAppendDoubleOnce(0.1, "0.1");
- testAppendDoubleOnce(12.0, "12.0");
- testAppendDoubleOnce(12.1, "12.1");
- testAppendDoubleOnce(12.00000001, "12.00000001");
- testAppendDoubleOnce(1e-9 + Math.ulp(1e-9), "1.0000000000000003E-9");
- testAppendDoubleOnce(1e-10 + Math.ulp(1e-10), "1.0000000000000002E-10");
- testAppendDoubleOnce(1e-11 + Math.ulp(1e-11), "1.0000000000000001E-11");
- double d = -1e30;
- testAppendDoubleOnce(d - Math.ulp(d), "-1000000000000000158000000000000");
- d = -1e31;
- testAppendDoubleOnce(d - Math.ulp(d), "-1.0000000000000001E31");
- d = -1e32;
- testAppendDoubleOnce(d - Math.ulp(d), "-1.0000000000000002E32");
-
- }
-
- public void testAppendDoubleOnce(double value, String expectedValue) {
- long address = UNSAFE.allocateMemory(max + 8);
- try {
- final String memVal = appendDoubleToString(value, address);
- assertEquals("value; " + value, expectedValue, memVal);
- } finally {
- UNSAFE.freeMemory(address);
- }
- }
-
- static final int max = 32;
-
- @Test
- public void testRandom() {
- int runLength = 10_000;
- IntStream.range(0, runLength).parallel().forEach(t -> {
- Random r = new Random();
- long address = UNSAFE.allocateMemory(max + 8);
- long l = r.nextLong() | 1L;
- for (int i = 0; i < 1_000; i++) {
- // agitate
- l += 2;
- double d = Double.longBitsToDouble(l);
- if (!Double.isFinite(d) || Math.abs(d) < 1e-20 || Math.abs(d) > 5e11) {
- break;
- }
- String s = appendDoubleToString(d, address);
- double d2 = Double.parseDouble(s);
- if (d != d2) {
- String message = "" + (d - d2);
- assertEquals(message, d, d2, 0);
- }
- }
- // this is called unless the test is about to die
- UNSAFE.freeMemory(address);
- });
- }
-
- @Test
- public void testSequential() {
- IntStream.range(0, 300).parallel().forEach(t -> {
- // odd numbers have the most precision error
- long address = UNSAFE.allocateMemory(max + 8);
- // double only has 16-17 digits of accuracy so 1 + x/1e15 has 16 digits.
- double n = 1e15;
- for (int i = 1; i < 10_000; i += 2) {
- // multiply by 10191 to traverse the space.
- long l = (t * 10_000L + i) * 10191L + (long) n;
- double d = l / n;
- String s = appendDoubleToString(d, address);
- double d2 = Double.parseDouble(s);
- if (d != d2)
- assertEquals("" + (d - d2), d, d2, 0);
- }
- // this is called unless the test is about to die
- UNSAFE.freeMemory(address);
- });
- }
-
- public String appendDoubleToString(double value, long address) {
- UNSAFE.putLong(address + max, 0L);
- final long endAddress = UnsafeText.appendDouble(address, value);
- if (endAddress > address + max)
- fail("value: " + value + " length: " + (endAddress - address));
- long end = UNSAFE.getLong(address + max);
- if (end != 0L)
- fail("Overwrite: " + Long.toHexString(end));
- return LongStream.range(address, endAddress)
- .mapToInt(addr -> UNSAFE.getByte(null, addr))
- .mapToObj(c -> (char) c)
- .reduce(new StringBuilder(), StringBuilder::append, StringBuilder::append)
- .toString();
- }
-
-}
diff --git a/src/test/java/net/openhft/chronicle/core/io/WgetTest.java b/src/test/java/net/openhft/chronicle/core/io/WgetTest.java
index 21d41f5ad3f..7ca3f22246b 100644
--- a/src/test/java/net/openhft/chronicle/core/io/WgetTest.java
+++ b/src/test/java/net/openhft/chronicle/core/io/WgetTest.java
@@ -1,11 +1,11 @@
package net.openhft.chronicle.core.io;
-import net.openhft.chronicle.core.io.Wget;
import org.junit.jupiter.api.Test;
import java.io.IOException;
-import static org.junit.jupiter.api.Assertions.*;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class WgetTest {
@@ -19,16 +19,6 @@ public void testHttpGetRequest() throws IOException {
assertFalse(sb.toString().isEmpty());
}
- @Test
- public void testDeprecatedMethod() throws IOException {
- String testUrl = "http://example.com";
-
- CharSequence result = Wget.url(testUrl);
-
- assertNotNull(result);
- assertFalse(result.toString().isEmpty());
- }
-
@Test
public void testHttpGetRequestWithInvalidUrl() {
String invalidUrl = "http://invalid.url";
diff --git a/src/test/java/net/openhft/chronicle/core/pom/PomPropertiesTest.java b/src/test/java/net/openhft/chronicle/core/pom/PomPropertiesTest.java
index 4520fc124bb..09c5e5450c0 100644
--- a/src/test/java/net/openhft/chronicle/core/pom/PomPropertiesTest.java
+++ b/src/test/java/net/openhft/chronicle/core/pom/PomPropertiesTest.java
@@ -2,7 +2,9 @@
import org.junit.jupiter.api.Test;
import java.util.Properties;
-import static org.junit.jupiter.api.Assertions.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
class PomPropertiesTest {
@@ -14,13 +16,13 @@ void testCreateWithValidArguments() {
@Test
void testCreateWithNullGroupId() {
- assertEquals("{}",
- PomProperties.create(null, "chronicle-queue").toString());
+ assertThrows(NullPointerException.class,
+ () -> PomProperties.create(null, "chronicle-queue").toString());
}
@Test
void testCreateWithNullArtifactId() {
- assertEquals("{}",
- PomProperties.create("net.openhft", null).toString());
+ assertThrows(NullPointerException.class,
+ () -> PomProperties.create("net.openhft", null).toString());
}
}
diff --git a/src/test/java/net/openhft/chronicle/core/pool/ClassAliasPoolTest.java b/src/test/java/net/openhft/chronicle/core/pool/ClassAliasPoolTest.java
index eb773775840..b9b939e69bb 100644
--- a/src/test/java/net/openhft/chronicle/core/pool/ClassAliasPoolTest.java
+++ b/src/test/java/net/openhft/chronicle/core/pool/ClassAliasPoolTest.java
@@ -33,7 +33,6 @@
public class ClassAliasPoolTest extends CoreTestCommon {
-
@Test
public void testApplyAliasForSet() {
assertEquals("!set", CLASS_ALIASES.applyAlias("Set").toString());
diff --git a/src/test/java/net/openhft/chronicle/core/pool/StringBuilderPoolTest.java b/src/test/java/net/openhft/chronicle/core/pool/StringBuilderPoolTest.java
deleted file mode 100644
index 715aa60f6f8..00000000000
--- a/src/test/java/net/openhft/chronicle/core/pool/StringBuilderPoolTest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package net.openhft.chronicle.core.pool;
-
-import net.openhft.chronicle.core.pool.StringBuilderPool;
-import net.openhft.chronicle.core.scoped.ScopedResourcePool;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.*;
-
-public class StringBuilderPoolTest {
-
- @Test
- public void testAcquireStringBuilder() {
- StringBuilderPool pool = new StringBuilderPool();
- StringBuilder sb1 = pool.acquireStringBuilder();
- assertNotNull(sb1);
- assertEquals(0, sb1.length());
- assertEquals(128, sb1.capacity());
-
- sb1.append("test");
-
- StringBuilder sb2 = pool.acquireStringBuilder();
- assertSame(sb1, sb2);
- assertEquals(0, sb2.length());
- }
-}
diff --git a/src/test/java/net/openhft/chronicle/core/pool/StringInternerTest.java b/src/test/java/net/openhft/chronicle/core/pool/StringInternerTest.java
index 8b90b30ef86..0f648a08f2f 100644
--- a/src/test/java/net/openhft/chronicle/core/pool/StringInternerTest.java
+++ b/src/test/java/net/openhft/chronicle/core/pool/StringInternerTest.java
@@ -41,7 +41,6 @@ public void testInternIndex() throws IllegalArgumentException {
for (int i = 0; i < 100; i++) {
assertEquals("" + i, si.get(si.index("" + i, null)));
}
-
}
private String[] uppercase;
@@ -77,5 +76,4 @@ private String randomLowercaseString() {
}
return sb.toString();
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/shutdown/HookletTest.java b/src/test/java/net/openhft/chronicle/core/shutdown/HookletTest.java
index 8859154a84b..f958b4d8931 100644
--- a/src/test/java/net/openhft/chronicle/core/shutdown/HookletTest.java
+++ b/src/test/java/net/openhft/chronicle/core/shutdown/HookletTest.java
@@ -74,4 +74,4 @@ public void testToString() {
assertTrue(toStringResult.startsWith("Hooklet{ priority: 10, identity: "));
assertTrue(toStringResult.contains("HookletTest"));
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/net/openhft/chronicle/core/threads/CleaningThreadLocalTest.java b/src/test/java/net/openhft/chronicle/core/threads/CleaningThreadLocalTest.java
index 287b32bb13a..4adb5da3b28 100644
--- a/src/test/java/net/openhft/chronicle/core/threads/CleaningThreadLocalTest.java
+++ b/src/test/java/net/openhft/chronicle/core/threads/CleaningThreadLocalTest.java
@@ -94,4 +94,4 @@ private void joinThread(Thread thread) {
throw new RuntimeException(e);
}
}
-}
\ No newline at end of file
+}
diff --git a/src/test/java/net/openhft/chronicle/core/threads/JitterSamplerTest.java b/src/test/java/net/openhft/chronicle/core/threads/JitterSamplerTest.java
deleted file mode 100644
index 914ce8b3ce7..00000000000
--- a/src/test/java/net/openhft/chronicle/core/threads/JitterSamplerTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 2016-2022 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.threads;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import net.openhft.chronicle.core.Jvm;
-import org.junit.Test;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import static org.junit.Assert.*;
-
-public class JitterSamplerTest extends CoreTestCommon {
-
- @Test
- public void takeSnapshot() throws InterruptedException {
- CountDownLatch latch = new CountDownLatch(2);
- Thread t = new Thread(() -> {
- JitterSampler.atStage("started");
- waitForLatch(latch);
- int millis = Jvm.isArm() ? 120 : 60;
- Jvm.pause(millis);
- JitterSampler.atStage("finishing");
- Jvm.pause(millis);
- JitterSampler.finished();
- });
- t.start();
- waitForLatch(latch);
- for (int i = 0; i < 10; i++) {
- Jvm.busyWaitMicros(1000);
- String s = JitterSampler.takeSnapshot(10_000_000);
- final String desc = JitterSampler.desc;
- if ("finishing".equals(desc)) {
- if (s != null && s.contains("finish"))
- break;
- } else {
- assertEquals("started", desc);
- }
- }
- t.join();
- String s = JitterSampler.takeSnapshot();
- assertNull(s);
- }
-
- private void waitForLatch(CountDownLatch latch) {
- latch.countDown();
- try {
- assertTrue(latch.await(3, TimeUnit.SECONDS));
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- throw new RuntimeException("Interrupted waiting for latch", e);
- }
- }
-}
diff --git a/src/test/java/net/openhft/chronicle/core/time/PosixTimeProviderTest.java b/src/test/java/net/openhft/chronicle/core/time/PosixTimeProviderTest.java
index 42c3240ac27..400a5a1d9cd 100644
--- a/src/test/java/net/openhft/chronicle/core/time/PosixTimeProviderTest.java
+++ b/src/test/java/net/openhft/chronicle/core/time/PosixTimeProviderTest.java
@@ -28,8 +28,6 @@
import org.jetbrains.annotations.NotNull;
import org.junit.Test;
-import java.util.concurrent.TimeUnit;
-
import static org.junit.Assert.assertTrue;
import static org.junit.Assume.assumeFalse;
import static org.junit.Assume.assumeTrue;
@@ -117,12 +115,10 @@ public void currentTime() throws IllegalStateException {
assumeTrue(!OS.isMacOSX());
TimeProvider tp = PosixTimeProvider.INSTANCE;
for (int i = 3; i >= 0; i--) {
- long time1 = tp.currentTime(TimeUnit.SECONDS);
long time2 = tp.currentTimeMillis();
long time3 = tp.currentTimeMicros();
long time4 = tp.currentTimeNanos();
try {
- assertBetween(time2 / 1000, time1, time2 / 1000 + 2);
assertBetween(time3 / 1000 - 1, time2, time3 / 1000 + 20);
assertBetween(time4 / 1000 - 100, time3, time4 / 1000 + 2_000);
} catch (AssertionError ae) {
diff --git a/src/test/java/net/openhft/chronicle/core/time/RunningMinimumTest.java b/src/test/java/net/openhft/chronicle/core/time/RunningMinimumTest.java
deleted file mode 100644
index ff68ea21de7..00000000000
--- a/src/test/java/net/openhft/chronicle/core/time/RunningMinimumTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package net.openhft.chronicle.core.time;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import org.jetbrains.annotations.NotNull;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * User: peter.lawrey
- * Date: 05/08/13
- * Time: 19:14
- */
-public class RunningMinimumTest extends CoreTestCommon {
- @Test
- public void testSample() {
- for (int k = 0; k < 1000; k++) {
- for (long delta : new long[]{0, Integer.MIN_VALUE, Integer.MAX_VALUE}) {
- @NotNull RunningMinimum rm = new RunningMinimum(50 * 1000);
- int j;
- for (j = 0; j < 50 * 1000000; j += 1000000) {
- long startTime = System.nanoTime() + j;
- long endTime = System.nanoTime() + j + delta + (long) (Math.pow(10 * 1000, Math.random()) * 1000);
- rm.sample(startTime, endTime);
- }
- assertEquals("delta=" + delta, delta, rm.minimum(), 40 * 1000);
- }
- }
- }
-
- @Test
- public void testVanillaDiff() {
- @NotNull VanillaDifferencer vd = new VanillaDifferencer();
- assertEquals(100, vd.sample(123400, 123500));
- }
-}
diff --git a/src/test/java/net/openhft/chronicle/core/time/SystemTimeProviderTest.java b/src/test/java/net/openhft/chronicle/core/time/SystemTimeProviderTest.java
index bff295ea805..d60c157678f 100644
--- a/src/test/java/net/openhft/chronicle/core/time/SystemTimeProviderTest.java
+++ b/src/test/java/net/openhft/chronicle/core/time/SystemTimeProviderTest.java
@@ -27,7 +27,6 @@
import org.junit.Test;
import java.security.SecureRandom;
-import java.util.concurrent.TimeUnit;
import static org.junit.Assert.assertTrue;
@@ -109,12 +108,10 @@ private void doCurrentTimeMicros() throws IllegalStateException {
public void currentTime() throws IllegalStateException {
for (int i = 3; i >= 0; i--) {
TimeProvider tp = SystemTimeProvider.INSTANCE;
- long time1 = tp.currentTime(TimeUnit.SECONDS);
long time2 = tp.currentTimeMillis();
long time3 = tp.currentTimeMicros();
long time4 = tp.currentTimeNanos();
try {
- assertBetween(time2 / 1000, time1, time2 / 1000 + 2);
assertBetween(time3 / 1000 - 8, time2, time3 / 1000 + 20);
assertBetween(time4 / 1000 - 100, time3, time4 / 1000 + 2_000);
} catch (AssertionError ae) {
@@ -142,6 +139,5 @@ public void resolution() {
// Performance test
assertTrue(h.totalCount() > 0);
}
-
}
}
diff --git a/src/test/java/net/openhft/chronicle/core/time/UniqueMicroTimeProviderTest.java b/src/test/java/net/openhft/chronicle/core/time/UniqueMicroTimeProviderTest.java
index 0b81da10230..976cefb89b3 100644
--- a/src/test/java/net/openhft/chronicle/core/time/UniqueMicroTimeProviderTest.java
+++ b/src/test/java/net/openhft/chronicle/core/time/UniqueMicroTimeProviderTest.java
@@ -222,4 +222,3 @@ public void currentTimeNanosShouldBeCorrect() {
}
}
}
-
diff --git a/src/test/java/net/openhft/chronicle/core/util/AnnotationsTest.java b/src/test/java/net/openhft/chronicle/core/util/AnnotationsTest.java
deleted file mode 100644
index 7b5ae989114..00000000000
--- a/src/test/java/net/openhft/chronicle/core/util/AnnotationsTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package net.openhft.chronicle.core.util;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.reflect.Method;
-
-import static org.junit.Assert.*;
-
-@RunWith(MockitoJUnitRunner.class)
-public class AnnotationsTest {
-
- @Retention(RetentionPolicy.RUNTIME)
- public @interface TestAnnotation {
- }
-
- public interface TestInterface {
- @TestAnnotation
- void interfaceMethod();
- }
-
- public static class SuperClass {
- public void superMethod() {
- }
- }
-
- public static class TestClass extends SuperClass implements TestInterface {
- public void testMethod() {
- }
-
- @Override
- public void interfaceMethod() {
- }
- }
-
- @Test
- public void findAnnotation_OnMethod() {
- TestAnnotation annotation = Annotations.findAnnotation(TestAnnotation.class, TestClass.class, "interfaceMethod", new Class>[0]);
-
- assertNotNull(annotation);
- }
-
- @Test
- public void findAnnotation_NotPresent() {
- TestAnnotation annotation = Annotations.findAnnotation(TestAnnotation.class, TestClass.class, "testMethod", new Class>[0]);
-
- assertNull(annotation);
- }
-
- @Test
- public void getAnnotation_DirectlyOnMethod() throws NoSuchMethodException {
- Method method = TestClass.class.getMethod("interfaceMethod");
- TestAnnotation annotation = Annotations.getAnnotation(method, TestAnnotation.class);
-
- assertNotNull(annotation);
- }
-
- @Test
- public void getAnnotation_NotPresent() throws NoSuchMethodException {
- Method method = TestClass.class.getMethod("testMethod");
- TestAnnotation annotation = Annotations.getAnnotation(method, TestAnnotation.class);
-
- assertNull(annotation);
- }
-}
diff --git a/src/test/java/net/openhft/chronicle/core/util/ByteConsumerTest.java b/src/test/java/net/openhft/chronicle/core/util/ByteConsumerTest.java
index c0f4d13969d..b0c46f033d9 100644
--- a/src/test/java/net/openhft/chronicle/core/util/ByteConsumerTest.java
+++ b/src/test/java/net/openhft/chronicle/core/util/ByteConsumerTest.java
@@ -1,9 +1,8 @@
package net.openhft.chronicle.core.util;
import org.junit.jupiter.api.Test;
-import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.ArgumentMatchers.anyByte;
-import static org.mockito.Mockito.*;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
class ByteConsumerTest {
@@ -16,35 +15,4 @@ void acceptShouldPerformOperation() {
assertEquals((byte) 10, resultContainer[0]);
}
-
- @Test
- void andThenShouldPerformBothOperationsInSequence() {
- byte[] resultContainer = new byte[2];
- ByteConsumer firstConsumer = value -> resultContainer[0] = value;
- ByteConsumer secondConsumer = value -> resultContainer[1] = (byte) (value + 10);
-
- ByteConsumer combinedConsumer = firstConsumer.andThen(secondConsumer);
-
- combinedConsumer.accept((byte) 5);
-
- assertEquals((byte) 5, resultContainer[0]);
- assertEquals((byte) 15, resultContainer[1]);
- }
-
- @Test
- void andThenShouldThrowNullPointerExceptionIfAfterIsNull() {
- ByteConsumer consumer = value -> { /* Do something */ };
- assertThrows(NullPointerException.class, () -> consumer.andThen(null));
- }
-
- @Test
- void andThenShouldNotPerformSecondOperationIfFirstThrowsException() {
- ByteConsumer firstConsumer = value -> { throw new RuntimeException(); };
- ByteConsumer secondConsumer = mock(ByteConsumer.class);
-
- ByteConsumer combinedConsumer = firstConsumer.andThen(secondConsumer);
-
- assertThrows(RuntimeException.class, () -> combinedConsumer.accept((byte) 5));
- verify(secondConsumer, never()).accept(anyByte());
- }
}
diff --git a/src/test/java/net/openhft/chronicle/core/util/IntConditionTest.java b/src/test/java/net/openhft/chronicle/core/util/IntConditionTest.java
index ceb4dbfd8b9..49698f04d6e 100644
--- a/src/test/java/net/openhft/chronicle/core/util/IntConditionTest.java
+++ b/src/test/java/net/openhft/chronicle/core/util/IntConditionTest.java
@@ -125,5 +125,4 @@ private void test(IntCondition predicate,
private static Map.Entry entry(int value, boolean expected) {
return new AbstractMap.SimpleImmutableEntry<>(value, expected);
}
-
}
diff --git a/src/test/java/net/openhft/chronicle/core/util/IntsTest.java b/src/test/java/net/openhft/chronicle/core/util/IntsTest.java
deleted file mode 100644
index 4a7f25de546..00000000000
--- a/src/test/java/net/openhft/chronicle/core/util/IntsTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright 2016-2022 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.util;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import org.jetbrains.annotations.NotNull;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-public class IntsTest extends CoreTestCommon {
-
- @Test
- public void require1Arg() {
- test(1, 0, v -> Ints.require(Ints.positive(), v));
- test(1, -1, v -> Ints.require(Ints.positive(), v));
- }
-
- @Test
- public void require2Arg() {
- test(1, 0, v -> Ints.require(Ints.equalTo(), v, 1));
- }
-
- @Test
- public void require3Ard() {
- test(0, 16, v -> Ints.require(Ints.between(), v, 0, 16));
- test(15, -1, v -> Ints.require(Ints.between(), v, 0, 16));
- }
-
- @Test
- public void shortAligned() {
- test(0, 1, v -> Ints.require(Ints.shortAligned(), v));
- test(2, 3, v -> Ints.require(Ints.shortAligned(), v));
- test(4, 5, v -> Ints.require(Ints.shortAligned(), v));
- test(6, 7, v -> Ints.require(Ints.shortAligned(), v));
- test(8, 9, v -> Ints.require(Ints.shortAligned(), v));
- }
- @Test
- public void intAligned() {
- test(0, 1, v -> Ints.require(Ints.intAligned(), v));
- test(0, 2, v -> Ints.require(Ints.intAligned(), v));
- test(0, 3, v -> Ints.require(Ints.intAligned(), v));
- test(4, 5, v -> Ints.require(Ints.intAligned(), v));
- test(4, 6, v -> Ints.require(Ints.intAligned(), v));
- }
- @Test
- public void longAligned() {
- test(0, 1, v -> Ints.require(Ints.longAligned(), v));
- test(0, 2, v -> Ints.require(Ints.longAligned(), v));
- test(0, 3, v -> Ints.require(Ints.longAligned(), v));
- test(0, 4, v -> Ints.require(Ints.longAligned(), v));
- test(0, 5, v -> Ints.require(Ints.longAligned(), v));
- test(0, 6, v -> Ints.require(Ints.longAligned(), v));
- test(0, 7, v -> Ints.require(Ints.longAligned(), v));
- test(8, 9, v -> Ints.require(Ints.longAligned(), v));
- }
-
- private void test(final int happy,
- final int sad,
- @NotNull final IntUnaryOperator mapper) {
- final long result = mapper.applyAsInt(happy);
- assertEquals(happy, result);
- try {
- final long result2 = mapper.applyAsInt(sad);
- fail(result2 + " is not valid!");
- } catch (IllegalArgumentException ignored) {
- // Happy path
- }
- }
-
- interface IntUnaryOperator {
- long applyAsInt(int happy) throws IllegalArgumentException;
- }
-
-}
diff --git a/src/test/java/net/openhft/chronicle/core/util/LongsTest.java b/src/test/java/net/openhft/chronicle/core/util/LongsTest.java
deleted file mode 100644
index 1e42ba9bdfa..00000000000
--- a/src/test/java/net/openhft/chronicle/core/util/LongsTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2016-2022 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.util;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import org.jetbrains.annotations.NotNull;
-import org.junit.Test;
-
-import static org.junit.Assert.*;
-
-public class LongsTest extends CoreTestCommon {
-
- @Test
- public void requireBoolean() {
- assertThrows(IllegalArgumentException.class, () -> Longs.require(() -> false, "Error"));
- Longs.require(() -> true, "OK");
- }
-
- @Test
- public void require1Arg() {
- test(1, 0, v -> Longs.require(Longs.positive(), v));
- test(1, -1, v -> Longs.require(Longs.positive(), v));
- }
-
- @Test
- public void require2Arg() {
- test(1, 0, v -> Longs.require(Longs.equalTo(), v, 1));
- }
-
- @Test
- public void require3Ard() {
- test(0, 16, v -> Longs.require(Longs.between(), v, 0, 16));
- test(15, -1, v -> Longs.require(Longs.between(), v, 0, 16));
- }
-
- @Test
- public void shortAligned() {
- test(0, 1, v -> Longs.require(Longs.shortAligned(), v));
- test(2, 3, v -> Longs.require(Longs.shortAligned(), v));
- test(4, 5, v -> Longs.require(Longs.shortAligned(), v));
- test(6, 7, v -> Longs.require(Longs.shortAligned(), v));
- test(8, 9, v -> Longs.require(Longs.shortAligned(), v));
- }
-
- @Test
- public void intAligned() {
- test(0, 1, v -> Longs.require(Longs.intAligned(), v));
- test(0, 2, v -> Longs.require(Longs.intAligned(), v));
- test(0, 3, v -> Longs.require(Longs.intAligned(), v));
- test(4, 5, v -> Longs.require(Longs.intAligned(), v));
- test(4, 6, v -> Longs.require(Longs.intAligned(), v));
- }
-
- @Test
- public void longAligned() {
- test(0, 1, v -> Longs.require(Longs.longAligned(), v));
- test(0, 2, v -> Longs.require(Longs.longAligned(), v));
- test(0, 3, v -> Longs.require(Longs.longAligned(), v));
- test(0, 4, v -> Longs.require(Longs.longAligned(), v));
- test(0, 5, v -> Longs.require(Longs.longAligned(), v));
- test(0, 6, v -> Longs.require(Longs.longAligned(), v));
- test(0, 7, v -> Longs.require(Longs.longAligned(), v));
- test(8, 9, v -> Longs.require(Longs.longAligned(), v));
- }
-
- private void test(final int happy,
- final int sad,
- @NotNull final LongUnaryOperator mapper) {
- final long result = mapper.applyAsLong(happy);
- assertEquals(happy, result);
- try {
- final long result2 = mapper.applyAsLong(sad);
- fail(result2 + " is not valid!");
- } catch (IllegalArgumentException ignored) {
- // Happy path
- }
- }
-
- interface LongUnaryOperator {
- long applyAsLong(int happy) throws IllegalArgumentException;
- }
-
-}
diff --git a/src/test/java/net/openhft/chronicle/core/util/ObjectUtilsTest.java b/src/test/java/net/openhft/chronicle/core/util/ObjectUtilsTest.java
index a47e7ef02ca..c0ffcd7221b 100644
--- a/src/test/java/net/openhft/chronicle/core/util/ObjectUtilsTest.java
+++ b/src/test/java/net/openhft/chronicle/core/util/ObjectUtilsTest.java
@@ -34,7 +34,7 @@
public class ObjectUtilsTest extends CoreTestCommon {
@Test
public void testImmutable() {
- for (@NotNull Class c : new Class[]{
+ for (@NotNull Class> c: new Class[]{
String.class,
Integer.class,
Date.class,
@@ -43,7 +43,7 @@ public void testImmutable() {
}) {
assertEquals(c.getName(), ObjectUtils.Immutability.MAYBE, ObjectUtils.isImmutable(c));
}
- for (@NotNull Class c : new Class[]{
+ for (@NotNull Class> c: new Class[]{
// StringBuilder.class, // StringBuilder implements Comparable in Java 11
ArrayList.class,
HashMap.class,
@@ -146,13 +146,6 @@ public void immutableShouldRegisterImmutability() {
// Verify the immutability status is correctly set (requires a way to check the status)
}
- @Test
- public void deprecatedImmutabileShouldStillFunction() {
- Class> testClass = RegularClass.class;
- ObjectUtils.immutabile(testClass, true);
- // Verify the immutability status is correctly set as with immutable method
- }
-
@Test
public void caseIgnoreLookupShouldCreateCorrectMap() {
// Assuming MyEnum is an enum class
diff --git a/src/test/java/net/openhft/chronicle/core/util/RecordingHistogramTest.java b/src/test/java/net/openhft/chronicle/core/util/RecordingHistogramTest.java
index 3e48f450539..b43c0d3624f 100644
--- a/src/test/java/net/openhft/chronicle/core/util/RecordingHistogramTest.java
+++ b/src/test/java/net/openhft/chronicle/core/util/RecordingHistogramTest.java
@@ -54,7 +54,6 @@ public void testReset() {
histogram.reset();
}
-
@Test
public void testSamples() {
Histogram h = new MyRecordingHistogram();
diff --git a/src/test/java/net/openhft/chronicle/core/util/ThrowingConsumerTest.java b/src/test/java/net/openhft/chronicle/core/util/ThrowingConsumerTest.java
deleted file mode 100644
index a5d11c55b0f..00000000000
--- a/src/test/java/net/openhft/chronicle/core/util/ThrowingConsumerTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.util;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import org.jetbrains.annotations.NotNull;
-import org.junit.Test;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.function.Consumer;
-
-import static org.junit.Assert.fail;
-
-public class ThrowingConsumerTest extends CoreTestCommon {
- @Test
- public void asConsumer() throws Exception {
- @NotNull Consumer sc = ThrowingConsumer.asConsumer(s -> {
- try (@NotNull BufferedReader br = new BufferedReader(new FileReader(s))) {
- System.out.println(br.readLine());
- }
- });
-
- try {
- sc.accept("doesn't exists");
- fail();
- if (false) throw new IOException();
- } catch (IOException e) {
- // expected
- }
- }
-}
diff --git a/src/test/java/net/openhft/chronicle/core/util/URIEncoderTest.java b/src/test/java/net/openhft/chronicle/core/util/URIEncoderTest.java
deleted file mode 100644
index a3c77432e81..00000000000
--- a/src/test/java/net/openhft/chronicle/core/util/URIEncoderTest.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2016-2020 chronicle.software
- *
- * https://chronicle.software
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package net.openhft.chronicle.core.util;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class URIEncoderTest extends CoreTestCommon {
- @Test
- public void encodeURI() throws Exception {
- assertEquals("~%25", URIEncoder.encodeURI("~%"));
- }
-}
diff --git a/src/test/java/net/openhft/chronicle/core/watcher/FileSystemWatcherMain.java b/src/test/java/net/openhft/chronicle/core/watcher/FileSystemWatcherMain.java
deleted file mode 100644
index 6f48a1aa204..00000000000
--- a/src/test/java/net/openhft/chronicle/core/watcher/FileSystemWatcherMain.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2016-2020 chronicle.software
- */
-
-package net.openhft.chronicle.core.watcher;
-
-import java.io.File;
-import java.io.IOException;
-
-public class FileSystemWatcherMain {
- public static void main(String[] args) throws IOException, InterruptedException {
- FileSystemWatcher fsw = new FileSystemWatcher();
- String absolutePath = new File(".").getAbsolutePath();
- System.out.println("Watching " + absolutePath);
- fsw.addPath(absolutePath);
- ClassifyingWatcherListener listener = new ClassifyingWatcherListener();
- listener.addClassifier(new PlainFileClassifier());
- fsw.addListener(listener);
- fsw.start();
- Thread.currentThread().join();
- }
-}
diff --git a/src/test/java/net/openhft/chronicle/core/watcher/FileSystemWatcherTest.java b/src/test/java/net/openhft/chronicle/core/watcher/FileSystemWatcherTest.java
deleted file mode 100644
index ec932bbc220..00000000000
--- a/src/test/java/net/openhft/chronicle/core/watcher/FileSystemWatcherTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2016-2020 chronicle.software
- */
-
-package net.openhft.chronicle.core.watcher;
-
-import net.openhft.chronicle.core.CoreTestCommon;
-import net.openhft.chronicle.core.Jvm;
-import net.openhft.chronicle.core.OS;
-import net.openhft.chronicle.core.io.IOTools;
-import net.openhft.chronicle.core.util.Time;
-import org.junit.*;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Paths;
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.concurrent.ConcurrentSkipListMap;
-import java.util.stream.Collectors;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assume.assumeFalse;
-
-@Ignore(/* flaky test for deprecated, never used code */)
-public class FileSystemWatcherTest extends CoreTestCommon {
- static String base = OS.getTarget() + "/FileSystemWatcherTest-" + Time.uniqueId();
-
- @Before
- public void setup() throws IOException {
- tearDown();
- Files.createDirectories(Paths.get(base));
- }
-
- @After
- public void tearDown() {
- IOTools.deleteDirWithFiles(base);
- }
-
- @Test
- public void bootstrapAndUpdate() throws IOException {
- assumeFalse(Jvm.isArm());
-
- /*
- This test fails on Windows and may also fail on MmcOS.
-
- The issue appears to be that the NIO file-watching service is very platform dependent.
-
- Eg. Linux does not produce events when a directory-entry is updated, WIndows does.
- Eg. Windows does not produce events when a file is opened for write - Linux does.
-
- This makes the results of this particular test heavily dependent on the platform.
-
- A practical solution would be to modify the test and framework so that only major events are generated (file created, modified etc) and filter out the unhelpful events (if possible ;-)
-
- In the meantime, this test has been ignored for Windows.
- */
- Assume.assumeTrue(OS.isLinux());
-
- SortedMap events = new ConcurrentSkipListMap<>();
-
- WatcherListener listener = new WatcherListener() {
- @Override
- public void onExists(String base, String filename, Boolean modified) {
- events.put(filename, "modified: " + modified);
- }
-
- @Override
- public void onRemoved(String base, String filename) {
- events.put(filename, "removed: true");
- }
- };
- assertTrue(new File(base + "/dir1").mkdir());
- assertTrue(new File(base + "/dir2").mkdir());
- assertTrue(new File(base + "/dir1/file11").createNewFile());
- assertTrue(new File(base + "/dir1/file12").createNewFile());
- assertTrue(new File(base + "/dir2/file20").createNewFile());
-
- FileSystemWatcher watcher = new FileSystemWatcher();
- watcher.addPath(base);
- watcher.start();
- watcher.addListener(listener);
- retryAssertEquals("dir1=modified: null\n" +
- "dir1/file11=modified: null\n" +
- "dir1/file12=modified: null\n" +
- "dir2=modified: null\n" +
- "dir2/file20=modified: null", events);
- try (FileWriter fw = new FileWriter(base + "/dir1/file11")) {
- }
- assertTrue(new File(base + "/dir2/file20").delete());
- assertTrue(new File(base + "/dir2/file21").createNewFile());
- assertTrue(new File(base + "/dir3/dir30").mkdirs());
- assertTrue(new File(base + "/dir3/dir30/file301").createNewFile());
-
- retryAssertEquals(
- "dir1=modified: null\n" +
- "dir1/file11=modified: true\n" +
- "dir1/file12=modified: null\n" +
- "dir2=modified: null\n" +
- "dir2/file20=removed: true\n" +
- "dir2/file21=modified: false\n" +
- "dir3=modified: false\n" +
- "dir3/dir30=modified: null\n" +
- "dir3/dir30/file301=modified: null", events);
-
- IOTools.deleteDirWithFiles(base + "/dir2", 2);
-
- retryAssertEquals(
- "dir1=modified: null\n" +
- "dir1/file11=modified: true\n" +
- "dir1/file12=modified: null\n" +
- "dir2=removed: true\n" +
- "dir2/file20=removed: true\n" +
- "dir2/file21=removed: true\n" +
- "dir3=modified: false\n" +
- "dir3/dir30=modified: null\n" +
- "dir3/dir30/file301=modified: null", events);
-
- watcher.stop();
- }
-
- private void retryAssertEquals(String expected, SortedMap events) {
- for (int i = Jvm.isDebug() ? 500 : 100; ; i--) {
- try {
- Jvm.pause(20);
- assertEquals(expected,
- events.entrySet().stream()
- .map(Map.Entry::toString)
- .collect(Collectors.joining("\n")));
- break;
- } catch (AssertionError ae) {
- if (i <= 0)
- throw ae;
- }
- }
- }
-}