diff --git a/src/test/java/io/tarantool/driver/TarantoolUtils.java b/src/test/java/io/tarantool/driver/TarantoolUtils.java index 2bd79851..dbe05ca7 100644 --- a/src/test/java/io/tarantool/driver/TarantoolUtils.java +++ b/src/test/java/io/tarantool/driver/TarantoolUtils.java @@ -1,7 +1,6 @@ package io.tarantool.driver; import io.tarantool.driver.utils.Assert; -import org.testcontainers.shaded.org.apache.commons.lang3.StringUtils; import java.util.Arrays; import java.util.Collections; @@ -18,13 +17,14 @@ private TarantoolUtils() { public static boolean versionGreaterOrEqualThen(String tarantoolVersion) { Assert.notNull(tarantoolVersion, "tarantoolVersion must not be null"); String tarantoolCiVersion = java.lang.System.getenv(TARANTOOL_VERSION); - if (StringUtils.isEmpty(tarantoolCiVersion)) { + if (tarantoolCiVersion == null || tarantoolCiVersion.isEmpty()) { return true; } TarantoolVersion ciVersion = new TarantoolVersion(tarantoolCiVersion); TarantoolVersion version = new TarantoolVersion(tarantoolVersion); return ciVersion.getMajor() >= version.getMajor() && ciVersion.getMinor() >= version.getMinor(); + } public static boolean versionWithUUID() { @@ -44,7 +44,8 @@ public static class TarantoolVersion { private Integer minor; public TarantoolVersion(String stringVersion) { - List majorMinor = StringUtils.isEmpty(stringVersion) ? Collections.emptyList() : + List majorMinor = stringVersion == null || stringVersion.isEmpty() ? + Collections.emptyList() : Arrays.stream(stringVersion.split("\\.")) .collect(Collectors.toList()); if (majorMinor.size() >= 1) { diff --git a/src/test/java/io/tarantool/driver/integration/ConnectionIT.java b/src/test/java/io/tarantool/driver/integration/ConnectionIT.java index a4de540d..2df82706 100644 --- a/src/test/java/io/tarantool/driver/integration/ConnectionIT.java +++ b/src/test/java/io/tarantool/driver/integration/ConnectionIT.java @@ -22,7 +22,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.testcontainers.junit.jupiter.Testcontainers; -import org.testcontainers.shaded.com.fasterxml.jackson.databind.util.ClassUtil; import java.util.ArrayList; import java.util.List; @@ -364,6 +363,6 @@ public void test_AddressProviderReturnsNull_shouldThrowTarantoolClientException( // then TarantoolClientException exception = assertThrows(TarantoolClientException.class, client::getVersion); - assertFalse(ClassUtil.getRootCause(exception) instanceof NullPointerException); + assertFalse(Utils.getRootCause(exception) instanceof NullPointerException); } } diff --git a/src/test/java/io/tarantool/driver/integration/ConvertersWithClusterClientIT.java b/src/test/java/io/tarantool/driver/integration/ConvertersWithClusterClientIT.java index eb739276..54cea5a6 100644 --- a/src/test/java/io/tarantool/driver/integration/ConvertersWithClusterClientIT.java +++ b/src/test/java/io/tarantool/driver/integration/ConvertersWithClusterClientIT.java @@ -13,13 +13,11 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIf; -import org.testcontainers.shaded.org.apache.commons.lang3.ArrayUtils; import java.time.Instant; import java.util.UUID; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.List; /** @@ -87,7 +85,7 @@ public void test_boxSelect_shouldReturnTupleWithInstant() throws Exception { public void test_boxOperations_shouldWorkWithVarbinary() throws Exception { //given byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8); - List byteList = Arrays.asList(ArrayUtils.toObject(bytes)); + List byteList = Utils.convertBytesToByteList(bytes); client.space("space_with_varbinary") .insert(tupleFactory.create(1, bytes)).get(); @@ -98,7 +96,7 @@ public void test_boxOperations_shouldWorkWithVarbinary() throws Exception { //then byte[] bytesFromTarantool = fields.getByteArray("varbinary_field"); - List byteListFromTarantool = Arrays.asList(ArrayUtils.toObject(bytesFromTarantool)); + List byteListFromTarantool = Utils.convertBytesToByteList(bytesFromTarantool); Assertions.assertEquals(byteList, byteListFromTarantool); } } diff --git a/src/test/java/io/tarantool/driver/integration/ConvertersWithProxyClientIT.java b/src/test/java/io/tarantool/driver/integration/ConvertersWithProxyClientIT.java index 42487e99..30809139 100644 --- a/src/test/java/io/tarantool/driver/integration/ConvertersWithProxyClientIT.java +++ b/src/test/java/io/tarantool/driver/integration/ConvertersWithProxyClientIT.java @@ -13,13 +13,11 @@ import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.EnabledIf; -import org.testcontainers.shaded.org.apache.commons.lang3.ArrayUtils; import java.time.Instant; import java.util.UUID; import java.nio.charset.StandardCharsets; -import java.util.Arrays; import java.util.List; /** @@ -89,7 +87,7 @@ public void test_crudSelect_shouldReturnTupleWithInstant() throws Exception { public void test_crudOperations_shouldWorkWithVarbinary() throws Exception { //given byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8); - List byteList = Arrays.asList(ArrayUtils.toObject(bytes)); + List byteList = Utils.convertBytesToByteList(bytes); client.space("space_with_varbinary") .insert(tupleFactory.create(1, bytes)).get(); @@ -100,7 +98,7 @@ public void test_crudOperations_shouldWorkWithVarbinary() throws Exception { //then byte[] bytesFromTarantool = fields.getByteArray("varbinary_field"); - List byteListFromTarantool = Arrays.asList(ArrayUtils.toObject(bytesFromTarantool)); + List byteListFromTarantool = Utils.convertBytesToByteList(bytesFromTarantool); Assertions.assertEquals(byteList, byteListFromTarantool); } @@ -108,7 +106,7 @@ public void test_crudOperations_shouldWorkWithVarbinary() throws Exception { public void test_crudOperations_shouldWorkWithBytesAsString() throws Exception { //given byte[] bytes = "hello".getBytes(StandardCharsets.UTF_8); - List byteList = Arrays.asList(ArrayUtils.toObject(bytes)); + List byteList = Utils.convertBytesToByteList(bytes); client.space("space_with_string") .insert(tupleFactory.create(1, bytes)).get(); @@ -119,7 +117,7 @@ public void test_crudOperations_shouldWorkWithBytesAsString() throws Exception { //then byte[] bytesFromTarantool = fields.getByteArray("string_field"); - List byteListFromTarantool = Arrays.asList(ArrayUtils.toObject(bytesFromTarantool)); + List byteListFromTarantool = Utils.convertBytesToByteList(bytesFromTarantool); Assertions.assertEquals(byteList, byteListFromTarantool); } } diff --git a/src/test/java/io/tarantool/driver/integration/Utils.java b/src/test/java/io/tarantool/driver/integration/Utils.java index 5576d666..5d0a38f0 100644 --- a/src/test/java/io/tarantool/driver/integration/Utils.java +++ b/src/test/java/io/tarantool/driver/integration/Utils.java @@ -15,6 +15,8 @@ import java.util.List; import java.util.Optional; import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; +import java.util.stream.IntStream; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -103,4 +105,26 @@ private static long crc32(byte[] data) { crc32 = Integer.reverse(crc32); // result reflect return crc32 & 0x00000000ffffffffL; // the unsigned java problem } + + /** + * Converts a byte array to a list of bytes + * + * @param bytes byte array + */ + static List convertBytesToByteList(byte[] bytes) { + return IntStream.range(0, bytes.length).mapToObj(i -> bytes[i]).collect(Collectors.toList()); + } + + /** + * Find the rootmost non-null cause of an Exception recursively + * + * @param t exception + * @return root cause of the exception or the exception itself + */ + static Throwable getRootCause(Throwable t) { + while (t.getCause() != null) { + t = t.getCause(); + } + return t; + } }