You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by yc...@apache.org on 2023/06/22 16:24:25 UTC
[cassandra-analytics] branch trunk updated: CASSANDRA-18599 Upgrade to JUnit 5
This is an automated email from the ASF dual-hosted git repository.
ycai pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra-analytics.git
The following commit(s) were added to refs/heads/trunk by this push:
new bd0b41f CASSANDRA-18599 Upgrade to JUnit 5
bd0b41f is described below
commit bd0b41fb82134844a15fbb43126424d96706d08e
Author: Doug Rohrer <dr...@apple.com>
AuthorDate: Wed Jun 14 13:33:29 2023 -0400
CASSANDRA-18599 Upgrade to JUnit 5
patch by Doug Rohrer, Francisco Guerrero; Reviewed by Dinesh Joshi, Yifan Cai for CASSANDRA-18599
---
.gitignore | 1 +
CHANGES.txt | 1 +
cassandra-analytics-core/build.gradle | 8 +-
.../bridge/CassandraVersionFeaturesTest.java | 17 +-
.../apache/cassandra/bridge/CompressionTests.java | 26 +-
.../org/apache/cassandra/bridge/VersionRunner.java | 25 +-
.../cassandra/clients/SidecarClientConfigTest.java | 4 +-
.../cassandra/clients/SidecarInstanceImplTest.java | 10 +-
.../cassandra/clients/SidecarInstanceTest.java | 8 +-
.../secrets/SslConfigSecretsProviderTest.java | 42 +-
.../apache/cassandra/secrets/SslConfigTest.java | 10 +-
.../org/apache/cassandra/spark/EndToEndTests.java | 456 ++++++++++++---------
.../cassandra/spark/KryoSerializationTests.java | 69 ++--
.../java/org/apache/cassandra/spark/TestUtils.java | 2 +-
.../java/org/apache/cassandra/spark/Tester.java | 26 +-
.../spark/bulkwriter/BulkSparkConfTest.java | 14 +-
.../spark/bulkwriter/CassandraRingMonitorTest.java | 12 +-
.../spark/bulkwriter/CqlTableInfoProviderTest.java | 6 +-
.../spark/bulkwriter/DecoratedKeyTest.java | 6 +-
.../spark/bulkwriter/RecordWriterTest.java | 57 +--
.../bulkwriter/RingInstanceSerializationTest.java | 4 +-
.../spark/bulkwriter/RingInstanceTest.java | 6 +-
.../spark/bulkwriter/SSTableWriterTest.java | 33 +-
.../bulkwriter/SqlToCqlTypeConverterTest.java | 124 +++---
.../bulkwriter/StreamSessionConsistencyTest.java | 59 ++-
.../spark/bulkwriter/StreamSessionTest.java | 49 +--
.../spark/bulkwriter/TableSchemaNormalizeTest.java | 4 +-
.../spark/bulkwriter/TableSchemaTest.java | 18 +-
.../spark/bulkwriter/TokenPartitionerTest.java | 8 +-
.../spark/cdc/watermarker/WatermarkerTests.java | 16 +-
.../data/CassandraDataSourceHelperCacheTest.java | 14 +-
.../cassandra/spark/data/CqlFieldComparators.java | 93 +++--
.../apache/cassandra/spark/data/CqlFieldTests.java | 108 ++---
.../DataLayerUnsupportedPushDownFiltersTest.java | 8 +-
.../cassandra/spark/data/DefaultSizingTest.java | 4 +-
.../cassandra/spark/data/LocalDataLayerTests.java | 28 +-
.../spark/data/PartitionedDataLayerTests.java | 83 ++--
.../spark/data/ReplicationFactorTests.java | 29 +-
.../apache/cassandra/spark/data/VersionRunner.java | 29 +-
.../spark/data/partitioner/CassandraRingTests.java | 12 +-
.../data/partitioner/ConsistencyLevelTests.java | 4 +-
.../data/partitioner/JDKSerializationTests.java | 43 +-
.../data/partitioner/MultipleReplicasTests.java | 26 +-
.../spark/data/partitioner/SingleReplicaTests.java | 52 ++-
.../data/partitioner/TokenPartitionerTests.java | 10 +-
.../spark/reader/CassandraBridgeTests.java | 4 +-
.../spark/reader/DataTypeSerializationTests.java | 14 +-
.../cassandra/spark/reader/OverlapTests.java | 6 +-
.../cassandra/spark/reader/PartitionKeyTests.java | 6 +-
.../apache/cassandra/spark/reader/RidTests.java | 12 +-
.../apache/cassandra/spark/reader/SchemaTests.java | 181 ++++----
.../spark/reader/TombstoneWriterTests.java | 8 +-
.../reader/common/CompressionInputStreamTests.java | 33 +-
.../cassandra/spark/utils/BuildInfoTest.java | 10 +-
.../spark/utils/ByteBufferUtilsTests.java | 6 +-
.../apache/cassandra/spark/utils/CqlUtilsTest.java | 126 +++---
.../cassandra/spark/utils/FilterUtilsTests.java | 21 +-
.../cassandra/spark/utils/RangeUtilsTest.java | 23 +-
.../spark/utils/SSTableInputStreamHttpTests.java | 29 +-
.../spark/utils/SSTableInputStreamTests.java | 26 +-
.../spark/sparksql/PartitionKeyFilterTests.java | 21 +-
.../spark/sparksql/SparkRangeFilterTests.java | 6 +-
.../spark/sparksql/SparkRowIteratorTests.java | 47 +--
.../org/apache/cassandra/spark/cdc/CdcTester.java | 28 +-
.../org/apache/cassandra/spark/cdc/CdcTests.java | 151 ++++---
.../cassandra/spark/cdc/CdcTombstoneTests.java | 191 +++++----
.../cassandra/spark/sparksql/CdcOffsetTests.java | 6 +-
cassandra-bridge/build.gradle | 5 +-
.../cassandra/bridge/BigNumberConfigImplTest.java | 4 +-
.../cassandra/spark/utils/ArrayUtilsTest.java | 14 +-
.../cassandra/spark/utils/LoggerHelperTests.java | 6 +-
.../cassandra/spark/utils/ThrowableUtilTests.java | 8 +-
cassandra-four-zero/build.gradle | 4 +-
.../cassandra/spark/data/types/DateTypeTests.java | 6 +-
.../cassandra/spark/reader/CdcScannerTests.java | 6 +-
.../cassandra/spark/reader/IndexDbTests.java | 16 +-
.../cassandra/spark/reader/IndexOffsetTests.java | 16 +-
.../spark/reader/KryoSerializationTests.java | 6 +-
.../cassandra/spark/reader/PartitionKeyTests.java | 6 +-
.../cassandra/spark/reader/ReaderUtilsTests.java | 10 +-
.../cassandra/spark/reader/SSTableCacheTests.java | 12 +-
.../cassandra/spark/reader/SSTableReaderTests.java | 12 +-
.../cassandra/spark/reader/SchemaBuilderTests.java | 4 +-
.../cassandra/spark/reader/SummaryDbTests.java | 14 +-
config/checkstyle/checkstyle.xml | 2 +-
gradle.properties | 3 +-
86 files changed, 1492 insertions(+), 1281 deletions(-)
diff --git a/.gitignore b/.gitignore
index c8e73d0..80c13ed 100644
--- a/.gitignore
+++ b/.gitignore
@@ -99,3 +99,4 @@ cassandra-analytics-build.properties
# MacOS
.DS_Store
+cassandra-analytics-core/dtest-jars
diff --git a/CHANGES.txt b/CHANGES.txt
index eeaee1c..947e97a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
1.0.0
+ * Upgrade to JUnit 5 (CASSANDRA-18599)
* Add support for TTL & Timestamps for bulk writes (CASSANDRA-18605)
* Add circleci configuration yaml for Cassandra Analytics (CASSANDRA-18578)
* Provide a SecretsProvider interface to abstract the secret provisioning (CASSANDRA-18545)
diff --git a/cassandra-analytics-core/build.gradle b/cassandra-analytics-core/build.gradle
index b81d6e7..37c67f8 100644
--- a/cassandra-analytics-core/build.gradle
+++ b/cassandra-analytics-core/build.gradle
@@ -74,14 +74,16 @@ project(':cassandra-analytics-core') {
compileOnly(group: "${sparkGroupId}", name: "spark-sql_${scalaMajorVersion}", version: "${project.rootProject.sparkVersion}")
testImplementation(group: 'com.google.guava', name: 'guava', version: '19.0')
- testImplementation(group: 'junit', name: 'junit', version: "${project.rootProject.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-api:${project.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-params:${project.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}")
testImplementation(group: 'org.quicktheories', name: 'quicktheories', version: "${project.rootProject.quickTheoriesVersion}")
testImplementation(group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.26')
testImplementation(group: 'org.mockito', name: 'mockito-core', version: "${project.rootProject.mockitoVersion}")
testImplementation(group: 'org.mockito', name: 'mockito-inline', version: "${project.rootProject.mockitoVersion}")
testImplementation(group: "${sparkGroupId}", name: "spark-core_${scalaMajorVersion}", version: "${project.rootProject.sparkVersion}")
testImplementation(group: "${sparkGroupId}", name: "spark-sql_${scalaMajorVersion}", version: "${project.rootProject.sparkVersion}")
- testImplementation(group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3')
+ testImplementation(group: 'org.hamcrest', name: 'hamcrest', version: '2.2')
testImplementation(group: 'org.openjdk.jmh', name: 'jmh-core', version: '1.33')
testImplementation(group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.13')
testImplementation(group: 'com.github.luben', name: 'zstd-jni', version: '1.5.0-4')
@@ -132,7 +134,7 @@ project(':cassandra-analytics-core') {
// Make it so unit tests run on a JAr with Cassandra bridge implementations built in
dependsOn(tasks.jar)
classpath = project.sourceSets.test.output + configurations.testRuntimeClasspath + files(jar.archiveFile)
- useJUnit()
+ useJUnitPlatform()
}
/* Start: JaCoCo check */
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CassandraVersionFeaturesTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CassandraVersionFeaturesTest.java
index e6b8a24..842477d 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CassandraVersionFeaturesTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CassandraVersionFeaturesTest.java
@@ -19,9 +19,10 @@
package org.apache.cassandra.bridge;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class CassandraVersionFeaturesTest
{
@@ -42,18 +43,20 @@ public class CassandraVersionFeaturesTest
testCassandraVersion("qwerty-cassandra-4.0-SNAPSHOT", 40, 0, "SNAPSHOT");
}
- @Test(expected = RuntimeException.class)
+ @Test()
public void testInvalidInput()
{
- CassandraVersionFeatures.cassandraVersionFeaturesFromCassandraVersion("qwerty");
+ assertThrows(RuntimeException.class, () ->
+ CassandraVersionFeatures.cassandraVersionFeaturesFromCassandraVersion("qwerty")
+ );
}
private static void testCassandraVersion(String version, int major, int minor, String suffix)
{
CassandraVersionFeatures features = CassandraVersionFeatures.cassandraVersionFeaturesFromCassandraVersion(version);
- assertEquals("Wrong major version for " + version + ",", major, features.getMajorVersion());
- assertEquals("Wrong minor version for " + version + ",", minor, features.getMinorVersion());
- assertEquals("Wrong version suffix for " + version + ",", suffix, features.getSuffix());
+ assertEquals(major, features.getMajorVersion(), "Wrong major version for " + version + ",");
+ assertEquals(minor, features.getMinorVersion(), "Wrong minor version for " + version + ",");
+ assertEquals(suffix, features.getSuffix(), "Wrong version suffix for " + version + ",");
}
}
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CompressionTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CompressionTests.java
index 24c8dce..3b59400 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CompressionTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/CompressionTests.java
@@ -23,30 +23,32 @@ import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.spark.utils.RandomUtils;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-public class CompressionTests extends VersionRunner
+public class CompressionTests
{
- public CompressionTests(CassandraVersion version)
- {
- super(version);
- }
+ private CassandraBridge bridge;
- @Test
- public void testCompressRandom() throws IOException
+ @ParameterizedTest()
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#versions")
+ public void testCompressRandom(CassandraVersion version) throws IOException
{
+ bridge = CassandraBridgeFactory.get(version);
// Test with random data - not highly compressible
testCompression(RandomUtils.randomBytes(4096));
}
- @Test
- public void testCompressUniform() throws IOException
+ @ParameterizedTest()
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#versions")
+ public void testCompressUniform(CassandraVersion version) throws IOException
{
+ bridge = CassandraBridgeFactory.get(version);
// Test with highly compressible data
byte[] bytes = new byte[4096];
Arrays.fill(bytes, (byte) 'a');
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/VersionRunner.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/VersionRunner.java
index 8d19ada..35550f8 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/VersionRunner.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/bridge/VersionRunner.java
@@ -21,31 +21,30 @@ package org.apache.cassandra.bridge;
import java.util.Arrays;
import java.util.Collection;
+import java.util.List;
import java.util.stream.Collectors;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.Named;
/**
- * Runs parameterized tests for all defined versions of Cassandra
+ * Shared version provider for all defined versions of Cassandra
*/
-@RunWith(Parameterized.class)
-public abstract class VersionRunner
+public final class VersionRunner
{
- protected final CassandraVersion version;
- protected final CassandraBridge bridge;
+ private VersionRunner()
+ {
+ throw new IllegalStateException(getClass() + " is static utility class and shall not be instantiated");
+ }
- @Parameterized.Parameters
- public static Collection<Object[]> versions()
+ public static Collection<CassandraVersion> versions()
{
return Arrays.stream(CassandraVersion.implementedVersions())
- .map(version -> new Object[]{version})
.collect(Collectors.toList());
}
- public VersionRunner(CassandraVersion version)
+ public static List<Named<CassandraBridge>> bridges()
{
- this.version = version;
- this.bridge = CassandraBridgeFactory.get(version);
+ return versions().stream().map(version -> Named.of(version.toString(), CassandraBridgeFactory.get(version)))
+ .collect(Collectors.toList());
}
}
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarClientConfigTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarClientConfigTest.java
index eb218f4..7a64231 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarClientConfigTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarClientConfigTest.java
@@ -20,9 +20,9 @@
package org.apache.cassandra.clients;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit tests for the {@link Sidecar.ClientConfig} inner class
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceImplTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceImplTest.java
index ffb1a64..b782514 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceImplTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceImplTest.java
@@ -19,8 +19,8 @@
package org.apache.cassandra.clients;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import com.esotericsoftware.kryo.io.Output;
import org.apache.cassandra.sidecar.client.SidecarInstance;
@@ -30,15 +30,15 @@ import static org.apache.cassandra.spark.utils.SerializationUtils.kryoDeserializ
import static org.apache.cassandra.spark.utils.SerializationUtils.kryoSerialize;
import static org.apache.cassandra.spark.utils.SerializationUtils.register;
import static org.apache.cassandra.spark.utils.SerializationUtils.serialize;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
/**
* Unit tests for the {@link SidecarInstanceImpl} class
*/
public class SidecarInstanceImplTest extends SidecarInstanceTest
{
- @BeforeClass
+ @BeforeAll
public static void setupKryo()
{
register(SidecarInstanceImpl.class, new SidecarInstanceImpl.Serializer());
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceTest.java
index d2033ba..450dfd5 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/clients/SidecarInstanceTest.java
@@ -19,13 +19,13 @@
package org.apache.cassandra.clients;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.sidecar.client.SidecarInstance;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Abstract class that provides a set of base unit tests for the {@link SidecarInstance} interface
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigSecretsProviderTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigSecretsProviderTest.java
index ac3a600..bf42dbd 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigSecretsProviderTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigSecretsProviderTest.java
@@ -38,29 +38,29 @@ import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.TrustManagerFactory;
import org.apache.commons.io.IOUtils;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
public class SslConfigSecretsProviderTest
{
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
+ @TempDir
+ public Path folder; // CHECKSTYLE IGNORE: Public mutable field for testing
String keyStorePassword;
String trustStorePassword;
- @Before
+ @BeforeEach
public void setup() throws IOException
{
- Path path = folder.newFolder("secrets-config").toPath();
+ Path path = folder.resolve("secrets-config");
+ Files.createDirectories(path);
try (InputStream stream = getClass().getResourceAsStream("/secrets/fakecerts/client-keystore.p12"))
{
@@ -88,10 +88,10 @@ public class SslConfigSecretsProviderTest
public void testSuccessWithCertsPaths() throws IOException
{
Map<String, String> jobOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- jobOptions.put(SslConfig.KEYSTORE_PATH, folder.getRoot().getAbsolutePath() + "/secrets-config/keystore.p12");
+ jobOptions.put(SslConfig.KEYSTORE_PATH, folder.toAbsolutePath() + "/secrets-config/keystore.p12");
jobOptions.put(SslConfig.KEYSTORE_PASSWORD, keyStorePassword);
jobOptions.put(SslConfig.KEYSTORE_TYPE, "PKCS12");
- jobOptions.put(SslConfig.TRUSTSTORE_PATH, folder.getRoot().getAbsolutePath() + "/secrets-config/truststore.jks");
+ jobOptions.put(SslConfig.TRUSTSTORE_PATH, folder.toAbsolutePath() + "/secrets-config/truststore.jks");
jobOptions.put(SslConfig.TRUSTSTORE_PASSWORD, trustStorePassword);
jobOptions.put(SslConfig.TRUSTSTORE_TYPE, "JKS");
@@ -125,9 +125,9 @@ public class SslConfigSecretsProviderTest
public void testSuccessWithEncodedCerts() throws IOException
{
Map<String, String> jobOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- String keyStorePath = folder.getRoot().getAbsolutePath() + "/secrets-config/keystore.p12";
+ String keyStorePath = folder.toAbsolutePath() + "/secrets-config/keystore.p12";
String encodedKeyStore = Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(keyStorePath)));
- String trustStorePath = folder.getRoot().getAbsolutePath() + "/secrets-config/truststore.jks";
+ String trustStorePath = folder.toAbsolutePath() + "/secrets-config/truststore.jks";
String encodedTrustStore = Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get(trustStorePath)));
jobOptions.put(SslConfig.KEYSTORE_BASE64_ENCODED, encodedKeyStore);
@@ -167,10 +167,10 @@ public class SslConfigSecretsProviderTest
public void testInvalidPathToKeyStore()
{
Map<String, String> jobOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- jobOptions.put(SslConfig.KEYSTORE_PATH, folder.getRoot().getAbsolutePath() + "/secrets-config/non-existent-keystore.p12");
+ jobOptions.put(SslConfig.KEYSTORE_PATH, folder.toAbsolutePath() + "/secrets-config/non-existent-keystore.p12");
jobOptions.put(SslConfig.KEYSTORE_PASSWORD, keyStorePassword);
jobOptions.put(SslConfig.KEYSTORE_TYPE, "PKCS12");
- jobOptions.put(SslConfig.TRUSTSTORE_PATH, folder.getRoot().getAbsolutePath() + "/secrets-config/truststore.jks");
+ jobOptions.put(SslConfig.TRUSTSTORE_PATH, folder.toAbsolutePath() + "/secrets-config/truststore.jks");
jobOptions.put(SslConfig.TRUSTSTORE_PASSWORD, trustStorePassword);
jobOptions.put(SslConfig.TRUSTSTORE_TYPE, "JKS");
@@ -194,10 +194,10 @@ public class SslConfigSecretsProviderTest
public void testInvalidPathToTrustStore()
{
Map<String, String> jobOptions = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
- jobOptions.put(SslConfig.KEYSTORE_PATH, folder.getRoot().getAbsolutePath() + "/secrets-config/keystore.p12");
+ jobOptions.put(SslConfig.KEYSTORE_PATH, folder.toAbsolutePath() + "/secrets-config/keystore.p12");
jobOptions.put(SslConfig.KEYSTORE_PASSWORD, keyStorePassword);
jobOptions.put(SslConfig.KEYSTORE_TYPE, "PKCS12");
- jobOptions.put(SslConfig.TRUSTSTORE_PATH, folder.getRoot().getAbsolutePath() + "/secrets-config/non-existent-truststore.jks");
+ jobOptions.put(SslConfig.TRUSTSTORE_PATH, folder.toAbsolutePath() + "/secrets-config/non-existent-truststore.jks");
jobOptions.put(SslConfig.TRUSTSTORE_PASSWORD, trustStorePassword);
jobOptions.put(SslConfig.TRUSTSTORE_TYPE, "JKS");
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigTest.java
index b1c6ba4..2f5e077 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/secrets/SslConfigTest.java
@@ -23,7 +23,7 @@ import java.util.Collections;
import java.util.Map;
import java.util.TreeMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.apache.cassandra.secrets.SslConfig.KEYSTORE_BASE64_ENCODED;
import static org.apache.cassandra.secrets.SslConfig.KEYSTORE_PASSWORD;
@@ -31,10 +31,10 @@ import static org.apache.cassandra.secrets.SslConfig.KEYSTORE_PATH;
import static org.apache.cassandra.secrets.SslConfig.TRUSTSTORE_BASE64_ENCODED;
import static org.apache.cassandra.secrets.SslConfig.TRUSTSTORE_PASSWORD;
import static org.apache.cassandra.secrets.SslConfig.TRUSTSTORE_PATH;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Unit tests for the {@link SslConfig} class
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/EndToEndTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/EndToEndTests.java
index ae1312b..a3f5956 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/EndToEndTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/EndToEndTests.java
@@ -41,12 +41,14 @@ import com.google.common.collect.Maps;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.commons.lang3.mutable.MutableLong;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.apache.cassandra.bridge.CassandraBridge;
+import org.apache.cassandra.bridge.CassandraBridgeFactory;
import org.apache.cassandra.bridge.CassandraVersion;
import org.apache.cassandra.spark.data.CqlField;
import org.apache.cassandra.spark.data.SSTable;
-import org.apache.cassandra.spark.data.VersionRunner;
import org.apache.cassandra.spark.stats.Stats;
import org.apache.cassandra.spark.utils.RandomUtils;
import org.apache.cassandra.spark.utils.streaming.SSTableSource;
@@ -55,11 +57,11 @@ import org.apache.spark.sql.Row;
import scala.collection.mutable.AbstractSeq;
import static org.apache.cassandra.spark.utils.ScalaConversionUtils.mutableSeqAsJavaList;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.booleans;
import static org.quicktheories.generators.SourceDSL.characters;
@@ -72,17 +74,14 @@ import static org.quicktheories.generators.SourceDSL.integers;
* Uses custom SSTableTombstoneWriter to write SSTables with tombstones
* to verify Spark Bulk Reader correctly purges tombstoned data.
*/
-public class EndToEndTests extends VersionRunner
+
+public class EndToEndTests
{
- public EndToEndTests(CassandraVersion version)
- {
- super(version);
- }
/* Partition Key Tests */
-
- @Test
- public void testSinglePartitionKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testSinglePartitionKey(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -93,8 +92,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testOnlyPartitionKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testOnlyPartitionKeys(CassandraBridge bridge)
{
// Special case where schema is only partition keys
Tester.builder(TestSchema.builder()
@@ -108,8 +108,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testOnlyPartitionClusteringKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testOnlyPartitionClusteringKeys(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("a", bridge.uuid())
@@ -119,8 +120,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testMultiplePartitionKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMultiplePartitionKeys(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("a", bridge.uuid())
@@ -134,8 +136,9 @@ public class EndToEndTests extends VersionRunner
/* Clustering Key Tests */
- @Test
- public void testBasicSingleClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testBasicSingleClusteringKey(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("a", bridge.bigint())
@@ -146,8 +149,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testSingleClusteringKeyOrderBy()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testSingleClusteringKeyOrderBy(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge), TestUtils.sortOrder())
.checkAssert((clusteringKeyType, sortOrder) ->
@@ -161,8 +165,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testMultipleClusteringKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMultipleClusteringKeys(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("a", bridge.uuid())
@@ -175,8 +180,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testManyClusteringKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testManyClusteringKeys(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("a", bridge.uuid())
@@ -193,8 +199,9 @@ public class EndToEndTests extends VersionRunner
/* Data Type Tests */
- @Test
- public void testAllDataTypesPartitionKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testAllDataTypesPartitionKey(CassandraBridge bridge)
{
// Test partition key can be read for all data types
qt().forAll(TestUtils.cql3Type(bridge))
@@ -211,8 +218,9 @@ public class EndToEndTests extends VersionRunner
});
}
- @Test
- public void testAllDataTypesValueColumn()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testAllDataTypesValueColumn(CassandraBridge bridge)
{
// Test value column can be read for all data types
qt().forAll(TestUtils.cql3Type(bridge))
@@ -228,8 +236,9 @@ public class EndToEndTests extends VersionRunner
/* Compaction */
- @Test
- public void testMultipleSSTablesCompaction()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMultipleSSTablesCompaction(CassandraBridge bridge)
{
AtomicLong startTotal = new AtomicLong(0);
AtomicLong newTotal = new AtomicLong(0);
@@ -286,8 +295,9 @@ public class EndToEndTests extends VersionRunner
});
}
- @Test
- public void testCompaction()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCompaction(CassandraBridge bridge)
{
int numRowsColumns = 20;
AtomicInteger total = new AtomicInteger(0);
@@ -339,8 +349,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testSingleClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testSingleClusteringKey(CassandraBridge bridge)
{
AtomicLong total = new AtomicLong(0);
Map<Integer, MutableLong> testSum = new HashMap<>();
@@ -405,8 +416,9 @@ public class EndToEndTests extends VersionRunner
/* Static Columns */
- @Test
- public void testOnlyStaticColumn()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testOnlyStaticColumn(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("a", bridge.uuid())
@@ -416,9 +428,10 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
@SuppressWarnings("UnstableApiUsage") // Use of Guava Uninterruptibles
- public void testStaticColumn()
+ public void testStaticColumn(CassandraBridge bridge)
{
int numRows = 100;
int numColumns = 20;
@@ -468,8 +481,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testNulledStaticColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testNulledStaticColumns(CassandraBridge bridge)
{
int numClusteringKeys = 10;
Tester.builder(TestSchema.builder()
@@ -502,9 +516,11 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testMultipleSSTableCompacted()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#versions")
+ public void testMultipleSSTableCompacted(CassandraVersion version)
{
+ CassandraBridge bridge = CassandraBridgeFactory.get(version);
TestSchema.Builder schemaBuilder = TestSchema.builder()
.withPartitionKey("a", bridge.uuid())
.withClusteringKey("b", bridge.aInt())
@@ -567,8 +583,9 @@ public class EndToEndTests extends VersionRunner
/* Tombstone Tests */
- @Test
- public void testPartitionTombstoneInt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testPartitionTombstoneInt(CassandraBridge bridge)
{
int numRows = 100;
int numColumns = 10;
@@ -614,8 +631,9 @@ public class EndToEndTests extends VersionRunner
});
}
- @Test
- public void testRowTombstoneInt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testRowTombstoneInt(CassandraBridge bridge)
{
int numRows = 100;
int numColumns = 10;
@@ -658,8 +676,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testRangeTombstoneInt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testRangeTombstoneInt(CassandraBridge bridge)
{
int numRows = 10;
int numColumns = 128;
@@ -708,8 +727,9 @@ public class EndToEndTests extends VersionRunner
});
}
- @Test
- public void testRangeTombstoneString()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testRangeTombstoneString(CassandraBridge bridge)
{
int numRows = 10;
int numColumns = 128;
@@ -763,8 +783,9 @@ public class EndToEndTests extends VersionRunner
/* Partial Rows: test reading rows with missing columns */
- @Test
- public void testPartialRow()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testPartialRow(CassandraBridge bridge)
{
Map<UUID, UUID> rows = new HashMap<>();
Tester.builder(TestSchema.builder()
@@ -804,8 +825,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testPartialRowClusteringKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testPartialRowClusteringKeys(CassandraBridge bridge)
{
Map<String, String> rows = new HashMap<>();
Tester.builder(TestSchema.builder()
@@ -857,8 +879,9 @@ public class EndToEndTests extends VersionRunner
/* Collections */
- @Test
- public void testSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testSet(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
@@ -870,8 +893,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testList()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testList(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
@@ -883,8 +907,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMap(CassandraBridge bridge)
{
qt().withExamples(50) // Limit number of tests otherwise n x n tests takes too long
.forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
@@ -897,8 +922,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testClusteringKeySet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testClusteringKeySet(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -910,8 +936,9 @@ public class EndToEndTests extends VersionRunner
/* Frozen Collections */
- @Test
- public void testFrozenSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testFrozenSet(CassandraBridge bridge)
{
// pk -> a frozen<set<?>>
qt().forAll(TestUtils.cql3Type(bridge))
@@ -924,8 +951,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testFrozenList()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testFrozenList(CassandraBridge bridge)
{
// pk -> a frozen<list<?>>
qt().forAll(TestUtils.cql3Type(bridge))
@@ -938,8 +966,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testFrozenMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testFrozenMap(CassandraBridge bridge)
{
// pk -> a frozen<map<?, ?>>
qt().withExamples(50) // Limit number of tests otherwise n x n tests takes too long
@@ -953,8 +982,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testNestedMapSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testNestedMapSet(CassandraBridge bridge)
{
// pk -> a map<text, frozen<set<text>>>
Tester.builder(TestSchema.builder()
@@ -965,8 +995,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testNestedMapList()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testNestedMapList(CassandraBridge bridge)
{
// pk -> a map<text, frozen<list<text>>>
Tester.builder(TestSchema.builder()
@@ -977,8 +1008,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testNestedMapMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testNestedMapMap(CassandraBridge bridge)
{
// pk -> a map<text, frozen<map<bigint, varchar>>>
Tester.builder(TestSchema.builder()
@@ -991,8 +1023,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testFrozenNestedMapMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testFrozenNestedMapMap(CassandraBridge bridge)
{
// pk -> a frozen<map<text, <map<int, timestamp>>>
Tester.builder(TestSchema.builder()
@@ -1007,8 +1040,9 @@ public class EndToEndTests extends VersionRunner
/* Filters */
- @Test
- public void testSinglePartitionKeyFilter()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testSinglePartitionKeyFilter(CassandraBridge bridge)
{
int numRows = 10;
Tester.builder(TestSchema.builder()
@@ -1032,8 +1066,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testMultiplePartitionKeyFilter()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMultiplePartitionKeyFilter(CassandraBridge bridge)
{
int numRows = 10;
int numColumns = 5;
@@ -1068,8 +1103,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testFiltersDoNotMatch()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testFiltersDoNotMatch(CassandraBridge bridge)
{
int numRows = 10;
Tester.builder(TestSchema.builder()
@@ -1087,8 +1123,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testFilterWithClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testFilterWithClusteringKey(CassandraBridge bridge)
{
int numRows = 10;
Tester.builder(TestSchema.builder()
@@ -1116,8 +1153,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testUdtNativeTypes()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdtNativeTypes(CassandraBridge bridge)
{
// pk -> a testudt<b text, c type, d int>
qt().forAll(TestUtils.cql3Type(bridge))
@@ -1133,8 +1171,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testUdtInnerSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdtInnerSet(CassandraBridge bridge)
{
// pk -> a testudt<b text, c frozen<type>, d int>
qt().forAll(TestUtils.cql3Type(bridge))
@@ -1150,8 +1189,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testUdtInnerList()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdtInnerList(CassandraBridge bridge)
{
// pk -> a testudt<b bigint, c frozen<list<type>>, d boolean>
qt().forAll(TestUtils.cql3Type(bridge))
@@ -1167,8 +1207,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testUdtInnerMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdtInnerMap(CassandraBridge bridge)
{
// pk -> a testudt<b float, c frozen<set<uuid>>, d frozen<map<type1, type2>>, e boolean>
qt().withExamples(50)
@@ -1186,8 +1227,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testMultipleUdts()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMultipleUdts(CassandraBridge bridge)
{
// pk -> col1 udt1<a float, b frozen<set<uuid>>, c frozen<set<type>>, d boolean>,
// col2 udt2<a text, b bigint, g varchar>, col3 udt3<int, type, ascii>
@@ -1215,8 +1257,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testNestedUdt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testNestedUdt(CassandraBridge bridge)
{
// pk -> a test_udt<b float, c frozen<set<uuid>>, d frozen<nested_udt<x int, y type, z int>>, e boolean>
qt().forAll(TestUtils.cql3Type(bridge))
@@ -1239,8 +1282,9 @@ public class EndToEndTests extends VersionRunner
/* Tuples */
- @Test
- public void testBasicTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testBasicTuple(CassandraBridge bridge)
{
// pk -> a tuple<int, type1, bigint, type2>
qt().withExamples(10)
@@ -1253,8 +1297,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testTupleWithClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testTupleWithClusteringKey(CassandraBridge bridge)
{
// pk -> col1 type1 -> a tuple<int, type2, bigint>
qt().withExamples(10)
@@ -1268,8 +1313,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testNestedTuples()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testNestedTuples(CassandraBridge bridge)
{
// pk -> a tuple<varchar, tuple<int, type1, float, varchar, tuple<bigint, boolean, type2>>, timeuuid>
// Test tuples nested within tuple
@@ -1291,8 +1337,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testTupleSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testTupleSet(CassandraBridge bridge)
{
// pk -> a tuple<varchar, tuple<int, varchar, float, varchar, set<type>>, timeuuid>
// Test set nested within tuple
@@ -1312,8 +1359,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testTupleList()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testTupleList(CassandraBridge bridge)
{
// pk -> a tuple<varchar, tuple<int, varchar, float, varchar, list<type>>, timeuuid>
// Test list nested within tuple
@@ -1333,8 +1381,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testTupleMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testTupleMap(CassandraBridge bridge)
{
// pk -> a tuple<varchar, tuple<int, varchar, float, varchar, map<type1, type2>>, timeuuid>
// Test map nested within tuple
@@ -1354,8 +1403,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testMapTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMapTuple(CassandraBridge bridge)
{
// pk -> a map<timeuuid, frozen<tuple<boolean, type, timestamp>>>
// Test tuple nested within map
@@ -1372,8 +1422,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testSetTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testSetTuple(CassandraBridge bridge)
{
// pk -> a set<frozen<tuple<type, float, text>>>
// Test tuple nested within set
@@ -1389,8 +1440,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testListTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testListTuple(CassandraBridge bridge)
{
// pk -> a list<frozen<tuple<int, inet, decimal, type>>>
// Test tuple nested within map
@@ -1407,8 +1459,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testTupleUDT()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testTupleUDT(CassandraBridge bridge)
{
// pk -> a tuple<varchar, frozen<nested_udt<x int, y type, z int>>, timeuuid>
// Test tuple with inner UDT
@@ -1428,8 +1481,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testUDTTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUDTTuple(CassandraBridge bridge)
{
// pk -> a nested_udt<x text, y tuple<int, float, type, timestamp>, z ascii>
// Test UDT with inner tuple
@@ -1450,8 +1504,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testTupleClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testTupleClusteringKey(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
@@ -1468,8 +1523,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testUdtClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdtClusteringKey(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
@@ -1487,8 +1543,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testComplexSchema()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testComplexSchema(CassandraBridge bridge)
{
String keyspace = "complex_schema2";
CqlField.CqlUdt udt1 = bridge.udt(keyspace, "udt1")
@@ -1533,8 +1590,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testNestedFrozenUDT()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testNestedFrozenUDT(CassandraBridge bridge)
{
// "(a bigint PRIMARY KEY, b <map<int, frozen<testudt>>>)"
// testudt(a text, b bigint, c int)
@@ -1550,8 +1608,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testDeepNestedUDT()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testDeepNestedUDT(CassandraBridge bridge)
{
String keyspace = "deep_nested_frozen_udt";
CqlField.CqlUdt udt1 = bridge.udt(keyspace, "udt1")
@@ -1649,8 +1708,9 @@ public class EndToEndTests extends VersionRunner
/* BigDecimal/Integer Tests */
- @Test
- public void testBigDecimal()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testBigDecimal(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -1659,8 +1719,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testBigInteger()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testBigInteger(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -1669,8 +1730,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testUdtFieldOrdering()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdtFieldOrdering(CassandraBridge bridge)
{
String keyspace = "udt_field_ordering";
CqlField.CqlUdt udt1 = bridge.udt(keyspace, "udt1")
@@ -1685,9 +1747,10 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
@SuppressWarnings("unchecked")
- public void testUdtTupleInnerNulls()
+ public void testUdtTupleInnerNulls(CassandraBridge bridge)
{
CqlField.CqlUdt udtType = bridge.udt("udt_inner_nulls", "udt")
.withField("a", bridge.uuid())
@@ -1764,8 +1827,9 @@ public class EndToEndTests extends VersionRunner
/* Complex Clustering Keys */
- @Test
- public void testUdtsWithNulls()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdtsWithNulls(CassandraBridge bridge)
{
CqlField.CqlUdt type = bridge.udt("udt_with_nulls", "udt1")
.withField("a", bridge.text())
@@ -1811,8 +1875,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testMapClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMapClusteringKey(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -1824,8 +1889,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testListClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testListClusteringKey(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -1836,8 +1902,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testSetClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testSetClusteringKey(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -1848,8 +1915,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testUdTClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdTClusteringKey(CassandraBridge bridge)
{
Tester.builder(keyspace -> TestSchema.builder()
.withKeyspace(keyspace)
@@ -1898,8 +1966,9 @@ public class EndToEndTests extends VersionRunner
}
};
- @Test
- public void testLargeBlobExclude()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testLargeBlobExclude(CassandraBridge bridge)
{
qt().forAll(booleans().all())
.checkAssert(enableCompression ->
@@ -1940,8 +2009,9 @@ public class EndToEndTests extends VersionRunner
);
}
- @Test
- public void testExcludeColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testExcludeColumns(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -1976,8 +2046,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testUpsertExcludeColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUpsertExcludeColumns(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -2013,8 +2084,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testExcludeNoColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testExcludeNoColumns(CassandraBridge bridge)
{
// Include all columns
Tester.builder(TestSchema.builder()
@@ -2031,8 +2103,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testUpsertExcludeNoColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUpsertExcludeNoColumns(CassandraBridge bridge)
{
// Include all columns
Tester.builder(TestSchema.builder()
@@ -2050,8 +2123,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testExcludeAllColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testExcludeAllColumns(CassandraBridge bridge)
{
// Exclude all columns except for partition/clustering keys
Tester.builder(TestSchema.builder()
@@ -2068,8 +2142,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testUpsertExcludeAllColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUpsertExcludeAllColumns(CassandraBridge bridge)
{
// Exclude all columns except for partition/clustering keys
Tester.builder(TestSchema.builder()
@@ -2087,8 +2162,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testExcludePartitionOnly()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testExcludePartitionOnly(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid()))
@@ -2097,8 +2173,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testExcludeKeysOnly()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testExcludeKeysOnly(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -2109,8 +2186,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testExcludeKeysStaticColumnOnly()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testExcludeKeysStaticColumnOnly(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder()
.withPartitionKey("pk", bridge.uuid())
@@ -2122,8 +2200,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testExcludeStaticColumn()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testExcludeStaticColumn(CassandraBridge bridge)
{
// Exclude static columns
Tester.builder(TestSchema.builder()
@@ -2138,8 +2217,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testUpsertExcludeStaticColumn()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUpsertExcludeStaticColumn(CassandraBridge bridge)
{
// Exclude static columns
Tester.builder(TestSchema.builder()
@@ -2155,8 +2235,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testLastModifiedTimestampAddedWithStaticColumn()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testLastModifiedTimestampAddedWithStaticColumn(CassandraBridge bridge)
{
int numRows = 5;
int numColumns = 5;
@@ -2188,14 +2269,15 @@ public class EndToEndTests extends VersionRunner
assertTrue(lmt > leastExpectedTimestamp);
// Due to the static column so the LMT is the same per partition.
// Using the pair of ck and lmt for uniqueness check.
- assertTrue("Observed a duplicated LMT", observedLMT.add(Pair.of(row.getInt(1), lmt)));
+ assertTrue(observedLMT.add(Pair.of(row.getInt(1), lmt)), "Observed a duplicated LMT");
}
})
.run();
}
- @Test
- public void testLastModifiedTimestampWithExcludeColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testLastModifiedTimestampWithExcludeColumns(CassandraBridge bridge)
{
Tester.builder(TestSchema.builder().withPartitionKey("pk", bridge.uuid())
.withClusteringKey("ck", bridge.aInt())
@@ -2233,8 +2315,9 @@ public class EndToEndTests extends VersionRunner
.run();
}
- @Test
- public void testLastModifiedTimestampAddedWithSimpleColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testLastModifiedTimestampAddedWithSimpleColumns(CassandraBridge bridge)
{
int numRows = 10;
long leastExpectedTimestamp = Timestamp.from(Instant.now()).getTime();
@@ -2268,14 +2351,15 @@ public class EndToEndTests extends VersionRunner
assertEquals(5, row.length());
long lmt = row.getTimestamp(4).getTime();
assertTrue(lmt > leastExpectedTimestamp + 10);
- assertTrue("Observed a duplicated LMT", observedLMT.add(lmt));
+ assertTrue(observedLMT.add(lmt), "Observed a duplicated LMT");
}
})
.run();
}
- @Test
- public void testLastModifiedTimestampAddedWithComplexColumns()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testLastModifiedTimestampAddedWithComplexColumns(CassandraBridge bridge)
{
long leastExpectedTimestamp = Timestamp.from(Instant.now()).getTime();
Set<Long> observedLMT = new HashSet<>();
@@ -2304,7 +2388,7 @@ public class EndToEndTests extends VersionRunner
assertEquals(8, row.length());
long lmt = row.getTimestamp(7).getTime();
assertTrue(lmt > leastExpectedTimestamp);
- assertTrue("Observed a duplicated LMT", observedLMT.add(lmt));
+ assertTrue(observedLMT.add(lmt), "Observed a duplicated LMT");
}
})
.run();
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/KryoSerializationTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/KryoSerializationTests.java
index a23206f..8190351 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/KryoSerializationTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/KryoSerializationTests.java
@@ -26,30 +26,31 @@ import java.util.UUID;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
-import org.apache.cassandra.bridge.CassandraVersion;
+import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.secrets.SslConfig;
import org.apache.cassandra.spark.data.CqlField;
import org.apache.cassandra.spark.data.CqlTable;
import org.apache.cassandra.spark.data.LocalDataLayer;
import org.apache.cassandra.spark.data.ReplicationFactor;
-import org.apache.cassandra.spark.data.VersionRunner;
import org.apache.cassandra.spark.data.partitioner.CassandraInstance;
import org.apache.cassandra.spark.data.partitioner.CassandraRing;
import org.apache.cassandra.spark.data.partitioner.TokenPartitioner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
import static org.quicktheories.generators.SourceDSL.booleans;
import static org.quicktheories.generators.SourceDSL.integers;
-public class KryoSerializationTests extends VersionRunner
+public class KryoSerializationTests
{
private static final Kryo KRYO = new Kryo();
@@ -58,11 +59,6 @@ public class KryoSerializationTests extends VersionRunner
new KryoRegister().registerClasses(KRYO);
}
- public KryoSerializationTests(CassandraVersion version)
- {
- super(version);
- }
-
private static Output serialize(Object object)
{
try (Output out = new Output(1024, -1))
@@ -80,8 +76,9 @@ public class KryoSerializationTests extends VersionRunner
}
}
- @Test
- public void testCqlField()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlField(CassandraBridge bridge)
{
qt().withExamples(25)
.forAll(booleans().all(), booleans().all(), TestUtils.cql3Type(bridge), integers().all())
@@ -103,8 +100,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testCqlFieldSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlFieldSet(CassandraBridge bridge)
{
qt().withExamples(25)
.forAll(booleans().all(), booleans().all(), TestUtils.cql3Type(bridge), integers().all())
@@ -127,8 +125,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testCqlFieldList()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlFieldList(CassandraBridge bridge)
{
qt().withExamples(25)
.forAll(booleans().all(), booleans().all(), TestUtils.cql3Type(bridge), integers().all())
@@ -151,8 +150,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testCqlFieldMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlFieldMap(CassandraBridge bridge)
{
qt().withExamples(25)
.forAll(booleans().all(), booleans().all(), TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
@@ -175,8 +175,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testCqlUdt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlUdt(CassandraBridge bridge)
{
qt().withExamples(25)
.forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
@@ -197,8 +198,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testCqlTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlTuple(CassandraBridge bridge)
{
qt().withExamples(25)
.forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
@@ -221,8 +223,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testCqlTable()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlTable(CassandraBridge bridge)
{
List<CqlField> fields = ImmutableList.of(new CqlField(true, false, false, "a", bridge.bigint(), 0),
new CqlField(true, false, false, "b", bridge.bigint(), 1),
@@ -244,7 +247,8 @@ public class KryoSerializationTests extends VersionRunner
assertEquals(table, deserialized);
}
- @Test
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
public void testCassandraInstance()
{
CassandraInstance instance = new CassandraInstance("-9223372036854775807", "local1-i1", "DC1");
@@ -254,7 +258,8 @@ public class KryoSerializationTests extends VersionRunner
assertEquals(instance, deserialized);
}
- @Test
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
public void testCassandraRing()
{
qt().forAll(TestUtils.partitioners())
@@ -268,8 +273,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testLocalDataLayer()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testLocalDataLayer(CassandraBridge bridge)
{
String path1 = UUID.randomUUID().toString();
String path2 = UUID.randomUUID().toString();
@@ -311,8 +317,9 @@ public class KryoSerializationTests extends VersionRunner
});
}
- @Test
- public void testCqlUdtField()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testCqlUdtField(CassandraBridge bridge)
{
CqlField.CqlUdt udt = bridge.udt("udt_keyspace", "udt_table")
.withField("c", bridge.text())
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/TestUtils.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/TestUtils.java
index 85b14f3..4b1f726 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/TestUtils.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/TestUtils.java
@@ -60,7 +60,7 @@ import org.apache.spark.sql.types.StructType;
import org.jetbrains.annotations.Nullable;
import org.quicktheories.core.Gen;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/Tester.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/Tester.java
index a7daaab..97e9a90 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/Tester.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/Tester.java
@@ -51,8 +51,8 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.quicktheories.core.Gen;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
@@ -449,8 +449,8 @@ public final class Tester
if (shouldCheckNumSSTables)
{
- assertEquals("Number of SSTables written does not match expected",
- sstableCount, TestUtils.countSSTables(directory));
+ assertEquals(sstableCount, TestUtils.countSSTables(directory),
+ "Number of SSTables written does not match expected");
}
Dataset<Row> dataset = TestUtils.openLocalDataset(partitioner,
@@ -470,8 +470,8 @@ public final class Tester
if (requiredColumns != null)
{
Set<String> actualColumns = new HashSet<>(Arrays.asList(row.schema().fieldNames()));
- assertEquals("Actual Columns and Required Columns should be the same",
- actualColumns, requiredColumns);
+ assertEquals(actualColumns, requiredColumns,
+ "Actual Columns and Required Columns should be the same");
}
TestSchema.TestRow actualRow = schema.toTestRow(row, requiredColumns);
@@ -479,9 +479,9 @@ public final class Tester
{
// If we wrote random data, verify values exist
String key = actualRow.getKey();
- assertTrue("Unexpected row read in Spark", rows.containsKey(key));
- assertEquals("Row read in Spark does not match expected",
- rows.get(key).withColumns(requiredColumns), actualRow);
+ assertTrue(rows.containsKey(key), "Unexpected row read in Spark");
+ assertEquals(rows.get(key).withColumns(requiredColumns), actualRow,
+ "Row read in Spark does not match expected");
}
for (Consumer<TestSchema.TestRow> readListener : readListeners)
@@ -492,15 +492,15 @@ public final class Tester
}
if (expectedRowCount >= 0)
{
- assertEquals("Number of rows read does not match expected", expectedRowCount * sstableCount, rowCount);
+ assertEquals(expectedRowCount * sstableCount, rowCount, "Number of rows read does not match expected");
}
// Verify numerical fields sum to expected value
for (String sumField : sumFields)
{
- assertEquals("Field '" + sumField + "' does not sum to expected amount",
- sum.get(sumField).getValue().longValue(),
- dataset.groupBy().sum(sumField).first().getLong(0));
+ assertEquals(sum.get(sumField).getValue().longValue(),
+ dataset.groupBy().sum(sumField).first().getLong(0),
+ "Field '" + sumField + "' does not sum to expected amount");
}
// Run SparkSQL checks
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/BulkSparkConfTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/BulkSparkConfTest.java
index d2f7ded..cbe6030 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/BulkSparkConfTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/BulkSparkConfTest.java
@@ -25,8 +25,8 @@ import java.util.TreeMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Maps;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.bulkwriter.util.SbwKryoRegistrator;
import org.apache.cassandra.spark.utils.BuildInfo;
@@ -36,10 +36,10 @@ import org.jetbrains.annotations.NotNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.isEmptyString;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class BulkSparkConfTest
{
@@ -47,7 +47,7 @@ public class BulkSparkConfTest
private BulkSparkConf bulkSparkConf;
private Map<String, String> defaultOptions;
- @Before
+ @BeforeEach
public void before()
{
sparkConf = new SparkConf();
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CassandraRingMonitorTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CassandraRingMonitorTest.java
index a06e217..d86506f 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CassandraRingMonitorTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CassandraRingMonitorTest.java
@@ -21,14 +21,14 @@ package org.apache.cassandra.spark.bulkwriter;
import java.util.concurrent.TimeUnit;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.bulkwriter.token.CassandraRing;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class CassandraRingMonitorTest
{
@@ -36,7 +36,7 @@ public class CassandraRingMonitorTest
private CassandraRing<RingInstance> ring;
private MockScheduledExecutorService executorService;
- @Before
+ @BeforeEach
public void setup()
{
changeCount = 0;
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CqlTableInfoProviderTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CqlTableInfoProviderTest.java
index 232f7a5..e39710e 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CqlTableInfoProviderTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/CqlTableInfoProviderTest.java
@@ -19,11 +19,11 @@
package org.apache.cassandra.spark.bulkwriter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.apache.cassandra.spark.bulkwriter.CqlTableInfoProvider.removeDeprecatedOptions;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class CqlTableInfoProviderTest
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/DecoratedKeyTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/DecoratedKeyTest.java
index e621d00..c7965c1 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/DecoratedKeyTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/DecoratedKeyTest.java
@@ -22,10 +22,10 @@ package org.apache.cassandra.spark.bulkwriter;
import java.math.BigInteger;
import java.nio.ByteBuffer;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
public class DecoratedKeyTest
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RecordWriterTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RecordWriterTest.java
index 1ccdc72..4dd8841 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RecordWriterTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RecordWriterTest.java
@@ -20,6 +20,7 @@
package org.apache.cassandra.spark.bulkwriter;
import java.math.BigInteger;
+import java.nio.file.Path;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -29,19 +30,21 @@ import java.util.stream.IntStream;
import java.util.stream.Stream;
import com.google.common.collect.Range;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.apache.cassandra.spark.bulkwriter.token.CassandraRing;
import org.apache.cassandra.spark.common.model.CassandraInstance;
import scala.Tuple2;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.Matchers.matchesPattern;
+import static org.hamcrest.Matchers.startsWith;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class RecordWriterTest
{
@@ -49,11 +52,10 @@ public class RecordWriterTest
public static final int FILES_PER_SSTABLE = 8;
public static final int UPLOADED_TABLES = 3;
private static final String[] COLUMN_NAMES = {"id", "date", "course", "marks"};
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
- @Rule
- public ExpectedException exception = ExpectedException.none();
+ @TempDir
+ public Path folder; // CHECKSTYLE IGNORE: Public mutable field for parameterized testing
+
private CassandraRing<RingInstance> ring;
private RecordWriter rw;
private MockTableWriter tw;
@@ -62,10 +64,10 @@ public class RecordWriterTest
private MockBulkWriterContext writerContext;
private TestTaskContext tc;
- @Before
+ @BeforeEach
public void setUp()
{
- tw = new MockTableWriter(folder.getRoot().toPath());
+ tw = new MockTableWriter(folder);
ring = RingUtils.buildRing(0, "app", "cluster", "DC1", "test", 12);
writerContext = new MockBulkWriterContext(ring);
tc = new TestTaskContext();
@@ -126,33 +128,32 @@ public class RecordWriterTest
@Test
public void testCorruptSSTable()
{
- // TODO: Add better error handling with human-readable exception messages in SSTableReader::new
- exception.expect(RuntimeException.class);
rw = new RecordWriter(writerContext, COLUMN_NAMES, () -> tc, (wc, path) -> new SSTableWriter(tw.setOutDir(path), path));
Iterator<Tuple2<DecoratedKey, Object[]>> data = generateData(5, true);
- rw.write(data);
- Map<CassandraInstance, List<UploadRequest>> uploads = writerContext.getUploads();
- assertThat(uploads.keySet().size(), is(REPLICA_COUNT)); // Should upload to 3 replicas
- assertThat(uploads.values().stream().mapToInt(List::size).sum(), is(REPLICA_COUNT * FILES_PER_SSTABLE * UPLOADED_TABLES));
+ // TODO: Add better error handling with human-readable exception messages in SSTableReader::new
+ // That way we can assert on the exception thrown here
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> rw.write(data));
}
@Test
public void testWriteWithOutOfRangeTokenFails()
{
- rw = new RecordWriter(writerContext, COLUMN_NAMES, () -> tc, (wc, path) -> new SSTableWriter(tw, folder.getRoot().toPath()));
- exception.expectMessage("Received Token 5765203080415074583 outside of expected range [-9223372036854775808‥0]");
+ rw = new RecordWriter(writerContext, COLUMN_NAMES, () -> tc, (wc, path) -> new SSTableWriter(tw, folder));
Iterator<Tuple2<DecoratedKey, Object[]>> data = generateData(5, false);
- rw.write(data);
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> rw.write(data));
+ assertThat(ex.getMessage(),
+ matchesPattern("java.lang.IllegalStateException: Received Token "
+ + "5765203080415074583 outside of expected range \\[-9223372036854775808(‥|..)0]"));
}
@Test
public void testAddRowThrowingFails()
{
- rw = new RecordWriter(writerContext, COLUMN_NAMES, () -> tc, (wc, path) -> new SSTableWriter(tw, folder.getRoot().toPath()));
+ rw = new RecordWriter(writerContext, COLUMN_NAMES, () -> tc, (wc, path) -> new SSTableWriter(tw, folder));
tw.setAddRowThrows(true);
- exception.expectMessage("java.lang.RuntimeException: Failed to write because addRow throws");
Iterator<Tuple2<DecoratedKey, Object[]>> data = generateData(5, true);
- rw.write(data);
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> rw.write(data));
+ assertEquals(ex.getMessage(), "java.lang.RuntimeException: Failed to write because addRow throws");
}
@Test
@@ -160,11 +161,11 @@ public class RecordWriterTest
{
// Mock context returns a 60-minute allowable time skew, so we use something just outside the limits
long sixtyOneMinutesInMillis = TimeUnit.MINUTES.toMillis(61);
- rw = new RecordWriter(writerContext, COLUMN_NAMES, () -> tc, (wc, path) -> new SSTableWriter(tw, folder.getRoot().toPath()));
+ rw = new RecordWriter(writerContext, COLUMN_NAMES, () -> tc, (wc, path) -> new SSTableWriter(tw, folder));
writerContext.setTimeProvider(() -> System.currentTimeMillis() - sixtyOneMinutesInMillis);
- exception.expectMessage("Time skew between Spark and Cassandra is too large. Allowable skew is 60 minutes. Spark executor time is ");
Iterator<Tuple2<DecoratedKey, Object[]>> data = generateData(5, true);
- rw.write(data);
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> rw.write(data));
+ assertThat(ex.getMessage(), startsWith("Time skew between Spark and Cassandra is too large. Allowable skew is 60 minutes. Spark executor time is "));
}
@Test
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceSerializationTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceSerializationTest.java
index 84f8f46..8876772 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceSerializationTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceSerializationTest.java
@@ -19,13 +19,13 @@
package org.apache.cassandra.spark.bulkwriter;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.sidecar.common.data.RingEntry;
import static org.apache.cassandra.spark.utils.SerializationUtils.deserialize;
import static org.apache.cassandra.spark.utils.SerializationUtils.serialize;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class RingInstanceSerializationTest
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceTest.java
index 3902109..52da964 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/RingInstanceTest.java
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Multimap;
import com.google.common.collect.Range;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.sidecar.common.data.RingEntry;
import org.apache.cassandra.spark.bulkwriter.token.CassandraRing;
@@ -44,8 +44,8 @@ import org.apache.cassandra.spark.common.model.CassandraInstance;
import org.apache.cassandra.spark.data.ReplicationFactor;
import org.apache.cassandra.spark.data.partitioner.Partitioner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
public class RingInstanceTest
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SSTableWriterTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SSTableWriterTest.java
index 3b3511c..18eb482 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SSTableWriterTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SSTableWriterTest.java
@@ -28,13 +28,11 @@ import java.util.Arrays;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableMap;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.bridge.CassandraVersion;
import org.apache.cassandra.bridge.CassandraVersionFeatures;
@@ -42,14 +40,12 @@ import org.apache.cassandra.spark.bulkwriter.token.CassandraRing;
import org.apache.cassandra.spark.bulkwriter.token.ConsistencyLevel;
import org.jetbrains.annotations.NotNull;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(Parameterized.class)
public class SSTableWriterTest
{
private static String previousMbeanState;
- @Parameterized.Parameters(name = "{index}: Testing Cassandra Version {0}")
public static Iterable<Object[]> data()
{
return Arrays.stream(CassandraVersion.supportedVersions())
@@ -57,14 +53,14 @@ public class SSTableWriterTest
.collect(Collectors.toList());
}
- @BeforeClass
+ @BeforeAll
public static void setProps()
{
previousMbeanState = System.getProperty("org.apache.cassandra.disable_mbean_registration");
System.setProperty("org.apache.cassandra.disable_mbean_registration", "true");
}
- @AfterClass
+ @AfterAll
public static void restoreProps()
{
if (previousMbeanState != null)
@@ -80,17 +76,16 @@ public class SSTableWriterTest
@NotNull
public CassandraRing<RingInstance> ring = RingUtils.buildRing(0, "app", "cluster", "DC1", "test", 12); // CHECKSTYLE IGNORE: Public mutable field
- @Rule
- public TemporaryFolder tmpDir = new TemporaryFolder();
+ @TempDir
+ public Path tmpDir; // CHECKSTYLE IGNORE: Public mutable field for testing
- @Parameterized.Parameter(0)
- public String version; // CHECKSTYLE IGNORE: Public mutable field for parameterized testing
- @Test
- public void canCreateWriterForVersion() throws IOException
+ @ParameterizedTest
+ @MethodSource("data")
+ public void canCreateWriterForVersion(String version) throws IOException
{
MockBulkWriterContext writerContext = new MockBulkWriterContext(ring, version, ConsistencyLevel.CL.LOCAL_QUORUM);
- SSTableWriter tw = new SSTableWriter(writerContext, tmpDir.getRoot().toPath());
+ SSTableWriter tw = new SSTableWriter(writerContext, tmpDir);
tw.addRow(BigInteger.ONE, ImmutableMap.of("id", 1, "date", 1, "course", "foo", "marks", 1));
tw.close(writerContext, 1);
try (DirectoryStream<Path> dataFileStream = Files.newDirectoryStream(tw.getOutDir(), "*Data.db"))
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SqlToCqlTypeConverterTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SqlToCqlTypeConverterTest.java
index 9efdb84..ccfd7e6 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SqlToCqlTypeConverterTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/SqlToCqlTypeConverterTest.java
@@ -22,10 +22,8 @@ package org.apache.cassandra.spark.bulkwriter;
import java.util.Arrays;
import java.util.Collection;
-import org.junit.Test;
-import org.junit.experimental.runners.Enclosed;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.spark.data.CqlField;
@@ -55,90 +53,66 @@ import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockLi
import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockMapCqlType;
import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockSetCqlType;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertThat;
+import static org.hamcrest.MatcherAssert.assertThat;
-@RunWith(Enclosed.class)
public final class SqlToCqlTypeConverterTest
{
- private SqlToCqlTypeConverterTest()
- {
- throw new IllegalStateException(getClass() + " is static utility class and shall not be instantiated");
- }
- @RunWith(Parameterized.class)
- public static class ConverterTests
+ public static Collection<Object[]> dataTypes()
{
- public ConverterTests(CqlField.CqlType dt, Class expectedConverter)
- {
- this.dt = dt;
- this.expectedConverter = expectedConverter;
- }
-
- @Parameterized.Parameters(name = "{index}: {0} -> {1}")
- public static Collection<Object[]> dataTypes()
- {
- return Arrays.asList(na(mockCqlType(BIGINT), SqlToCqlTypeConverter.LongConverter.class),
- na(mockCqlType(BLOB), SqlToCqlTypeConverter.BytesConverter.class),
- na(mockListCqlType(INT), SqlToCqlTypeConverter.ListConverter.class),
- na(mockCqlType(DECIMAL), SqlToCqlTypeConverter.BigDecimalConverter.class),
- na(mockCqlType(TIMESTAMP), SqlToCqlTypeConverter.TimestampConverter.class),
- na(mockCqlType(TIME), SqlToCqlTypeConverter.TimeConverter.class),
- na(mockCqlType(UUID), SqlToCqlTypeConverter.UUIDConverter.class),
- na(mockCqlType(VARINT), SqlToCqlTypeConverter.BigIntegerConverter.class),
- na(mockCqlType(TIMEUUID), SqlToCqlTypeConverter.TimeUUIDConverter.class),
- na(mockCqlType(INET), SqlToCqlTypeConverter.InetAddressConverter.class),
- na(mockCqlType(DATE), SqlToCqlTypeConverter.DateConverter.class),
- na(mockMapCqlType(INT, INT), SqlToCqlTypeConverter.MapConverter.class),
- na(mockSetCqlType(INET), SqlToCqlTypeConverter.SetConverter.class),
- // Special Cassandra 1.2 Timestamp type should use TimestampConverter
- na(mockCqlCustom("org.apache.cassandra.db.marshal.DateType"), SqlToCqlTypeConverter.TimestampConverter.class));
- }
-
- private CqlField.CqlType dt;
- private Class expectedConverter;
+ return Arrays.asList(na(mockCqlType(BIGINT), SqlToCqlTypeConverter.LongConverter.class),
+ na(mockCqlType(BLOB), SqlToCqlTypeConverter.BytesConverter.class),
+ na(mockListCqlType(INT), SqlToCqlTypeConverter.ListConverter.class),
+ na(mockCqlType(DECIMAL), SqlToCqlTypeConverter.BigDecimalConverter.class),
+ na(mockCqlType(TIMESTAMP), SqlToCqlTypeConverter.TimestampConverter.class),
+ na(mockCqlType(TIME), SqlToCqlTypeConverter.TimeConverter.class),
+ na(mockCqlType(UUID), SqlToCqlTypeConverter.UUIDConverter.class),
+ na(mockCqlType(VARINT), SqlToCqlTypeConverter.BigIntegerConverter.class),
+ na(mockCqlType(TIMEUUID), SqlToCqlTypeConverter.TimeUUIDConverter.class),
+ na(mockCqlType(INET), SqlToCqlTypeConverter.InetAddressConverter.class),
+ na(mockCqlType(DATE), SqlToCqlTypeConverter.DateConverter.class),
+ na(mockMapCqlType(INT, INT), SqlToCqlTypeConverter.MapConverter.class),
+ na(mockSetCqlType(INET), SqlToCqlTypeConverter.SetConverter.class),
+ // Special Cassandra 1.2 Timestamp type should use TimestampConverter
+ na(mockCqlCustom("org.apache.cassandra.db.marshal.DateType"), SqlToCqlTypeConverter.TimestampConverter.class));
+ }
- @Test
- public void testConverter()
- {
- assertConverterType(dt, expectedConverter);
- }
- private static Object[] na(CqlField.CqlType dataType, Class converter)
- {
- return new Object[]{dataType, converter};
- }
+ @ParameterizedTest(name = "{index}: {0} -> {1}")
+ @MethodSource("dataTypes")
+ public void testConverter(CqlField.CqlType dt, Class<?> expectedConverter)
+ {
+ assertConverterType(dt, expectedConverter);
}
- @RunWith(Parameterized.class)
- public static class TypeConverterNoOpTests
+ private static Object[] na(CqlField.CqlType dataType, Class<?> converter)
{
- @Parameterized.Parameters(name = "{index}: {0}")
- public static Collection<Object[]> dataTypes()
- {
- return Arrays.asList(na(mockCqlType(ASCII)),
- na(mockCqlType(BOOLEAN)),
- na(mockCqlType(COUNTER)),
- na(mockCqlType(DOUBLE)),
- na(mockCqlType(FLOAT)),
- na(mockCqlType(TEXT)),
- na(mockCqlType(VARCHAR)),
- na(mockCqlType(SMALLINT)),
- na(mockCqlType(TINYINT)));
- }
+ return new Object[]{dataType, converter};
+ }
- @Parameterized.Parameter
- public CqlField.CqlType dataType; // CHECKSTYLE IGNORE: Public mutable field for parameterized testing
+ public static Collection<Object[]> noOpDataTypes()
+ {
+ return Arrays.asList(na(mockCqlType(ASCII)),
+ na(mockCqlType(BOOLEAN)),
+ na(mockCqlType(COUNTER)),
+ na(mockCqlType(DOUBLE)),
+ na(mockCqlType(FLOAT)),
+ na(mockCqlType(TEXT)),
+ na(mockCqlType(VARCHAR)),
+ na(mockCqlType(SMALLINT)),
+ na(mockCqlType(TINYINT)));
+ }
- private static Object[] na(CqlField.CqlType dataType)
- {
- return new Object[]{dataType};
- }
+ private static Object[] na(CqlField.CqlType dataType)
+ {
+ return new Object[]{dataType};
+ }
- @Test
- public void testNoOpTypes()
- {
- assertConverterType(dataType, SqlToCqlTypeConverter.NoOp.class);
- }
+ @ParameterizedTest(name = "{index}: {0}")
+ @MethodSource("noOpDataTypes")
+ public void testNoOpTypes(CqlField.CqlType dataType)
+ {
+ assertConverterType(dataType, SqlToCqlTypeConverter.NoOp.class);
}
public static void assertConverterType(CqlField.CqlType dataType, Class expectedType)
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionConsistencyTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionConsistencyTest.java
index eb69631..642181d 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionConsistencyTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionConsistencyTest.java
@@ -21,6 +21,7 @@ package org.apache.cassandra.spark.bulkwriter;
import java.io.IOException;
import java.math.BigInteger;
+import java.nio.file.Path;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
@@ -35,12 +36,9 @@ import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.spark.bulkwriter.token.CassandraRing;
import org.apache.cassandra.spark.bulkwriter.token.ConsistencyLevel;
@@ -49,10 +47,9 @@ import org.apache.cassandra.spark.common.model.CassandraInstance;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-@RunWith(Parameterized.class)
public class StreamSessionConsistencyTest
{
private static final int NUMBER_DCS = 2;
@@ -70,20 +67,13 @@ public class StreamSessionConsistencyTest
6);
private static final Map<String, Object> COLUMN_BIND_VALUES = ImmutableMap.of("id", 0, "date", 1, "course", "course", "marks", 2);
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
+ @TempDir
+ public Path folder; // CHECKSTYLE IGNORE: Public mutable field for testing
private MockTableWriter tableWriter;
private StreamSession streamSession;
private MockBulkWriterContext writerContext;
private final MockScheduledExecutorService executor = new MockScheduledExecutorService();
- @Parameterized.Parameter(0)
- public ConsistencyLevel.CL consistencyLevel; // CHECKSTYLE IGNORE: Public mutable field for parameterized testing
-
- @Parameterized.Parameter(1)
- public List<Integer> failuresPerDc; // CHECKSTYLE IGNORE: Public mutable field for parameterized testing
-
- @Parameterized.Parameters(name = "CL: {0}, numFailures: {1}")
public static Collection<Object[]> data()
{
List<ConsistencyLevel.CL> cls = Arrays.stream(ConsistencyLevel.CL.values()).collect(Collectors.toList());
@@ -93,22 +83,24 @@ public class StreamSessionConsistencyTest
return clsToFailures.stream().map(List::toArray).collect(Collectors.toList());
}
- @Before
- public void setup()
+ private void setup(ConsistencyLevel.CL consistencyLevel, List<Integer> failuresPerDc)
{
- tableWriter = new MockTableWriter(folder.getRoot().toPath());
+ tableWriter = new MockTableWriter(folder);
writerContext = new MockBulkWriterContext(RING, "cassandra-4.0.0", consistencyLevel);
streamSession = new StreamSession(writerContext, "sessionId", RANGE, executor);
}
- @Test
- public void testConsistencyLevelAndFailureInCommit() throws IOException, ExecutionException, InterruptedException
+ @ParameterizedTest(name = "CL: {0}, numFailures: {1}")
+ @MethodSource("data")
+ public void testConsistencyLevelAndFailureInCommit(ConsistencyLevel.CL consistencyLevel,
+ List<Integer> failuresPerDc)
+ throws IOException, ExecutionException, InterruptedException
{
- streamSession = new StreamSession(writerContext, "sessionId", RANGE, executor);
+ setup(consistencyLevel, failuresPerDc);
AtomicInteger dc1Failures = new AtomicInteger(failuresPerDc.get(0));
AtomicInteger dc2Failures = new AtomicInteger(failuresPerDc.get(1));
ImmutableMap<String, AtomicInteger> dcFailures = ImmutableMap.of("DC1", dc1Failures, "DC2", dc2Failures);
- boolean shouldFail = calculateFailure(dc1Failures.get(), dc2Failures.get());
+ boolean shouldFail = calculateFailure(consistencyLevel, dc1Failures.get(), dc2Failures.get());
// Return successful result for 1st result, failed for the rest
writerContext.setCommitResultSupplier((uuids, dc) -> {
if (dcFailures.get(dc).getAndDecrement() > 0)
@@ -120,7 +112,7 @@ public class StreamSessionConsistencyTest
return new DataTransferApi.RemoteCommitResult(true, uuids, null, "");
}
});
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(102L), COLUMN_BIND_VALUES);
tr.close(writerContext, 1);
streamSession.scheduleStream(tr);
@@ -147,17 +139,20 @@ public class StreamSessionConsistencyTest
assertThat(instances, containsInAnyOrder(EXPECTED_INSTANCES.toArray()));
}
- @Test
- public void testConsistencyLevelAndFailureInUpload() throws IOException, ExecutionException, InterruptedException
+ @ParameterizedTest(name = "CL: {0}, numFailures: {1}")
+ @MethodSource("data")
+ public void testConsistencyLevelAndFailureInUpload(ConsistencyLevel.CL consistencyLevel,
+ List<Integer> failuresPerDc)
+ throws IOException, ExecutionException, InterruptedException
{
- streamSession = new StreamSession(writerContext, "sessionId", RANGE, executor);
+ setup(consistencyLevel, failuresPerDc);
AtomicInteger dc1Failures = new AtomicInteger(failuresPerDc.get(0));
AtomicInteger dc2Failures = new AtomicInteger(failuresPerDc.get(1));
int numFailures = dc1Failures.get() + dc2Failures.get();
ImmutableMap<String, AtomicInteger> dcFailures = ImmutableMap.of("DC1", dc1Failures, "DC2", dc2Failures);
- boolean shouldFail = calculateFailure(dc1Failures.get(), dc2Failures.get());
+ boolean shouldFail = calculateFailure(consistencyLevel, dc1Failures.get(), dc2Failures.get());
writerContext.setUploadSupplier(instance -> dcFailures.get(instance.getDataCenter()).getAndDecrement() <= 0);
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(102L), COLUMN_BIND_VALUES);
tr.close(writerContext, 1);
streamSession.scheduleStream(tr);
@@ -187,7 +182,7 @@ public class StreamSessionConsistencyTest
assertThat(instances, containsInAnyOrder(EXPECTED_INSTANCES.toArray()));
}
- private boolean calculateFailure(int dc1Failures, int dc2Failures)
+ private boolean calculateFailure(ConsistencyLevel.CL consistencyLevel, int dc1Failures, int dc2Failures)
{
// Assumes LOCAL_DC is DC1, given current CL and Failures, should we fail?
int localQuorum = REPLICATION_FACTOR / 2 + 1;
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionTest.java
index e5e5ab1..58805e8 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/StreamSessionTest.java
@@ -21,6 +21,7 @@ package org.apache.cassandra.spark.bulkwriter;
import java.io.IOException;
import java.math.BigInteger;
+import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -32,10 +33,9 @@ import com.google.common.collect.BoundType;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.apache.cassandra.spark.bulkwriter.token.CassandraRing;
import org.apache.cassandra.spark.common.model.CassandraInstance;
@@ -45,18 +45,19 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.iterableWithSize;
+import static org.hamcrest.Matchers.matchesPattern;
import static org.hamcrest.Matchers.startsWith;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class StreamSessionTest
{
public static final String LOAD_RANGE_ERROR_PREFIX = "Failed to load 1 ranges with LOCAL_QUORUM";
private static final Map<String, Object> COLUMN_BOUND_VALUES = ImmutableMap.of("id", 0, "date", 1, "course", "course", "marks", 2);
- @Rule
- public TemporaryFolder folder = new TemporaryFolder();
+ @TempDir
+ public Path folder; // CHECKSTYLE IGNORE: Public mutable field for testing
private static final int FILES_PER_SSTABLE = 8;
private static final int REPLICATION_FACTOR = 3;
private StreamSession ss;
@@ -67,13 +68,13 @@ public class StreamSessionTest
private MockTableWriter tableWriter;
private Range<BigInteger> range;
- @Before
+ @BeforeEach
public void setup()
{
range = Range.range(BigInteger.valueOf(101L), BoundType.CLOSED, BigInteger.valueOf(199L), BoundType.CLOSED);
ring = RingUtils.buildRing(0, "app", "cluster", "DC1", "test", 12);
writerContext = getBulkWriterContext();
- tableWriter = new MockTableWriter(folder.getRoot().toPath());
+ tableWriter = new MockTableWriter(folder);
executor = new MockScheduledExecutorService();
ss = new StreamSession(writerContext, "sessionId", range, executor);
expectedInstances = Lists.newArrayList("DC1-i1", "DC1-i2", "DC1-i3");
@@ -92,7 +93,7 @@ public class StreamSessionTest
public void testScheduleStreamSendsCorrectFilesToCorrectInstances(
) throws IOException, ExecutionException, InterruptedException
{
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(102L), COLUMN_BOUND_VALUES);
tr.close(writerContext, 1);
ss.scheduleStream(tr);
@@ -116,19 +117,19 @@ public class StreamSessionTest
writerContext,
"sessionId",
Range.range(BigInteger.valueOf(0L), BoundType.CLOSED, BigInteger.valueOf(0L), BoundType.OPEN)));
- assertThat(exception.getMessage(), startsWith("Partition range [0‥0) is mapping more than one range {}"));
+ assertThat(exception.getMessage(), matchesPattern("Partition range \\[0(‥|..)0\\) is mapping more than one range \\{}"));
}
@Test
public void testMismatchedTokenRangeFails() throws IOException
{
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(9999L), COLUMN_BOUND_VALUES);
tr.close(writerContext, 1);
IllegalStateException illegalStateException = assertThrows(IllegalStateException.class,
() -> ss.scheduleStream(tr));
- assertEquals(illegalStateException.getMessage(),
- "SSTable range [9999‥9999] should be enclosed in the partition range [101‥199]");
+ assertThat(illegalStateException.getMessage(), matchesPattern(
+ "SSTable range \\[9999(‥|..)9999] should be enclosed in the partition range \\[101(‥|..)199]"));
}
@Test
@@ -189,11 +190,12 @@ public class StreamSessionTest
{
writerContext.setInstancesAreAvailable(false);
ss = new StreamSession(writerContext, "sessionId", range, executor);
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(102L), COLUMN_BOUND_VALUES);
tr.close(writerContext, 1);
ss.scheduleStream(tr);
- assertThrows(LOAD_RANGE_ERROR_PREFIX, RuntimeException.class, () -> ss.close());
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> ss.close());
+ assertThat(ex.getMessage(), startsWith(LOAD_RANGE_ERROR_PREFIX));
}
@Test
@@ -232,7 +234,7 @@ public class StreamSessionTest
return new DataTransferApi.RemoteCommitResult(true, null, uuids, "");
}
});
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(102L), COLUMN_BOUND_VALUES);
tr.close(writerContext, 1);
ss.scheduleStream(tr);
@@ -264,7 +266,7 @@ public class StreamSessionTest
return new DataTransferApi.RemoteCommitResult(false, uuids, null, "");
}
});
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(102L), COLUMN_BOUND_VALUES);
tr.close(writerContext, 1);
ss.scheduleStream(tr);
@@ -285,11 +287,12 @@ public class StreamSessionTest
private void runFailedUpload() throws IOException, ExecutionException, InterruptedException
{
writerContext.setUploadSupplier(instance -> false);
- SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder.getRoot().toPath());
+ SSTableWriter tr = new NonValidatingTestSSTableWriter(tableWriter, folder);
tr.addRow(BigInteger.valueOf(102L), COLUMN_BOUND_VALUES);
tr.close(writerContext, 1);
ss.scheduleStream(tr);
- assertThrows(LOAD_RANGE_ERROR_PREFIX, RuntimeException.class, () -> ss.close());
+ RuntimeException ex = assertThrows(RuntimeException.class, () -> ss.close());
+ assertThat(ex.getMessage(), startsWith(LOAD_RANGE_ERROR_PREFIX));
}
@NotNull
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaNormalizeTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaNormalizeTest.java
index 28dab5f..0cc628e 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaNormalizeTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaNormalizeTest.java
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.google.common.net.InetAddresses;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.common.schema.ColumnType;
import org.apache.cassandra.spark.common.schema.ColumnTypes;
@@ -73,9 +73,9 @@ import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockCq
import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockListCqlType;
import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockMapCqlType;
import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockSetCqlType;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThat;
public class TableSchemaNormalizeTest
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaTest.java
index 895ca06..1c00d83 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TableSchemaTest.java
@@ -23,9 +23,7 @@ import java.util.Arrays;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.tuple.Pair;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.common.schema.ColumnType;
import org.apache.cassandra.spark.common.schema.ColumnTypes;
@@ -40,7 +38,8 @@ import static org.apache.cassandra.spark.bulkwriter.TableSchemaTestCommon.mockCq
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsEqual.equalTo;
-import static org.junit.Assert.assertThrows;
+import static org.hamcrest.core.StringStartsWith.startsWith;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class TableSchemaTest
{
@@ -54,9 +53,6 @@ public class TableSchemaTest
validCqlColumns = validPair.getValue();
}
- @Rule
- public ExpectedException exception = ExpectedException.none();
-
private StructType validDataFrameSchema;
private ImmutableMap<String, CqlField.CqlType> validCqlColumns;
@@ -173,11 +169,13 @@ public class TableSchemaTest
.add("course", DataTypes.StringType)
.add("marks", DataTypes.IntegerType);
- exception.expect(IllegalArgumentException.class);
- exception.expectMessage("Unknown fields");
+ IllegalArgumentException iex = assertThrows(IllegalArgumentException.class,
+ () ->
getValidSchemaBuilder()
.withDataFrameSchema(extraFieldsDataFrameSchema)
- .build();
+ .build()
+ );
+ assertThat(iex.getMessage(), startsWith("Unknown fields"));
}
@Test
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TokenPartitionerTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TokenPartitionerTest.java
index df4a67f..6940e50 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TokenPartitionerTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/bulkwriter/TokenPartitionerTest.java
@@ -23,20 +23,20 @@ import java.math.BigInteger;
import java.nio.ByteBuffer;
import com.google.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.bulkwriter.token.CassandraRing;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.number.OrderingComparison.greaterThanOrEqualTo;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class TokenPartitionerTest
{
private TokenPartitioner partitioner;
- @Before
+ @BeforeEach
public void createConfig()
{
}
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/cdc/watermarker/WatermarkerTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/cdc/watermarker/WatermarkerTests.java
index dd35d93..8eb6412 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/cdc/watermarker/WatermarkerTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/cdc/watermarker/WatermarkerTests.java
@@ -22,18 +22,18 @@ package org.apache.cassandra.spark.cdc.watermarker;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicReference;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.TestDataLayer;
import org.apache.cassandra.spark.cdc.CommitLog;
import org.apache.cassandra.spark.cdc.IPartitionUpdateWrapper;
import org.apache.cassandra.spark.data.partitioner.CassandraInstance;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -48,13 +48,13 @@ public class WatermarkerTests
return update;
}
- @BeforeClass
+ @BeforeAll
public static void setup()
{
InMemoryWatermarker.TEST_THREAD_NAME = Thread.currentThread().getName();
}
- @AfterClass
+ @AfterAll
public static void tearDown()
{
InMemoryWatermarker.TEST_THREAD_NAME = null;
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CassandraDataSourceHelperCacheTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CassandraDataSourceHelperCacheTest.java
index 80532ab..8c9836c 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CassandraDataSourceHelperCacheTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CassandraDataSourceHelperCacheTest.java
@@ -31,16 +31,16 @@ import java.util.concurrent.atomic.AtomicLong;
import com.google.common.base.Ticker;
import com.google.common.cache.Cache;
import com.google.common.collect.ImmutableMap;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.clients.Sidecar;
import org.apache.cassandra.secrets.SslConfig;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Tests the cache in {@link CassandraDataSourceHelper}
@@ -54,7 +54,7 @@ public class CassandraDataSourceHelperCacheTest
private CacheTicker cacheTicker;
- @Before
+ @BeforeEach
public void setup()
{
cacheTicker = new CacheTicker();
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldComparators.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldComparators.java
index 830fba6..9d22326 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldComparators.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldComparators.java
@@ -24,30 +24,28 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
-import org.apache.cassandra.bridge.CassandraVersion;
+import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.spark.sql.types.Decimal;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.integers;
public class CqlFieldComparators extends VersionRunner
{
- public CqlFieldComparators(CassandraVersion version)
- {
- super(version);
- }
private static CqlField createField(CqlField.CqlType type)
{
return new CqlField(false, false, false, "a", type, 0);
}
- @Test
- public void testStringComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testStringComparator(CassandraBridge bridge)
{
// ASCII
assertTrue(createField(bridge.ascii()).compare("a", "b") < 0);
@@ -88,8 +86,9 @@ public class CqlFieldComparators extends VersionRunner
assertEquals(0, createField(bridge.varchar()).compare("abd", "abd"));
}
- @Test
- public void testBigDecimalComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testBigDecimalComparator(CassandraBridge bridge)
{
BigDecimal value = BigDecimal.valueOf(Long.MAX_VALUE).multiply(BigDecimal.valueOf(2));
Decimal decimal1 = Decimal.apply(value);
@@ -100,8 +99,9 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.decimal()).compare(decimal2, decimal1) > 0);
}
- @Test
- public void testVarIntComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testVarIntComparator(CassandraBridge bridge)
{
BigDecimal value = BigDecimal.valueOf(Long.MAX_VALUE).multiply(BigDecimal.valueOf(2));
Decimal decimal1 = Decimal.apply(value);
@@ -112,8 +112,9 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.varint()).compare(decimal2, decimal1) > 0);
}
- @Test
- public void testIntegerComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testIntegerComparator(CassandraBridge bridge)
{
qt().forAll(integers().between(Integer.MIN_VALUE, Integer.MAX_VALUE - 1))
.checkAssert(integer -> {
@@ -127,8 +128,9 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.aInt()).compare(Integer.MAX_VALUE, Integer.MIN_VALUE) > 0);
}
- @Test
- public void testLongComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testLongComparator(CassandraBridge bridge)
{
assertTrue(createField(bridge.bigint()).compare(0L, 1L) < 0);
assertEquals(0, createField(bridge.bigint()).compare(1L, 1L));
@@ -139,8 +141,9 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.bigint()).compare(Long.MAX_VALUE, Long.MIN_VALUE) > 0);
}
- @Test
- public void testTimeComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testTimeComparator(CassandraBridge bridge)
{
assertTrue(createField(bridge.time()).compare(0L, 1L) < 0);
assertEquals(0, createField(bridge.time()).compare(1L, 1L));
@@ -151,8 +154,9 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.time()).compare(Long.MAX_VALUE, Long.MIN_VALUE) > 0);
}
- @Test
- public void testBooleanComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testBooleanComparator(CassandraBridge bridge)
{
assertTrue(createField(bridge.bool()).compare(false, true) < 0);
assertEquals(0, createField(bridge.bool()).compare(false, false));
@@ -160,24 +164,27 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.bool()).compare(true, false) > 0);
}
- @Test
- public void testFloatComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testFloatComparator(CassandraBridge bridge)
{
assertTrue(createField(bridge.aFloat()).compare(1f, 2f) < 0);
assertEquals(0, createField(bridge.aFloat()).compare(2f, 2f));
assertTrue(createField(bridge.aFloat()).compare(2f, 1f) > 0);
}
- @Test
- public void testDoubleComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testDoubleComparator(CassandraBridge bridge)
{
assertTrue(createField(bridge.aDouble()).compare(1d, 2d) < 0);
assertEquals(0, createField(bridge.aDouble()).compare(2d, 2d));
assertTrue(createField(bridge.aDouble()).compare(2d, 1d) > 0);
}
- @Test
- public void testTimestampComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testTimestampComparator(CassandraBridge bridge)
{
long timestamp1 = 1L;
long timestamp2 = 2L;
@@ -187,8 +194,9 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.timestamp()).compare(timestamp2, timestamp1) > 0);
}
- @Test
- public void testDateComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testDateComparator(CassandraBridge bridge)
{
int date1 = 1;
int date2 = 2;
@@ -198,22 +206,25 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.date()).compare(date2, date1) > 0);
}
- @Test
- public void testVoidComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testVoidComparator(CassandraBridge bridge)
{
assertEquals(0, createField(bridge.empty()).compare(null, null));
}
- @Test
- public void testShortComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testShortComparator(CassandraBridge bridge)
{
assertTrue(createField(bridge.smallint()).compare((short) 1, (short) 2) < 0);
assertEquals(0, createField(bridge.smallint()).compare((short) 2, (short) 2));
assertTrue(createField(bridge.smallint()).compare((short) 2, (short) 1) > 0);
}
- @Test
- public void testByteArrayComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testByteArrayComparator(CassandraBridge bridge)
{
byte[] bytes1 = new byte[]{0, 0, 0, 101};
byte[] bytes2 = new byte[]{0, 0, 0, 102};
@@ -228,8 +239,9 @@ public class CqlFieldComparators extends VersionRunner
assertTrue(createField(bridge.blob()).compare(bytes4, bytes3) > 0);
}
- @Test
- public void testInetComparator() throws UnknownHostException
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testInetComparator(CassandraBridge bridge) throws UnknownHostException
{
byte[] ip1 = InetAddress.getByAddress(CqlFieldComparators.toByteArray(2130706433)).getAddress(); // 127.0.0.1
byte[] ip2 = InetAddress.getByAddress(CqlFieldComparators.toByteArray(2130706434)).getAddress(); // 127.0.0.2
@@ -247,8 +259,9 @@ public class CqlFieldComparators extends VersionRunner
(byte) value};
}
- @Test
- public void testByteComparator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testByteComparator(CassandraBridge bridge)
{
byte byte1 = 101;
byte byte2 = 102;
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldTests.java
index b0bbb9e..af55773 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/CqlFieldTests.java
@@ -21,26 +21,23 @@ package org.apache.cassandra.spark.data;
import java.util.ArrayList;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.bridge.CassandraBridge;
-import org.apache.cassandra.bridge.CassandraVersion;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class CqlFieldTests extends VersionRunner
{
- public CqlFieldTests(CassandraVersion version)
- {
- super(version);
- }
- @Test
- public void testEquality()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testEquality(CassandraBridge bridge)
{
CqlField field1 = new CqlField(true, false, false, "a", bridge.bigint(), 0);
CqlField field2 = new CqlField(true, false, false, "a", bridge.bigint(), 0);
@@ -53,8 +50,9 @@ public class CqlFieldTests extends VersionRunner
assertEquals(field1, field1);
}
- @Test
- public void testNotEqualsName()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNotEqualsName(CassandraBridge bridge)
{
CqlField field1 = new CqlField(true, false, false, "a", bridge.bigint(), 0);
CqlField field2 = new CqlField(true, false, false, "b", bridge.bigint(), 0);
@@ -63,8 +61,9 @@ public class CqlFieldTests extends VersionRunner
assertNotEquals(field1.hashCode(), field2.hashCode());
}
- @Test
- public void testNotEqualsType()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNotEqualsType(CassandraBridge bridge)
{
CqlField field1 = new CqlField(true, false, false, "a", bridge.bigint(), 0);
CqlField field2 = new CqlField(true, false, false, "a", bridge.timestamp(), 0);
@@ -73,8 +72,9 @@ public class CqlFieldTests extends VersionRunner
assertNotEquals(field1.hashCode(), field2.hashCode());
}
- @Test
- public void testNotEqualsKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNotEqualsKey(CassandraBridge bridge)
{
CqlField field1 = new CqlField(true, false, false, "a", bridge.bigint(), 0);
CqlField field2 = new CqlField(false, true, false, "a", bridge.bigint(), 0);
@@ -83,8 +83,9 @@ public class CqlFieldTests extends VersionRunner
assertNotEquals(field1.hashCode(), field2.hashCode());
}
- @Test
- public void testNotEqualsPos()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNotEqualsPos(CassandraBridge bridge)
{
CqlField field1 = new CqlField(true, false, false, "a", bridge.bigint(), 0);
CqlField field2 = new CqlField(true, false, false, "a", bridge.bigint(), 1);
@@ -93,25 +94,27 @@ public class CqlFieldTests extends VersionRunner
assertNotEquals(field1.hashCode(), field2.hashCode());
}
- @Test
- public void testCqlTypeParser()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCqlTypeParser(CassandraBridge bridge)
{
- testCqlTypeParser("set<text>", bridge.text());
- testCqlTypeParser("set<float>", bridge.aFloat());
- testCqlTypeParser("set<time>", bridge.time());
- testCqlTypeParser("SET<BLOB>", bridge.blob());
- testCqlTypeParser("list<ascii>", bridge.ascii());
- testCqlTypeParser("list<int>", bridge.aInt());
- testCqlTypeParser("LIST<BIGINT>", bridge.bigint());
- testCqlTypeParser("map<int,text>", bridge.aInt(), bridge.text());
- testCqlTypeParser("map<boolean , decimal>", bridge.bool(), bridge.decimal());
- testCqlTypeParser("MAP<TIMEUUID,TIMESTAMP>", bridge.timeuuid(), bridge.timestamp());
- testCqlTypeParser("MAP<VARCHAR , double>", bridge.varchar(), bridge.aDouble());
- testCqlTypeParser("tuple<int, text>", bridge.aInt(), bridge.text());
+ testCqlTypeParser("set<text>", bridge.text(), bridge);
+ testCqlTypeParser("set<float>", bridge.aFloat(), bridge);
+ testCqlTypeParser("set<time>", bridge.time(), bridge);
+ testCqlTypeParser("SET<BLOB>", bridge.blob(), bridge);
+ testCqlTypeParser("list<ascii>", bridge.ascii(), bridge);
+ testCqlTypeParser("list<int>", bridge.aInt(), bridge);
+ testCqlTypeParser("LIST<BIGINT>", bridge.bigint(), bridge);
+ testCqlTypeParser("map<int,text>", bridge.aInt(), bridge.text(), bridge);
+ testCqlTypeParser("map<boolean , decimal>", bridge.bool(), bridge.decimal(), bridge);
+ testCqlTypeParser("MAP<TIMEUUID,TIMESTAMP>", bridge.timeuuid(), bridge.timestamp(), bridge);
+ testCqlTypeParser("MAP<VARCHAR , double>", bridge.varchar(), bridge.aDouble(), bridge);
+ testCqlTypeParser("tuple<int, text>", bridge.aInt(), bridge.text(), bridge);
}
- @Test
- public void testSplitMapTypes()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSplitMapTypes(CassandraBridge bridge)
{
splitMap("", "", null);
splitMap("text", "text", null);
@@ -133,8 +136,9 @@ public class CqlFieldTests extends VersionRunner
"frozen<map<set<int>,blob>>", "frozen<map<text, frozen<map<bigint, double>>>>");
}
- @Test
- public void testCqlNames()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCqlNames(CassandraBridge bridge)
{
assertEquals("set<bigint>", bridge.collection("set", bridge.bigint()).cqlName());
assertEquals("list<timestamp>", bridge.collection("LIST", bridge.timestamp()).cqlName());
@@ -145,8 +149,9 @@ public class CqlFieldTests extends VersionRunner
bridge.collection("tuPLe", bridge.aInt(), bridge.blob(), bridge.map(bridge.aInt(), bridge.aFloat())).cqlName());
}
- @Test
- public void testTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testTuple(CassandraBridge bridge)
{
String[] result = CassandraBridge.splitInnerTypes("a, b, c, d,e, f, g");
assertEquals("a", result[0]);
@@ -171,8 +176,9 @@ public class CqlFieldTests extends VersionRunner
}
}
- @Test
- public void testNestedSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNestedSet(CassandraBridge bridge)
{
CqlField.CqlType type = bridge.parseType("set<frozen<map<text, list<double>>>>");
assertNotNull(type);
@@ -186,8 +192,9 @@ public class CqlFieldTests extends VersionRunner
assertEquals(list.type(), bridge.aDouble());
}
- @Test
- public void testFrozenCqlTypeParser()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testFrozenCqlTypeParser(CassandraBridge bridge)
{
CqlField.CqlType type = bridge.parseType("frozen<map<text, float>>");
assertNotNull(type);
@@ -199,8 +206,9 @@ public class CqlFieldTests extends VersionRunner
assertEquals(map.valueType(), bridge.aFloat());
}
- @Test
- public void testFrozenCqlTypeNested()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testFrozenCqlTypeNested(CassandraBridge bridge)
{
CqlField.CqlType type = bridge.parseType("map<frozen<set<text>>, frozen<map<int, list<blob>>>>");
assertNotNull(type);
@@ -222,12 +230,12 @@ public class CqlFieldTests extends VersionRunner
assertEquals(((CqlField.CqlList) valueMap.valueType()).type(), bridge.blob());
}
- private void testCqlTypeParser(String str, CqlField.CqlType expectedType)
+ private void testCqlTypeParser(String str, CqlField.CqlType expectedType, CassandraBridge bridge)
{
- testCqlTypeParser(str, expectedType, null);
+ testCqlTypeParser(str, expectedType, null, bridge);
}
- private void testCqlTypeParser(String str, CqlField.CqlType expectedType, CqlField.CqlType otherType)
+ private void testCqlTypeParser(String str, CqlField.CqlType expectedType, CqlField.CqlType otherType, CassandraBridge bridge)
{
CqlField.CqlType type = bridge.parseType(str);
if (type instanceof CqlField.CqlTuple)
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DataLayerUnsupportedPushDownFiltersTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DataLayerUnsupportedPushDownFiltersTest.java
index ee6991d..b0f256b 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DataLayerUnsupportedPushDownFiltersTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DataLayerUnsupportedPushDownFiltersTest.java
@@ -24,7 +24,7 @@ import java.util.List;
import java.util.stream.Collectors;
import com.google.common.collect.ImmutableList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.spark.TestDataLayer;
@@ -48,9 +48,9 @@ import org.apache.spark.sql.sources.StringStartsWith;
import static org.apache.cassandra.spark.TestUtils.getFileType;
import static org.apache.cassandra.spark.TestUtils.runTest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
public class DataLayerUnsupportedPushDownFiltersTest
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DefaultSizingTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DefaultSizingTest.java
index 185286f..e9a7a54 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DefaultSizingTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/DefaultSizingTest.java
@@ -19,9 +19,9 @@
package org.apache.cassandra.spark.data;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit tests for the {@link DefaultSizing} class
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/LocalDataLayerTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/LocalDataLayerTests.java
index dfe92f0..c583775 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/LocalDataLayerTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/LocalDataLayerTests.java
@@ -28,27 +28,26 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.stream.Stream;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
+import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.bridge.CassandraVersion;
import org.apache.cassandra.spark.data.partitioner.Partitioner;
import org.apache.cassandra.spark.reader.SchemaTests;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class LocalDataLayerTests extends VersionRunner
{
- public LocalDataLayerTests(CassandraVersion version)
- {
- super(version);
- }
- @Test
- public void testLocalDataLayer() throws IOException
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testLocalDataLayer(CassandraBridge bridge) throws IOException
{
CassandraVersion version = bridge.getVersion();
Path directory1 = Files.createTempDirectory("d1");
@@ -69,8 +68,9 @@ public class LocalDataLayerTests extends VersionRunner
assertTrue(ssTables.openAll((ssTable, isRepairPrimary) -> null).isEmpty());
}
- @Test
- public void testEquality()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testEquality(CassandraBridge bridge)
{
CassandraVersion version = bridge.getVersion();
LocalDataLayer dataLayer1 = new LocalDataLayer(version, "backup_test", SchemaTests.SCHEMA,
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/PartitionedDataLayerTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/PartitionedDataLayerTests.java
index f65698b..6284c26 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/PartitionedDataLayerTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/PartitionedDataLayerTests.java
@@ -34,10 +34,12 @@ import java.util.function.Function;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
import org.apache.commons.lang3.RandomUtils;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
-import org.apache.cassandra.bridge.CassandraVersion;
+import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.data.partitioner.CassandraInstance;
import org.apache.cassandra.spark.data.partitioner.CassandraRing;
@@ -67,11 +69,12 @@ import static org.apache.cassandra.spark.data.partitioner.ConsistencyLevel.LOCAL
import static org.apache.cassandra.spark.data.partitioner.ConsistencyLevel.ONE;
import static org.apache.cassandra.spark.data.partitioner.ConsistencyLevel.TWO;
import static org.apache.cassandra.spark.data.partitioner.Partitioner.Murmur3Partitioner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Matchers.any;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.CALLS_REAL_METHODS;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -82,19 +85,15 @@ public class PartitionedDataLayerTests extends VersionRunner
{
int partitionId;
- public PartitionedDataLayerTests(CassandraVersion version)
- {
- super(version);
- }
-
- @Before
+ @BeforeEach
public void setup()
{
partitionId = TaskContext.getPartitionId();
}
- @Test
- public void testSplitQuorumAllUp()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSplitQuorumAllUp(CassandraBridge bridge)
{
runSplitTests(1, UP);
runSplitTests(2, UP, UP);
@@ -206,33 +205,43 @@ public class PartitionedDataLayerTests extends VersionRunner
null);
}
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void testReplicationFactorDCRequired()
{
// DC required for DC-local consistency level
- PartitionedDataLayer.validateReplicationFactor(LOCAL_QUORUM,
- TestUtils.networkTopologyStrategy(ImmutableMap.of("PV", 3, "MR", 3)),
- null);
+ assertThrows(IllegalArgumentException.class,
+ () -> PartitionedDataLayer
+ .validateReplicationFactor(LOCAL_QUORUM,
+ TestUtils.networkTopologyStrategy(ImmutableMap.of("PV", 3, "MR", 3)),
+ null)
+ );
}
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void testReplicationFactorUnknownDC()
{
- PartitionedDataLayer.validateReplicationFactor(LOCAL_QUORUM,
- TestUtils.networkTopologyStrategy(ImmutableMap.of("PV", 3, "MR", 3)),
- "ST");
+ assertThrows(IllegalArgumentException.class,
+ () -> PartitionedDataLayer
+ .validateReplicationFactor(LOCAL_QUORUM,
+ TestUtils.networkTopologyStrategy(ImmutableMap.of("PV", 3, "MR", 3)),
+ "ST")
+ );
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testReplicationFactorRF0()
{
- PartitionedDataLayer.validateReplicationFactor(LOCAL_QUORUM,
- TestUtils.networkTopologyStrategy(ImmutableMap.of("PV", 3, "MR", 0)),
- "MR");
+ assertThrows(IllegalArgumentException.class,
+ () -> PartitionedDataLayer
+ .validateReplicationFactor(LOCAL_QUORUM,
+ TestUtils.networkTopologyStrategy(ImmutableMap.of("PV", 3, "MR", 0)),
+ "MR")
+ );
}
- @Test
- public void testSSTableSupplier()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSSTableSupplier(CassandraBridge bridge)
{
CassandraRing ring = TestUtils.createRing(Murmur3Partitioner, 3);
CqlTable table = TestSchema.basic(bridge).buildTable();
@@ -243,8 +252,9 @@ public class PartitionedDataLayerTests extends VersionRunner
assertNotNull(ssTableReaders);
}
- @Test
- public void testSSTableSupplierWithMatchingFilters()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSSTableSupplierWithMatchingFilters(CassandraBridge bridge)
{
CassandraRing ring = TestUtils.createRing(Partitioner.Murmur3Partitioner, 3);
CqlTable table = TestSchema.basic(bridge).buildTable();
@@ -258,8 +268,9 @@ public class PartitionedDataLayerTests extends VersionRunner
assertNotNull(ssTableReaders);
}
- @Test(expected = NotEnoughReplicasException.class)
- public void testSSTableSupplierWithNonMatchingFilters()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSSTableSupplierWithNonMatchingFilters(CassandraBridge bridge)
{
CassandraRing ring = TestUtils.createRing(Partitioner.Murmur3Partitioner, 3);
CqlTable table = TestSchema.basic(bridge).buildTable();
@@ -267,7 +278,9 @@ public class PartitionedDataLayerTests extends VersionRunner
PartitionKeyFilter filter = PartitionKeyFilter.create(ByteBuffer.wrap(RandomUtils.nextBytes(10)),
BigInteger.valueOf(6917529027641081853L));
- SSTablesSupplier supplier = dataLayer.sstables(partitionId, null, Collections.singletonList(filter));
+ assertThrows(NotEnoughReplicasException.class,
+ () -> dataLayer.sstables(partitionId, null, Collections.singletonList(filter))
+ );
}
@Test
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/ReplicationFactorTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/ReplicationFactorTests.java
index 82d9d88..af46546 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/ReplicationFactorTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/ReplicationFactorTests.java
@@ -22,11 +22,12 @@ package org.apache.cassandra.spark.data;
import java.util.ArrayList;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class ReplicationFactorTests
{
@@ -76,20 +77,24 @@ public class ReplicationFactorTests
assertEquals(Integer.valueOf(5), replicationFactor.getOptions().get("replication_factor"));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void testUnexpectedRFClass()
{
- new ReplicationFactor(ImmutableMap.of(
- "class", "org.apache.cassandra.locator.NotSimpleStrategy",
- "replication_factor", "5"));
+ assertThrows(IllegalArgumentException.class,
+ () -> new ReplicationFactor(ImmutableMap.of(
+ "class", "org.apache.cassandra.locator.NotSimpleStrategy",
+ "replication_factor", "5"))
+ );
}
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void testUnknownRFClass()
{
- new ReplicationFactor(ImmutableMap.of(
- "class", "NoSuchStrategy",
- "replication_factor", "5"));
+ assertThrows(IllegalArgumentException.class,
+ () -> new ReplicationFactor(ImmutableMap.of(
+ "class", "NoSuchStrategy",
+ "replication_factor", "5"))
+ );
}
@Test
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/VersionRunner.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/VersionRunner.java
index c493466..30af0e4 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/VersionRunner.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/VersionRunner.java
@@ -19,11 +19,9 @@
package org.apache.cassandra.spark.data;
+import java.util.Arrays;
import java.util.Collection;
-
-import com.google.common.collect.ImmutableList;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import java.util.stream.Collectors;
import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.bridge.CassandraBridgeFactory;
@@ -32,23 +30,22 @@ import org.apache.cassandra.bridge.CassandraVersion;
/**
* Run tests Parameterized for multiple versions of Cassandra
*/
-// TODO: Merge org.apache.cassandra.bridge.VersionRunner and org.apache.cassandra.spark.data.VersionRunner
-@RunWith(Parameterized.class)
-public abstract class VersionRunner
+public class VersionRunner
{
- protected final CassandraVersion version;
- protected final CassandraBridge bridge;
+ protected VersionRunner()
+ {
+ }
- @Parameterized.Parameters
- public static Collection<Object[]> versions()
+ public static Collection<CassandraVersion> versions()
{
- // TODO: Make use of TestUtils.testableVersions() instead
- return ImmutableList.of(new Object[]{CassandraVersion.FOURZERO});
+ return Arrays.stream(CassandraVersion.implementedVersions())
+ .collect(Collectors.toList());
}
- public VersionRunner(CassandraVersion version)
+ public static Collection<CassandraBridge> bridges()
{
- this.version = version;
- this.bridge = CassandraBridgeFactory.get(version);
+ return versions().stream().map(CassandraBridgeFactory::get)
+ .collect(Collectors.toList());
}
}
+
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/CassandraRingTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/CassandraRingTests.java
index 670ca32..13482cd 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/CassandraRingTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/CassandraRingTests.java
@@ -29,14 +29,14 @@ import com.google.common.collect.Multimap;
import com.google.common.collect.Range;
import com.google.common.collect.RangeSet;
import com.google.common.collect.TreeRangeSet;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.data.ReplicationFactor;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
@SuppressWarnings("UnstableApiUsage")
public class CassandraRingTests
@@ -59,7 +59,7 @@ public class CassandraRingTests
RangeSet<BigInteger> rangeSet = TreeRangeSet.create();
ranges.forEach(rangeSet::add);
- validTokens.forEach(token -> assertTrue(token + " should have been a valid token", rangeSet.contains(token)));
+ validTokens.forEach(token -> assertTrue(rangeSet.contains(token), token + " should have been a valid token"));
invalidTokens.forEach(token -> assertFalse(rangeSet.contains(token)));
}
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/ConsistencyLevelTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/ConsistencyLevelTests.java
index 30fb6c8..ba9e7ee 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/ConsistencyLevelTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/ConsistencyLevelTests.java
@@ -20,11 +20,11 @@
package org.apache.cassandra.spark.data.partitioner;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.data.ReplicationFactor;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class ConsistencyLevelTests
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/JDKSerializationTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/JDKSerializationTests.java
index e1b9dcd..747047a 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/JDKSerializationTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/JDKSerializationTests.java
@@ -35,7 +35,8 @@ import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Range;
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.bridge.CassandraBridgeFactory;
@@ -55,21 +56,18 @@ import org.apache.cassandra.spark.data.VersionRunner;
import org.apache.cassandra.spark.utils.test.TestSchema;
import org.jetbrains.annotations.NotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
public class JDKSerializationTests extends VersionRunner
{
- public JDKSerializationTests(CassandraVersion version)
- {
- super(version);
- }
- @Test
- public void testCassandraRing()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCassandraRing(CassandraBridge bridge)
{
qt().forAll(TestUtils.partitioners(), arbitrary().pick(Arrays.asList(1, 3, 6, 12, 128)))
.checkAssert(((partitioner, numInstances) -> {
@@ -91,8 +89,9 @@ public class JDKSerializationTests extends VersionRunner
}));
}
- @Test
- public void testTokenPartitioner()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testTokenPartitioner(CassandraBridge bridge)
{
qt().forAll(TestUtils.partitioners(),
arbitrary().pick(Arrays.asList(1, 3, 6, 12, 128)),
@@ -114,8 +113,9 @@ public class JDKSerializationTests extends VersionRunner
}));
}
- @Test
- public void testPartitionedDataLayer()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testPartitionedDataLayer(CassandraBridge bridge)
{
CassandraRing ring = TestUtils.createRing(Partitioner.Murmur3Partitioner, 1024);
TestSchema schema = TestSchema.basic(bridge);
@@ -130,8 +130,9 @@ public class JDKSerializationTests extends VersionRunner
assertEquals(Partitioner.Murmur3Partitioner, deserialized.partitioner());
}
- @Test
- public void testCqlFieldSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCqlFieldSet(CassandraBridge bridge)
{
CqlField.CqlSet setType = bridge.set(bridge.text());
CqlField field = new CqlField(true, false, false, RandomStringUtils.randomAlphanumeric(5, 20), setType, 10);
@@ -145,8 +146,9 @@ public class JDKSerializationTests extends VersionRunner
assertEquals(field.isClusteringColumn(), deserialized.isClusteringColumn());
}
- @Test
- public void testCqlUdt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCqlUdt(CassandraBridge bridge)
{
CqlField.CqlUdt udt1 = bridge
.udt("udt_keyspace", "udt_table")
@@ -284,8 +286,9 @@ public class JDKSerializationTests extends VersionRunner
}
}
- @Test
- public void testSecretsConfig()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSecretsConfig(CassandraBridge bridge)
{
SslConfig config = new SslConfig.Builder<>()
.keyStorePath("keyStorePath")
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/MultipleReplicasTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/MultipleReplicasTests.java
index 78d8615..6f1c4f1 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/MultipleReplicasTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/MultipleReplicasTests.java
@@ -29,7 +29,7 @@ import java.util.stream.IntStream;
import java.util.stream.Stream;
import com.google.common.collect.Range;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.data.PartitionedDataLayer;
@@ -37,8 +37,9 @@ import org.apache.cassandra.spark.data.SSTable;
import org.apache.cassandra.spark.reader.SparkSSTableReader;
import org.apache.cassandra.spark.stats.Stats;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.eq;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -91,22 +92,29 @@ public class MultipleReplicasTests
runTest(5, 3, 2, 0);
}
- @Test(expected = AssertionError.class)
+ @Test()
public void testRF1NotEnoughReplicas()
{
- runTest(1, 1, 1, 0);
+ assertThrows(AssertionError.class,
+ () -> runTest(1, 1, 1, 0)
+ );
}
- @Test(expected = AssertionError.class)
+ @Test()
public void testRF3QuorumNotEnoughReplicas()
{
- runTest(3, 2, 1, 1);
+ assertThrows(AssertionError.class,
+ () -> runTest(3, 2, 1, 1)
+ );
}
- @Test(expected = AssertionError.class)
+ @Test()
public void testRFAllNotEnoughReplicas()
{
- runTest(3, 3, 1, 0);
+ assertThrows(AssertionError.class,
+ () ->
+ runTest(3, 3, 1, 0)
+ );
}
private static void runTest(int numInstances, int rfFactor, int numDownPrimaryInstances, int numDownBackupInstances)
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/SingleReplicaTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/SingleReplicaTests.java
index 4bca3a4..609b22b 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/SingleReplicaTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/SingleReplicaTests.java
@@ -30,7 +30,7 @@ import java.util.stream.Stream;
import com.google.common.collect.Range;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.data.FileType;
import org.apache.cassandra.spark.data.IncompleteSSTableException;
@@ -41,10 +41,11 @@ import org.apache.cassandra.spark.reader.SparkSSTableReader;
import org.apache.cassandra.spark.reader.common.SSTableStreamException;
import org.jetbrains.annotations.Nullable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doCallRealMethod;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -82,32 +83,39 @@ public class SingleReplicaTests
runTest(false, FileType.INDEX);
}
- @Test(expected = IOException.class)
- public void testMissingDataFile() throws ExecutionException, InterruptedException, IOException
+ @Test()
+ public void testMissingDataFile()
{
- runTest(true, FileType.DATA);
+ assertThrows(IOException.class,
+ () -> runTest(true, FileType.DATA)
+ );
}
- @Test(expected = IOException.class)
- public void testMissingStatisticsFile() throws ExecutionException, InterruptedException, IOException
- {
- runTest(true, FileType.STATISTICS);
+ @Test()
+ public void testMissingStatisticsFile()
+ { assertThrows(IOException.class,
+ () -> runTest(true, FileType.STATISTICS)
+ );
}
- @Test(expected = IOException.class)
- public void testMissingSummaryPrimaryIndex() throws ExecutionException, InterruptedException, IOException
+ @Test()
+ public void testMissingSummaryPrimaryIndex()
{
- runTest(true, FileType.SUMMARY, FileType.INDEX);
+ assertThrows(IOException.class,
+ () -> runTest(true, FileType.SUMMARY, FileType.INDEX)
+ );
}
- @Test(expected = IOException.class)
- public void testFailOpenReader() throws ExecutionException, InterruptedException, IOException
+ @Test()
+ public void testFailOpenReader()
{
- runTest(true,
- (ssTable, isRepairPrimary) -> {
- throw new IOException("Couldn't open Summary.db file");
- },
- Range.closed(BigInteger.valueOf(-9223372036854775808L), BigInteger.valueOf(8710962479251732707L)));
+ assertThrows(IOException.class,
+ () -> runTest(true,
+ (ssTable, isRepairPrimary) -> {
+ throw new IOException("Couldn't open Summary.db file");
+ },
+ Range.closed(BigInteger.valueOf(-9223372036854775808L), BigInteger.valueOf(8710962479251732707L)))
+ );
}
@Test
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/TokenPartitionerTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/TokenPartitionerTests.java
index 6eae4ce..b7ac2bd 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/TokenPartitionerTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/data/partitioner/TokenPartitionerTests.java
@@ -28,13 +28,13 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.google.common.collect.Range;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.utils.RandomUtils;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
@@ -76,8 +76,8 @@ public class TokenPartitionerTests
for (Map.Entry<BigInteger, Integer> entry : tokens.entrySet())
{
- assertFalse("Token not found in any token partitions: " + entry.getKey(), entry.getValue() < 1);
- assertFalse("Token exists in more than one token partition: " + entry.getKey(), entry.getValue() > 1);
+ assertFalse(entry.getValue() < 1, "Token not found in any token partitions: " + entry.getKey());
+ assertFalse(entry.getValue() > 1, "Token exists in more than one token partition: " + entry.getKey());
}
}
}
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/CassandraBridgeTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/CassandraBridgeTests.java
index 9a494c8..e0b13be 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/CassandraBridgeTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/CassandraBridgeTests.java
@@ -19,12 +19,12 @@
package org.apache.cassandra.spark.reader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.TestUtils;
import org.apache.spark.sql.types.DataTypes;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.quicktheories.QuickTheory.qt;
public class CassandraBridgeTests
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/DataTypeSerializationTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/DataTypeSerializationTests.java
index ccd7414..f7eddd4 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/DataTypeSerializationTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/DataTypeSerializationTests.java
@@ -35,7 +35,7 @@ import java.util.UUID;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.BigNumberConfig;
import org.apache.cassandra.spark.TestUtils;
@@ -47,12 +47,12 @@ import org.apache.spark.sql.types.Decimal;
import org.apache.spark.unsafe.types.UTF8String;
import static org.apache.cassandra.spark.TestUtils.runTest;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.bigDecimals;
import static org.quicktheories.generators.SourceDSL.bigIntegers;
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/OverlapTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/OverlapTests.java
index 550bef0..9e6de0c 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/OverlapTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/OverlapTests.java
@@ -22,13 +22,13 @@ package org.apache.cassandra.spark.reader;
import java.math.BigInteger;
import com.google.common.base.Preconditions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.TokenRange;
import org.apache.cassandra.spark.data.partitioner.Partitioner;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class OverlapTests
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java
index 79cba2a..b497062 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java
@@ -27,14 +27,14 @@ import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.data.CqlField;
import org.apache.cassandra.spark.data.CqlTable;
import static org.apache.cassandra.spark.TestUtils.runTest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/RidTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/RidTests.java
index 6378a27..607063c 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/RidTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/RidTests.java
@@ -23,13 +23,13 @@ import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class RidTests
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/SchemaTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/SchemaTests.java
index 955fca7..17ab97f 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/SchemaTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/SchemaTests.java
@@ -27,10 +27,10 @@ import java.util.regex.Matcher;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.bridge.CassandraBridge;
-import org.apache.cassandra.bridge.CassandraVersion;
import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.data.CqlField;
import org.apache.cassandra.spark.data.CqlTable;
@@ -39,13 +39,14 @@ import org.apache.cassandra.spark.data.VersionRunner;
import org.apache.cassandra.spark.data.partitioner.Partitioner;
import org.jetbrains.annotations.Nullable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotSame;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.quicktheories.QuickTheory.qt;
public class SchemaTests extends VersionRunner
@@ -68,13 +69,10 @@ public class SchemaTests extends VersionRunner
+ " AND memtable_flush_period_in_ms = 0\n"
+ " AND min_index_interval = 128\n;";
- public SchemaTests(CassandraVersion version)
- {
- super(version);
- }
- @Test
- public void testBuild()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testBuild(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
@@ -95,8 +93,9 @@ public class SchemaTests extends VersionRunner
assertEquals(2, table.numValueColumns());
}
- @Test
- public void testEquality()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testEquality(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
@@ -111,8 +110,9 @@ public class SchemaTests extends VersionRunner
assertEquals(table1.hashCode(), table2.hashCode());
}
- @Test
- public void testSameKeyspace()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSameKeyspace(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
@@ -123,8 +123,9 @@ public class SchemaTests extends VersionRunner
assertEquals("sbr_test", table1.table());
}
- @Test
- public void testHasher()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testHasher(CassandraBridge bridge)
{
// Casts to (ByteBuffer) required when compiling with Java 8
assertEquals(BigInteger.valueOf(6747049197585865300L),
@@ -137,14 +138,16 @@ public class SchemaTests extends VersionRunner
bridge.hash(Partitioner.RandomPartitioner, (ByteBuffer) ByteBuffer.allocate(4).putInt(1929239).flip()));
}
- @Test
- public void testUUID()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testUUID(CassandraBridge bridge)
{
assertEquals(1, bridge.getTimeUUID().version());
}
- @Test
- public void testCollections()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCollections(CassandraBridge bridge)
{
String createStatement = "CREATE TABLE backup_test.collection_test (account_id uuid PRIMARY KEY, balance bigint, names set<text>);";
ReplicationFactor replicationFactor = new ReplicationFactor(
@@ -153,8 +156,9 @@ public class SchemaTests extends VersionRunner
assertEquals(CqlField.CqlType.InternalType.Set, table.getField("names").type().internalType());
}
- @Test
- public void testSetClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSetClusteringKey(CassandraBridge bridge)
{
String createStatement = "CREATE TABLE backup_test.sbr_test_set_ck (pk uuid, ck frozen<set<text>>, PRIMARY KEY (pk, ck));";
ReplicationFactor replicationFactor = new ReplicationFactor(
@@ -162,8 +166,9 @@ public class SchemaTests extends VersionRunner
bridge.buildSchema(createStatement, "backup_test", replicationFactor);
}
- @Test
- public void testListClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testListClusteringKey(CassandraBridge bridge)
{
String createStatement = "CREATE TABLE backup_test.sbr_test_list_ck (pk uuid, ck frozen<list<bigint>>, PRIMARY KEY (pk, ck));";
ReplicationFactor replicationFactor = new ReplicationFactor(
@@ -171,8 +176,9 @@ public class SchemaTests extends VersionRunner
bridge.buildSchema(createStatement, "backup_test", replicationFactor);
}
- @Test
- public void testMapClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testMapClusteringKey(CassandraBridge bridge)
{
String createStatement = "CREATE TABLE backup_test.sbr_test_map_ck (pk uuid, ck frozen<map<uuid, timestamp>>, PRIMARY KEY (pk, ck));";
ReplicationFactor replicationFactor = new ReplicationFactor(
@@ -180,56 +186,66 @@ public class SchemaTests extends VersionRunner
bridge.buildSchema(createStatement, "backup_test", replicationFactor);
}
- @Test(expected = UnsupportedOperationException.class)
- public void testNativeUnsupportedColumnMetaData()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNativeUnsupportedColumnMetaData(CassandraBridge bridge)
{
String createStatement = "CREATE TABLE backup_test.sbr_test (account_id uuid, transactions counter, PRIMARY KEY(account_id));";
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
- bridge.buildSchema(createStatement, "backup_test", replicationFactor);
+ assertThrows(UnsupportedOperationException.class,
+ () -> bridge.buildSchema(createStatement, "backup_test", replicationFactor)
+ );
}
- @Test(expected = UnsupportedOperationException.class)
- public void testUnsupportedInnerType()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testUnsupportedInnerType(CassandraBridge bridge)
{
String createStatement = "CREATE TABLE backup_test.sbr_test (account_id uuid, transactions counter, PRIMARY KEY(account_id));";
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
- bridge.buildSchema(createStatement, "backup_test", replicationFactor);
+ assertThrows(UnsupportedOperationException.class,
+ () -> bridge.buildSchema(createStatement, "backup_test", replicationFactor)
+ );
}
- @Test(expected = UnsupportedOperationException.class)
- public void testUnsupportedUdt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testUnsupportedUdt(CassandraBridge bridge)
{
String createStatement = "CREATE TABLE backup_test.sbr_test (account_id uuid, transactions frozen<testudt>, PRIMARY KEY (account_id));";
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
- bridge.buildSchema(createStatement, "backup_test", replicationFactor, Partitioner.Murmur3Partitioner,
- ImmutableSet.of("CREATE TYPE backup_test.testudt(birthday timestamp, count bigint, length counter);"));
+ assertThrows(UnsupportedOperationException.class,
+ () -> bridge.buildSchema(createStatement, "backup_test", replicationFactor, Partitioner.Murmur3Partitioner,
+ ImmutableSet.of("CREATE TYPE backup_test.testudt(birthday timestamp, count bigint, length counter);"))
+ );
}
- @Test
- public void testCollectionMatcher()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCollectionMatcher(CassandraBridge bridge)
{
- qt().forAll(TestUtils.cql3Type(bridge)).checkAssert(type -> testMatcher("set<%s>", "set", type));
- qt().forAll(TestUtils.cql3Type(bridge)).checkAssert(type -> testMatcher("list<%s>", "list", type));
+ qt().forAll(TestUtils.cql3Type(bridge)).checkAssert(type -> testMatcher("set<%s>", "set", type, bridge));
+ qt().forAll(TestUtils.cql3Type(bridge)).checkAssert(type -> testMatcher("list<%s>", "list", type, bridge));
qt().forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge)).checkAssert((first, second) -> {
- testMatcher("map<%s,%s>", "map", first, second);
- testMatcher("map<%s , %s>", "map", first, second);
+ testMatcher("map<%s,%s>", "map", first, second, bridge);
+ testMatcher("map<%s , %s>", "map", first, second, bridge);
});
- qt().forAll(TestUtils.cql3Type(bridge)).checkAssert(type -> testMatcher(type.cqlName(), null, null));
+ qt().forAll(TestUtils.cql3Type(bridge)).checkAssert(type -> testMatcher(type.cqlName(), null, null, bridge));
qt().forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge)).checkAssert((first, second) -> {
- testMatcher("tuple<%s,%s>", "tuple", first, second);
- testMatcher("tuple<%s , %s>", "tuple", first, second);
+ testMatcher("tuple<%s,%s>", "tuple", first, second, bridge);
+ testMatcher("tuple<%s , %s>", "tuple", first, second, bridge);
});
}
- private void testMatcher(String pattern, String collection, CqlField.NativeType type)
+ private void testMatcher(String pattern, String collection, CqlField.NativeType type, CassandraBridge bridge)
{
- testMatcher(pattern, collection, type, null);
+ testMatcher(pattern, collection, type, null, bridge);
}
- private void testMatcher(String pattern, String collection, CqlField.NativeType first, CqlField.NativeType second)
+ private void testMatcher(String pattern, String collection, CqlField.NativeType first, CqlField.NativeType second, CassandraBridge bridge)
{
boolean isMap = second != null;
String string;
@@ -267,21 +283,23 @@ public class SchemaTests extends VersionRunner
}
}
- @Test
- public void testFrozenMatcher()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testFrozenMatcher(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge))
- .checkAssert(type -> testFrozen("frozen<set<%s>>", CqlField.CqlSet.class, type));
+ .checkAssert(type -> testFrozen("frozen<set<%s>>", CqlField.CqlSet.class, type, bridge));
qt().forAll(TestUtils.cql3Type(bridge))
- .checkAssert(type -> testFrozen("frozen<list<%s>>", CqlField.CqlList.class, type));
+ .checkAssert(type -> testFrozen("frozen<list<%s>>", CqlField.CqlList.class, type, bridge));
qt().forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge)).checkAssert((first, second) -> {
- testFrozen("frozen<map<%s,%s>>", CqlField.CqlMap.class, first, second);
- testFrozen("frozen<map<%s , %s>>", CqlField.CqlMap.class, first, second);
+ testFrozen("frozen<map<%s,%s>>", CqlField.CqlMap.class, first, second, bridge);
+ testFrozen("frozen<map<%s , %s>>", CqlField.CqlMap.class, first, second, bridge);
});
}
- @Test
- public void testNestedFrozenSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNestedFrozenSet(CassandraBridge bridge)
{
String pattern = "map<text, frozen<set<bigint>>>";
CqlField.CqlType type = bridge.parseType(pattern);
@@ -297,8 +315,9 @@ public class SchemaTests extends VersionRunner
assertSame(inner.type(), bridge.bigint());
}
- @Test
- public void testNestedFrozenMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNestedFrozenMap(CassandraBridge bridge)
{
String pattern = "map<text, frozen<map<bigint, text>>>";
CqlField.CqlType type = bridge.parseType(pattern);
@@ -317,15 +336,15 @@ public class SchemaTests extends VersionRunner
private void testFrozen(String pattern,
Class<? extends CqlField.CqlCollection> collectionType,
- CqlField.CqlType innerType)
+ CqlField.CqlType innerType, CassandraBridge bridge)
{
- testFrozen(pattern, collectionType, innerType, null);
+ testFrozen(pattern, collectionType, innerType, null, bridge);
}
private void testFrozen(String pattern,
Class<? extends CqlField.CqlCollection> collectionType,
CqlField.CqlType first,
- @Nullable CqlField.CqlType second)
+ @Nullable CqlField.CqlType second, CassandraBridge bridge)
{
pattern = second != null ? String.format(pattern, first, second) : String.format(pattern, first);
CqlField.CqlType type = bridge.parseType(pattern);
@@ -345,8 +364,9 @@ public class SchemaTests extends VersionRunner
/* User-Defined Types */
- @Test
- public void testUdts()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testUdts(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
@@ -390,8 +410,9 @@ public class SchemaTests extends VersionRunner
assertEquals(bridge.aInt(), udtField.field(3).type());
}
- @Test
- public void testCollectionUdts()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCollectionUdts(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
@@ -425,8 +446,9 @@ public class SchemaTests extends VersionRunner
assertEquals(bridge.aInt(), udtField.field(3).type());
}
- @Test
- public void testParseUdt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testParseUdt(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
@@ -443,8 +465,9 @@ public class SchemaTests extends VersionRunner
assertEquals(bridge.text(), fields.get(3).type());
}
- @Test
- public void testParseTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testParseTuple(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
@@ -468,8 +491,9 @@ public class SchemaTests extends VersionRunner
assertEquals(bridge.bool(), tuple.type(3));
}
- @Test
- public void testComplexSchema()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testComplexSchema(CassandraBridge bridge)
{
String keyspace = "complex_schema1";
String type1 = "CREATE TYPE " + keyspace + ".field_with_timestamp (\n"
@@ -565,8 +589,9 @@ public class SchemaTests extends VersionRunner
((CqlField.CqlMap) ((CqlField.CqlFrozen) fieldsUDT.field(9).type()).inner()).valueType().internalType());
}
- @Test
- public void testNestedUDTs()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testNestedUDTs(CassandraBridge bridge)
{
ReplicationFactor replicationFactor = new ReplicationFactor(
ReplicationFactor.ReplicationStrategy.NetworkTopologyStrategy, ImmutableMap.of("DC1", 3, "DC2", 3));
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/TombstoneWriterTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/TombstoneWriterTests.java
index b200a30..26c133c 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/TombstoneWriterTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/TombstoneWriterTests.java
@@ -23,7 +23,7 @@ import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.file.Path;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -31,9 +31,9 @@ import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.data.FileType;
import org.apache.cassandra.spark.utils.test.TestSchema;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
/**
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/common/CompressionInputStreamTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/common/CompressionInputStreamTests.java
index 91e9adf..e952585 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/common/CompressionInputStreamTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/reader/common/CompressionInputStreamTests.java
@@ -29,13 +29,14 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.UUID;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.stats.Stats;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class CompressionInputStreamTests
{
@@ -80,24 +81,32 @@ public class CompressionInputStreamTests
}
}
- @Test(expected = IndexOutOfBoundsException.class)
+ @Test()
public void testBigLongArrayIllegalSize()
{
- new BigLongArray(-1);
+ assertThrows(IndexOutOfBoundsException.class,
+ () -> new BigLongArray(-1)
+ );
}
- @Test(expected = IndexOutOfBoundsException.class)
+ @Test()
public void testBigLongArrayEmpty()
{
- BigLongArray array = new BigLongArray(0);
- array.set(0, 0L);
+ assertThrows(IndexOutOfBoundsException.class,
+ () -> {
+ BigLongArray array = new BigLongArray(0);
+ array.set(0, 0L);
+ });
}
- @Test(expected = IndexOutOfBoundsException.class)
+ @Test()
public void testBigLongArrayOutOfRange()
{
- BigLongArray array = new BigLongArray(500);
- array.set(501, 999L);
+ assertThrows(IndexOutOfBoundsException.class,
+ () -> {
+ BigLongArray array = new BigLongArray(500);
+ array.set(501, 999L);
+ });
}
@Test
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/BuildInfoTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/BuildInfoTest.java
index 836989b..ccac01e 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/BuildInfoTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/BuildInfoTest.java
@@ -19,12 +19,12 @@
package org.apache.cassandra.spark.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class BuildInfoTest
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/ByteBufferUtilsTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/ByteBufferUtilsTests.java
index 9f81670..e8e4209 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/ByteBufferUtilsTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/ByteBufferUtilsTests.java
@@ -27,10 +27,10 @@ import java.nio.charset.StandardCharsets;
import com.google.common.io.ByteArrayDataInput;
import com.google.common.io.ByteStreams;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
@SuppressWarnings("UnstableApiUsage")
public class ByteBufferUtilsTests
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/CqlUtilsTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/CqlUtilsTest.java
index 8b4ffaa..cdc1d4f 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/CqlUtilsTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/CqlUtilsTest.java
@@ -31,21 +31,22 @@ import java.util.stream.Collectors;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.io.FileUtils;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
-import org.apache.cassandra.bridge.CassandraVersion;
+import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.spark.data.CqlTable;
import org.apache.cassandra.spark.data.ReplicationFactor;
import org.apache.cassandra.spark.data.VersionRunner;
import org.apache.cassandra.spark.data.partitioner.Partitioner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Unit tests for {@link CqlUtils}
@@ -54,26 +55,23 @@ public class CqlUtilsTest extends VersionRunner
{
static String fullSchemaSample;
- public CqlUtilsTest(CassandraVersion version)
- {
- super(version);
- }
-
- @BeforeClass
+ @BeforeAll
public static void setup() throws URISyntaxException, IOException
{
fullSchemaSample = loadFullSchemaSample();
}
- @Test
- public void textExtractIndexCount()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void textExtractIndexCount(CassandraBridge bridge)
{
int indexCount = CqlUtils.extractIndexCount(fullSchemaSample, "cycling", "rank_by_year_and_name");
assertEquals(3, indexCount);
}
- @Test
- public void testExtractKeyspace()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractKeyspace(CassandraBridge bridge)
{
String keyspaceSchema = CqlUtils.extractKeyspaceSchema(fullSchemaSample, "keyspace");
String tagEntityRelationV4KeyspaceSchema = CqlUtils.extractKeyspaceSchema(fullSchemaSample, "quoted_keyspace");
@@ -94,8 +92,9 @@ public class CqlUtilsTest extends VersionRunner
+ "WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.LocalStrategy' } AND DURABLE_WRITES = true;", systemSchemaKeyspaceSchema);
}
- @Test
- public void testExtractKeyspaceNames()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractKeyspaceNames(CassandraBridge bridge)
{
Set<String> keyspaceNames = CqlUtils.extractKeyspaceNames(fullSchemaSample);
assertEquals(3, keyspaceNames.size());
@@ -111,8 +110,9 @@ public class CqlUtilsTest extends VersionRunner
assertEquals(3, rfMap.get("quoted_keyspace").getOptions().get("datacenter2").intValue());
}
- @Test
- public void testExtractReplicationFactor()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractReplicationFactor(CassandraBridge bridge)
{
ReplicationFactor keyspaceRf = CqlUtils.extractReplicationFactor(fullSchemaSample, "keyspace");
assertNotNull(keyspaceRf);
@@ -139,8 +139,9 @@ public class CqlUtilsTest extends VersionRunner
assertEquals(ImmutableMap.of(), systemSchemaRf.getOptions());
}
- @Test
- public void testEscapedColumnNames()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testEscapedColumnNames(CassandraBridge bridge)
{
String cleaned = CqlUtils.extractTableSchema(fullSchemaSample, "cycling", "rank_by_year_and_name_quoted_columns");
assertEquals("CREATE TABLE cycling.rank_by_year_and_name_quoted_columns("
@@ -155,8 +156,9 @@ public class CqlUtilsTest extends VersionRunner
+ " AND cdc = false;", cleaned);
}
- @Test
- public void testExtractTableSchemaCase1()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractTableSchemaCase1(CassandraBridge bridge)
{
String schemaStr = "CREATE TABLE keyspace.table ("
+ "key blob, "
@@ -201,8 +203,9 @@ public class CqlUtilsTest extends VersionRunner
assertEquals(expectedCreateStmt, actualCreateStmt);
}
- @Test
- public void testFailsWithUnbalancedParenthesis()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testFailsWithUnbalancedParenthesis(CassandraBridge bridge)
{
String schemaStr = "CREATE TABLE keyspace.table (key blob, c0 text, c1 text, PRIMARY KEY (key);";
@@ -219,8 +222,9 @@ public class CqlUtilsTest extends VersionRunner
}
}
- @Test
- public void testExtractTableSchemaCase2()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractTableSchemaCase2(CassandraBridge bridge)
{
String schemaStr = "CREATE TABLE keyspace.table ("
+ "key blob, "
@@ -261,8 +265,9 @@ public class CqlUtilsTest extends VersionRunner
assert expectedCreateStmt.equals(actualCreateStmt);
}
- @Test
- public void testEscapedTableName()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testEscapedTableName(CassandraBridge bridge)
{
String schemaStr = "CREATE TABLE ks.\\\"tb\\\" (\\n"
+ "\\\"key\\\" text,\\n"
@@ -317,16 +322,18 @@ public class CqlUtilsTest extends VersionRunner
assertEquals("id1", table.getField("id1").name());
}
- @Test
- public void testCleanTableName()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCleanTableName(CassandraBridge bridge)
{
assertEquals("test", CqlUtils.cleanTableName("test"));
assertEquals("test", CqlUtils.cleanTableName("\"test\""));
assertEquals("test", CqlUtils.cleanTableName("\"\"test\"\""));
}
- @Test
- public void testExtractTableSchemaCase3()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractTableSchemaCase3(CassandraBridge bridge)
{
String schemaStr = "CREATE TABLE keyspace.table ("
+ "key blob, "
@@ -366,8 +373,9 @@ public class CqlUtilsTest extends VersionRunner
assert expectedCreateStmt.equals(actualCreateStmt);
}
- @Test
- public void testBasicExtractUDTs()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testBasicExtractUDTs(CassandraBridge bridge)
{
String schemaStr = "CREATE TYPE udt_keyspace.test_idt1 (a text, b bigint, c int, d float);\n"
+ "CREATE TYPE udt_keyspace.test_idt2 (x boolean, y timestamp, z timeuuid);";
@@ -377,8 +385,9 @@ public class CqlUtilsTest extends VersionRunner
assertTrue(udts.contains("CREATE TYPE udt_keyspace.test_idt2 (x boolean, y timestamp, z timeuuid);"));
}
- @Test
- public void testExtractUDTs()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractUDTs(CassandraBridge bridge)
{
String schema = "\"CREATE TYPE some_keyspace.udt123 (\\n\" +\n"
+ " \" x uuid,\\n\" +\n"
@@ -454,8 +463,9 @@ public class CqlUtilsTest extends VersionRunner
+ ");"));
}
- @Test
- public void testExtractKeyspacesUDTs()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractKeyspacesUDTs(CassandraBridge bridge)
{
String schemaTxt = "\"CREATE KEYSPACE keyspace_with_udts WITH REPLICATION = {"
+ " 'class' : 'org.apache.cassandra.locator.NetworkTopologyStrategy',"
@@ -497,8 +507,9 @@ public class CqlUtilsTest extends VersionRunner
assertTrue(udtStr.contains("ks1.field_with_timestamp"));
}
- @Test
- public void testExtractTableSchemaCase4()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractTableSchemaCase4(CassandraBridge bridge)
{
String schemaStr = "CREATE TABLE keyspace.table (value text PRIMARY KEY);";
String expectedCreateStmt = "CREATE TABLE keyspace.table (value text PRIMARY KEY);";
@@ -506,8 +517,9 @@ public class CqlUtilsTest extends VersionRunner
assert expectedCreateStmt.equals(actualCreateStmt);
}
- @Test
- public void testParseClusteringKeySchema()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testParseClusteringKeySchema(CassandraBridge bridge)
{
String schemaTxt = "CREATE TABLE ks1.tb1 (\n"
+ " namespace int,\n"
@@ -543,8 +555,9 @@ public class CqlUtilsTest extends VersionRunner
Collections.emptySet(), null, 0);
}
- @Test
- public void testExtractClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractClusteringKey(CassandraBridge bridge)
{
assertEquals("CLUSTERING ORDER BY (c ASC)",
CqlUtils.extractClustering("CREATE TABLE ks1.tb1 (a int, b text, c int, d timestamp, PRIMARY KEY ((a, b), c)"
@@ -610,8 +623,9 @@ public class CqlUtilsTest extends VersionRunner
+ " AND read_repair = 'BLOCKING' AND speculative_retry = 'MIN(99p,15ms)'"));
}
- @Test
- public void testClusteringOrderByIsRetained()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testClusteringOrderByIsRetained(CassandraBridge bridge)
{
String schemaStr = "CREATE TABLE keyspace.table (id bigint, version bigint PRIMARY KEY (id, version)) "
+ "WITH CLUSTERING ORDER BY (id DESC, version DESC) AND foo = 1;";
@@ -621,8 +635,9 @@ public class CqlUtilsTest extends VersionRunner
assertEquals(expectedCreateStmt, actualCreateStmt);
}
- @Test
- public void testExtractCdcFlag()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testExtractCdcFlag(CassandraBridge bridge)
{
assertTrue(CqlUtils.extractOverrideProperties("CREATE TABLE k.t (a int PRIMARY KEY, b int);",
Collections.singletonList("cdc")).isEmpty());
@@ -644,8 +659,9 @@ public class CqlUtilsTest extends VersionRunner
Collections.singletonList("cdc")).contains("cdc = false"));
}
- @Test
- public void testCdcExtractSchema()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCdcExtractSchema(CassandraBridge bridge)
{
String schema = "CREATE KEYSPACE ks1"
+ " WITH REPLICATION = { 'class' : 'org.apache.cassandra.locator.NetworkTopologyStrategy',"
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/FilterUtilsTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/FilterUtilsTests.java
index 75e0276..f6e4e0b 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/FilterUtilsTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/FilterUtilsTests.java
@@ -25,23 +25,26 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.spark.sql.sources.EqualTo;
import org.apache.spark.sql.sources.Filter;
import org.apache.spark.sql.sources.In;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class FilterUtilsTests
{
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void testPartialPartitionKeyFilter()
{
Filter[] filters = new Filter[]{new EqualTo("a", "1")};
- Map<String, List<String>> partitionKeyValues = FilterUtils.extractPartitionKeyValues(filters, new HashSet<>(Arrays.asList("a", "b")));
+ assertThrows(IllegalArgumentException.class,
+ () -> FilterUtils.extractPartitionKeyValues(filters, new HashSet<>(Arrays.asList("a", "b")))
+ );
}
@Test
@@ -54,11 +57,13 @@ public class FilterUtilsTests
assertTrue(partitionKeyValues.containsKey("b"));
}
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void testCartesianProductOfInValidValues()
{
List<List<String>> orderedValues = Arrays.asList(Arrays.asList("1", "2"), Arrays.asList("a", "b", "c"), Collections.emptyList());
- List<List<String>> product = FilterUtils.cartesianProduct(orderedValues);
+ assertThrows(IllegalArgumentException.class,
+ () -> FilterUtils.cartesianProduct(orderedValues)
+ );
}
@Test
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/RangeUtilsTest.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/RangeUtilsTest.java
index 9cba503..a13d8b4 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/RangeUtilsTest.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/RangeUtilsTest.java
@@ -28,14 +28,14 @@ import java.util.regex.Pattern;
import com.google.common.collect.Multimap;
import com.google.common.collect.Range;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.data.partitioner.CassandraInstance;
import org.apache.cassandra.spark.data.partitioner.Partitioner;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class RangeUtilsTest
{
@@ -161,13 +161,14 @@ public class RangeUtilsTest
new String[]{"(0,4611686018427387904]"});
}
- @Test(expected = IllegalArgumentException.class)
+ @Test()
public void testCalculateTokenRangesRFGreaterThanNodesFails()
{
- assertTokenRanges(2, 3,
- new String[]{"Does Not"},
- new String[]{"Matter"});
- fail("Expected failure when RF greater than number of Nodes");
+ assertThrows(IllegalArgumentException.class,
+ () -> assertTokenRanges(2, 3,
+ new String[]{"Does Not"},
+ new String[]{"Matter"})
+ );
}
@Test
@@ -194,8 +195,8 @@ public class RangeUtilsTest
assertEquals(expectedRanges.length, actual.size());
for (String expected : expectedRanges)
{
- assertTrue(String.format("Expected range %s not found in %s", expected, actual),
- actual.contains(range(expected)));
+ assertTrue(actual.contains(range(expected)),
+ String.format("Expected range %s not found in %s", expected, actual));
}
}
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamHttpTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamHttpTests.java
index 1ab0584..b7bbf10 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamHttpTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamHttpTests.java
@@ -26,7 +26,6 @@ import java.io.RandomAccessFile;
import java.net.InetSocketAddress;
import java.nio.file.Files;
import java.nio.file.Path;
-import java.nio.file.Paths;
import java.security.MessageDigest;
import java.util.Arrays;
import java.util.List;
@@ -37,11 +36,10 @@ import java.util.concurrent.TimeUnit;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.apache.commons.codec.digest.DigestUtils;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -57,8 +55,8 @@ import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
@@ -78,8 +76,8 @@ public class SSTableInputStreamHttpTests
.build());
private static final Logger LOGGER = LoggerFactory.getLogger(SSTableInputStreamHttpTests.class);
- @ClassRule
- public static TemporaryFolder DIRECTORY = new TemporaryFolder(); // CHECKSTYLE IGNORE: Constant cannot be made final
+ @TempDir
+ public static Path DIRECTORY; // CHECKSTYLE IGNORE: Constant cannot be made final
private static final String HOST = "localhost";
private static final int PORT = 8001;
private static final int HTTP_CLIENT_CHUNK_SIZE = 8192;
@@ -87,7 +85,7 @@ public class SSTableInputStreamHttpTests
private static HttpServer SERVER; // CHECKSTYLE IGNORE: Constant cannot be made final
private static CloseableHttpClient CLIENT; // CHECKSTYLE IGNORE: Constant cannot be made final
- @BeforeClass
+ @BeforeAll
public static void setup() throws IOException
{
// Create in-test HTTP server to handle range requests and tmp files
@@ -96,8 +94,8 @@ public class SSTableInputStreamHttpTests
SERVER.createContext("/", exchange -> {
try
{
- String uri = exchange.getRequestURI().getPath();
- Path path = Paths.get(DIRECTORY.getRoot().getPath(), uri);
+ String uri = exchange.getRequestURI().getPath().replaceFirst("/", "");
+ Path path = DIRECTORY.resolve(uri);
// Extract Range from header
long size = Files.size(path);
@@ -158,7 +156,7 @@ public class SSTableInputStreamHttpTests
CLIENT = HttpClients.createDefault();
}
- @AfterClass
+ @AfterAll
public static void tearDown()
{
SERVER.stop(0);
@@ -268,8 +266,7 @@ public class SSTableInputStreamHttpTests
{
try
{
- // Create tmp file with random data
- Path path = DIRECTORY.newFile().toPath();
+ Path path = Files.createTempFile(DIRECTORY, null, null);
MessageDigest digest = DigestUtils.getMd5Digest();
try (BufferedOutputStream out = new BufferedOutputStream(Files.newOutputStream(path)))
{
diff --git a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java
index bb2b656..0f2551c 100644
--- a/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java
+++ b/cassandra-analytics-core/src/test/java/org/apache/cassandra/spark/utils/SSTableInputStreamTests.java
@@ -34,7 +34,7 @@ import com.google.common.collect.ImmutableList;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import com.google.common.util.concurrent.Uninterruptibles;
import org.apache.commons.lang.mutable.MutableInt;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.data.FileType;
import org.apache.cassandra.spark.data.SSTable;
@@ -46,10 +46,11 @@ import org.apache.cassandra.spark.utils.streaming.StreamConsumer;
import org.jetbrains.annotations.Nullable;
import static org.apache.cassandra.spark.utils.streaming.SSTableInputStream.timeoutLeftNanos;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
/**
* Test the {@link SSTableInputStream} by mocking the {@link SSTableSource}
@@ -147,8 +148,8 @@ public class SSTableInputStreamTests
assertEquals(fileSize, is.bytesRead());
}
- @Test(expected = IOException.class)
- public void testFailure() throws IOException
+ @Test()
+ public void testFailure()
{
int chunksPerRequest = 10;
int numRequests = 10;
@@ -168,8 +169,9 @@ public class SSTableInputStreamTests
writeBuffers(consumer, randomBuffers(chunksPerRequest));
}
}, null);
- readStreamFully(new SSTableInputStream<>(source, STATS));
- fail("Should have failed with IOException");
+ assertThrows(IOException.class,
+ () -> readStreamFully(new SSTableInputStream<>(source, STATS))
+ );
}
@Test
@@ -229,9 +231,9 @@ public class SSTableInputStreamTests
}
Duration duration = Duration.ofNanos(System.nanoTime() - startTime);
Duration maxAcceptable = timeout.plus(Duration.ofMillis(sleepTimeInMillis));
- assertTrue("Timeout didn't account for activity time. "
- + "Took " + duration.toMillis() + "ms should have taken at most " + maxAcceptable.toMillis() + "ms",
- duration.minus(maxAcceptable).toMillis() < 100);
+ assertTrue(duration.minus(maxAcceptable).toMillis() < 100,
+ "Timeout didn't account for activity time. "
+ + "Took " + duration.toMillis() + "ms should have taken at most " + maxAcceptable.toMillis() + "ms");
}
@Test
diff --git a/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/PartitionKeyFilterTests.java b/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/PartitionKeyFilterTests.java
index 99e0a2c..6f939ec 100644
--- a/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/PartitionKeyFilterTests.java
+++ b/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/PartitionKeyFilterTests.java
@@ -28,7 +28,7 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.google.common.collect.Range;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.TokenRange;
import org.apache.cassandra.spark.TestUtils;
@@ -39,9 +39,10 @@ import org.apache.cassandra.spark.reader.SparkSSTableReader;
import org.apache.cassandra.spark.sparksql.filters.PartitionKeyFilter;
import org.apache.cassandra.spark.utils.RangeUtils;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.quicktheories.QuickTheory.qt;
@@ -74,10 +75,12 @@ public class PartitionKeyFilterTests
});
}
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void testEmptyKey()
{
- PartitionKeyFilter.create(ByteBuffer.wrap(new byte[0]), BigInteger.ZERO);
+ assertThrows(IllegalArgumentException.class, () ->
+ PartitionKeyFilter.create(ByteBuffer.wrap(new byte[0]),
+ BigInteger.ZERO));
}
@Test
@@ -99,9 +102,9 @@ public class PartitionKeyFilterTests
// Check boundary tokens only match 1 Spark token range
PartitionKeyFilter filter = PartitionKeyFilter.create(bridge.aInt().serialize(11), token);
assertEquals(1, tokenPartitioner.subRanges().stream()
- .map(RangeUtils::toTokenRange)
- .filter(filter::overlaps)
- .count());
+ .map(RangeUtils::toTokenRange)
+ .filter(filter::overlaps)
+ .count());
}
});
}
diff --git a/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRangeFilterTests.java b/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRangeFilterTests.java
index 6ddc465..00e8231 100644
--- a/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRangeFilterTests.java
+++ b/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRangeFilterTests.java
@@ -21,14 +21,14 @@ package org.apache.cassandra.spark.sparksql;
import java.math.BigInteger;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.TokenRange;
import org.apache.cassandra.spark.reader.SparkSSTableReader;
import org.apache.cassandra.spark.sparksql.filters.SparkRangeFilter;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
diff --git a/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRowIteratorTests.java b/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRowIteratorTests.java
index 024a882..c3c8d84 100644
--- a/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRowIteratorTests.java
+++ b/cassandra-analytics-core/src/test/spark2/org/apache/cassandra/spark/sparksql/SparkRowIteratorTests.java
@@ -26,7 +26,8 @@ import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
-import org.junit.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.bridge.CassandraBridge;
import org.apache.cassandra.bridge.CassandraBridgeFactory;
@@ -35,7 +36,6 @@ import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.data.CqlField;
import org.apache.cassandra.spark.data.CqlTable;
import org.apache.cassandra.spark.data.DataLayer;
-import org.apache.cassandra.spark.data.VersionRunner;
import org.apache.cassandra.spark.reader.Rid;
import org.apache.cassandra.spark.reader.StreamScanner;
import org.apache.cassandra.spark.sparksql.filters.PartitionKeyFilter;
@@ -43,26 +43,22 @@ import org.apache.cassandra.spark.stats.Stats;
import org.apache.cassandra.spark.utils.ColumnTypes;
import org.apache.cassandra.spark.utils.test.TestSchema;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.anyListOf;
+import static org.mockito.ArgumentMatchers.anyListOf;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.quicktheories.QuickTheory.qt;
-public class SparkRowIteratorTests extends VersionRunner
+public class SparkRowIteratorTests
{
private static final int NUM_ROWS = 50;
- public SparkRowIteratorTests(CassandraVersion version)
- {
- super(version);
- }
-
- @Test
- public void testBasicKeyValue()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testBasicKeyValue(CassandraBridge bridge)
{
// I.e. "create table keyspace.table (a %s, b %s, primary key(a));"
qt().forAll(TestUtils.versions(), TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
@@ -72,8 +68,9 @@ public class SparkRowIteratorTests extends VersionRunner
.build()));
}
- @Test
- public void testMultiPartitionKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMultiPartitionKeys(CassandraBridge bridge)
{
qt().forAll(TestUtils.versions(), TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
.checkAssert((version, type1, type2, type3) -> runTest(version, TestSchema.builder()
@@ -84,8 +81,9 @@ public class SparkRowIteratorTests extends VersionRunner
.build()));
}
- @Test
- public void testBasicClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testBasicClusteringKey(CassandraBridge bridge)
{
for (CassandraVersion version : TestUtils.testableVersions())
{
@@ -99,8 +97,9 @@ public class SparkRowIteratorTests extends VersionRunner
}
}
- @Test
- public void testMultiClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testMultiClusteringKey(CassandraBridge bridge)
{
for (CassandraVersion version : TestUtils.testableVersions())
{
@@ -116,8 +115,9 @@ public class SparkRowIteratorTests extends VersionRunner
}
}
- @Test
- public void testUdt()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testUdt(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
.checkAssert((type1, type2) -> runTest(CassandraVersion.FOURZERO, TestSchema.builder()
@@ -131,8 +131,9 @@ public class SparkRowIteratorTests extends VersionRunner
.build()));
}
- @Test
- public void testTuple()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.bridge.VersionRunner#bridges")
+ public void testTuple(CassandraBridge bridge)
{
qt().forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
.checkAssert((type1, type2) -> runTest(CassandraVersion.FOURZERO, TestSchema.builder()
diff --git a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTester.java b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTester.java
index 076976e..b722ca9 100644
--- a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTester.java
+++ b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTester.java
@@ -37,7 +37,6 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.google.common.util.concurrent.Uninterruptibles;
-import org.junit.rules.TemporaryFolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -55,9 +54,9 @@ import org.apache.spark.sql.streaming.StreamingQuery;
import org.apache.spark.sql.streaming.StreamingQueryException;
import org.jetbrains.annotations.Nullable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
/**
* Helper for writing CommitLogs using the TestSchema
@@ -71,11 +70,11 @@ public class CdcTester
// TODO: Use generic CommitLog
public static CassandraBridge.ICommitLog COMMIT_LOG; // CHECKSTYLE IGNORE: Constant cannot be made final
- public static void setup(CassandraBridge bridge, TemporaryFolder testFolder)
+ public static void setup(CassandraBridge bridge, Path testFolder)
{
- bridge.setCommitLogPath(testFolder.getRoot().toPath());
- bridge.setCDC(testFolder.getRoot().toPath());
- COMMIT_LOG = bridge.testCommitLog(testFolder.getRoot());
+ bridge.setCommitLogPath(testFolder.getRoot());
+ bridge.setCDC(testFolder.getRoot());
+ COMMIT_LOG = bridge.testCommitLog(testFolder.toFile());
}
public static void tearDown()
@@ -359,12 +358,13 @@ public class CdcTester
String key = actualRow.getKey();
TestSchema.TestRow expectedRow = rows.get(key);
assertNotNull(expectedRow);
- assertEquals("Row read in Spark does not match expected",
- expectedRow.withColumns(requiredColumns).nullifyUnsetColumn(), actualRow);
+ assertEquals(expectedRow.withColumns(requiredColumns).nullifyUnsetColumn(), actualRow,
+ "Row read in Spark does not match expected");
actualRowCount++;
}
- assertEquals(String.format("Expected %d rows, but %d read testId=%s",
- expectedNumRows, actualRowCount, testId), rows.size(), actualRowCount);
+ assertEquals(rows.size(), actualRowCount,
+ String.format("Expected %d rows, but %d read testId=%s",
+ expectedNumRows, actualRowCount, testId));
}
else
{
@@ -390,10 +390,6 @@ public class CdcTester
.collect(Collectors.toList());
}
- public static Builder builder(CassandraBridge bridge, TemporaryFolder testDir, TestSchema.Builder schemaBuilder)
- {
- return builder(bridge, testDir.getRoot().toPath(), schemaBuilder);
- }
public static Builder builder(CassandraBridge bridge, Path testDir, TestSchema.Builder schemaBuilder)
{
diff --git a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTests.java b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTests.java
index 9fcd6b1..0ce3c45 100644
--- a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTests.java
+++ b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTests.java
@@ -22,6 +22,7 @@ package org.apache.cassandra.spark.cdc;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.Collections;
@@ -35,16 +36,14 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.bridge.CassandraBridge;
-import org.apache.cassandra.bridge.CassandraVersion;
import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.Tester;
import org.apache.cassandra.spark.cdc.watermarker.Watermarker;
@@ -57,38 +56,31 @@ import org.apache.cassandra.spark.utils.test.TestSchema;
import org.apache.spark.sql.Row;
import org.jetbrains.annotations.Nullable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.quicktheories.QuickTheory.qt;
-@Ignore
+@Disabled
public class CdcTests extends VersionRunner
{
- @ClassRule
- public static TemporaryFolder DIRECTORY = new TemporaryFolder(); // CHECKSTYLE IGNORE: Constant cannot be made final
+ @TempDir
+ public static Path DIRECTORY; // CHECKSTYLE IGNORE: Constant cannot be made final
- @Before
- public void setup()
+ public void setup(CassandraBridge bridge)
{
CdcTester.setup(bridge, DIRECTORY);
}
- @After
+ @AfterEach
public void tearDown()
{
CdcTester.tearDown();
}
- public CdcTests(CassandraVersion version)
- {
- super(version);
- }
-
- @Test
- public void testSinglePartitionKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSinglePartitionKey(CassandraBridge bridge)
{
+ setup(bridge);
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
CdcTester.builder(bridge, DIRECTORY, TestSchema.builder()
@@ -102,15 +94,17 @@ public class CdcTests extends VersionRunner
BitSet actual = BitSet.valueOf(updatedFieldsIndicator);
BitSet expected = new BitSet(3);
expected.set(0, 3); // Expecting all columns to be set
- assertEquals(expected, actual);
+ Assertions.assertEquals(expected, actual);
}
})
.run());
}
- @Test
- public void testUpdatedFieldsIndicator()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testUpdatedFieldsIndicator(CassandraBridge bridge)
{
+ setup(bridge);
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
CdcTester.builder(bridge, DIRECTORY, TestSchema.builder()
@@ -135,16 +129,19 @@ public class CdcTests extends VersionRunner
BitSet expected = new BitSet(3);
expected.set(0); // Expecting pk to be set
expected.set(2); // And c2 to be set
- assertEquals(expected, bs);
- assertNull("c1 should be null", row.get(1));
+ Assertions.assertEquals(expected, bs);
+ Object actual = row.get(1);
+ Assertions.assertNull(actual, "c1 should be null");
}
})
.run());
}
- @Test
- public void testMultipleWritesToSameKeyInBatch()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testMultipleWritesToSameKeyInBatch(CassandraBridge bridge)
{
+ setup(bridge);
// The test writes different groups of mutations.
// Each group of mutations write to the same key with a different timestamp.
// For CDC, it only deduplicates and emits the replicated mutations, i.e. they have the same writetime.
@@ -182,7 +179,7 @@ public class CdcTests extends VersionRunner
.withChecker((testRows, actualRows) -> {
int partitions = testRows.size();
int mutations = actualRows.size();
- assertEquals("Each PK should get 2 mutations", partitions * 2, mutations);
+ Assertions.assertEquals(partitions * 2, (Object) mutations, "Each PK should get 2 mutations");
})
.withRowChecker(sparkRows -> {
long timestamp = -1L;
@@ -196,8 +193,7 @@ public class CdcTests extends VersionRunner
{
long lastTimestamp = timestamp;
timestamp = getMicros(row.getTimestamp(3));
- assertTrue("Writetime should be monotonically increasing",
- lastTimestamp < timestamp);
+ Assertions.assertTrue(lastTimestamp < timestamp, "Writetime should be monotonically increasing");
}
}
})
@@ -211,9 +207,11 @@ public class CdcTests extends VersionRunner
return TimeUnit.MILLISECONDS.toMicros(millis) + TimeUnit.NANOSECONDS.toMicros(nanos);
}
- @Test
- public void testCompactOnlyWithEnoughReplicas()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCompactOnlyWithEnoughReplicas(CassandraBridge bridge)
{
+ setup(bridge);
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
CdcTester.builder(bridge, DIRECTORY, TestSchema.builder()
@@ -248,11 +246,11 @@ public class CdcTests extends VersionRunner
int uniqueTsCount = rows.stream().map(r -> r.getTimestamp(3).getTime())
.collect(Collectors.toSet())
.size();
- Assert.assertEquals("Output rows should have distinct lastModified timestamps", size, uniqueTsCount);
+ Assertions.assertEquals(size, uniqueTsCount, "Output rows should have distinct lastModified timestamps");
})
.withChecker((testRows, actualRows) -> {
- Assert.assertEquals("There should be exact one row less in the output.",
- actualRows.size() + 1, testRows.size());
+ Assertions.assertEquals(actualRows.size() + 1, testRows.size(),
+ "There should be exact one row less in the output.");
boolean allContains = true;
TestSchema.TestRow unexpectedRow = null;
for (TestSchema.TestRow row : actualRows)
@@ -266,15 +264,17 @@ public class CdcTests extends VersionRunner
}
if (!allContains && unexpectedRow != null)
{
- Assert.fail("Found an unexpected row from the output: " + unexpectedRow);
+ Assertions.fail("Found an unexpected row from the output: " + unexpectedRow);
}
})
.run());
}
- @Test
- public void testCompositePartitionKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testCompositePartitionKey(CassandraBridge bridge)
{
+ setup(bridge);
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
CdcTester.builder(bridge, DIRECTORY, TestSchema.builder()
@@ -287,9 +287,11 @@ public class CdcTests extends VersionRunner
);
}
- @Test
- public void testClusteringKey()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testClusteringKey(CassandraBridge bridge)
{
+ setup(bridge);
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
CdcTester.builder(bridge, DIRECTORY, TestSchema.builder()
@@ -301,9 +303,11 @@ public class CdcTests extends VersionRunner
);
}
- @Test
- public void testMultipleClusteringKeys()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testMultipleClusteringKeys(CassandraBridge bridge)
{
+ setup(bridge);
qt().withExamples(50)
.forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
.checkAssert((type1, type2, type3) ->
@@ -318,9 +322,11 @@ public class CdcTests extends VersionRunner
);
}
- @Test
- public void testSet()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testSet(CassandraBridge bridge)
{
+ setup(bridge);
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
CdcTester.builder(bridge, DIRECTORY, TestSchema.builder()
@@ -330,9 +336,11 @@ public class CdcTests extends VersionRunner
.run());
}
- @Test
- public void testList()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testList(CassandraBridge bridge)
{
+ setup(bridge);
qt().forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
CdcTester.builder(bridge, DIRECTORY, TestSchema.builder()
@@ -342,9 +350,11 @@ public class CdcTests extends VersionRunner
.run());
}
- @Test
- public void testMap()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testMap(CassandraBridge bridge)
{
+ setup(bridge);
// TODO
qt().withExamples(1)
.forAll(TestUtils.cql3Type(bridge), TestUtils.cql3Type(bridge))
@@ -356,9 +366,11 @@ public class CdcTests extends VersionRunner
.run());
}
- @Test
- public void testUpdateFlag()
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testUpdateFlag(CassandraBridge bridge)
{
+ setup(bridge);
qt().withExamples(10)
.forAll(TestUtils.cql3Type(bridge))
.checkAssert(type ->
@@ -388,7 +400,7 @@ public class CdcTests extends VersionRunner
{
int index = row.getInt(1);
boolean isUpdate = row.getBoolean(4);
- assertEquals(isUpdate, index >= halfway);
+ Assertions.assertEquals(isUpdate, index >= halfway);
}
})
.run());
@@ -396,9 +408,11 @@ public class CdcTests extends VersionRunner
// CommitLog Reader
- @Test
- public void testReaderWatermarking() throws IOException
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void testReaderWatermarking(CassandraBridge bridge) throws IOException
{
+ setup(bridge);
TestSchema schema = TestSchema.builder()
.withPartitionKey("pk", bridge.bigint())
.withColumn("c1", bridge.bigint())
@@ -424,7 +438,7 @@ public class CdcTests extends VersionRunner
AtomicReference<CommitLog.Marker> currentMarker = new AtomicReference<>();
List<CommitLog.Marker> markers = Collections.synchronizedList(new ArrayList<>());
Watermarker watermarker = createWatermarker(currentMarker, markers);
- File logFile = Files.list(DIRECTORY.getRoot().toPath().resolve("cdc"))
+ File logFile = Files.list(DIRECTORY.resolve("cdc"))
.max((first, second) -> {
try
{
@@ -439,8 +453,8 @@ public class CdcTests extends VersionRunner
.toFile();
// Read entire CommitLog and verify correct
- Set<Long> allRows = readLog(cqlTable, logFile, watermarker, keys);
- assertEquals(numRows, allRows.size());
+ Set<Long> allRows = readLog(cqlTable, logFile, watermarker, keys, bridge);
+ Assertions.assertEquals(numRows, (Object) allRows.size());
// Re-read CommitLog from each watermark position and verify subset of partitions are read
int foundRows = allRows.size();
@@ -450,20 +464,21 @@ public class CdcTests extends VersionRunner
for (CommitLog.Marker marker : allMarkers)
{
currentMarker.set(marker);
- Set<Long> result = readLog(cqlTable, logFile, watermarker, keys);
- assertTrue(result.size() < foundRows);
+ Set<Long> result = readLog(cqlTable, logFile, watermarker, keys, bridge);
+ Assertions.assertTrue(result.size() < foundRows);
foundRows = result.size();
if (prevMarker != null)
{
- assertTrue(prevMarker.compareTo(marker) < 0);
- assertTrue(prevMarker.position() < marker.position());
+ Assertions.assertTrue(prevMarker.compareTo(marker) < 0);
+ boolean actual = prevMarker.position() < marker.position();
+ Assertions.assertTrue(actual);
}
prevMarker = marker;
if (marker.equals(allMarkers.get(allMarkers.size() - 1)))
{
// Last marker should return 0 updates and be at the end of the file
- assertTrue(result.isEmpty());
+ Assertions.assertTrue(result.isEmpty());
}
else
{
@@ -531,12 +546,12 @@ public class CdcTests extends VersionRunner
};
}
- private Set<Long> readLog(CqlTable table, File logFile, Watermarker watermarker, Set<Long> keys)
+ private Set<Long> readLog(CqlTable table, File logFile, Watermarker watermarker, Set<Long> keys, CassandraBridge bridge)
{
try (LocalCommitLog log = new LocalCommitLog(logFile))
{
Set<Long> result = bridge.readLog(table, log, watermarker);
- result.forEach(key -> assertTrue("Unexpected keys have been read from the commit log", keys.contains(key)));
+ result.forEach(key -> Assertions.assertTrue(keys.contains(key), "Unexpected keys have been read from the commit log"));
return result;
}
catch (Exception exception)
diff --git a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTombstoneTests.java b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTombstoneTests.java
index 78cc444..f309731 100644
--- a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTombstoneTests.java
+++ b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/cdc/CdcTombstoneTests.java
@@ -20,6 +20,7 @@
package org.apache.cassandra.spark.cdc;
import java.nio.ByteBuffer;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashMap;
@@ -33,15 +34,15 @@ import java.util.function.Function;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
import org.apache.cassandra.bridge.CassandraBridge;
-import org.apache.cassandra.bridge.CassandraVersion;
import org.apache.cassandra.bridge.RangeTombstone;
import org.apache.cassandra.spark.TestUtils;
import org.apache.cassandra.spark.Tester;
@@ -53,40 +54,39 @@ import org.apache.spark.sql.Row;
import scala.collection.mutable.AbstractSeq;
import static org.apache.cassandra.spark.utils.ScalaConversionUtils.mutableSeqAsJavaList;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
-@Ignore
+@Disabled
public class CdcTombstoneTests extends VersionRunner
{
- @ClassRule
- public static TemporaryFolder DIRECTORY = new TemporaryFolder(); // CHECKSTYLE IGNORE: Constant cannot be made final
+ @TempDir
+ public static Path DIRECTORY; // CHECKSTYLE IGNORE: Constant cannot be made final
+ private CassandraBridge bridge;
- @Before
- public void setup()
+ @BeforeEach
+ @ParameterizedTest
+ @MethodSource("org.apache.cassandra.spark.data.VersionRunner#bridges")
+ public void setup(CassandraBridge bridge)
{
+ this.bridge = bridge;
CdcTester.setup(bridge, DIRECTORY);
}
- @After
+ @AfterEach
public void tearDown()
{
CdcTester.tearDown();
}
- public CdcTombstoneTests(CassandraVersion version)
- {
- super(version);
- }
-
private static void assertEqualsWithMessage(Object expected, Object actual)
{
- assertTrue(String.format("Expect %s to equal to %s, but not.", expected, actual),
- ComparisonUtils.equals(expected, actual));
+ boolean actual1 = ComparisonUtils.equals(expected, actual);
+ assertTrue(actual1, String.format("Expect %s to equal to %s, but not.", expected, actual));
}
@Test
@@ -121,10 +121,18 @@ public class CdcTombstoneTests extends VersionRunner
expected.set(2); // ... and c2 to be set
expected.set(3); // ... and c3 to be set
assertEquals(expected, bs);
- assertNotNull("pk should not be null", row.get(0)); // pk should be set
- assertNull("c1 should be null", row.get(1)); // null due to unset
- assertNull("c2 should be null", row.get(2)); // null due to deletion
- assertNull("c3 should be null", row.get(3)); // null due to deletion
+ // pk should be set
+ Object actual = row.get(0);
+ assertNotNull(actual, "pk should not be null");
+ // null due to unset
+ Object actual3 = row.get(1);
+ assertNull(actual3, "c1 should be null");
+ // null due to deletion
+ Object actual2 = row.get(2);
+ assertNull(actual2, "c2 should be null");
+ // null due to deletion
+ Object actual1 = row.get(3);
+ assertNull(actual1, "c3 should be null");
}
})
.run());
@@ -202,13 +210,12 @@ public class CdcTombstoneTests extends VersionRunner
// Disable checker on the test row. The check is done in the row checker below.
.withChecker((testRows, actualRows) -> { })
.withRowChecker(sparkRows -> {
- assertEquals("Unexpected number of rows in output", numRows, sparkRows.size());
+ assertEquals(numRows, (Object) sparkRows.size(), "Unexpected number of rows in output");
for (int index = 0; index < sparkRows.size(); index++)
{
Row row = sparkRows.get(index);
long lmtInMillis = row.getTimestamp(numOfColumns).getTime();
- assertTrue("Last modification time should have a lower bound of " + minTimestamp,
- lmtInMillis >= minTimestamp);
+ assertTrue(lmtInMillis >= minTimestamp, "Last modification time should have a lower bound of " + minTimestamp);
byte[] updatedFieldsIndicator = (byte[]) row.get(numOfColumns + 1); // Indicator column
BitSet bs = BitSet.valueOf(updatedFieldsIndicator);
BitSet expected = new BitSet(numOfColumns);
@@ -219,17 +226,21 @@ public class CdcTombstoneTests extends VersionRunner
{
expected.set(1);
}
- assertEquals("row" + index + " should only have the primary keys to be flagged.",
- expected, bs);
- assertNotNull("pk should not be null", row.get(0)); // pk should be set
+ assertEquals(expected, bs, "row" + index + " should only have the primary keys to be flagged.");
+ // pk should be set
+ Object actual1 = row.get(0);
+ assertNotNull(actual1, "pk should not be null");
if (hasClustering)
{
- assertNotNull("ck should not be null", row.get(1)); // ck should be set
+ // ck should be set
+ Object actual = row.get(1);
+ assertNotNull(actual, "ck should not be null");
}
for (int colIndex = hasClustering ? 2 : 1; colIndex < numOfColumns; colIndex++)
{
// null due to row deletion
- assertNull("None primary key columns should be null", row.get(colIndex));
+ Object actual = row.get(colIndex);
+ assertNull(actual, "None primary key columns should be null");
}
}
else
@@ -238,10 +249,10 @@ public class CdcTombstoneTests extends VersionRunner
for (int colIndex = 0; colIndex < numOfColumns; colIndex++)
{
expected.set(colIndex);
- assertNotNull("All column values should exist for full row update",
- row.get(colIndex));
+ Object actual = row.get(colIndex);
+ assertNotNull(actual, "All column values should exist for full row update");
}
- assertEquals("row" + index + " should have all columns set", expected, bs);
+ assertEquals(expected, bs, "row" + index + " should have all columns set");
}
}
})
@@ -341,13 +352,12 @@ public class CdcTombstoneTests extends VersionRunner
// Disable checker on the test row. The check is done in the row checker below.
.withChecker((testRows, actualRows) -> { })
.withRowChecker(sparkRows -> {
- assertEquals("Unexpected number of rows in output", numRows, sparkRows.size());
+ assertEquals(numRows, (Object) sparkRows.size(), "Unexpected number of rows in output");
for (int index = 0, pkValidationIdx = 0; index < sparkRows.size(); index++)
{
Row row = sparkRows.get(index);
long lmtInMillis = row.getTimestamp(numOfColumns).getTime();
- assertTrue("Last modification time should have a lower bound of " + minTimestamp,
- lmtInMillis >= minTimestamp);
+ assertTrue(lmtInMillis >= minTimestamp, "Last modification time should have a lower bound of " + minTimestamp);
byte[] updatedFieldsIndicator = (byte[]) row.get(numOfColumns + 1); // Indicator column
BitSet bs = BitSet.valueOf(updatedFieldsIndicator);
BitSet expected = new BitSet(numOfColumns);
@@ -359,23 +369,26 @@ public class CdcTombstoneTests extends VersionRunner
for (int key = 0; key < partitionKeys; key++)
{
expected.set(key);
- assertNotNull("partition key should not be null", row.get(key));
+ Object actual = row.get(key);
+ assertNotNull(actual, "partition key should not be null");
pk.add(row.get(key));
}
- assertEquals("row" + index + " should only have only the partition keys to be flagged.",
- expected, bs);
+ assertEquals(expected, bs, "row" + index + " should only have only the partition keys to be flagged.");
List<Object> expectedPK = validationPk.get(pkValidationIdx++);
- assertTrue("Partition deletion should indicate the correct partition at row" + index + ". "
- + "Expected: " + expectedPK + ", actual: " + pk,
- ComparisonUtils.equals(expectedPK.toArray(), pk.toArray()));
+ boolean actual1 = ComparisonUtils.equals(expectedPK.toArray(), pk.toArray());
+ assertTrue(actual1, "Partition deletion should indicate the correct partition at row" + index + ". "
+ + "Expected: " + expectedPK + ", actual: " + pk);
if (hasClustering)
{
- assertNull("ck should be null at row" + index, row.get(partitionKeys)); // ck should be set
+ // ck should be set
+ Object actual = row.get(partitionKeys);
+ assertNull(actual, "ck should be null at row" + index);
}
for (int colIndex = partitionKeys; colIndex < numOfColumns; colIndex++)
{
// null due to partition deletion
- assertNull("None partition key columns should be null at row" + 1, row.get(colIndex));
+ Object actual = row.get(colIndex);
+ assertNull(actual, "None partition key columns should be null at row" + 1);
}
}
else
@@ -384,10 +397,10 @@ public class CdcTombstoneTests extends VersionRunner
for (int colIndex = 0; colIndex < numOfColumns; colIndex++)
{
expected.set(colIndex);
- assertNotNull("All column values should exist for full row update",
- row.get(colIndex));
+ Object actual = row.get(colIndex);
+ assertNotNull(actual, "All column values should exist for full row update");
}
- assertEquals("row" + index + " should have all columns set", expected, bs);
+ assertEquals(expected, bs, "row" + index + " should have all columns set");
}
}
})
@@ -474,13 +487,12 @@ public class CdcTombstoneTests extends VersionRunner
// Disable checker on the test row. The check is done in the sparkrow checker below.
.withChecker((testRows, actualRows) -> { })
.withRowChecker(sparkRows -> {
- assertEquals("Unexpected number of rows in output", numRows, sparkRows.size());
+ assertEquals(numRows, (Object) sparkRows.size(), "Unexpected number of rows in output");
for (int rowIndex = 0; rowIndex < sparkRows.size(); rowIndex++)
{
Row row = sparkRows.get(rowIndex);
long lmtInMillis = row.getTimestamp(numOfColumns).getTime();
- assertTrue("Last modification time should have a lower bound of " + minTimestamp,
- lmtInMillis >= minTimestamp);
+ assertTrue(lmtInMillis >= minTimestamp, "Last modification time should have a lower bound of " + minTimestamp);
byte[] updatedFieldsIndicator = (byte[]) row.get(numOfColumns + 1); // Indicator column
BitSet bs = BitSet.valueOf(updatedFieldsIndicator);
BitSet expected = new BitSet(numOfColumns);
@@ -495,16 +507,17 @@ public class CdcTombstoneTests extends VersionRunner
assertNotNull(cellTombstonesPerColumn);
for (String name : collectionColumnNames)
{
- assertNull("Collection column should be null after deletion",
- row.get(row.fieldIndex(name)));
+ Object actual1 = row.get(row.fieldIndex(name));
+ assertNull(actual1, "Collection column should be null after deletion");
- assertNotNull(cellTombstonesPerColumn.get(name));
+ Object actual = cellTombstonesPerColumn.get(name);
+ assertNotNull(actual);
List<?> deletedCellKeys =
mutableSeqAsJavaList((AbstractSeq<?>) cellTombstonesPerColumn.get(name));
- assertEquals(1, deletedCellKeys.size());
+ assertEquals(1, (Object) deletedCellKeys.size());
byte[] keyBytesRead = (byte[]) deletedCellKeys.get(0);
- assertArrayEquals("The key encoded should be the same",
- elementDeletionIndices.get(rowIndex), keyBytesRead);
+ assertArrayEquals(elementDeletionIndices.get(rowIndex), keyBytesRead,
+ "The key encoded should be the same");
}
}
else
@@ -512,13 +525,13 @@ public class CdcTombstoneTests extends VersionRunner
// Verify update
for (int colIndex = 0; colIndex < numOfColumns; colIndex++)
{
- assertNotNull("All column values should exist for full row update",
- row.get(colIndex));
+ Object actual = row.get(colIndex);
+ assertNotNull(actual, "All column values should exist for full row update");
}
- assertNull("the cell deletion map should be absent",
- row.get(numOfColumns + 3));
+ Object actual = row.get(numOfColumns + 3);
+ assertNull(actual, "the cell deletion map should be absent");
}
- assertEquals("row" + rowIndex + " should have all columns set", expected, bs);
+ assertEquals(expected, bs, "row" + rowIndex + " should have all columns set");
}
})
.run());
@@ -643,13 +656,12 @@ public class CdcTombstoneTests extends VersionRunner
// Disable checker on the test row. The check is done in the sparkrow checker below.
.withChecker((testRows, actualRows) -> { })
.withSparkRowTestRowsChecker((testRows, sparkRows) -> {
- assertEquals("Unexpected number of rows in output", numRows, sparkRows.size());
+ assertEquals(numRows, (Object) sparkRows.size(), "Unexpected number of rows in output");
for (int rowIndex = 0; rowIndex < sparkRows.size(); rowIndex++)
{
Row row = sparkRows.get(rowIndex);
long lmtInMillis = row.getTimestamp(numOfColumns).getTime();
- assertTrue("Last modification time should have a lower bound of " + minTimestamp,
- minTimestamp <= lmtInMillis);
+ assertTrue(minTimestamp <= lmtInMillis, "Last modification time should have a lower bound of " + minTimestamp);
byte[] updatedFieldsIndicator = (byte[]) row.get(numOfColumns + 1); // Indicator column
BitSet bs = BitSet.valueOf(updatedFieldsIndicator);
BitSet expected = new BitSet(numOfColumns);
@@ -659,29 +671,34 @@ public class CdcTombstoneTests extends VersionRunner
{
if (column < numOfPartitionKeys)
{
- assertNotNull("All partition keys should exist for range tombstone",
- row.get(column));
+ Object actual = row.get(column);
+ assertNotNull(actual, "All partition keys should exist for range tombstone");
expected.set(column);
}
else
{
- assertNull("Non-partition key columns should be null",
- row.get(column));
+ Object actual = row.get(column);
+ assertNull(actual, "Non-partition key columns should be null");
}
Object deletionColumn = row.get(numOfColumns + 4); // Range deletion column
- assertNotNull(deletionColumn);
+ assertNotNull(null, (String) deletionColumn);
List<?> tombstones = mutableSeqAsJavaList((AbstractSeq<?>) deletionColumn);
- assertEquals("There should be 1 range tombstone", 1, tombstones.size());
+ assertEquals(1, (Object) tombstones.size(), "There should be 1 range tombstone");
TestSchema.TestRow sourceRow = rangeTombestones.get(rowIndex);
RangeTombstone expectedTombstone = sourceRow.rangeTombstones().get(0);
Row rangeTombstone = (Row) tombstones.get(0);
- assertEquals("Range tombstone should have 4 fields", 4, rangeTombstone.length());
- assertEquals(expectedTombstone.open.inclusive, rangeTombstone.getAs("StartInclusive"));
- assertEquals(expectedTombstone.close.inclusive, rangeTombstone.getAs("EndInclusive"));
+ Object actual = rangeTombstone.length();
+ assertEquals(4, actual, "Range tombstone should have 4 fields");
+ Object actual4 = rangeTombstone.getAs("StartInclusive");
+ assertEquals(expectedTombstone.open.inclusive, actual4);
+ Object actual3 = rangeTombstone.getAs("EndInclusive");
+ assertEquals(expectedTombstone.close.inclusive, actual3);
Row open = rangeTombstone.getAs("Start");
- assertEquals(numOfClusteringKeys, open.length());
+ Object actual2 = open.length();
+ assertEquals(numOfClusteringKeys, actual2);
Row close = rangeTombstone.getAs("End");
- assertEquals(numOfClusteringKeys, close.length());
+ Object actual1 = close.length();
+ assertEquals(numOfClusteringKeys, actual1);
for (int keyIndex = 0; keyIndex < numOfClusteringKeys; keyIndex++)
{
assertEqualsWithMessage(expectedTombstone.open.values[keyIndex],
@@ -695,14 +712,14 @@ public class CdcTombstoneTests extends VersionRunner
{
for (int columnIndex = 0; columnIndex < numOfColumns; columnIndex++)
{
- assertNotNull("All column values should exist for full row update",
- row.get(columnIndex));
+ Object actual = row.get(columnIndex);
+ assertNotNull(actual, "All column values should exist for full row update");
expected.set(columnIndex);
}
- assertNull("the cell deletion map should be absent",
- row.get(numOfColumns + 3));
+ Object actual = row.get(numOfColumns + 3);
+ assertNull(actual, "the cell deletion map should be absent");
}
- assertEquals("row" + rowIndex + " should have the expected columns set", expected, bs);
+ assertEquals(expected, bs, "row" + rowIndex + " should have the expected columns set");
}
})
.run());
diff --git a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/sparksql/CdcOffsetTests.java b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/sparksql/CdcOffsetTests.java
index 0cea310..366503a 100644
--- a/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/sparksql/CdcOffsetTests.java
+++ b/cassandra-analytics-core/src/test/spark3/org/apache/cassandra/spark/sparksql/CdcOffsetTests.java
@@ -21,12 +21,12 @@ package org.apache.cassandra.spark.sparksql;
import java.io.IOException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.sparksql.filters.CdcOffset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class CdcOffsetTests
{
diff --git a/cassandra-bridge/build.gradle b/cassandra-bridge/build.gradle
index 838944b..0cbf3d1 100644
--- a/cassandra-bridge/build.gradle
+++ b/cassandra-bridge/build.gradle
@@ -27,6 +27,7 @@ project(':cassandra-bridge') {
testImplementation(group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jacksonVersion}")
testImplementation(group: 'com.google.guava', name: 'guava', version: '31.1-jre')
testImplementation(group: 'org.slf4j', name: 'slf4j-simple', version: '1.7.26')
- testImplementation(group: 'junit', name: 'junit', version: "${project.rootProject.junitVersion}")
- }
+ testImplementation("org.junit.jupiter:junit-jupiter-api:${project.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-params:${project.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}") }
}
diff --git a/cassandra-bridge/src/test/java/org/apache/cassandra/bridge/BigNumberConfigImplTest.java b/cassandra-bridge/src/test/java/org/apache/cassandra/bridge/BigNumberConfigImplTest.java
index c1187b8..a300517 100644
--- a/cassandra-bridge/src/test/java/org/apache/cassandra/bridge/BigNumberConfigImplTest.java
+++ b/cassandra-bridge/src/test/java/org/apache/cassandra/bridge/BigNumberConfigImplTest.java
@@ -23,11 +23,11 @@ import java.io.IOException;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Unit tests for {@link BigNumberConfigImpl}
diff --git a/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ArrayUtilsTest.java b/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ArrayUtilsTest.java
index 3685961..186da9d 100644
--- a/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ArrayUtilsTest.java
+++ b/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ArrayUtilsTest.java
@@ -21,8 +21,8 @@ package org.apache.cassandra.spark.utils;
import java.util.function.Consumer;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import static org.apache.cassandra.spark.utils.ArrayUtils.retain;
@@ -32,7 +32,7 @@ public class ArrayUtilsTest
public void testRetain()
{
Object[] source = new Object[]{1, 2, 3, 4, 5};
- Assert.assertArrayEquals(new Object[]{1, 2, 3}, retain(source, 0, 3));
+ Assertions.assertArrayEquals(new Object[]{1, 2, 3}, retain(source, 0, 3));
}
@Test
@@ -40,16 +40,16 @@ public class ArrayUtilsTest
{
// Not using JUnit rule ExpectedException in order to assert multiple throwables
expectedThrows(() -> retain(null, 0, 1),
- throwable -> Assert.assertSame(IllegalArgumentException.class, throwable.getClass()));
+ throwable -> Assertions.assertSame(IllegalArgumentException.class, throwable.getClass()));
expectedThrows(() -> retain(new Object[]{1, 2, 3}, -1, 1),
- throwable -> Assert.assertSame(IllegalArgumentException.class, throwable.getClass()));
+ throwable -> Assertions.assertSame(IllegalArgumentException.class, throwable.getClass()));
expectedThrows(() -> retain(new Object[]{1, 2, 3}, 0, -1),
- throwable -> Assert.assertSame(IllegalArgumentException.class, throwable.getClass()));
+ throwable -> Assertions.assertSame(IllegalArgumentException.class, throwable.getClass()));
expectedThrows(() -> retain(new Object[]{1, 2, 3}, 0, 5),
- throwable -> Assert.assertSame(IllegalArgumentException.class, throwable.getClass()));
+ throwable -> Assertions.assertSame(IllegalArgumentException.class, throwable.getClass()));
}
private void expectedThrows(Runnable test, Consumer<Throwable> throwableVerifier)
diff --git a/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/LoggerHelperTests.java b/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/LoggerHelperTests.java
index c95900e..8c6f9dc 100644
--- a/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/LoggerHelperTests.java
+++ b/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/LoggerHelperTests.java
@@ -19,12 +19,12 @@
package org.apache.cassandra.spark.utils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class LoggerHelperTests
{
diff --git a/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ThrowableUtilTests.java b/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ThrowableUtilTests.java
index 9cd46c7..f48fd41 100644
--- a/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ThrowableUtilTests.java
+++ b/cassandra-bridge/src/test/java/org/apache/cassandra/spark/utils/ThrowableUtilTests.java
@@ -22,13 +22,13 @@ package org.apache.cassandra.spark.utils;
import java.io.IOException;
import java.util.Objects;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.spark.exceptions.TransportFailureException;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class ThrowableUtilTests
{
diff --git a/cassandra-four-zero/build.gradle b/cassandra-four-zero/build.gradle
index 7f6c4e5..0e85e06 100644
--- a/cassandra-four-zero/build.gradle
+++ b/cassandra-four-zero/build.gradle
@@ -40,7 +40,9 @@ project(':cassandra-four-zero') {
testImplementation(project(':cassandra-bridge'))
- testImplementation(group: 'junit', name: 'junit', version: "${project.rootProject.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-api:${project.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-params:${project.junitVersion}")
+ testImplementation("org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}")
testImplementation(group: 'org.quicktheories', name: 'quicktheories', version: "${project.rootProject.quickTheoriesVersion}")
testImplementation("org.mockito:mockito-core:${project.rootProject.mockitoVersion}")
testImplementation(group: "${sparkGroupId}", name: "spark-core_${scalaMajorVersion}", version: "${project.rootProject.sparkVersion}")
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/data/types/DateTypeTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/data/types/DateTypeTests.java
index 0acbf2a..5a6a8b7 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/data/types/DateTypeTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/data/types/DateTypeTests.java
@@ -21,13 +21,13 @@ package org.apache.cassandra.spark.data.types;
import java.time.LocalDate;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridgeImplementation;
import org.apache.cassandra.serializers.SimpleDateSerializer;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class DateTypeTests
{
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/CdcScannerTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/CdcScannerTests.java
index 32fbf17..a7da6f3 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/CdcScannerTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/CdcScannerTests.java
@@ -25,14 +25,14 @@ import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.db.commitlog.PartitionUpdateWrapper;
import org.apache.cassandra.spark.cdc.watermarker.Watermarker;
import org.apache.cassandra.spark.stats.Stats;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexDbTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexDbTests.java
index bc75155..efeee8d 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexDbTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexDbTests.java
@@ -35,7 +35,7 @@ import java.util.stream.Collectors;
import java.util.stream.IntStream;
import com.google.common.base.Preconditions;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridgeImplementation;
import org.apache.cassandra.bridge.TokenRange;
@@ -51,10 +51,10 @@ import org.apache.cassandra.spark.utils.test.TestSSTable;
import org.apache.cassandra.spark.utils.test.TestSchema;
import org.jetbrains.annotations.NotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.Generate.constant;
import static org.quicktheories.generators.SourceDSL.arbitrary;
@@ -110,13 +110,13 @@ public class IndexDbTests
Collections.sort(tokens);
TableMetadata metadata = Schema.instance.getTableMetadata(schema.keyspace, schema.table);
- assertNotNull("Could not find table metadata", metadata);
+ assertNotNull(metadata, "Could not find table metadata");
Path summaryDb = TestSSTable.firstIn(directory.path(), FileType.SUMMARY);
- assertNotNull("Could not find summary", summaryDb);
+ assertNotNull(summaryDb, "Could not find summary");
SSTable ssTable = TestSSTable.firstIn(directory.path());
- assertNotNull("Could not find SSTable", ssTable);
+ assertNotNull(ssTable, "Could not find SSTable");
int rowSize = 39;
int sample = 4;
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexOffsetTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexOffsetTests.java
index f56164b..039f3f5 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexOffsetTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/IndexOffsetTests.java
@@ -27,7 +27,7 @@ import java.util.Collection;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import org.apache.commons.lang.mutable.MutableInt;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,8 +45,8 @@ import org.apache.cassandra.spark.utils.TemporaryDirectory;
import org.apache.cassandra.spark.utils.test.TestSSTable;
import org.apache.cassandra.spark.utils.test.TestSchema;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
import static org.quicktheories.generators.SourceDSL.booleans;
@@ -97,13 +97,13 @@ public class IndexOffsetTests
assertEquals(1, TestSSTable.countIn(directory.path()));
TableMetadata metadata = Schema.instance.getTableMetadata(schema.keyspace, schema.table);
- assertNotNull("Could not find table metadata", metadata);
+ assertNotNull(metadata, "Could not find table metadata");
SSTable ssTable = TestSSTable.firstIn(directory.path());
- assertNotNull("Could not find SSTable", ssTable);
+ assertNotNull(ssTable, "Could not find SSTable");
Collection<TokenRange> ranges = RANGES.get(partitioner);
- assertNotNull("Unknown paritioner", ranges);
+ assertNotNull(ranges, "Unknown paritioner");
LOGGER.info("Testing index offsets numKeys={} sparkPartitions={} partitioner={} enableCompression={}",
numKeys, ranges.size(), partitioner.name(), enableCompression);
@@ -173,8 +173,8 @@ public class IndexOffsetTests
.getToken()),
partitioner.name());
}
- assertEquals(count > 0 ? "Key " + index + " read " + count + " times"
- : "Key not found: " + index, 1, count);
+ assertEquals(1, count, count > 0 ? "Key " + index + " read " + count + " times"
+ : "Key not found: " + index);
index++;
}
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/KryoSerializationTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/KryoSerializationTests.java
index cb22c9f..30abfb9 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/KryoSerializationTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/KryoSerializationTests.java
@@ -25,7 +25,7 @@ import java.util.UUID;
import java.util.concurrent.TimeUnit;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
@@ -44,8 +44,8 @@ import org.apache.cassandra.serializers.UTF8Serializer;
import org.apache.cassandra.serializers.UUIDSerializer;
import org.apache.cassandra.spark.data.ReplicationFactor;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class KryoSerializationTests
{
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java
index f31cedd..bf1a252 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/PartitionKeyTests.java
@@ -24,7 +24,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridgeImplementation;
import org.apache.cassandra.db.marshal.AbstractType;
@@ -34,8 +34,8 @@ import org.apache.cassandra.spark.data.CqlType;
import org.apache.cassandra.spark.utils.ComparisonUtils;
import org.apache.cassandra.spark.utils.test.TestSchema;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/ReaderUtilsTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/ReaderUtilsTests.java
index c81e408..c3f4fa0 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/ReaderUtilsTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/ReaderUtilsTests.java
@@ -35,7 +35,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridgeImplementation;
import org.apache.cassandra.db.DecoratedKey;
@@ -60,10 +60,10 @@ import org.apache.cassandra.spark.utils.test.TestSSTable;
import org.apache.cassandra.spark.utils.test.TestSchema;
import org.apache.cassandra.utils.Pair;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.quicktheories.QuickTheory.qt;
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableCacheTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableCacheTests.java
index cb4d724..fc9db86 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableCacheTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableCacheTests.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.stream.IntStream;
import com.google.common.collect.ImmutableMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridgeImplementation;
import org.apache.cassandra.db.DecoratedKey;
@@ -43,11 +43,11 @@ import org.apache.cassandra.spark.utils.test.TestSchema;
import org.apache.cassandra.utils.BloomFilter;
import org.apache.cassandra.utils.Pair;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableReaderTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableReaderTests.java
index 95e9193..4bad54a 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableReaderTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SSTableReaderTests.java
@@ -47,7 +47,7 @@ import java.util.stream.Stream;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang.StringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -84,11 +84,11 @@ import org.apache.cassandra.utils.Pair;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SchemaBuilderTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SchemaBuilderTests.java
index 275040e..70ad3f8 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SchemaBuilderTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SchemaBuilderTests.java
@@ -21,7 +21,7 @@ package org.apache.cassandra.spark.reader;
import java.util.HashMap;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridgeImplementation;
import org.apache.cassandra.cql3.CQLFragmentParser;
@@ -36,7 +36,7 @@ import org.apache.cassandra.spark.data.ReplicationFactor;
import org.apache.cassandra.utils.FBUtilities;
import static org.apache.cassandra.spark.reader.SchemaBuilder.rfToMap;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class SchemaBuilderTests
{
diff --git a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SummaryDbTests.java b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SummaryDbTests.java
index f61132c..508395c 100644
--- a/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SummaryDbTests.java
+++ b/cassandra-four-zero/src/test/java/org/apache/cassandra/spark/reader/SummaryDbTests.java
@@ -29,7 +29,7 @@ import java.util.Collections;
import java.util.List;
import java.util.stream.LongStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.apache.cassandra.bridge.CassandraBridgeImplementation;
import org.apache.cassandra.dht.IPartitioner;
@@ -42,9 +42,9 @@ import org.apache.cassandra.spark.utils.TemporaryDirectory;
import org.apache.cassandra.spark.utils.test.TestSSTable;
import org.apache.cassandra.spark.utils.test.TestSchema;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.quicktheories.QuickTheory.qt;
import static org.quicktheories.generators.SourceDSL.arbitrary;
@@ -107,13 +107,13 @@ public class SummaryDbTests
Collections.sort(tokens);
TableMetadata metadata = Schema.instance.getTableMetadata(schema.keyspace, schema.table);
- assertNotNull("Could not find table metadata", metadata);
+ assertNotNull(metadata, "Could not find table metadata");
Path summaryDb = TestSSTable.firstIn(directory.path(), FileType.SUMMARY);
- assertNotNull("Could not find summary", summaryDb);
+ assertNotNull(summaryDb, "Could not find summary");
SSTable ssTable = TestSSTable.firstIn(directory.path());
- assertNotNull("Could not find SSTable", ssTable);
+ assertNotNull(ssTable, "Could not find SSTable");
// Binary search Summary.db file in token order and verify offsets are ordered
SummaryDbUtils.Summary summary = SummaryDbUtils.readSummary(metadata, ssTable);
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
index 8a3dbdb..39a53e9 100644
--- a/config/checkstyle/checkstyle.xml
+++ b/config/checkstyle/checkstyle.xml
@@ -63,7 +63,7 @@
<!-- See https://checkstyle.org/config_sizes.html -->
<module name="FileLength">
<property name="fileExtensions" value="java, xml, properties, gradle, sh" />
- <property name="max" value="2400" />
+ <property name="max" value="2500" />
</module>
<module name="LineLength">
<property name="fileExtensions" value="java, xml, properties, gradle, sh" />
diff --git a/gradle.properties b/gradle.properties
index 6fb6ad4..bcdcb1e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -22,11 +22,12 @@ description=Apache Cassandra Spark Analytics
analyticsJDKLevel=11
intellijVersion=9.0.4
-junitVersion=4.13
+junitVersion=5.9.2
quickTheoriesVersion=0.26
mockitoVersion=3.12.4
jnaVersion=5.9.0
scala=2.12
spark=3
+vertxVersion=4.2.1
org.gradle.jvmargs=-Xmx4096m
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org