customFieldMeta = new HashMap<>();
@@ -103,8 +98,9 @@ public void testNoOfflineData() throws Throwable {
int dataSize = (int) file.length();
byte[] dataBytes = new byte[dataSize];
- InputStream is = new FileInputStream(file);
- is.read(dataBytes, 0, dataSize);
+ try (InputStream is = new FileInputStream(file)) {
+ is.read(dataBytes, 0, dataSize);
+ }
SnowflakeResultSetSerializableV1 resultSetSerializable = new SnowflakeResultSetSerializableV1();
resultSetSerializable.setRootAllocator(new RootAllocator(Long.MAX_VALUE));
@@ -149,7 +145,7 @@ public void testEmptyResultSet() throws Throwable {
/** Testing the case that all data comes from chunk downloader */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = SkipOnThinJar.class)
+ @DontRunOnThinJar
public void testOnlyOfflineData() throws Throwable {
final int colCount = 2;
final int chunkCount = 10;
@@ -199,7 +195,7 @@ public void testOnlyOfflineData() throws Throwable {
/** Testing the case that all data comes from chunk downloader */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = SkipOnThinJar.class)
+ @DontRunOnThinJar
public void testFirstResponseAndOfflineData() throws Throwable {
final int colCount = 2;
final int chunkCount = 10;
@@ -229,8 +225,9 @@ public void testFirstResponseAndOfflineData() throws Throwable {
int dataSize = (int) arrowFile.length();
byte[] dataBytes = new byte[dataSize];
- InputStream is = new FileInputStream(arrowFile);
- is.read(dataBytes, 0, dataSize);
+ try (InputStream is = new FileInputStream(arrowFile)) {
+ is.read(dataBytes, 0, dataSize);
+ }
SnowflakeResultSetSerializableV1 resultSetSerializable = new SnowflakeResultSetSerializableV1();
resultSetSerializable.setFirstChunkStringData(Base64.getEncoder().encodeToString(dataBytes));
@@ -280,8 +277,7 @@ private class MockChunkDownloader implements ChunkDownloader {
public SnowflakeResultChunk getNextChunkToConsume() throws SnowflakeSQLException {
if (currentFileIndex < resultFileNames.size()) {
ArrowResultChunk resultChunk = new ArrowResultChunk("", 0, 0, 0, rootAllocator, null);
- try {
- InputStream is = new FileInputStream(resultFileNames.get(currentFileIndex));
+ try (InputStream is = new FileInputStream(resultFileNames.get(currentFileIndex))) {
resultChunk.readArrowStream(is);
currentFileIndex++;
@@ -380,12 +376,13 @@ Object[][] generateData(Schema schema, int rowCount) {
File createArrowFile(String fileName, Schema schema, Object[][] data, int rowsPerRecordBatch)
throws IOException {
- File file = resultFolder.newFile(fileName);
+ File file = new File(tempDir, fileName);
+ file.createNewFile();
VectorSchemaRoot root = VectorSchemaRoot.create(schema, allocator);
- try (ArrowWriter writer =
- new ArrowStreamWriter(
- root, new DictionaryProvider.MapDictionaryProvider(), new FileOutputStream(file))) {
+ try (FileOutputStream fos = new FileOutputStream(file);
+ ArrowWriter writer =
+ new ArrowStreamWriter(root, new DictionaryProvider.MapDictionaryProvider(), fos)) {
writer.start();
for (int i = 0; i < data[0].length; ) {
@@ -592,7 +589,7 @@ private void writeTimestampStructToField(
/** Test that first chunk containing struct vectors (used for timestamps) can be sorted */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = SkipOnThinJar.class)
+ @DontRunOnThinJar
public void testSortedResultChunkWithStructVectors() throws Throwable {
try (Statement statement = connection.createStatement()) {
statement.execute("create or replace table teststructtimestamp (t1 timestamp_ltz)");
@@ -638,8 +635,9 @@ public void testSortedResultChunkWithStructVectors() throws Throwable {
int dataSize = (int) file.length();
byte[] dataBytes = new byte[dataSize];
- InputStream is = new FileInputStream(file);
- is.read(dataBytes, 0, dataSize);
+ try (InputStream is = new FileInputStream(file)) {
+ is.read(dataBytes, 0, dataSize);
+ }
resultSetSerializable.setRootAllocator(new RootAllocator(Long.MAX_VALUE));
resultSetSerializable.setFirstChunkStringData(
@@ -663,7 +661,7 @@ public void testSortedResultChunkWithStructVectors() throws Throwable {
/** Test that the first chunk can be sorted */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = SkipOnThinJar.class)
+ @DontRunOnThinJar
public void testSortedResultChunk() throws Throwable {
try (Statement statement = connection.createStatement()) {
statement.execute(
@@ -725,8 +723,9 @@ public void testSortedResultChunk() throws Throwable {
int dataSize = (int) file.length();
byte[] dataBytes = new byte[dataSize];
- InputStream is = new FileInputStream(file);
- is.read(dataBytes, 0, dataSize);
+ try (InputStream is = new FileInputStream(file)) {
+ is.read(dataBytes, 0, dataSize);
+ }
resultSetSerializable.setRootAllocator(new RootAllocator(Long.MAX_VALUE));
resultSetSerializable.setFirstChunkStringData(
diff --git a/src/test/java/net/snowflake/client/core/SFLoginInputTest.java b/src/test/java/net/snowflake/client/core/SFLoginInputTest.java
index 7d8a5b67b..b34eebc02 100644
--- a/src/test/java/net/snowflake/client/core/SFLoginInputTest.java
+++ b/src/test/java/net/snowflake/client/core/SFLoginInputTest.java
@@ -1,8 +1,8 @@
package net.snowflake.client.core;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SFLoginInputTest {
diff --git a/src/test/java/net/snowflake/client/core/SFSessionPropertyTest.java b/src/test/java/net/snowflake/client/core/SFSessionPropertyTest.java
index 8c7a6fb1f..142f92217 100644
--- a/src/test/java/net/snowflake/client/core/SFSessionPropertyTest.java
+++ b/src/test/java/net/snowflake/client/core/SFSessionPropertyTest.java
@@ -7,10 +7,10 @@
import static org.hamcrest.CoreMatchers.endsWith;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.fail;
import net.snowflake.client.jdbc.ErrorCode;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SFSessionPropertyTest {
@Test
@@ -28,7 +28,7 @@ public void testCheckApplicationName() throws SFException {
for (String invalid : invalidApplicationName) {
try {
SFSessionProperty.checkPropertyValue(SFSessionProperty.APPLICATION, invalid);
- Assert.fail();
+ fail();
} catch (SFException e) {
assertThat(e.getVendorCode(), is(ErrorCode.INVALID_PARAMETER_VALUE.getMessageCode()));
}
@@ -48,7 +48,7 @@ public void testCustomSuffixForUserAgentHeaders() {
public void testInvalidMaxRetries() {
try {
SFSessionProperty.checkPropertyValue(SFSessionProperty.MAX_HTTP_RETRIES, "invalidValue");
- Assert.fail("testInvalidMaxRetries");
+ fail("testInvalidMaxRetries");
} catch (SFException e) {
assertThat(e.getVendorCode(), is(ErrorCode.INVALID_PARAMETER_VALUE.getMessageCode()));
}
@@ -67,7 +67,7 @@ public void testvalidMaxRetries() throws SFException {
public void testInvalidPutGetMaxRetries() {
try {
SFSessionProperty.checkPropertyValue(SFSessionProperty.PUT_GET_MAX_RETRIES, "invalidValue");
- Assert.fail("testInvalidMaxRetries");
+ fail("testInvalidMaxRetries");
} catch (SFException e) {
assertThat(e.getVendorCode(), is(ErrorCode.INVALID_PARAMETER_VALUE.getMessageCode()));
}
diff --git a/src/test/java/net/snowflake/client/core/SFTrustManagerIT.java b/src/test/java/net/snowflake/client/core/SFTrustManagerIT.java
index f30cd88e1..51f5c6690 100644
--- a/src/test/java/net/snowflake/client/core/SFTrustManagerIT.java
+++ b/src/test/java/net/snowflake/client/core/SFTrustManagerIT.java
@@ -20,8 +20,9 @@
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Stream;
import javax.net.ssl.SSLHandshakeException;
-import net.snowflake.client.category.TestCategoryCore;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.jdbc.BaseJDBCTest;
import net.snowflake.client.jdbc.telemetryOOB.TelemetryService;
import net.snowflake.client.log.SFLogger;
@@ -29,45 +30,42 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.io.TempDir;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
-@Category(TestCategoryCore.class)
+// @Category(TestCategoryCore.class)
+@Tag(TestTags.CORE)
public class SFTrustManagerIT extends BaseJDBCTest {
private static final SFLogger logger = SFLoggerFactory.getLogger(SFTrustManagerIT.class);
- public SFTrustManagerIT(String host) {
- this.host = host;
- }
-
- @Parameterized.Parameters(name = "host={0}")
- public static Object[][] data() {
- return new Object[][] {
- // this host generates many "SSLHandshake Certificate Revocation
- // check failed. Could not retrieve OCSP Response." when running in parallel CI builds
- // {"storage.googleapis.com"},
- {"ocspssd.us-east-1.snowflakecomputing.com/ocsp/fetch"},
- {"sfcsupport.snowflakecomputing.com"},
- {"sfcsupport.us-east-1.snowflakecomputing.com"},
- {"sfcsupport.eu-central-1.snowflakecomputing.com"},
- {"sfc-dev1-regression.s3.amazonaws.com"},
- {"sfc-ds2-customer-stage.s3.amazonaws.com"},
- {"snowflake.okta.com"},
- {"sfcdev2.blob.core.windows.net"}
- };
+ private static class HostProvider implements ArgumentsProvider {
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ return Stream.of(
+ // this host generates many "SSLHandshake Certificate Revocation
+ // check failed. Could not retrieve OCSP Response." when running in parallel CI builds
+ // Arguments.of("storage.googleapis.com"),
+ Arguments.of("ocspssd.us-east-1.snowflakecomputing.com/ocsp/fetch"),
+ Arguments.of("sfcsupport.snowflakecomputing.com"),
+ Arguments.of("sfcsupport.us-east-1.snowflakecomputing.com"),
+ Arguments.of("sfcsupport.eu-central-1.snowflakecomputing.com"),
+ Arguments.of("sfc-dev1-regression.s3.amazonaws.com"),
+ Arguments.of("sfc-ds2-customer-stage.s3.amazonaws.com"),
+ Arguments.of("snowflake.okta.com"),
+ Arguments.of("sfcdev2.blob.core.windows.net"));
+ }
}
private boolean defaultState;
- private final String host;
- @Before
+ @BeforeEach
public void setUp() {
TelemetryService service = TelemetryService.getInstance();
service.updateContextForIT(getConnectionParameters());
@@ -76,7 +74,7 @@ public void setUp() {
service.enable();
}
- @After
+ @AfterEach
public void tearDown() throws InterruptedException {
TelemetryService service = TelemetryService.getInstance();
// wait 5 seconds while the service is flushing
@@ -90,15 +88,16 @@ public void tearDown() throws InterruptedException {
System.clearProperty(SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_URL);
}
- @Rule public TemporaryFolder tmpFolder = new TemporaryFolder();
+ @TempDir File tmpFolder;
/**
* OCSP tests for the Snowflake and AWS S3 HTTPS connections.
*
* Whatever the default method is used.
*/
- @Test
- public void testOcsp() throws Throwable {
+ @ParameterizedTest
+ @ArgumentsSource(HostProvider.class)
+ public void testOcsp(String host) throws Throwable {
System.setProperty(
SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED, Boolean.TRUE.toString());
HttpClient client =
@@ -115,11 +114,13 @@ public void testOcsp() throws Throwable {
*
*
Specifying an non-existing file will force to fetch OCSP response.
*/
- @Test
- public void testOcspWithFileCache() throws Throwable {
+ @ParameterizedTest
+ @ArgumentsSource(HostProvider.class)
+ public void testOcspWithFileCache(String host) throws Throwable {
System.setProperty(
SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED, Boolean.FALSE.toString());
- File ocspCacheFile = tmpFolder.newFile();
+ File ocspCacheFile = new File(tmpFolder, "ocsp-cache");
+ ocspCacheFile.createNewFile();
HttpClient client =
HttpUtil.buildHttpClient(
new HttpClientSettingsKey(OCSPMode.FAIL_CLOSED),
@@ -130,11 +131,13 @@ public void testOcspWithFileCache() throws Throwable {
}
/** OCSP tests for the Snowflake and AWS S3 HTTPS connections using the server cache. */
- @Test
- public void testOcspWithServerCache() throws Throwable {
+ @ParameterizedTest
+ @ArgumentsSource(HostProvider.class)
+ public void testOcspWithServerCache(String host) throws Throwable {
System.setProperty(
SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED, Boolean.TRUE.toString());
- File ocspCacheFile = tmpFolder.newFile();
+ File ocspCacheFile = new File(tmpFolder, "ocsp-cache");
+ ocspCacheFile.createNewFile();
HttpClient client =
HttpUtil.buildHttpClient(
new HttpClientSettingsKey(OCSPMode.FAIL_CLOSED),
@@ -148,11 +151,13 @@ public void testOcspWithServerCache() throws Throwable {
* OCSP tests for the Snowflake and AWS S3 HTTPS connections without using the server cache. This
* test should always pass - even with OCSP Outage.
*/
- @Test
- public void testOcspWithoutServerCache() throws Throwable {
+ @ParameterizedTest
+ @ArgumentsSource(HostProvider.class)
+ public void testOcspWithoutServerCache(String host) throws Throwable {
System.setProperty(
SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED, Boolean.FALSE.toString());
- File ocspCacheFile = tmpFolder.newFile();
+ File ocspCacheFile = new File(tmpFolder, "ocsp-cache");
+ ocspCacheFile.createNewFile();
HttpClient client =
HttpUtil.buildHttpClient(
new HttpClientSettingsKey(OCSPMode.FAIL_OPEN),
@@ -163,8 +168,9 @@ public void testOcspWithoutServerCache() throws Throwable {
}
/** OCSP tests for the Snowflake and AWS S3 HTTPS connections using the server cache. */
- @Test
- public void testInvalidCacheFile() throws Throwable {
+ @ParameterizedTest
+ @ArgumentsSource(HostProvider.class)
+ public void testInvalidCacheFile(String host) throws Throwable {
System.setProperty(
SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_ENABLED, Boolean.TRUE.toString());
// a file under never exists.
diff --git a/src/test/java/net/snowflake/client/core/SFTrustManagerMockitoMockLatestIT.java b/src/test/java/net/snowflake/client/core/SFTrustManagerMockitoMockLatestIT.java
index 862f4867e..e561f9acd 100644
--- a/src/test/java/net/snowflake/client/core/SFTrustManagerMockitoMockLatestIT.java
+++ b/src/test/java/net/snowflake/client/core/SFTrustManagerMockitoMockLatestIT.java
@@ -14,32 +14,33 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import net.snowflake.client.TestUtil;
-import net.snowflake.client.category.TestCategoryCore;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.jdbc.SnowflakeUtil;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
import org.mockito.MockedStatic;
-@Category(TestCategoryCore.class)
+// @Category(TestCategoryCore.class)
+@Tag(TestTags.CORE)
public class SFTrustManagerMockitoMockLatestIT {
- @Rule public TemporaryFolder tmpFolder = new TemporaryFolder();
+ @TempDir private File tmpFolder;
/*
* Test SF_OCSP_RESPONSE_CACHE_DIR environment variable changes the
* location of the OCSP cache directory.
*/
@Test
- @Ignore("static initialization block of SFTrustManager class doesn't run sometimes")
+ @Disabled("static initialization block of SFTrustManager class doesn't run sometimes")
public void testUnitOCSPWithCustomCacheDirectory() throws IOException {
try (MockedStatic mockedTrustManagerFactory =
mockStatic(TrustManagerFactory.class);
MockedStatic mockedSnowflakeUtil = mockStatic(SnowflakeUtil.class)) {
- File cacheFolder = tmpFolder.newFolder();
+ File cacheFolder = new File(tmpFolder, "cache");
+ cacheFolder.mkdirs();
mockedSnowflakeUtil
.when(() -> TestUtil.systemGetEnv("SF_OCSP_RESPONSE_CACHE_DIR"))
.thenReturn(cacheFolder.getCanonicalPath());
diff --git a/src/test/java/net/snowflake/client/core/SFTrustManagerTest.java b/src/test/java/net/snowflake/client/core/SFTrustManagerTest.java
index 6a55b2cd4..77a06cb2a 100644
--- a/src/test/java/net/snowflake/client/core/SFTrustManagerTest.java
+++ b/src/test/java/net/snowflake/client/core/SFTrustManagerTest.java
@@ -11,10 +11,24 @@
import java.util.Properties;
import net.snowflake.client.jdbc.SnowflakeResultSetSerializable;
import net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
public class SFTrustManagerTest {
/** Test building OCSP retry URL */
+ static String originalRetryUrlPattern;
+
+ @BeforeAll
+ public static void saveStaticValues() {
+ originalRetryUrlPattern = SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_RETRY_URL_PATTERN;
+ }
+
+ @AfterAll
+ public static void restoreStaticValues() {
+ SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_RETRY_URL_PATTERN = originalRetryUrlPattern;
+ }
+
@Test
public void testBuildRetryURL() throws Exception {
// private link
diff --git a/src/test/java/net/snowflake/client/core/SQLInputOutputTest.java b/src/test/java/net/snowflake/client/core/SQLInputOutputTest.java
index 346d43c34..f8224a8eb 100644
--- a/src/test/java/net/snowflake/client/core/SQLInputOutputTest.java
+++ b/src/test/java/net/snowflake/client/core/SQLInputOutputTest.java
@@ -4,7 +4,7 @@
import static org.mockito.Mockito.mock;
import java.sql.SQLData;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SQLInputOutputTest {
diff --git a/src/test/java/net/snowflake/client/core/SecureStorageManagerTest.java b/src/test/java/net/snowflake/client/core/SecureStorageManagerTest.java
index b6f8a16ac..b79875038 100644
--- a/src/test/java/net/snowflake/client/core/SecureStorageManagerTest.java
+++ b/src/test/java/net/snowflake/client/core/SecureStorageManagerTest.java
@@ -16,11 +16,11 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningNotOnLinux;
-import net.snowflake.client.RunningNotOnWinMac;
-import org.junit.Rule;
-import org.junit.Test;
+import net.snowflake.client.annotations.RunOnLinux;
+import net.snowflake.client.annotations.RunOnMac;
+import net.snowflake.client.annotations.RunOnWindows;
+import net.snowflake.client.annotations.RunOnWindowsOrMac;
+import org.junit.jupiter.api.Test;
class MockAdvapi32Lib implements SecureStorageWindowsManager.Advapi32Lib {
@Override
@@ -213,8 +213,6 @@ Pointer getPointer() {
}
public class SecureStorageManagerTest {
- // This is required to use ConditionalIgnore annotation
- @Rule public ConditionalIgnoreRule rule = new ConditionalIgnoreRule();
private static final String host = "fakeHost";
private static final String user = "fakeUser";
@@ -227,7 +225,7 @@ public class SecureStorageManagerTest {
private static final String MFA_TOKEN = "MFATOKEN";
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningNotOnWinMac.class)
+ @RunOnWindowsOrMac
public void testLoadNativeLibrary() {
// Only run on Mac or Windows. Make sure the loading of native platform library won't break.
if (Constants.getOS() == Constants.OS.MAC) {
@@ -240,6 +238,7 @@ public void testLoadNativeLibrary() {
}
@Test
+ @RunOnWindows
public void testWindowsManager() {
SecureStorageWindowsManager.Advapi32LibManager.setInstance(new MockAdvapi32Lib());
SecureStorageManager manager = SecureStorageWindowsManager.builder();
@@ -249,6 +248,7 @@ public void testWindowsManager() {
}
@Test
+ @RunOnMac
public void testMacManager() {
SecureStorageAppleManager.SecurityLibManager.setInstance(new MockSecurityLib());
SecureStorageManager manager = SecureStorageAppleManager.builder();
@@ -258,7 +258,7 @@ public void testMacManager() {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningNotOnLinux.class)
+ @RunOnLinux
public void testLinuxManager() {
SecureStorageManager manager = SecureStorageLinuxManager.getInstance();
diff --git a/src/test/java/net/snowflake/client/core/SessionUtilExternalBrowserTest.java b/src/test/java/net/snowflake/client/core/SessionUtilExternalBrowserTest.java
index 2ba00f378..02f6193d6 100644
--- a/src/test/java/net/snowflake/client/core/SessionUtilExternalBrowserTest.java
+++ b/src/test/java/net/snowflake/client/core/SessionUtilExternalBrowserTest.java
@@ -5,10 +5,9 @@
package net.snowflake.client.core;
import static org.hamcrest.CoreMatchers.equalTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-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.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
import static org.mockito.Mockito.when;
@@ -32,8 +31,9 @@
import net.snowflake.common.core.ClientAuthnDTO;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.hamcrest.MatcherAssert;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
@@ -164,11 +164,13 @@ public void testSessionUtilExternalBrowser() throws Throwable {
SessionUtilExternalBrowser sub =
FakeSessionUtilExternalBrowser.createInstance(loginInput, false);
sub.authenticate();
- assertThat("", sub.getToken(), equalTo(FakeSessionUtilExternalBrowser.MOCK_SAML_TOKEN));
+ MatcherAssert.assertThat(
+ "", sub.getToken(), equalTo(FakeSessionUtilExternalBrowser.MOCK_SAML_TOKEN));
sub = FakeSessionUtilExternalBrowser.createInstance(loginInput, true);
sub.authenticate();
- assertThat("", sub.getToken(), equalTo(FakeSessionUtilExternalBrowser.MOCK_SAML_TOKEN));
+ MatcherAssert.assertThat(
+ "", sub.getToken(), equalTo(FakeSessionUtilExternalBrowser.MOCK_SAML_TOKEN));
}
}
@@ -200,7 +202,7 @@ public void testSessionUtilExternalBrowserFail() throws Throwable {
sub.authenticate();
fail("should have failed with an exception.");
} catch (SnowflakeSQLException ex) {
- assertThat("Error is expected", ex.getErrorCode(), equalTo(123456));
+ MatcherAssert.assertThat("Error is expected", ex.getErrorCode(), equalTo(123456));
}
}
}
@@ -248,7 +250,7 @@ private SFLoginInput initMockLoginInput() {
// Run this test manually to test disabling storing temporary credetials with external browser
// auth. This is valid for versions after 3.18.0.
@Test
- @Ignore
+ @Disabled
public void testEnableClientStoreTemporaryCredential() throws Exception {
Map params = AbstractDriverIT.getConnectionParameters();
SnowflakeBasicDataSource ds = new SnowflakeBasicDataSource();
@@ -270,7 +272,7 @@ public void testEnableClientStoreTemporaryCredential() throws Exception {
// open a browser window for authentication, close the window, and you should get the expected
// error message within the set timeout. Valid for driver versions after 3.18.0.
@Test
- @Ignore
+ @Disabled
public void testExternalBrowserTimeout() throws Exception {
Map params = AbstractDriverIT.getConnectionParameters();
SnowflakeBasicDataSource ds = new SnowflakeBasicDataSource();
diff --git a/src/test/java/net/snowflake/client/core/SessionUtilLatestIT.java b/src/test/java/net/snowflake/client/core/SessionUtilLatestIT.java
index be6c03b01..49507f8c7 100644
--- a/src/test/java/net/snowflake/client/core/SessionUtilLatestIT.java
+++ b/src/test/java/net/snowflake/client/core/SessionUtilLatestIT.java
@@ -5,8 +5,8 @@
package net.snowflake.client.core;
import static net.snowflake.client.TestUtil.systemGetEnv;
-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;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockStatic;
@@ -21,7 +21,7 @@
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
-import net.snowflake.client.category.TestCategoryCore;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.jdbc.BaseJDBCTest;
import net.snowflake.client.jdbc.ErrorCode;
import net.snowflake.client.jdbc.SnowflakeSQLException;
@@ -33,14 +33,15 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpRequestBase;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.MockedStatic.Verification;
import org.mockito.Mockito;
-@Category(TestCategoryCore.class)
+// @Category(TestCategoryCore.class)
+@Tag(TestTags.CORE)
public class SessionUtilLatestIT extends BaseJDBCTest {
/**
@@ -50,7 +51,7 @@ public class SessionUtilLatestIT extends BaseJDBCTest {
* @throws SFException
* @throws SnowflakeSQLException
*/
- @Ignore
+ @Disabled
@Test
public void testJwtAuthTimeoutRetry() throws SFException, SnowflakeSQLException {
final SFLoginInput loginInput = initMockLoginInput();
diff --git a/src/test/java/net/snowflake/client/core/SessionUtilTest.java b/src/test/java/net/snowflake/client/core/SessionUtilTest.java
index cab5fb68f..86819dc5b 100644
--- a/src/test/java/net/snowflake/client/core/SessionUtilTest.java
+++ b/src/test/java/net/snowflake/client/core/SessionUtilTest.java
@@ -5,9 +5,9 @@
package net.snowflake.client.core;
import static org.hamcrest.MatcherAssert.assertThat;
-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 com.fasterxml.jackson.databind.node.BooleanNode;
import java.io.IOException;
@@ -20,9 +20,25 @@
import net.snowflake.client.jdbc.MockConnectionTest;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
public class SessionUtilTest {
+ private static String originalUrlValue;
+ private static String originalRetryUrlPattern;
+
+ @BeforeAll
+ public static void saveStaticValues() {
+ originalUrlValue = SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_URL_VALUE;
+ originalRetryUrlPattern = SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_RETRY_URL_PATTERN;
+ }
+
+ @AfterAll
+ public static void restoreStaticValues() {
+ SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_URL_VALUE = originalUrlValue;
+ SFTrustManager.SF_OCSP_RESPONSE_CACHE_SERVER_RETRY_URL_PATTERN = originalRetryUrlPattern;
+ }
/** Test isPrefixEqual */
@Test
diff --git a/src/test/java/net/snowflake/client/core/SnowflakeMFACacheTest.java b/src/test/java/net/snowflake/client/core/SnowflakeMFACacheTest.java
index f1f0a3e73..0524ab6b8 100644
--- a/src/test/java/net/snowflake/client/core/SnowflakeMFACacheTest.java
+++ b/src/test/java/net/snowflake/client/core/SnowflakeMFACacheTest.java
@@ -4,8 +4,9 @@
package net.snowflake.client.core;
-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.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
@@ -29,9 +30,8 @@
import net.snowflake.client.jdbc.SnowflakeSQLException;
import org.apache.commons.io.IOUtils;
import org.apache.http.client.methods.HttpPost;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
@@ -216,7 +216,7 @@ public String answer(InvocationOnMock invocation) throws Throwable {
// This connection would receive an exception and then should clean up the mfa cache
try {
Connection con3 = DriverManager.getConnection(url, prop);
- Assert.fail();
+ fail();
} catch (SnowflakeSQLException ex) {
// An exception is forced to happen by mocking. Do nothing.
}
@@ -336,7 +336,7 @@ public void testUnavailableLocalSecureStorage() throws SQLException {
// Run this test manually to test disabling the client request MFA token. Use an MFA
// authentication enabled user. This is valid for versions after 3.18.0.
@Test
- @Ignore
+ @Disabled
public void testEnableClientRequestMfaToken() throws SQLException {
Map params = AbstractDriverIT.getConnectionParameters();
SnowflakeBasicDataSource ds = new SnowflakeBasicDataSource();
diff --git a/src/test/java/net/snowflake/client/core/SqlInputTimestampUtilTest.java b/src/test/java/net/snowflake/client/core/SqlInputTimestampUtilTest.java
index 752229fc9..305f5563d 100644
--- a/src/test/java/net/snowflake/client/core/SqlInputTimestampUtilTest.java
+++ b/src/test/java/net/snowflake/client/core/SqlInputTimestampUtilTest.java
@@ -1,6 +1,6 @@
package net.snowflake.client.core;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.Timestamp;
import java.time.LocalDateTime;
@@ -8,12 +8,12 @@
import java.util.Map;
import java.util.TimeZone;
import net.snowflake.client.jdbc.SnowflakeUtil;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
-@Ignore
+@Disabled
public class SqlInputTimestampUtilTest {
private static final String TIMESTAMP_IN_FORMAT_1 = "2021-12-22 09:43:44.000 +0100";
@@ -24,7 +24,7 @@ public class SqlInputTimestampUtilTest {
private static SFBaseSession mockSession;
- @BeforeClass
+ @BeforeAll
public static void setup() {
CONNECTION_PARAMS.put("TIMESTAMP_OUTPUT_FORMAT", "YYYY-MM-DD HH24:MI:SS.FF3 TZHTZM");
CONNECTION_PARAMS.put("TIMESTAMP_TZ_OUTPUT_FORMAT", "DY, DD MON YYYY HH24:MI:SS TZHTZM");
diff --git a/src/test/java/net/snowflake/client/core/StmtUtilTest.java b/src/test/java/net/snowflake/client/core/StmtUtilTest.java
index 75daa9a03..a64cbfcec 100644
--- a/src/test/java/net/snowflake/client/core/StmtUtilTest.java
+++ b/src/test/java/net/snowflake/client/core/StmtUtilTest.java
@@ -13,17 +13,18 @@
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
-import net.snowflake.client.category.TestCategoryCore;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.StmtUtil.StmtInput;
import net.snowflake.client.jdbc.BaseJDBCTest;
import org.apache.http.Header;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.mockito.MockedStatic;
import org.mockito.MockedStatic.Verification;
import org.mockito.Mockito;
-@Category(TestCategoryCore.class)
+// @Category(TestCategoryCore.class)
+@Tag(TestTags.CORE)
public class StmtUtilTest extends BaseJDBCTest {
/** SNOW-862760 Verify that additional headers are added to request */
diff --git a/src/test/java/net/snowflake/client/core/URLUtilTest.java b/src/test/java/net/snowflake/client/core/URLUtilTest.java
index b61324eee..d2903b2c5 100644
--- a/src/test/java/net/snowflake/client/core/URLUtilTest.java
+++ b/src/test/java/net/snowflake/client/core/URLUtilTest.java
@@ -3,11 +3,11 @@
*/
package net.snowflake.client.core;
-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 org.junit.Test;
+import org.junit.jupiter.api.Test;
public class URLUtilTest {
diff --git a/src/test/java/net/snowflake/client/core/arrow/ArrowResultUtilTest.java b/src/test/java/net/snowflake/client/core/arrow/ArrowResultUtilTest.java
index 75b24cc07..4dc6855b1 100644
--- a/src/test/java/net/snowflake/client/core/arrow/ArrowResultUtilTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/ArrowResultUtilTest.java
@@ -4,43 +4,42 @@
package net.snowflake.client.core.arrow;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Random;
import java.util.TimeZone;
+import java.util.stream.Stream;
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.SFSession;
-import org.junit.After;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import net.snowflake.client.providers.TimezoneProvider;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class ArrowResultUtilTest {
- // test on multiple time zones
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"}, {"America/Los_Angeles"}, {"America/New_York"}, {"Asia/Singapore"}, {"MEZ"},
- };
- }
-
- @After
- public void clearTimeZone() {
+ @AfterAll
+ public static void clearTimeZone() {
System.clearProperty("user.timezone");
}
- public ArrowResultUtilTest(String tz) {
- System.setProperty("user.timezone", tz);
+ public static void setTimeZone(String string) {
+ System.setProperty("user.timezone", string);
}
- @Test
- @Ignore
+ @ParameterizedTest(name = "Timezone = {0}")
+ @ArgumentsSource(TimezoneProvider.class)
+ @Disabled
/** This is to show we can have 30X improvement using new API */
- public void testGetDatePerformance() throws SFException {
+ public void testGetDatePerformance(String timezone) throws SFException {
+ setTimeZone(timezone);
Random random = new Random();
int dateBound = 50000;
int times = 100000;
@@ -71,17 +70,43 @@ public void testGetDatePerformance() throws SFException {
System.out.println(duration1 + " " + duration2 + " " + duration3);
}
- @Test
- public void testToJavaTimestamp() {
+ private static class testCasesProvider implements ArgumentsProvider {
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ List timezones =
+ new ArrayList() {
+ {
+ add("UTC");
+ add("America/Los_Angeles");
+ add("America/New_York");
+ add("Asia/Singapore");
+ add("MEZ");
+ }
+ };
+
+ long[] cases = {-1123456789, -123456789, 123456789, 123123456789L, -123123456789L};
+ long[] millisecs = {-1124, -124, 123, 123123, -123124};
+ int[] nanos = {876543211, 876543211, 123456789, 123456789, 876543211};
+
+ List args = new ArrayList<>();
+ for (String timezone : timezones) {
+ for (int i = 0; i < cases.length; i++) {
+ args.add(Arguments.of(timezone, cases[i], millisecs[i], nanos[i]));
+ }
+ }
+
+ return args.stream();
+ }
+ }
+
+ @ParameterizedTest
+ @ArgumentsSource(testCasesProvider.class)
+ public void testToJavaTimestamp(String timezone, long cas, long millisecs, int nanos) {
// ex: -1.123456789, -0.123456789, 0.123456789, 123.123456789, -123.123456789
- long[] cases = {-1123456789, -123456789, 123456789, 123123456789l, -123123456789l};
- long[] millisecs = {-1124, -124, 123, 123123, -123124};
- int[] nanos = {876543211, 876543211, 123456789, 123456789, 876543211};
+ setTimeZone(timezone);
int scale = 9;
- for (int i = 0; i < cases.length; i++) {
- Timestamp ts = ArrowResultUtil.toJavaTimestamp(cases[i], scale);
- assertEquals(millisecs[i], ts.getTime());
- assertEquals(nanos[i], ts.getNanos());
- }
+ Timestamp ts = ArrowResultUtil.toJavaTimestamp(cas, scale);
+ assertEquals(millisecs, ts.getTime());
+ assertEquals(nanos, ts.getNanos());
}
}
diff --git a/src/test/java/net/snowflake/client/core/arrow/BaseConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/BaseConverterTest.java
index e669ac006..a738676fb 100644
--- a/src/test/java/net/snowflake/client/core/arrow/BaseConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/BaseConverterTest.java
@@ -10,9 +10,9 @@
import net.snowflake.client.jdbc.ErrorCode;
import net.snowflake.common.core.SFBinaryFormat;
import net.snowflake.common.core.SnowflakeDateTimeFormat;
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Before;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeEach;
public class BaseConverterTest implements DataConversionContext {
private SnowflakeDateTimeFormat dateTimeFormat =
@@ -30,16 +30,16 @@ public class BaseConverterTest implements DataConversionContext {
private boolean honorClientTZForTimestampNTZ;
protected final int invalidConversionErrorCode = ErrorCode.INVALID_VALUE_CONVERT.getMessageCode();
- @After
+ @AfterEach
public void clearTimeZone() {
System.clearProperty("user.timezone");
}
- @Before
+ @BeforeEach
public void assumeLittleEndian() {
- Assume.assumeTrue(
- "Arrow doesn't support cross endianness",
- ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN));
+ Assumptions.assumeTrue(
+ ByteOrder.nativeOrder().equals(ByteOrder.LITTLE_ENDIAN),
+ "Arrow doesn't support cross endianness");
}
@Override
diff --git a/src/test/java/net/snowflake/client/core/arrow/BigIntToFixedConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/BigIntToFixedConverterTest.java
index 74eabad29..230288f4a 100644
--- a/src/test/java/net/snowflake/client/core/arrow/BigIntToFixedConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/BigIntToFixedConverterTest.java
@@ -7,8 +7,8 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.math.BigDecimal;
import java.nio.ByteBuffer;
@@ -27,7 +27,7 @@
import org.apache.arrow.vector.BigIntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class BigIntToFixedConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/arrow/BigIntToTimeConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/BigIntToTimeConverterTest.java
index 9248440bb..b2be8f8cd 100644
--- a/src/test/java/net/snowflake/client/core/arrow/BigIntToTimeConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/BigIntToTimeConverterTest.java
@@ -7,8 +7,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Time;
import java.util.HashMap;
@@ -20,32 +20,24 @@
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.SFSession;
+import net.snowflake.client.providers.TimezoneProvider;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.BigIntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class BigIntToTimeConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
+ public void setTimezone(String tz) {
+ System.setProperty("user.timezone", tz);
}
- public BigIntToTimeConverterTest(String tz) {
- System.setProperty("user.timezone", tz);
+ @AfterAll
+ public static void clearTimezone() {
+ System.clearProperty("user.timezone");
}
/** allocator for arrow */
@@ -55,8 +47,10 @@ public BigIntToTimeConverterTest(String tz) {
private int scale = 9;
- @Test
- public void testTime() throws SFException {
+ @ParameterizedTest(name = "{0}")
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testTime(String tz) throws SFException {
+ setTimezone(tz);
// test old and new dates
long[] testTimesInt64 = {12345678000000L};
diff --git a/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampLTZConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampLTZConverterTest.java
index 26fdbc052..298bf443b 100644
--- a/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampLTZConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampLTZConverterTest.java
@@ -8,8 +8,8 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.sql.Time;
@@ -23,34 +23,17 @@
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
import net.snowflake.client.jdbc.SnowflakeUtil;
+import net.snowflake.client.providers.TimezoneProvider;
import net.snowflake.common.core.SFTimestamp;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.BigIntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class BigIntToTimestampLTZConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
- }
-
- public BigIntToTimestampLTZConverterTest(String tz) {
- System.setProperty("user.timezone", tz);
- }
/** allocator for arrow */
private BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
@@ -59,8 +42,10 @@ public BigIntToTimestampLTZConverterTest(String tz) {
private int oldScale = 9;
- @Test
- public void testTimestampLTZ() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testTimestampLTZ(String timezone) throws SFException {
+ System.setProperty("user.timezone", timezone);
// test old and new dates
long[] testTimestampsInt64 = {
1546391837,
diff --git a/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampNTZConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampNTZConverterTest.java
index df4370641..6f2c0420d 100644
--- a/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampNTZConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/BigIntToTimestampNTZConverterTest.java
@@ -4,18 +4,21 @@
package net.snowflake.client.core.arrow;
+import static net.snowflake.client.providers.ProvidersUtil.cartesianProduct;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
@@ -23,33 +26,32 @@
import net.snowflake.client.TestUtil;
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
+import net.snowflake.client.providers.SnowflakeArgumentsProvider;
+import net.snowflake.client.providers.TimezoneProvider;
import net.snowflake.common.core.SFTimestamp;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.BigIntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class BigIntToTimestampNTZConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
+ static class FlagProvider extends SnowflakeArgumentsProvider {
+ @Override
+ protected List rawArguments(ExtensionContext context) {
+ return Arrays.asList(Arguments.of(true), Arguments.of(false));
+ }
}
- public BigIntToTimestampNTZConverterTest(String tz) {
- System.setProperty("user.timezone", tz);
+ static class DataProvider extends SnowflakeArgumentsProvider {
+ @Override
+ protected List rawArguments(ExtensionContext context) {
+ return cartesianProduct(context, new TimezoneProvider(), new FlagProvider());
+ }
}
/** allocator for arrow */
@@ -59,25 +61,18 @@ public BigIntToTimestampNTZConverterTest(String tz) {
private int oldScale = 9;
- @Test
- public void testHonorClientTZForTimestampNTZDisabled() throws SFException {
- this.setHonorClientTZForTimestampNTZ(false);
- testTimestampNTZ();
- }
-
- @Test
- public void testHonorClientTZForTimestampNTZEnabled() throws SFException {
- this.setHonorClientTZForTimestampNTZ(true);
- testTimestampNTZ();
- }
-
- @Test
- public void testWithNullTimezone() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testWithNullTimezone(String tz) throws SFException {
+ System.setProperty("user.timezone", tz);
testTimestampNTZ(null);
}
- @Test
- public void testTimestampNTZ() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(DataProvider.class)
+ public void testTimestampNTZ(String tz, boolean flag) throws SFException {
+ this.setHonorClientTZForTimestampNTZ(flag);
+ System.setProperty("user.timezone", tz);
testTimestampNTZ(TimeZone.getDefault());
}
diff --git a/src/test/java/net/snowflake/client/core/arrow/BitToBooleanConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/BitToBooleanConverterTest.java
index e5091d6fc..c30bbd0e6 100644
--- a/src/test/java/net/snowflake/client/core/arrow/BitToBooleanConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/BitToBooleanConverterTest.java
@@ -3,8 +3,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.util.ArrayList;
import java.util.HashMap;
@@ -19,7 +19,7 @@
import org.apache.arrow.vector.BitVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class BitToBooleanConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/arrow/DateConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/DateConverterTest.java
index b63ae9a2d..6857394fc 100644
--- a/src/test/java/net/snowflake/client/core/arrow/DateConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/DateConverterTest.java
@@ -3,8 +3,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.util.Arrays;
@@ -18,33 +18,20 @@
import net.snowflake.client.TestUtil;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.json.DateTimeConverter;
+import net.snowflake.client.providers.TimezoneProvider;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.DateDayVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class DateConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
- }
- public DateConverterTest(String tz) {
+ private static void setTimeZone(String tz) {
System.setProperty("user.timezone", tz);
}
@@ -78,26 +65,28 @@ public DateConverterTest(String tz) {
put("America/New_York", Arrays.asList("2016-04-20", -4));
put("Pacific/Honolulu", Arrays.asList("2016-04-20", -10));
put("Asia/Singapore", Arrays.asList("2016-04-19", 8));
- put("MEZ", Arrays.asList("2016-04-20", 0));
- put("MESZ", Arrays.asList("2016-04-20", 0));
+ put("CET", Arrays.asList("2016-04-19", 2)); // because of daylight savings
+ put("GMT+0200", Arrays.asList("2016-04-19", 2));
}
};
public static final int MILLIS_IN_ONE_HOUR = 3600000;
private TimeZone defaultTimeZone;
- @Before
+ @BeforeEach
public void getDefaultTimeZone() {
this.defaultTimeZone = TimeZone.getDefault();
}
- @After
+ @AfterEach
public void restoreDefaultTimeZone() {
TimeZone.setDefault(defaultTimeZone);
}
- @Test
- public void testDate() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testDate(String tz) throws SFException {
+ setTimeZone(tz);
Map customFieldMeta = new HashMap<>();
customFieldMeta.put("logicalType", "DATE");
Set nullValIndex = new HashSet<>();
@@ -153,8 +142,10 @@ public void testDate() throws SFException {
vector.clear();
}
- @Test
- public void testRandomDates() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testRandomDates(String tz) throws SFException {
+ setTimeZone(tz);
int dateBound = 50000;
int rowCount = 50000;
Map customFieldMeta = new HashMap<>();
@@ -196,8 +187,10 @@ public void testRandomDates() throws SFException {
}
}
- @Test
- public void testTimezoneDates() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testTimezoneDates(String tz) throws SFException {
+ setTimeZone(tz);
int testDay = 16911;
Map customFieldMeta = new HashMap<>();
customFieldMeta.put("logicalType", "DATE");
@@ -211,7 +204,6 @@ public void testTimezoneDates() throws SFException {
// Test JDBC_FORMAT_DATE_WITH_TIMEZONE=TRUE with different session timezones
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
- String tz = System.getProperty("user.timezone");
ArrowVectorConverter converter = new DateConverter(vector, 0, this, true);
converter.setUseSessionTimezone(true);
converter.setSessionTimeZone(TimeZone.getTimeZone(tz));
diff --git a/src/test/java/net/snowflake/client/core/arrow/DoubleToRealConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/DoubleToRealConverterTest.java
index b242a2be8..718daa69c 100644
--- a/src/test/java/net/snowflake/client/core/arrow/DoubleToRealConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/DoubleToRealConverterTest.java
@@ -6,8 +6,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.nio.ByteBuffer;
import java.util.ArrayList;
@@ -25,7 +25,7 @@
import org.apache.arrow.vector.Float8Vector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class DoubleToRealConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/arrow/IntToFixedConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/IntToFixedConverterTest.java
index c11d8275d..fc4db1875 100644
--- a/src/test/java/net/snowflake/client/core/arrow/IntToFixedConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/IntToFixedConverterTest.java
@@ -7,9 +7,9 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.math.BigDecimal;
import java.nio.ByteBuffer;
@@ -29,7 +29,7 @@
import org.apache.arrow.vector.IntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class IntToFixedConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/arrow/IntToTimeConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/IntToTimeConverterTest.java
index 92c560db3..1f4bd955f 100644
--- a/src/test/java/net/snowflake/client/core/arrow/IntToTimeConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/IntToTimeConverterTest.java
@@ -8,10 +8,9 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.nio.ByteBuffer;
import java.sql.Time;
import java.util.HashMap;
import java.util.HashSet;
@@ -22,46 +21,31 @@
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.SFSession;
+import net.snowflake.client.providers.TimezoneProvider;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
import org.apache.arrow.vector.IntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class IntToTimeConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
- }
-
- private ByteBuffer bb;
-
- public IntToTimeConverterTest(String tz) {
- System.setProperty("user.timezone", tz);
- this.setScale(scale);
- }
-
/** allocator for arrow */
private BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
private Random random = new Random();
+ public IntToTimeConverterTest() {
+ this.setScale(scale);
+ }
+
private int scale = 3;
- @Test
- public void testTime() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testTime(String timezone) throws SFException {
+ System.setProperty("user.timezone", timezone);
// test old and new dates
int[] testTimesInt = {12345678};
diff --git a/src/test/java/net/snowflake/client/core/arrow/SmallIntToFixedConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/SmallIntToFixedConverterTest.java
index 5513a420b..d37b005b1 100644
--- a/src/test/java/net/snowflake/client/core/arrow/SmallIntToFixedConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/SmallIntToFixedConverterTest.java
@@ -7,9 +7,9 @@
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.math.BigDecimal;
import java.nio.ByteBuffer;
@@ -29,7 +29,7 @@
import org.apache.arrow.vector.SmallIntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class SmallIntToFixedConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/arrow/ThreeFieldStructToTimestampTZConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/ThreeFieldStructToTimestampTZConverterTest.java
index 10721fbc1..09cd4a587 100644
--- a/src/test/java/net/snowflake/client/core/arrow/ThreeFieldStructToTimestampTZConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/ThreeFieldStructToTimestampTZConverterTest.java
@@ -4,15 +4,17 @@
package net.snowflake.client.core.arrow;
+import static java.util.stream.Stream.concat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -20,6 +22,7 @@
import java.util.Map;
import java.util.Random;
import java.util.Set;
+import java.util.stream.Stream;
import net.snowflake.client.TestUtil;
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
@@ -33,29 +36,73 @@
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class ThreeFieldStructToTimestampTZConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
+ private static class TimezoneProvider implements ArgumentsProvider {
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ List timezones =
+ new ArrayList() {
+ {
+ add("America/Los_Angeles");
+ add("America/New_York");
+ add("Pacific/Honolulu");
+ add("Asia/Singapore");
+ add("MESZ");
+ add("MEZ");
+ add("UTC");
+ }
+ };
+
+ Stream args = Stream.empty();
+
+ for (String timezone : timezones) {
+ args =
+ concat(
+ args,
+ Stream.of(
+ Arguments.argumentSet(
+ timezone,
+ timezone,
+ new long[] {1546391837, 1546391837, 0, 123, -12346, -12345},
+ new int[] {0, 10, 100, 456, 876543211, 0},
+ new int[] {960, 1440, 960, 960, 1440, 1440},
+ new String[] {
+ "1546391837.000000000 960",
+ "1546391837.000000010 1440",
+ "0.000000100 960",
+ "123.000000456 960",
+ "-12345.123456789 1440",
+ "-12345.000000000 1440"
+ }),
+ Arguments.argumentSet(
+ timezone + " Overflow",
+ timezone,
+ new long[] {1546391837},
+ new int[] {0},
+ new int[] {960},
+ new String[] {"1546391837.000000000 960"})));
+ }
+
+ return args;
+ }
}
- public ThreeFieldStructToTimestampTZConverterTest(String tz) {
+ private static void setTimezone(String tz) {
System.setProperty("user.timezone", tz);
}
+ @AfterAll
+ public static void clearTimezone() {
+ System.clearProperty("user.timezone");
+ }
+
/** allocator for arrow */
private BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
@@ -63,42 +110,16 @@ public ThreeFieldStructToTimestampTZConverterTest(String tz) {
private int oldScale = 9;
- @Test
- public void simpleTest() throws SFException {
- // test old and new dates
- long[] testSecondsInt64 = {1546391837, 1546391837, 0, 123, -12346, -12345};
-
- int[] testNanos = {0, 10, 100, 456, 876543211, 0};
-
- int[] testTimeZoneIndices = {960, 1440, 960, 960, 1440, 1440};
-
- String[] testTimesJson = {
- "1546391837.000000000 960",
- "1546391837.000000010 1440",
- "0.000000100 960",
- "123.000000456 960",
- "-12345.123456789 1440",
- "-12345.000000000 1440"
- };
- testTimestampTZ(testSecondsInt64, testNanos, testTimeZoneIndices, testTimesJson);
- }
-
- @Test
- public void timestampOverflowTest() throws SFException {
- // test old and new dates
- long[] testSecondsInt64 = {1546391837};
-
- int[] testNanos = {0};
-
- int[] testTimeZoneIndices = {960};
-
- String[] testTimesJson = {"1546391837.000000000 960"};
- testTimestampTZ(testSecondsInt64, testNanos, testTimeZoneIndices, testTimesJson);
- }
-
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
public void testTimestampTZ(
- long[] testSecondsInt64, int[] testNanos, int[] testTimeZoneIndices, String[] testTimesJson)
+ String tz,
+ long[] testSecondsInt64,
+ int[] testNanos,
+ int[] testTimeZoneIndices,
+ String[] testTimesJson)
throws SFException {
+ setTimezone(tz);
Map customFieldMeta = new HashMap<>();
customFieldMeta.put("logicalType", "TIMESTAMP");
diff --git a/src/test/java/net/snowflake/client/core/arrow/TinyIntToFixedConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/TinyIntToFixedConverterTest.java
index 8000ec885..8a1e9b359 100644
--- a/src/test/java/net/snowflake/client/core/arrow/TinyIntToFixedConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/TinyIntToFixedConverterTest.java
@@ -6,9 +6,9 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.math.BigDecimal;
import java.util.ArrayList;
@@ -27,7 +27,7 @@
import org.apache.arrow.vector.TinyIntVector;
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TinyIntToFixedConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampLTZConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampLTZConverterTest.java
index 8ce93fb6a..4fd4f07f3 100644
--- a/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampLTZConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampLTZConverterTest.java
@@ -4,15 +4,17 @@
package net.snowflake.client.core.arrow;
+import static java.util.stream.Stream.concat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -20,6 +22,7 @@
import java.util.Map;
import java.util.Random;
import java.util.Set;
+import java.util.stream.Stream;
import net.snowflake.client.TestUtil;
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
@@ -33,29 +36,70 @@
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class TwoFieldStructToTimestampLTZConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
+
+ static class DataProvider implements ArgumentsProvider {
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ List timezones =
+ new ArrayList() {
+ {
+ add("America/Los_Angeles");
+ add("America/New_York");
+ add("Pacific/Honolulu");
+ add("Asia/Singapore");
+ add("MESZ");
+ add("MEZ");
+ add("UTC");
+ }
+ };
+
+ Stream args = Stream.empty();
+
+ for (String timezone : timezones) {
+ args =
+ concat(
+ args,
+ Stream.of(
+ Arguments.argumentSet(
+ timezone,
+ timezone,
+ new long[] {1546391837, 0, -1546391838, -1546391838, -1546391838},
+ new int[] {0, 1, 999999990, 876543211, 1},
+ new String[] {
+ "1546391837.000000000",
+ "0.000000001",
+ "-1546391837.000000010",
+ "-1546391837.123456789",
+ "-1546391837.999999999"
+ }),
+ Arguments.argumentSet(
+ timezone + " Overflow",
+ timezone,
+ new long[] {154639183700000L},
+ new int[] {0},
+ new String[] {"154639183700000.000000000"})));
+ }
+ return args;
+ }
}
- public TwoFieldStructToTimestampLTZConverterTest(String tz) {
+ private static void setTimezone(String tz) {
System.setProperty("user.timezone", tz);
}
+ @AfterAll
+ public static void clearTimezone() {
+ System.clearProperty("user.timezone");
+ }
+
/** allocator for arrow */
private BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
@@ -63,37 +107,13 @@ public TwoFieldStructToTimestampLTZConverterTest(String tz) {
private int oldScale = 9;
- @Test
- public void simpleTests() throws SFException {
- // test old and new dates
- long[] testSecondsInt64 = {1546391837, 0, -1546391838, -1546391838, -1546391838};
-
- int[] testNanoSecs = {0, 1, 999999990, 876543211, 1};
-
- String[] testTimesJson = {
- "1546391837.000000000",
- "0.000000001",
- "-1546391837.000000010",
- "-1546391837.123456789",
- "-1546391837.999999999"
- };
- testTimestampLTZ(testSecondsInt64, testNanoSecs, testTimesJson);
- }
-
- @Test
- public void timestampOverflowTests() throws SFException {
- // test old and new dates
- long[] testSecondsInt64 = {154639183700000l};
-
- int[] testNanoSecs = {0};
-
- String[] testTimesJson = {"154639183700000.000000000"};
- testTimestampLTZ(testSecondsInt64, testNanoSecs, testTimesJson);
- }
-
- public void testTimestampLTZ(long[] testSecondsInt64, int[] testNanoSecs, String[] testTimesJson)
+ @ParameterizedTest
+ @ArgumentsSource(DataProvider.class)
+ public void testTimestampLTZ(
+ String timezone, long[] testSecondsInt64, int[] testNanoSecs, String[] testTimesJson)
throws SFException {
+ setTimezone(timezone);
Map customFieldMeta = new HashMap<>();
customFieldMeta.put("logicalType", "TIMESTAMP");
Set nullValIndex = new HashSet<>();
diff --git a/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampNTZConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampNTZConverterTest.java
index 2b5bf0e16..3b84176e4 100644
--- a/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampNTZConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampNTZConverterTest.java
@@ -4,15 +4,17 @@
package net.snowflake.client.core.arrow;
+import static java.util.stream.Stream.concat;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
@@ -21,6 +23,7 @@
import java.util.Random;
import java.util.Set;
import java.util.TimeZone;
+import java.util.stream.Stream;
import net.snowflake.client.TestUtil;
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
@@ -33,29 +36,24 @@
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class TwoFieldStructToTimestampNTZConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
- }
- public TwoFieldStructToTimestampNTZConverterTest(String tz) {
+ private static void setTimezone(String tz) {
System.setProperty("user.timezone", tz);
}
+ @AfterAll
+ public static void clearTimezone() {
+ System.clearProperty("user.timezone");
+ }
+
/** allocator for arrow */
private BufferAllocator allocator = new RootAllocator(Long.MAX_VALUE);
@@ -63,56 +61,80 @@ public TwoFieldStructToTimestampNTZConverterTest(String tz) {
private int oldScale = 9;
- @Test
- public void timestampOverflowTest() throws SFException {
- // test old and new dates
- long[] testSecondsInt64 = {154639183700000l};
-
- int[] testNanoSecs = {0};
-
- String[] testTimesJson = {"154639183700000.000000000"};
- this.setHonorClientTZForTimestampNTZ(false);
- testTimestampNTZ(testSecondsInt64, testNanoSecs, testTimesJson);
- }
-
- @Test
- public void testHonorClientTZForTimestampNTZDisabled() throws SFException {
- // test old and new dates
- long[] testSecondsInt64 = {1546391837, 0, -1546391838, -1546391838, -1546391838};
-
- int[] testNanoSecs = {0, 1, 999999990, 876543211, 1};
-
- String[] testTimesJson = {
- "1546391837.000000000",
- "0.000000001",
- "-1546391837.000000010",
- "-1546391837.123456789",
- "-1546391837.999999999"
- };
- this.setHonorClientTZForTimestampNTZ(false);
- testTimestampNTZ(testSecondsInt64, testNanoSecs, testTimesJson);
- }
+ static class DataProvider implements ArgumentsProvider {
+
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ List timezones =
+ new ArrayList() {
+ {
+ add("America/Los_Angeles");
+ add("America/New_York");
+ add("Pacific/Honolulu");
+ add("Asia/Singapore");
+ add("MESZ");
+ add("MEZ");
+ add("UTC");
+ }
+ };
+
+ Stream args = Stream.empty();
+
+ for (String timezone : timezones) {
+ args =
+ concat(
+ args,
+ Stream.of(
+ Arguments.argumentSet(
+ timezone + " Overflow",
+ timezone,
+ false,
+ new long[] {154639183700000L},
+ new int[] {0},
+ new String[] {"154639183700000.000000000"}),
+ Arguments.argumentSet(
+ timezone + " HonorClientTZForTimestampNTZ Disabled",
+ timezone,
+ false,
+ new long[] {1546391837, 0, -1546391838, -1546391838, -1546391838},
+ new int[] {0, 1, 999999990, 876543211, 1},
+ new String[] {
+ "1546391837.000000000",
+ "0.000000001",
+ "-1546391837.000000010",
+ "-1546391837.123456789",
+ "-1546391837.999999999"
+ }),
+ Arguments.argumentSet(
+ timezone + " HonorClientTZForTimestampNTZ Enabled",
+ timezone,
+ true,
+ new long[] {1546391837, 1546391837, 1546391837, 1546391837, 1546391837},
+ new int[] {0, 1, 10, 100, 999999999},
+ new String[] {
+ "1546391837.000000000",
+ "1546391837.000000001",
+ "1546391837.000000010",
+ "1546391837.000000100",
+ "1546391837.999999999"
+ })));
+ }
- @Test
- public void testHonorClientTZForTimestampNTZEnabled() throws SFException {
- // test old and new dates
- long[] testSecondsInt64 = {1546391837, 1546391837, 1546391837, 1546391837, 1546391837};
-
- int[] testNanoSecs = {0, 1, 10, 100, 999999999};
-
- String[] testTimesJson = {
- "1546391837.000000000",
- "1546391837.000000001",
- "1546391837.000000010",
- "1546391837.000000100",
- "1546391837.999999999"
- };
- this.setHonorClientTZForTimestampNTZ(true);
- testTimestampNTZ(testSecondsInt64, testNanoSecs, testTimesJson);
+ return args;
+ }
}
- public void testTimestampNTZ(long[] testSecondsInt64, int[] testNanoSecs, String[] testTimesJson)
+ @ParameterizedTest
+ @ArgumentsSource(DataProvider.class)
+ public void testTimestampNTZ(
+ String timezone,
+ boolean honorClientTZForTimestampNTZ,
+ long[] testSecondsInt64,
+ int[] testNanoSecs,
+ String[] testTimesJson)
throws SFException {
+ this.setHonorClientTZForTimestampNTZ(honorClientTZForTimestampNTZ);
+ setTimezone(timezone);
Map customFieldMeta = new HashMap<>();
customFieldMeta.put("logicalType", "TIMESTAMP");
diff --git a/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampTZConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampTZConverterTest.java
index 742b82751..767938d06 100644
--- a/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampTZConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/TwoFieldStructToTimestampTZConverterTest.java
@@ -7,8 +7,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.sql.Time;
@@ -24,6 +24,7 @@
import net.snowflake.client.core.ResultUtil;
import net.snowflake.client.core.SFException;
import net.snowflake.client.jdbc.SnowflakeUtil;
+import net.snowflake.client.providers.TimezoneProvider;
import net.snowflake.common.core.SFTimestamp;
import org.apache.arrow.memory.BufferAllocator;
import org.apache.arrow.memory.RootAllocator;
@@ -33,27 +34,18 @@
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.Field;
import org.apache.arrow.vector.types.pojo.FieldType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
public class TwoFieldStructToTimestampTZConverterTest extends BaseConverterTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- return new Object[][] {
- {"UTC"},
- {"America/Los_Angeles"},
- {"America/New_York"},
- {"Pacific/Honolulu"},
- {"Asia/Singapore"},
- {"MEZ"},
- {"MESZ"}
- };
+ public static void setTimezone(String tz) {
+ System.setProperty("user.timezone", tz);
}
- public TwoFieldStructToTimestampTZConverterTest(String tz) {
- System.setProperty("user.timezone", tz);
+ @AfterAll
+ public static void clearTimezone() {
+ System.clearProperty("user.timezone");
}
/** allocator for arrow */
@@ -63,8 +55,10 @@ public TwoFieldStructToTimestampTZConverterTest(String tz) {
private int oldScale = 9;
- @Test
- public void testTimestampTZ() throws SFException {
+ @ParameterizedTest
+ @ArgumentsSource(TimezoneProvider.class)
+ public void testTimestampTZ(String tz) throws SFException {
+ setTimezone(tz);
// test old and new dates
long[] testEpochesInt64 = {1546391837, 1546391837, 0, 123, -12345, -12345678};
diff --git a/src/test/java/net/snowflake/client/core/arrow/VarBinaryToBinaryConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/VarBinaryToBinaryConverterTest.java
index b6ea49f05..231df247c 100644
--- a/src/test/java/net/snowflake/client/core/arrow/VarBinaryToBinaryConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/VarBinaryToBinaryConverterTest.java
@@ -6,8 +6,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.util.ArrayList;
import java.util.Base64;
@@ -25,7 +25,7 @@
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class VarBinaryToBinaryConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/arrow/VarCharConverterTest.java b/src/test/java/net/snowflake/client/core/arrow/VarCharConverterTest.java
index 6569c0309..692e171d0 100644
--- a/src/test/java/net/snowflake/client/core/arrow/VarCharConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/arrow/VarCharConverterTest.java
@@ -6,8 +6,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.nio.charset.StandardCharsets;
import java.sql.Date;
@@ -27,7 +27,7 @@
import org.apache.arrow.vector.types.Types;
import org.apache.arrow.vector.types.pojo.FieldType;
import org.apache.commons.lang3.RandomStringUtils;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class VarCharConverterTest extends BaseConverterTest {
/** allocator for arrow */
diff --git a/src/test/java/net/snowflake/client/core/bind/BindExceptionTest.java b/src/test/java/net/snowflake/client/core/bind/BindExceptionTest.java
index f3ae88eee..d50118ff8 100644
--- a/src/test/java/net/snowflake/client/core/bind/BindExceptionTest.java
+++ b/src/test/java/net/snowflake/client/core/bind/BindExceptionTest.java
@@ -1,9 +1,9 @@
package net.snowflake.client.core.bind;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import net.snowflake.client.jdbc.telemetry.TelemetryField;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class BindExceptionTest {
diff --git a/src/test/java/net/snowflake/client/core/json/BooleanConverterTest.java b/src/test/java/net/snowflake/client/core/json/BooleanConverterTest.java
index 2162d651a..292c3862f 100644
--- a/src/test/java/net/snowflake/client/core/json/BooleanConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/json/BooleanConverterTest.java
@@ -2,10 +2,11 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.sql.Types;
import net.snowflake.client.core.SFException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class BooleanConverterTest {
private final BooleanConverter booleanConverter = new BooleanConverter();
@@ -44,8 +45,8 @@ public void testConvertString() throws SFException {
assertThat(booleanConverter.getBoolean("FALSE", Types.CHAR), equalTo(false));
}
- @Test(expected = SFException.class)
- public void testConvertOtherType() throws SFException {
- booleanConverter.getBoolean("1", Types.BINARY);
+ @Test
+ public void testConvertOtherType() {
+ assertThrows(SFException.class, () -> booleanConverter.getBoolean("1", Types.BINARY));
}
}
diff --git a/src/test/java/net/snowflake/client/core/json/BytesConverterTest.java b/src/test/java/net/snowflake/client/core/json/BytesConverterTest.java
index 47e898486..3f7956ad7 100644
--- a/src/test/java/net/snowflake/client/core/json/BytesConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/json/BytesConverterTest.java
@@ -1,6 +1,6 @@
package net.snowflake.client.core.json;
-import static org.junit.Assert.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import java.math.BigInteger;
import java.nio.ByteBuffer;
@@ -8,7 +8,7 @@
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.SFSession;
import org.apache.arrow.vector.Float8Vector;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class BytesConverterTest {
private final Converters converters =
diff --git a/src/test/java/net/snowflake/client/core/json/DateTimeConverterTest.java b/src/test/java/net/snowflake/client/core/json/DateTimeConverterTest.java
index 985264f3e..21fe82043 100644
--- a/src/test/java/net/snowflake/client/core/json/DateTimeConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/json/DateTimeConverterTest.java
@@ -1,7 +1,7 @@
package net.snowflake.client.core.json;
-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 java.sql.Date;
import java.sql.Time;
@@ -15,7 +15,7 @@
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.SFSession;
import net.snowflake.client.jdbc.SnowflakeUtil;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class DateTimeConverterTest {
private final TimeZone honoluluTimeZone =
diff --git a/src/test/java/net/snowflake/client/core/json/NumberConverterTest.java b/src/test/java/net/snowflake/client/core/json/NumberConverterTest.java
index c37573b72..41f6460b4 100644
--- a/src/test/java/net/snowflake/client/core/json/NumberConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/json/NumberConverterTest.java
@@ -6,7 +6,7 @@
import java.math.BigDecimal;
import java.sql.Types;
import net.snowflake.client.core.SFException;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class NumberConverterTest {
private final NumberConverter numberConverter = new NumberConverter();
diff --git a/src/test/java/net/snowflake/client/core/json/StringConverterTest.java b/src/test/java/net/snowflake/client/core/json/StringConverterTest.java
index 5fe3dd2cb..d2ddb3eee 100644
--- a/src/test/java/net/snowflake/client/core/json/StringConverterTest.java
+++ b/src/test/java/net/snowflake/client/core/json/StringConverterTest.java
@@ -1,6 +1,6 @@
package net.snowflake.client.core.json;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.mock;
import java.sql.Types;
@@ -12,8 +12,8 @@
import net.snowflake.client.jdbc.SnowflakeUtil;
import net.snowflake.common.core.SFBinaryFormat;
import net.snowflake.common.core.SnowflakeDateTimeFormat;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
public class StringConverterTest {
private final TimeZone honoluluTimeZone =
@@ -24,7 +24,7 @@ public class StringConverterTest {
private StringConverter stringConverter;
- @Before
+ @BeforeEach
public void init() {
SnowflakeDateTimeFormat timestampNTZFormatter =
SnowflakeDateTimeFormat.fromSqlFormat("YYYY-MM-DD HH24:MI:SS.FF3");
diff --git a/src/test/java/net/snowflake/client/jdbc/ArrowResultChunkTest.java b/src/test/java/net/snowflake/client/jdbc/ArrowResultChunkTest.java
index 2c37ddf5d..59e2b30a2 100644
--- a/src/test/java/net/snowflake/client/jdbc/ArrowResultChunkTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/ArrowResultChunkTest.java
@@ -6,7 +6,7 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ArrowResultChunkTest {
@Test
diff --git a/src/test/java/net/snowflake/client/jdbc/BaseJDBCTest.java b/src/test/java/net/snowflake/client/jdbc/BaseJDBCTest.java
index a326dea12..c1abedf68 100644
--- a/src/test/java/net/snowflake/client/jdbc/BaseJDBCTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/BaseJDBCTest.java
@@ -3,9 +3,9 @@
*/
package net.snowflake.client.jdbc;
-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.fail;
import java.io.IOException;
import java.io.InputStream;
diff --git a/src/test/java/net/snowflake/client/jdbc/BaseJDBCWithSharedConnectionIT.java b/src/test/java/net/snowflake/client/jdbc/BaseJDBCWithSharedConnectionIT.java
index 5602bffca..f05d45afe 100644
--- a/src/test/java/net/snowflake/client/jdbc/BaseJDBCWithSharedConnectionIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/BaseJDBCWithSharedConnectionIT.java
@@ -2,22 +2,29 @@
import java.sql.Connection;
import java.sql.SQLException;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import java.sql.Statement;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
public class BaseJDBCWithSharedConnectionIT extends BaseJDBCTest {
protected static Connection connection;
- @BeforeClass
+ @BeforeAll
public static void setUpConnection() throws SQLException {
connection = getConnection();
}
- @AfterClass
+ @AfterAll
public static void closeConnection() throws SQLException {
if (connection != null && !connection.isClosed()) {
connection.close();
}
}
+
+ public Statement createStatement(String queryResultFormat) throws SQLException {
+ Statement stmt = connection.createStatement();
+ stmt.execute("alter session set jdbc_query_result_format = '" + queryResultFormat + "'");
+ return stmt;
+ }
}
diff --git a/src/test/java/net/snowflake/client/jdbc/BaseWiremockTest.java b/src/test/java/net/snowflake/client/jdbc/BaseWiremockTest.java
index 5a2fe8e96..f36f55eb5 100644
--- a/src/test/java/net/snowflake/client/jdbc/BaseWiremockTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/BaseWiremockTest.java
@@ -1,12 +1,10 @@
package net.snowflake.client.jdbc;
-import static junit.framework.TestCase.assertEquals;
import static net.snowflake.client.AbstractDriverIT.getConnectionParameters;
import static net.snowflake.client.jdbc.SnowflakeUtil.systemGetProperty;
import static org.awaitility.Awaitility.await;
-import static org.junit.Assume.assumeFalse;
-import static org.junit.Assume.assumeNoException;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+// import static org.junit.jupiter.api.Assumptions.assumeNoException;
import java.io.File;
import java.io.IOException;
@@ -16,9 +14,7 @@
import java.time.Duration;
import java.util.Map;
import java.util.Properties;
-import net.snowflake.client.RunningNotOnGithubActionsMac;
-import net.snowflake.client.RunningNotOnJava21;
-import net.snowflake.client.RunningNotOnJava8;
+import net.snowflake.client.AssumptionUtils;
import net.snowflake.client.core.HttpUtil;
import net.snowflake.client.log.SFLogger;
import net.snowflake.client.log.SFLoggerFactory;
@@ -28,11 +24,12 @@
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeAll;
-public abstract class BaseWiremockTest {
+abstract class BaseWiremockTest {
protected static final SFLogger logger = SFLoggerFactory.getLogger(BaseWiremockTest.class);
protected static final String WIREMOCK_HOME_DIR = ".wiremock";
@@ -45,12 +42,12 @@ public abstract class BaseWiremockTest {
private static String originalTrustStorePath;
protected static Process wiremockStandalone;
- @BeforeClass
+ @BeforeAll
public static void setUpClass() {
- assumeFalse(RunningNotOnJava8.isRunningOnJava8());
- assumeFalse(RunningNotOnJava21.isRunningOnJava21());
- assumeFalse(
- RunningNotOnGithubActionsMac
+ Assumptions.assumeFalse(AssumptionUtils.isRunningOnJava8());
+ Assumptions.assumeFalse(AssumptionUtils.isRunningOnJava21());
+ Assumptions.assumeFalse(
+ AssumptionUtils
.isRunningOnGithubActionsMac()); // disabled until issue with access to localhost
// (https://github.com/snowflakedb/snowflake-jdbc/pull/1807#discussion_r1686229430) is fixed on
// github actions mac image. Ticket to enable when fixed: SNOW-1555950
@@ -58,14 +55,14 @@ public static void setUpClass() {
startWiremockStandAlone();
}
- @After
+ @AfterEach
public void tearDown() {
restoreTrustStorePathProperty();
resetWiremock();
HttpUtil.httpClient.clear();
}
- @AfterClass
+ @AfterAll
public static void tearDownClass() {
stopWiremockStandAlone();
}
@@ -225,10 +222,10 @@ protected void importMapping(String mappingImport) {
HttpPost request = createWiremockPostRequest(mappingImport, "/__admin/mappings/import");
try (CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = httpClient.execute(request)) {
- assumeTrue(response.getStatusLine().getStatusCode() == 200);
+ Assumptions.assumeTrue(response.getStatusLine().getStatusCode() == 200);
} catch (Exception e) {
logger.error("Importing mapping failed", e);
- assumeNoException(e);
+ Assumptions.abort("Importing mapping failed");
}
}
diff --git a/src/test/java/net/snowflake/client/jdbc/BindUploaderIT.java b/src/test/java/net/snowflake/client/jdbc/BindUploaderIT.java
index dec8bd6aa..4fbe0d9fa 100644
--- a/src/test/java/net/snowflake/client/jdbc/BindUploaderIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/BindUploaderIT.java
@@ -4,9 +4,9 @@
package net.snowflake.client.jdbc;
-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 java.math.BigDecimal;
import java.sql.Connection;
@@ -20,18 +20,19 @@
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.ParameterBindingDTO;
import net.snowflake.client.core.SFSession;
import net.snowflake.client.core.bind.BindUploader;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-
-@Category(TestCategoryOthers.class)
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class BindUploaderIT extends BaseJDBCTest {
BindUploader bindUploader;
Connection conn;
@@ -86,21 +87,21 @@ public class BindUploaderIT extends BaseJDBCTest {
+ STAGE_DIR
+ "' ORDER BY $1 ASC";
- @BeforeClass
+ @BeforeAll
public static void classSetUp() throws Exception {
Connection connection = getConnection();
connection.createStatement().execute(createTableSQL);
connection.close();
}
- @AfterClass
+ @AfterAll
public static void classTearDown() throws Exception {
Connection connection = getConnection();
connection.createStatement().execute(deleteTableSQL);
connection.close();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
conn = getConnection();
session = conn.unwrap(SnowflakeConnectionV1.class).getSfSession();
@@ -109,7 +110,7 @@ public void setUp() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
- @After
+ @AfterEach
public void tearDown() throws SQLException {
conn.close();
bindUploader.close();
diff --git a/src/test/java/net/snowflake/client/jdbc/BindUploaderLatestIT.java b/src/test/java/net/snowflake/client/jdbc/BindUploaderLatestIT.java
index 41c409d8b..a5c34ef2b 100644
--- a/src/test/java/net/snowflake/client/jdbc/BindUploaderLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/BindUploaderLatestIT.java
@@ -12,8 +12,8 @@
import static net.snowflake.client.jdbc.BindUploaderIT.getBindings;
import static net.snowflake.client.jdbc.BindUploaderIT.parseRow;
import static net.snowflake.client.jdbc.BindUploaderIT.row1;
-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;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -21,16 +21,16 @@
import java.sql.Statement;
import java.util.Map;
import java.util.TimeZone;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.ParameterBindingDTO;
import net.snowflake.client.core.SFSession;
import net.snowflake.client.core.bind.BindUploader;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Bind Uploader tests for the latest JDBC driver. This doesn't work for the oldest supported
@@ -38,24 +38,25 @@
* tests still is not applicable. If it is applicable, move tests to BindUploaderIT so that both the
* latest and oldest supported driver run the tests.
*/
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class BindUploaderLatestIT extends BaseJDBCTest {
BindUploader bindUploader;
Connection conn;
SFSession session;
TimeZone prevTimeZone; // store last time zone and restore after tests
- @BeforeClass
+ @BeforeAll
public static void classSetUp() throws Exception {
BindUploaderIT.classSetUp();
}
- @AfterClass
+ @AfterAll
public static void classTearDown() throws Exception {
BindUploaderIT.classTearDown();
}
- @Before
+ @BeforeEach
public void setUp() throws Exception {
conn = getConnection();
session = conn.unwrap(SnowflakeConnectionV1.class).getSfSession();
@@ -64,7 +65,7 @@ public void setUp() throws Exception {
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
- @After
+ @AfterEach
public void tearDown() throws SQLException {
conn.close();
bindUploader.close();
diff --git a/src/test/java/net/snowflake/client/jdbc/BindingAndInsertingStructuredTypesLatestIT.java b/src/test/java/net/snowflake/client/jdbc/BindingAndInsertingStructuredTypesLatestIT.java
index a408e5d5a..97ce1b6b8 100644
--- a/src/test/java/net/snowflake/client/jdbc/BindingAndInsertingStructuredTypesLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/BindingAndInsertingStructuredTypesLatestIT.java
@@ -3,11 +3,11 @@
*/
package net.snowflake.client.jdbc;
-import static org.junit.Assert.assertArrayEquals;
-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.assertArrayEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
@@ -30,40 +30,23 @@
import java.util.TimeZone;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryResultSet;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.structs.SnowflakeObjectTypeFactories;
import net.snowflake.client.jdbc.structuredtypes.sqldata.AllTypesClass;
import net.snowflake.client.jdbc.structuredtypes.sqldata.SimpleClass;
-import org.junit.After;
-import org.junit.Assume;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
-@Category(TestCategoryResultSet.class)
+import net.snowflake.client.providers.ResultFormatProvider;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+// @Category(TestCategoryResultSet.class)
+@Tag(TestTags.RESULT_SET)
public class BindingAndInsertingStructuredTypesLatestIT extends BaseJDBCTest {
-
- @Parameterized.Parameters(name = "format={0}")
- public static Object[][] data() {
- return new Object[][] {
- {ResultSetFormatType.JSON},
- {ResultSetFormatType.ARROW_WITH_JSON_STRUCTURED_TYPES},
- {ResultSetFormatType.NATIVE_ARROW}
- };
- }
-
- private final ResultSetFormatType queryResultFormat;
-
- public BindingAndInsertingStructuredTypesLatestIT(ResultSetFormatType queryResultFormat) {
- this.queryResultFormat = queryResultFormat;
- }
-
- public Connection init() throws SQLException {
+ public Connection init(ResultSetFormatType queryResultFormat) throws SQLException {
Connection conn = BaseJDBCTest.getConnection(BaseJDBCTest.DONT_INJECT_SOCKET_TIMEOUT);
try (Statement stmt = conn.createStatement()) {
stmt.execute("alter session set ENABLE_STRUCTURED_TYPES_IN_CLIENT_RESPONSE = true");
@@ -84,25 +67,26 @@ public Connection init() throws SQLException {
return conn;
}
- @Before
+ @BeforeEach
public void setup() {
SnowflakeObjectTypeFactories.register(SimpleClass.class, SimpleClass::new);
SnowflakeObjectTypeFactories.register(AllTypesClass.class, AllTypesClass::new);
}
- @After
+ @AfterEach
public void clean() {
SnowflakeObjectTypeFactories.unregister(SimpleClass.class);
SnowflakeObjectTypeFactories.unregister(AllTypesClass.class);
}
// TODO Structured types feature exists only on QA environments
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteObject() throws SQLException {
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteObject(ResultSetFormatType queryResultFormat) throws SQLException {
SimpleClass sc = new SimpleClass("text1", 2);
SimpleClass sc2 = new SimpleClass("text2", 3);
- try (Connection connection = init()) {
+ try (Connection connection = init(queryResultFormat)) {
Statement statement = connection.createStatement();
statement.execute(
"CREATE OR REPLACE TABLE test_table (ob OBJECT(string varchar, intValue NUMBER))");
@@ -133,11 +117,12 @@ public void testWriteObject() throws SQLException {
}
}
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteNullObject() throws SQLException {
- Assume.assumeTrue(queryResultFormat != ResultSetFormatType.NATIVE_ARROW);
- try (Connection connection = init();
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteNullObject(ResultSetFormatType queryResultFormat) throws SQLException {
+ Assumptions.assumeTrue(queryResultFormat != ResultSetFormatType.NATIVE_ARROW);
+ try (Connection connection = init(queryResultFormat);
Statement statement = connection.createStatement();
SnowflakePreparedStatementV1 stmtement2 =
(SnowflakePreparedStatementV1)
@@ -158,10 +143,12 @@ public void testWriteNullObject() throws SQLException {
}
}
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteObjectBindingNull() throws SQLException {
- try (Connection connection = init();
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteObjectBindingNull(ResultSetFormatType queryResultFormat)
+ throws SQLException {
+ try (Connection connection = init(queryResultFormat);
Statement statement = connection.createStatement();
SnowflakePreparedStatementV1 stmt =
(SnowflakePreparedStatementV1)
@@ -181,11 +168,12 @@ public void testWriteObjectBindingNull() throws SQLException {
}
}
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteObjectAllTypes() throws SQLException {
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteObjectAllTypes(ResultSetFormatType queryResultFormat) throws SQLException {
TimeZone.setDefault(TimeZone.getTimeZone(ZoneOffset.UTC));
- try (Connection connection = init();
+ try (Connection connection = init(queryResultFormat);
Statement statement = connection.createStatement();
SnowflakePreparedStatementV1 stmt =
(SnowflakePreparedStatementV1)
@@ -271,10 +259,11 @@ public static Timestamp toTimestamp(ZonedDateTime dateTime) {
return new Timestamp(dateTime.toInstant().getEpochSecond() * 1000L);
}
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteArray() throws SQLException {
- try (Connection connection = init();
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteArray(ResultSetFormatType queryResultFormat) throws SQLException {
+ try (Connection connection = init(queryResultFormat);
Statement statement = connection.createStatement();
SnowflakePreparedStatementV1 stmt =
(SnowflakePreparedStatementV1)
@@ -298,10 +287,11 @@ public void testWriteArray() throws SQLException {
}
}
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteArrayNoBinds() throws SQLException {
- try (Connection connection = init();
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteArrayNoBinds(ResultSetFormatType queryResultFormat) throws SQLException {
+ try (Connection connection = init(queryResultFormat);
Statement statement = connection.createStatement();
SnowflakePreparedStatementV1 stmt =
(SnowflakePreparedStatementV1)
@@ -322,10 +312,11 @@ public void testWriteArrayNoBinds() throws SQLException {
}
}
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteMapOfSqlData() throws SQLException {
- try (Connection connection = init();
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteMapOfSqlData(ResultSetFormatType queryResultFormat) throws SQLException {
+ try (Connection connection = init(queryResultFormat);
Statement statement = connection.createStatement();
SnowflakePreparedStatementV1 stmt =
(SnowflakePreparedStatementV1)
@@ -358,10 +349,11 @@ public void testWriteMapOfSqlData() throws SQLException {
}
}
- @Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
- public void testWriteMapOfInteger() throws SQLException {
- try (Connection connection = init();
+ @ParameterizedTest
+ @ArgumentsSource(ResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testWriteMapOfInteger(ResultSetFormatType queryResultFormat) throws SQLException {
+ try (Connection connection = init(queryResultFormat);
Statement statement = connection.createStatement();
SnowflakePreparedStatementV1 stmt =
(SnowflakePreparedStatementV1)
diff --git a/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java b/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java
index c2a8bc3ee..ce50540de 100644
--- a/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java
@@ -6,8 +6,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.nullValue;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Date;
import java.sql.PreparedStatement;
@@ -18,21 +18,38 @@
import java.sql.Types;
import java.util.Calendar;
import java.util.TimeZone;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.experimental.theories.DataPoints;
-import org.junit.experimental.theories.Theories;
-import org.junit.experimental.theories.Theory;
-import org.junit.runner.RunWith;
+import java.util.stream.Stream;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+import org.junit.jupiter.params.provider.ValueSource;
/** Integration tests for binding variable */
-@RunWith(Theories.class)
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class BindingDataIT extends BaseJDBCWithSharedConnectionIT {
- @DataPoints public static short[] shortValues = {0, 1, -1, Short.MIN_VALUE, Short.MAX_VALUE};
+ static TimeZone timeZone;
- @Theory
+ @BeforeAll
+ public static void setTimeZone() {
+ timeZone = TimeZone.getDefault();
+ TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
+ }
+
+ @AfterAll
+ public static void resetTimeZone() {
+ TimeZone.setDefault(timeZone);
+ }
+
+ @ParameterizedTest
+ @ValueSource(shorts = {0, 1, -1, Short.MIN_VALUE, Short.MAX_VALUE})
public void testBindShort(short shortValue) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -58,7 +75,8 @@ public void testBindShort(short shortValue) throws SQLException {
}
}
- @Theory
+ @ParameterizedTest
+ @ValueSource(shorts = {0, 1, -1, Short.MIN_VALUE, Short.MAX_VALUE})
public void testBindShortViaSetObject(short shortValue) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -84,9 +102,8 @@ public void testBindShortViaSetObject(short shortValue) throws SQLException {
}
}
- @DataPoints public static int[] intValues = {0, 1, -1, Integer.MAX_VALUE, Integer.MIN_VALUE};
-
- @Theory
+ @ParameterizedTest
+ @ValueSource(ints = {0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE})
public void testBindInt(int intValue) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -113,9 +130,8 @@ public void testBindInt(int intValue) throws SQLException {
}
}
- @DataPoints public static byte[] byteValues = {0, 1, -1, Byte.MAX_VALUE, Byte.MIN_VALUE};
-
- @Theory
+ @ParameterizedTest
+ @ValueSource(bytes = {0, 1, -1, Byte.MAX_VALUE, Byte.MIN_VALUE})
public void testBindByte(byte byteValue) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -184,18 +200,21 @@ public void testBindNull() throws SQLException {
}
}
- @DataPoints
- public static Time[] timeValues = {
- Time.valueOf("00:00:00"),
- Time.valueOf("12:34:56"),
- Time.valueOf("12:00:00"),
- Time.valueOf("11:59:59"),
- Time.valueOf("15:30:00"),
- Time.valueOf("13:01:01"),
- Time.valueOf("12:00:00"),
- };
-
- @Theory
+ static class TimeProvider implements ArgumentsProvider {
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ return Stream.of(
+ Arguments.of(Time.valueOf("00:00:00")),
+ Arguments.of(Time.valueOf("12:34:56")),
+ Arguments.of(Time.valueOf("12:00:00")),
+ Arguments.of(Time.valueOf("11:59:59")),
+ Arguments.of(Time.valueOf("15:30:00")),
+ Arguments.of(Time.valueOf("13:01:01")));
+ }
+ }
+
+ @ParameterizedTest
+ @ArgumentsSource(TimeProvider.class)
public void testBindTime(Time timeVal) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -225,7 +244,8 @@ public void testBindTime(Time timeVal) throws SQLException {
* Bind time with calendar is not supported now. Everything is in UTC, need to revisit in the
* future
*/
- @Theory
+ @ParameterizedTest
+ @ArgumentsSource(TimeProvider.class)
public void testBindTimeWithCalendar(Time timeVal) throws SQLException {
Calendar utcCal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Calendar laCal = Calendar.getInstance(TimeZone.getTimeZone("PST"));
@@ -256,7 +276,8 @@ public void testBindTimeWithCalendar(Time timeVal) throws SQLException {
}
}
- @Theory
+ @ParameterizedTest
+ @ArgumentsSource(TimeProvider.class)
public void testBindTimeViaSetObject(Time timeVal) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -282,7 +303,8 @@ public void testBindTimeViaSetObject(Time timeVal) throws SQLException {
}
}
- @Theory
+ @ParameterizedTest
+ @ArgumentsSource(TimeProvider.class)
public void testBindTimeViaSetObjectCast(Time timeVal) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -308,18 +330,22 @@ public void testBindTimeViaSetObjectCast(Time timeVal) throws SQLException {
}
}
- @DataPoints
- public static Date[] dateValues = {
- Date.valueOf("2000-01-01"),
- Date.valueOf("3000-01-01"),
- Date.valueOf("1970-01-01"),
- Date.valueOf("1969-01-01"),
- Date.valueOf("1500-01-01"),
- Date.valueOf("1400-01-01"),
- Date.valueOf("1000-01-01")
- };
-
- @Theory
+ static class DateProvider implements ArgumentsProvider {
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ return Stream.of(
+ Arguments.of(Date.valueOf("2000-01-01")),
+ Arguments.of(Date.valueOf("3000-01-01")),
+ Arguments.of(Date.valueOf("1970-01-01")),
+ Arguments.of(Date.valueOf("1969-01-01")),
+ Arguments.of(Date.valueOf("1500-01-01")),
+ Arguments.of(Date.valueOf("1400-01-01")),
+ Arguments.of(Date.valueOf("1000-01-01")));
+ }
+ }
+
+ @ParameterizedTest
+ @ArgumentsSource(DateProvider.class)
public void testBindDate(Date dateValue) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -346,7 +372,8 @@ public void testBindDate(Date dateValue) throws SQLException {
}
}
- @Theory
+ @ParameterizedTest
+ @ArgumentsSource(DateProvider.class)
public void testBindDateWithCalendar(Date dateValue) throws SQLException {
Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
@@ -375,7 +402,8 @@ public void testBindDateWithCalendar(Date dateValue) throws SQLException {
}
}
- @Theory
+ @ParameterizedTest
+ @ValueSource(ints = {0, 1, -1, Integer.MIN_VALUE, Integer.MAX_VALUE})
public void testBindObjectWithScaleZero(int intValue) throws SQLException {
try (Statement statement = connection.createStatement()) {
try {
@@ -429,7 +457,7 @@ public void testBindNullForAllTypes() throws Throwable {
while (result.next()) {
String testType = result.getString(1);
for (int i = 2; i <= 13; ++i) {
- assertNull(String.format("Java Type: %s is not null", testType), result.getString(i));
+ assertNull(result.getString(i), String.format("Java Type: %s is not null", testType));
}
}
}
diff --git a/src/test/java/net/snowflake/client/jdbc/BindingDataLatestIT.java b/src/test/java/net/snowflake/client/jdbc/BindingDataLatestIT.java
index 71c556686..4ba35a672 100644
--- a/src/test/java/net/snowflake/client/jdbc/BindingDataLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/BindingDataLatestIT.java
@@ -5,8 +5,8 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.Connection;
import java.sql.PreparedStatement;
@@ -17,11 +17,10 @@
import java.util.Calendar;
import java.util.TimeZone;
import net.snowflake.client.AbstractDriverIT;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Binding Data integration tests for the latest JDBC driver. This doesn't work for the oldest
@@ -29,7 +28,8 @@
* to examine if the tests still are not applicable. If it is applicable, move tests to
* BindingDataIT so that both the latest and oldest supported driver run the tests.
*/
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class BindingDataLatestIT extends AbstractDriverIT {
TimeZone origTz = TimeZone.getDefault();
TimeZone tokyoTz = TimeZone.getTimeZone("Asia/Tokyo");
@@ -67,7 +67,7 @@ public void testBindTimestampTZ() throws SQLException {
* @throws SQLException
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testTimestampBindingWithNTZType() throws SQLException {
TimeZone.setDefault(tokyoTz);
try (Connection connection = getConnection();
@@ -124,7 +124,7 @@ public void testTimestampBindingWithNTZType() throws SQLException {
* @throws SQLException
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testTimestampBindingWithLTZType() throws SQLException {
TimeZone.setDefault(tokyoTz);
try (Connection connection = getConnection();
@@ -188,7 +188,7 @@ public void testTimestampBindingWithLTZType() throws SQLException {
* @throws SQLException
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testTimestampBindingWithLTZTypeForDayLightSavingTimeZone() throws SQLException {
Calendar australia = Calendar.getInstance(australiaTz);
TimeZone.setDefault(australiaTz);
diff --git a/src/test/java/net/snowflake/client/jdbc/CallableStatementIT.java b/src/test/java/net/snowflake/client/jdbc/CallableStatementIT.java
index d6536dc93..0fe155727 100644
--- a/src/test/java/net/snowflake/client/jdbc/CallableStatementIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/CallableStatementIT.java
@@ -5,8 +5,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.math.BigDecimal;
import java.net.URL;
@@ -15,74 +15,27 @@
import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.Calendar;
import java.util.HashMap;
-import net.snowflake.client.category.TestCategoryStatement;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import net.snowflake.client.category.TestTags;
+import net.snowflake.client.providers.SimpleResultFormatProvider;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
-@Category(TestCategoryStatement.class)
-public class CallableStatementIT extends BaseJDBCTest {
- @Parameterized.Parameters
- public static Object[][] data() {
- // all tests in this class need to run for both query result formats json and arrow
- return new Object[][] {{"JSON"}, {"arrow"}};
- }
-
- private static String queryResultFormat;
-
- public CallableStatementIT(String format) {
- queryResultFormat = format;
- }
-
- public static Connection getConnection() throws SQLException {
- Connection conn = BaseJDBCTest.getConnection();
- try (Statement stmt = conn.createStatement()) {
- stmt.execute("alter session set jdbc_query_result_format = '" + queryResultFormat + "'");
- }
- return conn;
- }
-
- private final String createStoredProcedure =
- "create or replace procedure square_it(num FLOAT) returns float not "
- + "null language javascript as $$ return NUM * NUM; $$";
- private final String createSecondStoredProcedure =
- "create or replace procedure add_nums(x DOUBLE, y DOUBLE) "
- + "returns double not null language javascript as $$ return X + Y; $$";
- private final String deleteStoredProcedure = "drop procedure if exists square_it(FLOAT)";
- private final String deleteSecondStoredProcedure = "drop procedure if exists add_nums(INT, INT)";
+// @Category(TestCategoryStatement.class)
+@Tag(TestTags.STATEMENT)
+public class CallableStatementIT extends CallableStatementITBase {
- @Before
- public void setUp() throws SQLException {
- try (Connection con = getConnection();
- Statement statement = con.createStatement()) {
- statement.execute(createStoredProcedure);
- statement.execute(createSecondStoredProcedure);
- }
- }
-
- @After
- public void tearDown() throws SQLException {
- try (Connection con = getConnection();
- Statement statement = con.createStatement()) {
- statement.execute(deleteStoredProcedure);
- statement.execute(deleteSecondStoredProcedure);
- }
- }
-
- @Test
- public void testPrepareCall() throws SQLException {
+ @ParameterizedTest
+ @ArgumentsSource(SimpleResultFormatProvider.class)
+ public void testPrepareCall(String queryResultFormat) throws SQLException {
// test CallableStatement with no binding parameters
- try (Connection connection = getConnection()) {
+ try (Connection connection = getConnection(queryResultFormat)) {
try (CallableStatement callableStatement = connection.prepareCall("call square_it(5)")) {
assertThat(callableStatement.getParameterMetaData().getParameterCount(), is(0));
}
diff --git a/src/test/java/net/snowflake/client/jdbc/CallableStatementITBase.java b/src/test/java/net/snowflake/client/jdbc/CallableStatementITBase.java
new file mode 100644
index 000000000..8635d4246
--- /dev/null
+++ b/src/test/java/net/snowflake/client/jdbc/CallableStatementITBase.java
@@ -0,0 +1,48 @@
+package net.snowflake.client.jdbc;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.sql.Statement;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+
+public class CallableStatementITBase extends BaseJDBCTest {
+ public static Connection getConnection() throws SQLException {
+ return BaseJDBCTest.getConnection();
+ }
+
+ public static Connection getConnection(String queryResultFormat) throws SQLException {
+ Connection conn = BaseJDBCTest.getConnection();
+ try (Statement stmt = conn.createStatement()) {
+ stmt.execute("alter session set jdbc_query_result_format = '" + queryResultFormat + "'");
+ }
+ return conn;
+ }
+
+ private final String createStoredProcedure =
+ "create or replace procedure square_it(num FLOAT) returns float not "
+ + "null language javascript as $$ return NUM * NUM; $$";
+ private final String createSecondStoredProcedure =
+ "create or replace procedure add_nums(x DOUBLE, y DOUBLE) "
+ + "returns double not null language javascript as $$ return X + Y; $$";
+ private final String deleteStoredProcedure = "drop procedure if exists square_it(FLOAT)";
+ private final String deleteSecondStoredProcedure = "drop procedure if exists add_nums(INT, INT)";
+
+ @BeforeEach
+ public void setUp() throws SQLException {
+ try (Connection con = getConnection();
+ Statement statement = con.createStatement()) {
+ statement.execute(createStoredProcedure);
+ statement.execute(createSecondStoredProcedure);
+ }
+ }
+
+ @AfterEach
+ public void tearDown() throws SQLException {
+ try (Connection con = getConnection();
+ Statement statement = con.createStatement()) {
+ statement.execute(deleteStoredProcedure);
+ statement.execute(deleteSecondStoredProcedure);
+ }
+ }
+}
diff --git a/src/test/java/net/snowflake/client/jdbc/CallableStatementLatestIT.java b/src/test/java/net/snowflake/client/jdbc/CallableStatementLatestIT.java
index a4aaea709..54a9f304e 100644
--- a/src/test/java/net/snowflake/client/jdbc/CallableStatementLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/CallableStatementLatestIT.java
@@ -2,24 +2,24 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-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 java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
-import net.snowflake.client.category.TestCategoryStatement;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.category.TestTags;
+import net.snowflake.client.providers.SimpleResultFormatProvider;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@Category(TestCategoryStatement.class)
-public class CallableStatementLatestIT extends CallableStatementIT {
-
- public CallableStatementLatestIT(String format) {
- super(format);
- }
+// @Category(TestCategoryStatement.class)
+@Tag(TestTags.STATEMENT)
+public class CallableStatementLatestIT extends CallableStatementITBase {
/**
* Test that function that removes curly brackets from outside of call statements works properly
@@ -44,10 +44,11 @@ public void testParseSqlEscapeSyntaxFunction() {
*
* @throws SQLException
*/
- @Test
- public void testPrepareCallWithCurlyBracketSyntax() throws SQLException {
+ @ParameterizedTest
+ @ArgumentsSource(SimpleResultFormatProvider.class)
+ public void testPrepareCallWithCurlyBracketSyntax(String queryResultFormat) throws SQLException {
// test CallableStatement with no binding parameters
- try (Connection connection = getConnection()) {
+ try (Connection connection = getConnection(queryResultFormat)) {
try (CallableStatement callableStatement = connection.prepareCall("{call square_it(5)}")) {
assertThat(callableStatement.getParameterMetaData().getParameterCount(), is(0));
}
diff --git a/src/test/java/net/snowflake/client/jdbc/ChunkDownloaderS3RetryUrlLatestIT.java b/src/test/java/net/snowflake/client/jdbc/ChunkDownloaderS3RetryUrlLatestIT.java
index cfb8e086d..2cb847e6b 100644
--- a/src/test/java/net/snowflake/client/jdbc/ChunkDownloaderS3RetryUrlLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ChunkDownloaderS3RetryUrlLatestIT.java
@@ -3,7 +3,7 @@
*/
package net.snowflake.client.jdbc;
-import static org.junit.Assert.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertFalse;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -12,7 +12,7 @@
import java.util.List;
import java.util.Map;
import net.snowflake.client.AbstractDriverIT;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.ExecTimeTelemetryData;
import net.snowflake.client.core.HttpUtil;
import net.snowflake.client.core.SFBaseSession;
@@ -20,18 +20,19 @@
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.CloseableHttpClient;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class ChunkDownloaderS3RetryUrlLatestIT extends AbstractDriverIT {
private SFStatement sfStatement;
private SFBaseSession sfBaseSession;
private ChunkDownloadContext sfContext;
- @Before
+ @BeforeEach
public void setup() throws SQLException, InterruptedException {
try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
diff --git a/src/test/java/net/snowflake/client/jdbc/ClientMemoryLimitParallelIT.java b/src/test/java/net/snowflake/client/jdbc/ClientMemoryLimitParallelIT.java
index 56d954653..d7179e130 100644
--- a/src/test/java/net/snowflake/client/jdbc/ClientMemoryLimitParallelIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ClientMemoryLimitParallelIT.java
@@ -1,26 +1,27 @@
package net.snowflake.client.jdbc;
import static net.snowflake.client.AbstractDriverIT.getConnection;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author azhan attempts to test the CLIENT_MEMORY_LIMIT working in multi-threading
*/
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class ClientMemoryLimitParallelIT extends BaseJDBCWithSharedConnectionIT {
private static Logger LOGGER =
LoggerFactory.getLogger(ClientMemoryLimitParallelIT.class.getName());
@@ -62,14 +63,14 @@ public class ClientMemoryLimitParallelIT extends BaseJDBCWithSharedConnectionIT
+ rowCount
+ "));";
- @Before
+ @BeforeEach
public void setUp() throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute(createTestTableSQL);
}
}
- @After
+ @AfterEach
public void tearDown() throws SQLException {
try (Statement statement = connection.createStatement()) {
statement.execute("drop table if exists testtable_cml");
@@ -81,8 +82,8 @@ public void tearDown() throws SQLException {
* in multi-threading
*/
@Test
- @Ignore("Long term high memory usage test")
- public void testParallelQueries() throws Exception {
+ @Disabled("Long term high memory usage test")
+ void testParallelQueries() throws Exception {
Runnable testQuery =
new Runnable() {
public void run() {
@@ -122,8 +123,7 @@ public void run() {
* make sure there is no hanging
*/
@Test
- public void testQueryNotHanging() throws SQLException {
- Properties paramProperties = new Properties();
+ void testQueryNotHanging() throws SQLException {
try (Statement statement = connection.createStatement()) {
queryRows(statement, 100, 160);
}
diff --git a/src/test/java/net/snowflake/client/jdbc/CompressedStreamFactoryTest.java b/src/test/java/net/snowflake/client/jdbc/CompressedStreamFactoryTest.java
index 86eb5764a..0c3f69470 100644
--- a/src/test/java/net/snowflake/client/jdbc/CompressedStreamFactoryTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/CompressedStreamFactoryTest.java
@@ -1,7 +1,7 @@
package net.snowflake.client.jdbc;
-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 com.github.luben.zstd.ZstdInputStream;
import com.github.luben.zstd.ZstdOutputStream;
@@ -14,7 +14,7 @@
import org.apache.commons.io.IOUtils;
import org.apache.http.Header;
import org.apache.http.message.BasicHeader;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class CompressedStreamFactoryTest {
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectStringParseTest.java b/src/test/java/net/snowflake/client/jdbc/ConnectStringParseTest.java
index 871a6cfcd..c2f7eeb5c 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectStringParseTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectStringParseTest.java
@@ -2,11 +2,11 @@
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Properties;
import net.snowflake.client.core.SFSessionProperty;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class ConnectStringParseTest {
@Test
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionAlreadyClosedIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionAlreadyClosedIT.java
index fd0b69488..89b57f558 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectionAlreadyClosedIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectionAlreadyClosedIT.java
@@ -5,11 +5,12 @@
import java.sql.Connection;
import java.util.Properties;
-import net.snowflake.client.category.TestCategoryConnection;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(TestCategoryConnection.class)
+// @Category(TestCategoryConnection.class)
+@Tag(TestTags.CONNECTION)
public class ConnectionAlreadyClosedIT extends BaseJDBCTest {
@Test
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionFeatureNotSupportedIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionFeatureNotSupportedIT.java
index f91eee092..6881d7327 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectionFeatureNotSupportedIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectionFeatureNotSupportedIT.java
@@ -8,11 +8,12 @@
import java.sql.SQLException;
import java.sql.Savepoint;
import java.util.HashMap;
-import net.snowflake.client.category.TestCategoryConnection;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(TestCategoryConnection.class)
+// @Category(TestCategoryConnection.class)
+@Tag(TestTags.CONNECTION)
public class ConnectionFeatureNotSupportedIT extends BaseJDBCTest {
@Test
public void testFeatureNotSupportedException() throws Throwable {
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java
index 00656e305..244a478c7 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectionIT.java
@@ -8,11 +8,11 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.Assume.assumeTrue;
+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.fail;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
import java.io.File;
import java.io.FileInputStream;
@@ -42,23 +42,22 @@
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import net.snowflake.client.ConditionalIgnoreRule.ConditionalIgnore;
-import net.snowflake.client.RunningNotOnTestaccount;
-import net.snowflake.client.RunningOnGithubAction;
+import net.snowflake.client.AssumptionUtils;
import net.snowflake.client.TestUtil;
-import net.snowflake.client.category.TestCategoryConnection;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.annotations.RunOnTestaccount;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.SFSession;
import net.snowflake.common.core.SqlState;
import org.apache.commons.codec.binary.Base64;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
/** Connection integration tests */
-@Category(TestCategoryConnection.class)
+// @Category(TestCategoryConnection.class)
+@Tag(TestTags.CONNECTION)
public class ConnectionIT extends BaseJDBCWithSharedConnectionIT {
// create a local constant for this code for testing purposes (already defined in GS)
public static final int INVALID_CONNECTION_INFO_CODE = 390100;
@@ -70,7 +69,7 @@ public class ConnectionIT extends BaseJDBCWithSharedConnectionIT {
String errorMessage = null;
- @Rule public TemporaryFolder tmpFolder = new TemporaryFolder();
+ @TempDir private File tmpFolder;
@Test
public void testSimpleConnection() throws SQLException {
@@ -86,7 +85,7 @@ public void testSimpleConnection() throws SQLException {
}
@Test
- @Ignore
+ @Disabled
public void test300ConnectionsWithSingleClientInstance() throws SQLException {
// concurrent testing
int size = 300;
@@ -214,7 +213,7 @@ public void testDataCompletenessInLowMemory() throws Exception {
}
@Test
- @ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testConnectionGetAndSetDBAndSchema() throws SQLException {
final String SECOND_DATABASE = "SECOND_DATABASE";
final String SECOND_SCHEMA = "SECOND_SCHEMA";
@@ -350,7 +349,7 @@ public void testConnectViaDataSource() throws SQLException {
}
@Test
- @Ignore
+ @Disabled
public void testDataSourceOktaSerialization() throws Exception {
// test with username/password authentication
// set up DataSource object and ensure connection works
@@ -368,7 +367,8 @@ public void testDataSourceOktaSerialization() throws Exception {
ResultSet resultSet = statement.executeQuery("select 1")) {
resultSet.next();
assertThat("select 1", resultSet.getInt(1), equalTo(1));
- File serializedFile = tmpFolder.newFile("serializedStuff.ser");
+ File serializedFile = new File(tmpFolder, "serializedStuff.ser");
+ serializedFile.createNewFile();
// serialize datasource object into a file
try (FileOutputStream outputFile = new FileOutputStream(serializedFile);
ObjectOutputStream out = new ObjectOutputStream(outputFile)) {
@@ -391,7 +391,7 @@ public void testDataSourceOktaSerialization() throws Exception {
}
@Test
- @ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testConnectUsingKeyPair() throws Exception {
Map parameters = getConnectionParameters();
String testUser = parameters.get("user");
@@ -449,7 +449,7 @@ public void testConnectUsingKeyPair() throws Exception {
DriverManager.getConnection(uri, properties);
fail();
} catch (SQLException e) {
- Assert.assertEquals(390144, e.getErrorCode());
+ assertEquals(390144, e.getErrorCode());
}
// test multiple key pair
try (Connection connection = getConnection();
@@ -506,7 +506,7 @@ public void testBadPrivateKey() throws Exception {
}
@Test
- @ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDifferentKeyLength() throws Exception {
Map parameters = getConnectionParameters();
String testUser = parameters.get("user");
@@ -840,7 +840,7 @@ public void testResultSetsClosedByStatement() throws SQLException {
}
@Test
- @ConditionalIgnore(condition = RunningNotOnTestaccount.class)
+ @RunOnTestaccount
public void testOKTAConnection() throws Throwable {
Map params = getConnectionParameters();
Properties properties = new Properties();
@@ -857,7 +857,7 @@ public void testOKTAConnection() throws Throwable {
}
@Test
- @ConditionalIgnore(condition = RunningNotOnTestaccount.class)
+ @RunOnTestaccount
public void testOKTAConnectionWithOktauserParam() throws Throwable {
Map params = getConnectionParameters();
Properties properties = new Properties();
@@ -888,7 +888,7 @@ public void testValidateDefaultParameters() throws Throwable {
fail("should fail");
} catch (SQLException ex) {
assertEquals(
- "error code", ex.getErrorCode(), SESSION_CREATION_OBJECT_DOES_NOT_EXIST_NOT_AUTHORIZED);
+ ex.getErrorCode(), SESSION_CREATION_OBJECT_DOES_NOT_EXIST_NOT_AUTHORIZED, "error code");
}
// schema is invalid
@@ -899,7 +899,7 @@ public void testValidateDefaultParameters() throws Throwable {
fail("should fail");
} catch (SQLException ex) {
assertEquals(
- "error code", ex.getErrorCode(), SESSION_CREATION_OBJECT_DOES_NOT_EXIST_NOT_AUTHORIZED);
+ ex.getErrorCode(), SESSION_CREATION_OBJECT_DOES_NOT_EXIST_NOT_AUTHORIZED, "error code");
}
// warehouse is invalid
@@ -910,7 +910,7 @@ public void testValidateDefaultParameters() throws Throwable {
fail("should fail");
} catch (SQLException ex) {
assertEquals(
- "error code", ex.getErrorCode(), SESSION_CREATION_OBJECT_DOES_NOT_EXIST_NOT_AUTHORIZED);
+ ex.getErrorCode(), SESSION_CREATION_OBJECT_DOES_NOT_EXIST_NOT_AUTHORIZED, "error code");
}
// role is invalid
@@ -920,7 +920,7 @@ public void testValidateDefaultParameters() throws Throwable {
DriverManager.getConnection(params.get("uri"), props);
fail("should fail");
} catch (SQLException ex) {
- assertEquals("error code", ex.getErrorCode(), ROLE_IN_CONNECT_STRING_DOES_NOT_EXIST);
+ assertEquals(ex.getErrorCode(), ROLE_IN_CONNECT_STRING_DOES_NOT_EXIST, "error code");
}
}
@@ -950,7 +950,7 @@ public void testNoValidateDefaultParameters() throws Throwable {
DriverManager.getConnection(params.get("uri"), props);
fail("should fail");
} catch (SQLException ex) {
- assertEquals("error code", ex.getErrorCode(), ROLE_IN_CONNECT_STRING_DOES_NOT_EXIST);
+ assertEquals(ex.getErrorCode(), ROLE_IN_CONNECT_STRING_DOES_NOT_EXIST, "error code");
}
}
@@ -961,7 +961,7 @@ public void testNoValidateDefaultParameters() throws Throwable {
*
* @throws SQLException
*/
- @Ignore
+ @Disabled
@Test
public void testOrgAccountUrl() throws SQLException {
Properties props = new Properties();
@@ -987,7 +987,7 @@ public void testOrgAccountUrl() throws SQLException {
* @throws SQLException
* @throws NoSuchAlgorithmException
*/
- @Ignore
+ @Disabled
@Test
public void testOrgAccountUrlWithKeyPair() throws SQLException, NoSuchAlgorithmException {
@@ -1042,7 +1042,7 @@ private Properties setCommonConnectionParameters(boolean validateDefaultParamete
@Test
public void testFailOverOrgAccount() throws SQLException {
// only when set_git_info.sh picks up a SOURCE_PARAMETER_FILE
- assumeTrue(RunningOnGithubAction.isRunningOnGithubAction());
+ assumeTrue(AssumptionUtils.isRunningOnGithubAction());
Map kvParams = getConnectionParameters(null, "ORG");
Properties connProps = kvMap2Properties(kvParams, false);
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java
index 4dbbcb021..c8886231c 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectionLatestIT.java
@@ -14,13 +14,13 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.core.AnyOf.anyOf;
-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.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.assertNotEquals;
+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;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -51,11 +51,10 @@
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import javax.net.ssl.SSLHandshakeException;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningNotOnAWS;
-import net.snowflake.client.RunningOnGithubAction;
import net.snowflake.client.TestUtil;
-import net.snowflake.client.category.TestCategoryConnection;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.annotations.RunOnAWS;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.HttpClientSettingsKey;
import net.snowflake.client.core.HttpUtil;
import net.snowflake.client.core.ObjectMapperFactory;
@@ -73,13 +72,12 @@
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-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.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
/**
* Connection integration tests for the latest JDBC driver. This doesn't work for the oldest
@@ -87,14 +85,15 @@
* if the tests still is not applicable. If it is applicable, move tests to ConnectionIT so that
* both the latest and oldest supported driver run the tests.
*/
-@Category(TestCategoryConnection.class)
+// @Category(TestCategoryConnection.class)
+@Tag(TestTags.CONNECTION)
public class ConnectionLatestIT extends BaseJDBCTest {
- @Rule public TemporaryFolder tmpFolder = new TemporaryFolder();
+ @TempDir private File tmpFolder;
private static final SFLogger logger = SFLoggerFactory.getLogger(ConnectionLatestIT.class);
private boolean defaultState;
- @Before
+ @BeforeEach
public void setUp() {
TelemetryService service = TelemetryService.getInstance();
service.updateContextForIT(getConnectionParameters());
@@ -103,7 +102,7 @@ public void setUp() {
TelemetryService.enable();
}
- @After
+ @AfterEach
public void tearDown() throws InterruptedException {
TelemetryService service = TelemetryService.getInstance();
// wait 5 seconds while the service is flushing
@@ -193,12 +192,13 @@ public void testHeartbeatFrequencyTooSmall() throws Exception {
* @throws Throwable
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void putGetStatementsHaveQueryID() throws Throwable {
try (Connection con = getConnection();
Statement statement = con.createStatement()) {
String sourceFilePath = getFullPathFileInResource(TEST_DATA_FILE);
- File destFolder = tmpFolder.newFolder();
+ File destFolder = new File(tmpFolder, "dest");
+ destFolder.mkdirs();
String destFolderCanonicalPath = destFolder.getCanonicalPath();
statement.execute("CREATE OR REPLACE STAGE testPutGet_stage");
SnowflakeStatement snowflakeStatement = statement.unwrap(SnowflakeStatement.class);
@@ -210,7 +210,7 @@ public void putGetStatementsHaveQueryID() throws Throwable {
String statementPutQueryId = snowflakeStatement.getQueryID();
TestUtil.assertValidQueryId(statementPutQueryId);
assertNotEquals(
- "create query id is override by put query id", createStageQueryId, statementPutQueryId);
+ createStageQueryId, statementPutQueryId, "create query id is override by put query id");
resultSetPutQueryId = resultSet.unwrap(SnowflakeResultSet.class).getQueryID();
TestUtil.assertValidQueryId(resultSetPutQueryId);
assertEquals(resultSetPutQueryId, statementPutQueryId);
@@ -222,7 +222,7 @@ public void putGetStatementsHaveQueryID() throws Throwable {
String resultSetGetQueryId = resultSet.unwrap(SnowflakeResultSet.class).getQueryID();
TestUtil.assertValidQueryId(resultSetGetQueryId);
assertNotEquals(
- "put and get query id should be different", resultSetGetQueryId, resultSetPutQueryId);
+ resultSetGetQueryId, resultSetPutQueryId, "put and get query id should be different");
assertEquals(resultSetGetQueryId, statementGetQueryId);
}
}
@@ -230,12 +230,13 @@ public void putGetStatementsHaveQueryID() throws Throwable {
/** Added in > 3.14.4 */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void putGetStatementsHaveQueryIDEvenWhenFail() throws Throwable {
try (Connection con = getConnection();
Statement statement = con.createStatement()) {
String sourceFilePath = getFullPathFileInResource(TEST_DATA_FILE);
- File destFolder = tmpFolder.newFolder();
+ File destFolder = new File(tmpFolder, "dest");
+ destFolder.mkdirs();
String destFolderCanonicalPath = destFolder.getCanonicalPath();
SnowflakeStatement snowflakeStatement = statement.unwrap(SnowflakeStatement.class);
try {
@@ -255,7 +256,7 @@ public void putGetStatementsHaveQueryIDEvenWhenFail() throws Throwable {
assertEquals(snowflakeStatement.getQueryID(), e.getQueryId());
}
String getQueryId = snowflakeStatement.getQueryID();
- assertNotEquals("put and get query id should be different", putQueryId, getQueryId);
+ assertNotEquals(putQueryId, getQueryId, "put and get query id should be different");
String stageName = "stage_" + SnowflakeUtil.randomAlphaNumeric(10);
statement.execute("CREATE OR REPLACE STAGE " + stageName);
TestUtil.assertValidQueryId(snowflakeStatement.getQueryID());
@@ -719,7 +720,7 @@ public void testHttpsLoginTimeoutWithSSL() throws InterruptedException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testKeyPairFileDataSourceSerialization() throws Exception {
// test with key/pair authentication where key is in file
// set up DataSource object and ensure connection works
@@ -739,7 +740,8 @@ public void testKeyPairFileDataSourceSerialization() throws Exception {
connectAndExecuteSelect1(ds);
- File serializedFile = tmpFolder.newFile("serializedStuff.ser");
+ File serializedFile = new File(tmpFolder, "serializedStuff.ser");
+ serializedFile.createNewFile();
// serialize datasource object into a file
try (FileOutputStream outputFile = new FileOutputStream(serializedFile);
ObjectOutputStream out = new ObjectOutputStream(outputFile)) {
@@ -764,7 +766,7 @@ private static String readPrivateKeyFileToBase64Content(String fileName) throws
/** Works in > 3.18.0 */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testKeyPairBase64DataSourceSerialization() throws Exception {
// test with key/pair authentication where key is passed as a Base64 string value
// set up DataSource object and ensure connection works
@@ -784,7 +786,8 @@ public void testKeyPairBase64DataSourceSerialization() throws Exception {
connectAndExecuteSelect1(ds);
- File serializedFile = tmpFolder.newFile("serializedStuff.ser");
+ File serializedFile = new File(tmpFolder, "serializedStuff.ser");
+ serializedFile.createNewFile();
// serialize datasource object into a file
try (FileOutputStream outputFile = new FileOutputStream(serializedFile);
ObjectOutputStream out = new ObjectOutputStream(outputFile)) {
@@ -807,7 +810,7 @@ public void testKeyPairBase64DataSourceSerialization() throws Exception {
* executions
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testPrivateKeyInConnectionString() throws SQLException, IOException {
Map parameters = getConnectionParameters();
String testUser = parameters.get("user");
@@ -910,7 +913,7 @@ private static void unsetPublicKey(String testUser) throws SQLException {
// This will only work with JDBC driver versions higher than 3.15.1
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testPrivateKeyInConnectionStringWithBouncyCastle() throws SQLException, IOException {
System.setProperty(SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM, "true");
testPrivateKeyInConnectionString();
@@ -923,7 +926,7 @@ public void testPrivateKeyInConnectionStringWithBouncyCastle() throws SQLExcepti
* executions
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testPrivateKeyBase64InConnectionString() throws SQLException, IOException {
Map parameters = getConnectionParameters();
String testUser = parameters.get("user");
@@ -1011,7 +1014,7 @@ private static void connectExpectingInvalidOrUnsupportedPrivateKey(
/** Works in > 3.18.0 */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testPrivateKeyBase64InConnectionStringWithBouncyCastle()
throws SQLException, IOException {
System.setProperty(SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM, "true");
@@ -1019,7 +1022,7 @@ public void testPrivateKeyBase64InConnectionStringWithBouncyCastle()
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testBasicDataSourceSerialization() throws Exception {
// test with username/password authentication
// set up DataSource object and ensure connection works
@@ -1034,7 +1037,8 @@ public void testBasicDataSourceSerialization() throws Exception {
connectAndExecuteSelect1(ds);
- File serializedFile = tmpFolder.newFile("serializedStuff.ser");
+ File serializedFile = new File(tmpFolder, "serializedStuff.ser");
+ serializedFile.createNewFile();
// serialize datasource object into a file
try (FileOutputStream outputFile = new FileOutputStream(serializedFile);
ObjectOutputStream out = new ObjectOutputStream(outputFile)) {
@@ -1245,7 +1249,7 @@ public void testGetChildQueryIdsNegativeTestQueryFailed() throws Exception {
* likely not having the test account we used here.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testAuthenticatorEndpointWithDashInAccountName() throws Exception {
Map params = getConnectionParameters();
String serverUrl =
@@ -1304,7 +1308,7 @@ public void testReadOnly() throws Throwable {
* the error code is ErrorCode.S3_OPERATION_ERROR so only runs on AWS.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningNotOnAWS.class)
+ @RunOnAWS
public void testDownloadStreamWithFileNotFoundException() throws SQLException {
try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
@@ -1366,19 +1370,19 @@ private Boolean isPbes2KeySupported() throws SQLException, IOException, Security
String passphrase = System.getenv(passphraseEnv);
assertNotNull(
+ passphrase,
privateKeyFileNameEnv
+ " environment variable can't be empty. "
- + "Please provide the filename for your private key located in the resource folder",
- passphrase);
+ + "Please provide the filename for your private key located in the resource folder");
assertNotNull(
+ passphrase,
publicKeyFileNameEnv
+ " environment variable can't be empty. "
- + "Please provide the filename for your public key located in the resource folder",
- passphrase);
+ + "Please provide the filename for your public key located in the resource folder");
assertNotNull(
- passphraseEnv + " environment variable is required to decrypt private key.", passphrase);
+ passphrase, passphraseEnv + " environment variable is required to decrypt private key.");
Map parameters = getConnectionParameters();
String testUser = parameters.get("user");
Properties properties = new Properties();
@@ -1436,8 +1440,8 @@ private Boolean isPbes2KeySupported() throws SQLException, IOException, Security
* @throws IOException
*/
@Test
- @Ignore
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @Disabled
+ @DontRunOnGithubActions
public void testPbes2Support() throws SQLException, IOException {
System.clearProperty(SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM);
boolean pbes2Supported = isPbes2KeySupported();
@@ -1450,7 +1454,7 @@ public void testPbes2Support() throws SQLException, IOException {
String failureMessage =
"The failure means that the JDK version can decrypt a private key generated by OpenSSL v3 and "
+ "BouncyCastle shouldn't be needed anymore";
- assertFalse(failureMessage, pbes2Supported);
+ assertFalse(pbes2Supported, failureMessage);
// The expectation is that this is going to pass once we add Bouncy Castle in the list of
// providers
@@ -1460,12 +1464,12 @@ public void testPbes2Support() throws SQLException, IOException {
"Bouncy Castle Provider should have been loaded with the -D"
+ SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM
+ "JVM argument and this should have decrypted the private key generated by OpenSSL v3";
- assertTrue(failureMessage, pbes2Supported);
+ assertTrue(pbes2Supported, failureMessage);
}
// Test for regenerating okta one-time token for versions > 3.15.1
@Test
- @Ignore
+ @Disabled
public void testDataSourceOktaGenerates429StatusCode() throws Exception {
// test with username/password authentication
// set up DataSource object and ensure connection works
@@ -1563,26 +1567,26 @@ public void shouldGetDifferentTimestampLtzConsistentBetweenFormats() throws Exce
arrowResultSet.getTimestamp(column).getTimezoneOffset(),
arrowResultSet.getTimestamp(column).getClass());
assertEquals(
+ jsonResultSet.getString(column),
+ arrowResultSet.getString(column),
"Expecting that string representation are the same for row "
+ rowIdx
+ " and column "
- + column,
- jsonResultSet.getString(column),
- arrowResultSet.getString(column));
+ + column);
assertEquals(
+ jsonResultSet.getTimestamp(column).toString(),
+ arrowResultSet.getTimestamp(column).toString(),
"Expecting that string representation (via toString) are the same for row "
+ rowIdx
+ " and column "
- + column,
- jsonResultSet.getTimestamp(column).toString(),
- arrowResultSet.getTimestamp(column).toString());
+ + column);
assertEquals(
+ jsonResultSet.getTimestamp(column),
+ arrowResultSet.getTimestamp(column),
"Expecting that timestamps are the same for row "
+ rowIdx
+ " and column "
- + column,
- jsonResultSet.getTimestamp(column),
- arrowResultSet.getTimestamp(column));
+ + column);
}
rowIdx++;
}
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionManual.java b/src/test/java/net/snowflake/client/jdbc/ConnectionManual.java
index 91d5f7bc8..4b7d569d5 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectionManual.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectionManual.java
@@ -1,6 +1,6 @@
package net.snowflake.client.jdbc;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.sql.Connection;
import java.sql.DriverManager;
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionPoolingIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionPoolingIT.java
index 770acda0a..da6aef32e 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectionPoolingIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectionPoolingIT.java
@@ -3,7 +3,7 @@
*/
package net.snowflake.client.jdbc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.zaxxer.hikari.HikariConfig;
@@ -15,17 +15,18 @@
import java.sql.Statement;
import java.util.Map;
import java.util.Properties;
-import net.snowflake.client.category.TestCategoryConnection;
+import net.snowflake.client.category.TestTags;
import org.apache.commons.dbcp.BasicDataSource;
import org.apache.commons.dbcp.PoolingDataSource;
import org.apache.commons.pool.impl.GenericObjectPool;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/** Connection pool interface test */
-@Category(TestCategoryConnection.class)
+// @Category(TestCategoryConnection.class)
+@Tag(TestTags.CONNECTION)
public class ConnectionPoolingIT {
private BasicDataSource bds = null;
private ComboPooledDataSource cpds = null;
@@ -48,7 +49,7 @@ public ConnectionPoolingIT() {
ssl = params.get("ssl");
}
- @Before
+ @BeforeEach
public void setUp() throws SQLException {
try (Connection connection = BaseJDBCTest.getConnection();
Statement statement = connection.createStatement()) {
@@ -57,7 +58,7 @@ public void setUp() throws SQLException {
}
}
- @After
+ @AfterEach
public void tearDown() throws SQLException {
try (Connection connection = BaseJDBCTest.getConnection();
Statement statement = connection.createStatement(); ) {
diff --git a/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java b/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java
index 49c6c6d10..464adabe6 100644
--- a/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/ConnectionWithOCSPModeIT.java
@@ -9,8 +9,8 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.IsInstanceOf.instanceOf;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.fail;
import java.net.SocketTimeoutException;
import java.security.cert.CertificateExpiredException;
@@ -19,17 +19,16 @@
import java.util.Properties;
import javax.net.ssl.SSLHandshakeException;
import javax.net.ssl.SSLPeerUnverifiedException;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryConnection;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.SFOCSPException;
import net.snowflake.client.core.SFTrustManager;
import org.hamcrest.Matcher;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Tests for connection with OCSP mode mainly negative cases by injecting errors.
@@ -38,7 +37,8 @@
*
* hang_webserver.py 12345
*/
-@Category(TestCategoryConnection.class)
+// @Category(TestCategoryConnection.class)
+@Tag(TestTags.CONNECTION)
public class ConnectionWithOCSPModeIT extends BaseJDBCTest {
private final String testUser = "fakeuser";
private final String testPassword = "testpassword";
@@ -46,12 +46,12 @@ public class ConnectionWithOCSPModeIT extends BaseJDBCTest {
private static int nameCounter = 0;
- @Before
+ @BeforeEach
public void setUp() {
SFTrustManager.deleteCache();
}
- @After
+ @AfterEach
public void tearDown() {
SFTrustManager.cleanTestSystemParameters();
}
@@ -340,7 +340,7 @@ public void testOCSPResponderTimeoutFailOpen() {
/** Test OCSP Responder hang and timeout. SocketTimeoutException exception should be raised. */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testOCSPResponderTimeoutFailClosed() {
System.setProperty(SFTrustManager.SF_OCSP_TEST_OCSP_RESPONDER_TIMEOUT, "1000");
System.setProperty(SFTrustManager.SF_OCSP_TEST_RESPONDER_URL, "http://localhost:12345/hang");
@@ -380,7 +380,7 @@ public void testOCSPResponder403FailOpen() {
* is invalid.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testOCSPResponder403FailClosed() {
System.setProperty(SFTrustManager.SF_OCSP_TEST_RESPONDER_URL, "http://localhost:12345/403");
System.setProperty(
@@ -397,7 +397,7 @@ public void testOCSPResponder403FailClosed() {
/** Test Certificate Expired. Will fail in both FAIL_OPEN and FAIL_CLOSED. */
@Test
- @Ignore("Issuer of root CA expired")
+ @Disabled("Issuer of root CA expired")
// https://support.sectigo.com/articles/Knowledge/Sectigo-AddTrust-External-CA-Root-Expiring-May-30-2020
public void testExpiredCert() {
try {
diff --git a/src/test/java/net/snowflake/client/jdbc/CustomProxyLatestIT.java b/src/test/java/net/snowflake/client/jdbc/CustomProxyLatestIT.java
index c6fb29bf4..85e593924 100644
--- a/src/test/java/net/snowflake/client/jdbc/CustomProxyLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/CustomProxyLatestIT.java
@@ -1,13 +1,13 @@
package net.snowflake.client.jdbc;
-import static junit.framework.TestCase.assertEquals;
-import static junit.framework.TestCase.fail;
import static net.snowflake.client.AbstractDriverIT.getFullPathFileInResource;
import static net.snowflake.client.jdbc.SnowflakeDriverIT.findFile;
import static net.snowflake.client.jdbc.SnowflakeUtil.systemGetProperty;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
-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.junit.jupiter.api.Assertions.fail;
import java.io.File;
import java.net.Authenticator;
@@ -18,17 +18,16 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.HttpClientSettingsKey;
import net.snowflake.client.core.HttpProtocol;
import net.snowflake.client.core.HttpUtil;
import net.snowflake.client.core.SFSession;
import net.snowflake.common.core.SqlState;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
// To run these tests, you must:
// 1.) Start up a proxy connection. The simplest ways are via Squid or BurpSuite. Confluence doc on
@@ -37,9 +36,10 @@
// 2.) Enter your own username and password for the account you're connecting to
// 3.) Adjust parameters like role, database, schema, etc to match with account accordingly
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class CustomProxyLatestIT {
- @Rule public TemporaryFolder tmpFolder = new TemporaryFolder();
+ @TempDir private File tmpFolder;
/**
* Before running this test, change the user and password to appropriate values. Set up 2
@@ -51,7 +51,7 @@ public class CustomProxyLatestIT {
* @throws SQLException
*/
@Test
- @Ignore
+ @Disabled
public void test2ProxiesWithSameJVM() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -107,7 +107,7 @@ public void test2ProxiesWithSameJVM() throws SQLException {
* @throws SQLException
*/
@Test
- @Ignore
+ @Disabled
public void testTLSIssue() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -149,7 +149,7 @@ public void testTLSIssue() throws SQLException {
* http instead of https proxy parameters for non-TLS proxy
*/
@Test
- @Ignore
+ @Disabled
public void testJVMParamsWithNonProxyHostsHonored() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -172,7 +172,7 @@ public void testJVMParamsWithNonProxyHostsHonored() throws SQLException {
/** Test TLS issue against S3 client to ensure proxy works with PUT/GET statements */
@Test
- @Ignore
+ @Disabled
public void testTLSIssueWithConnectionStringAgainstS3()
throws ClassNotFoundException, SQLException {
@@ -193,7 +193,7 @@ public void testTLSIssueWithConnectionStringAgainstS3()
* @throws SQLException
*/
@Test
- @Ignore
+ @Disabled
public void testNonProxyHostAltering() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -243,7 +243,7 @@ public void testNonProxyHostAltering() throws SQLException {
* @throws SQLException
*/
@Test
- @Ignore
+ @Disabled
public void testSizeOfHttpClientNoProxies() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -279,7 +279,7 @@ public void testSizeOfHttpClientNoProxies() throws SQLException {
}
@Test
- @Ignore
+ @Disabled
public void testCorrectProxySettingFromConnectionString()
throws ClassNotFoundException, SQLException {
String connectionUrl =
@@ -299,7 +299,7 @@ public void testCorrectProxySettingFromConnectionString()
}
@Test
- @Ignore
+ @Disabled
public void testWrongProxyPortSettingFromConnectionString()
throws ClassNotFoundException, SQLException {
@@ -313,7 +313,7 @@ public void testWrongProxyPortSettingFromConnectionString()
}
@Test
- @Ignore
+ @Disabled
public void testWrongProxyPasswordSettingFromConnectionString()
throws ClassNotFoundException, SQLException {
@@ -334,7 +334,7 @@ public void testWrongProxyPasswordSettingFromConnectionString()
}
@Test
- @Ignore
+ @Disabled
public void testInvalidProxyPortFromConnectionString()
throws ClassNotFoundException, SQLException {
@@ -355,7 +355,7 @@ public void testInvalidProxyPortFromConnectionString()
}
@Test
- @Ignore
+ @Disabled
public void testNonProxyHostsFromConnectionString() throws ClassNotFoundException, SQLException {
String connectionUrl =
@@ -368,7 +368,7 @@ public void testNonProxyHostsFromConnectionString() throws ClassNotFoundExceptio
}
@Test
- @Ignore
+ @Disabled
public void testWrongNonProxyHostsFromConnectionString()
throws ClassNotFoundException, SQLException {
@@ -383,7 +383,7 @@ public void testWrongNonProxyHostsFromConnectionString()
}
@Test
- @Ignore
+ @Disabled
public void testUnsetJvmPropertiesForInvalidSettings() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -435,11 +435,9 @@ public PasswordAuthentication getPasswordAuthentication() {
stmt.execute("use warehouse TINY_WAREHOUSE");
stmt.execute("CREATE OR REPLACE STAGE testPutGet_stage");
assertTrue(
- "Failed to put a file",
stmt.execute(
- "PUT file://"
- + getFullPathFileInResource("orders_100.csv")
- + " @testPutGet_stage"));
+ "PUT file://" + getFullPathFileInResource("orders_100.csv") + " @testPutGet_stage"),
+ "Failed to put a file");
String sql = "select $1 from values(1),(3),(5),(7)";
try (ResultSet res = stmt.executeQuery(sql)) {
while (res.next()) {
@@ -454,7 +452,7 @@ public PasswordAuthentication getPasswordAuthentication() {
}
@Test
- @Ignore
+ @Disabled
public void testProxyConnectionWithAzure() throws ClassNotFoundException, SQLException {
String connectionUrl =
"jdbc:snowflake://aztestaccount.east-us-2.azure.snowflakecomputing.com/?tracing=ALL";
@@ -463,7 +461,7 @@ public void testProxyConnectionWithAzure() throws ClassNotFoundException, SQLExc
}
@Test
- @Ignore
+ @Disabled
public void testProxyConnectionWithAzureWithConnectionString()
throws ClassNotFoundException, SQLException {
String connectionUrl =
@@ -476,7 +474,7 @@ public void testProxyConnectionWithAzureWithConnectionString()
}
@Test
- @Ignore
+ @Disabled
public void testProxyConnectionWithoutProxyPortOrHost()
throws ClassNotFoundException, SQLException {
// proxyPort is empty
@@ -553,7 +551,7 @@ public void testProxyConnectionWithoutProxyPortOrHost()
* @throws SQLException
*/
@Test
- @Ignore
+ @Disabled
public void testProxyConnectionWithJVMParameters() throws SQLException, ClassNotFoundException {
String connectionUrl =
"jdbc:snowflake://aztestaccount.east-us-2.azure.snowflakecomputing.com/?tracing=ALL";
@@ -571,7 +569,7 @@ public void testProxyConnectionWithJVMParameters() throws SQLException, ClassNot
}
@Test
- @Ignore
+ @Disabled
public void testProxyConnectionWithAzureWithWrongConnectionString()
throws ClassNotFoundException {
String connectionUrl =
@@ -598,7 +596,7 @@ public void testProxyConnectionWithAzureWithWrongConnectionString()
* is specified. Set up a http proxy and change the settings below.
*/
@Test
- @Ignore
+ @Disabled
public void testSetJVMProxyHttp() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -624,7 +622,7 @@ public void testSetJVMProxyHttp() throws SQLException {
* below.
*/
@Test
- @Ignore
+ @Disabled
public void testSetJVMProxyHttps() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -649,7 +647,7 @@ public void testSetJVMProxyHttps() throws SQLException {
* https proxy and change the settings below.
*/
@Test
- @Ignore
+ @Disabled
public void testSetJVMProxyDefaultHttps() throws SQLException {
Properties props = new Properties();
props.put("user", "USER");
@@ -725,19 +723,20 @@ public PasswordAuthentication getPasswordAuthentication() {
String TEST_DATA_FILE = "orders_100.csv";
String sourceFilePath = getFullPathFileInResource(TEST_DATA_FILE);
- File destFolder = tmpFolder.newFolder();
+ File destFolder = new File(tmpFolder, "dest");
+ destFolder.mkdirs();
String destFolderCanonicalPath = destFolder.getCanonicalPath();
String destFolderCanonicalPathWithSeparator = destFolderCanonicalPath + File.separator;
assertTrue(
- "Failed to put a file",
- stmt.execute("PUT file://" + sourceFilePath + " @testPutGet_stage"));
+ stmt.execute("PUT file://" + sourceFilePath + " @testPutGet_stage"),
+ "Failed to put a file");
findFile(stmt, "ls @testPutGet_stage/");
// download the file we just uploaded to stage
assertTrue(
- "Failed to get a file",
stmt.execute(
- "GET @testPutGet_stage 'file://" + destFolderCanonicalPath + "' parallel=8"));
+ "GET @testPutGet_stage 'file://" + destFolderCanonicalPath + "' parallel=8"),
+ "Failed to get a file");
// Make sure that the downloaded file exists, it should be gzip compressed
File downloaded = new File(destFolderCanonicalPathWithSeparator + TEST_DATA_FILE + ".gz");
diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataIT.java
index ce3130761..37c3fbce0 100644
--- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataIT.java
@@ -8,12 +8,11 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.hamcrest.Matchers.hasItem;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotEquals;
-import static org.junit.Assert.assertThat;
-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.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.google.common.base.Strings;
import java.sql.Connection;
@@ -28,15 +27,16 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
import net.snowflake.client.TestUtil;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
+import org.hamcrest.MatcherAssert;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/** Database Metadata IT */
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class DatabaseMetaDataIT extends BaseJDBCWithSharedConnectionIT {
private static final Pattern VERSION_PATTERN =
Pattern.compile("^(\\d+)\\.(\\d+)(?:\\.\\d+)+\\s*.*");
@@ -118,7 +118,7 @@ public void testGetCatalogs() throws SQLException {
// nop
}
}
- assertThat(cnt, greaterThanOrEqualTo(1));
+ MatcherAssert.assertThat(cnt, greaterThanOrEqualTo(1));
try {
assertTrue(resultSet.isAfterLast());
fail("The result set is automatically closed when all rows are fetched.");
@@ -156,7 +156,7 @@ public void testGetSchemas() throws Throwable {
}
}
}
- assertThat(schemas.size(), greaterThanOrEqualTo(1));
+ MatcherAssert.assertThat(schemas.size(), greaterThanOrEqualTo(1));
Set schemasInDb = new HashSet<>();
try (ResultSet resultSet = metaData.getSchemas(connection.getCatalog(), "%")) {
@@ -167,9 +167,9 @@ public void testGetSchemas() throws Throwable {
}
}
}
- assertThat(schemasInDb.size(), greaterThanOrEqualTo(1));
- assertThat(schemas.size(), greaterThanOrEqualTo(schemasInDb.size()));
- schemasInDb.forEach(schemaInDb -> assertThat(schemas, hasItem(schemaInDb)));
+ MatcherAssert.assertThat(schemasInDb.size(), greaterThanOrEqualTo(1));
+ MatcherAssert.assertThat(schemas.size(), greaterThanOrEqualTo(schemasInDb.size()));
+ schemasInDb.forEach(schemaInDb -> MatcherAssert.assertThat(schemas, hasItem(schemaInDb)));
assertTrue(schemas.contains(currentSchema));
assertTrue(schemasInDb.contains(currentSchema));
@@ -185,7 +185,7 @@ public void testGetSchemas() throws Throwable {
while (resultSet.next()) {
schemas2.add(resultSet.getString(1));
}
- assertThat(schemas2.size(), equalTo(1));
+ MatcherAssert.assertThat(schemas2.size(), equalTo(1));
}
}
}
@@ -205,7 +205,7 @@ public void testGetTableTypes() throws Throwable {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetTables() throws Throwable {
Set tables = null;
try (Statement statement = connection.createStatement()) {
@@ -564,7 +564,7 @@ public void testProcedure() throws Throwable {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetTablePrivileges() throws Exception {
try (Statement statement = connection.createStatement()) {
String database = connection.getCatalog();
diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java
index ec590b066..00dc3ab20 100644
--- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalIT.java
@@ -5,9 +5,9 @@
import static net.snowflake.client.jdbc.DatabaseMetaDataIT.EXPECTED_MAX_BINARY_LENGTH;
import static net.snowflake.client.jdbc.DatabaseMetaDataIT.verifyResultSetMetaDataColumns;
-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 java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -15,24 +15,24 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/** Database Metadata IT */
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class DatabaseMetaDataInternalIT extends BaseJDBCTest {
private Connection connection;
private Statement statement;
private DatabaseMetaData databaseMetaData;
private ResultSet resultSet;
- @Before
+ @BeforeEach
public void setUp() throws SQLException {
try (Connection con = getConnection()) {
initMetaData(con);
@@ -68,7 +68,7 @@ static void initMetaData(Connection con) throws SQLException {
}
}
- @After
+ @AfterEach
public void tearDown() throws SQLException {
try (Connection con = getConnection()) {
endMetaData(con);
@@ -83,7 +83,8 @@ static void endMetaData(Connection con) throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @Disabled // TODO: SNOW-1805299
+ @DontRunOnGithubActions
public void testGetColumn() throws SQLException {
String getAllColumnsCount = "select count(*) from db.information_schema.columns";
connection = getConnection();
@@ -166,7 +167,7 @@ public void testGetColumn() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetFunctions() throws SQLException {
connection = getConnection();
statement = connection.createStatement();
@@ -241,7 +242,8 @@ public void testGetFunctions() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @Disabled // TODO: SNOW-1805299
+ @DontRunOnGithubActions
public void testGetSchema() throws SQLException {
String getSchemaCount = "select count(*) from db.information_schema.schemata";
connection = getConnection();
@@ -290,9 +292,9 @@ public void testGetSchema() throws SQLException {
* getTables() function Author: Andong Zhan Created on 09/28/2018
*/
@Test
- @Ignore // SNOW-85084 detected this is a flaky test, so ignore it here.
+ @Disabled // SNOW-85084 detected this is a flaky test, so ignore it here.
// We have other regression tests to cover it
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetTablesReusingCachedResults() throws SQLException {
Connection snowflakeConnection = getSnowflakeAdminConnection();
Statement snowflake = snowflakeConnection.createStatement();
@@ -449,7 +451,8 @@ private long getAccountId(Statement stmt, String accountName) throws SQLExceptio
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @Disabled // TODO: SNOW-1805299
+ @DontRunOnGithubActions
public void testGetTables() throws SQLException {
String getAllTable = "select count(*) from db.information_schema.tables";
String getAllBaseTable =
@@ -579,7 +582,7 @@ public void testGetTables() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetMetaDataUseConnectionCtx() throws SQLException {
try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalLatestIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalLatestIT.java
index 15701ca17..6cb11d438 100644
--- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataInternalLatestIT.java
@@ -2,8 +2,8 @@
import static net.snowflake.client.jdbc.DatabaseMetaDataInternalIT.endMetaData;
import static net.snowflake.client.jdbc.DatabaseMetaDataInternalIT.initMetaData;
-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;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -17,13 +17,12 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Database Metadata tests for the latest JDBC driver. This doesn't work for the oldest supported
@@ -31,17 +30,18 @@
* tests still is not applicable. If it is applicable, move tests to DatabaseMetaDataIT so that both
* the latest and oldest supported driver run the tests.
*/
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class DatabaseMetaDataInternalLatestIT extends BaseJDBCTest {
- @Before
+ @BeforeEach
public void setUp() throws Exception {
try (Connection con = getConnection()) {
initMetaData(con);
}
}
- @After
+ @AfterEach
public void tearDown() throws Exception {
try (Connection con = getConnection()) {
endMetaData(con);
@@ -49,7 +49,7 @@ public void tearDown() throws Exception {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetMetaDataUseConnectionCtx() throws SQLException {
try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
@@ -79,7 +79,7 @@ public void testGetMetaDataUseConnectionCtx() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetFunctionColumns() throws SQLException {
try (Connection connection = getConnection();
Statement statement = connection.createStatement()) {
@@ -253,7 +253,7 @@ public void testGetFunctionColumns() throws SQLException {
/** Tests that calling getTables() concurrently doesn't cause data race condition. */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetTablesRaceCondition()
throws SQLException, ExecutionException, InterruptedException {
try (Connection connection = getConnection()) {
diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java
index 082907502..89e731f83 100644
--- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataLatestIT.java
@@ -10,12 +10,11 @@
import static net.snowflake.client.jdbc.SnowflakeDatabaseMetaData.StringFunctionsSupported;
import static net.snowflake.client.jdbc.SnowflakeDatabaseMetaData.SystemFunctionsSupported;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
-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.assertNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import java.lang.reflect.Field;
import java.sql.Connection;
@@ -30,16 +29,16 @@
import java.util.Map;
import java.util.Properties;
import java.util.Set;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
import net.snowflake.client.TestUtil;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.SFBaseSession;
import net.snowflake.client.core.SFSessionProperty;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.hamcrest.MatcherAssert;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* DatabaseMetaData test for the latest JDBC driver. This doesn't work for the oldest supported
@@ -47,7 +46,8 @@
* tests still is not applicable. If it is applicable, move tests to DatabaseMetaDataIT so that both
* the latest and oldest supported driver run the tests.
*/
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class DatabaseMetaDataLatestIT extends BaseJDBCWithSharedConnectionIT {
private static final String TEST_PROC =
"create or replace procedure testproc(param1 float, param2 string)\n"
@@ -99,7 +99,7 @@ public void createDoubleQuotedSchemaAndCatalog(Statement statement) throws SQLEx
statement.execute("create or replace schema \"dbwith\"\"quotes\".\"schemawith\"\"quotes\"");
}
- @Before
+ @BeforeEach
public void setUp() throws SQLException {
try (Statement stmt = connection.createStatement()) {
stmt.execute("USE DATABASE " + startingDatabase);
@@ -181,32 +181,32 @@ public void testUseConnectionCtx() throws Exception {
databaseMetaData = connection.getMetaData();
try (ResultSet resultSet = databaseMetaData.getSchemas(null, null)) {
- assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
+ MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
}
try (ResultSet resultSet = databaseMetaData.getTables(null, null, null, null)) {
- assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(6));
+ MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(6));
}
try (ResultSet resultSet = databaseMetaData.getColumns(null, null, null, null)) {
- assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(26));
+ MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(26));
}
try (ResultSet resultSet = databaseMetaData.getPrimaryKeys(null, null, null)) {
- assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
+ MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
}
try (ResultSet resultSet = databaseMetaData.getImportedKeys(null, null, null)) {
- assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
+ MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
}
try (ResultSet resultSet = databaseMetaData.getExportedKeys(null, null, null)) {
- assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
+ MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
}
try (ResultSet resultSet =
databaseMetaData.getCrossReference(null, null, null, null, null, null)) {
- assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
+ MatcherAssert.assertThat(getSizeOfResultSet(resultSet), greaterThanOrEqualTo(2));
}
});
}
@@ -272,7 +272,7 @@ public void testDoubleQuotedDatabaseAndSchema() throws Exception {
* This tests the ability to have quotes inside a database or schema within getSchemas() function.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDoubleQuotedDatabaseInGetSchemas() throws SQLException {
try (Statement statement = connection.createStatement()) {
// Create a database with double quotes inside the database name
@@ -300,7 +300,7 @@ public void testDoubleQuotedDatabaseInGetSchemas() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDoubleQuotedDatabaseInGetTables() throws SQLException {
try (Statement statement = connection.createStatement()) {
// Create a database with double quotes inside the database name
@@ -316,7 +316,7 @@ public void testDoubleQuotedDatabaseInGetTables() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDoubleQuotedDatabaseInGetColumns() throws SQLException {
try (Statement statement = connection.createStatement()) {
// Create a database and schema with double quotes inside the database name
@@ -332,7 +332,7 @@ public void testDoubleQuotedDatabaseInGetColumns() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDoubleQuotedDatabaseforGetPrimaryKeysAndForeignKeys() throws SQLException {
try (Statement statement = connection.createStatement()) {
// Create a database and schema with double quotes inside the database name
@@ -361,7 +361,7 @@ public void testDoubleQuotedDatabaseforGetPrimaryKeysAndForeignKeys() throws SQL
* getPrimaryKeys and getImportedKeys functions by setting enablePatternSearch = false.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDoubleQuotedDatabaseforGetPrimaryKeysAndForeignKeysWithPatternSearchDisabled()
throws SQLException {
Properties properties = new Properties();
@@ -390,7 +390,7 @@ public void testDoubleQuotedDatabaseforGetPrimaryKeysAndForeignKeysWithPatternSe
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDoubleQuotedDatabaseInGetProcedures() throws SQLException {
try (Statement statement = connection.createStatement()) {
// Create a database and schema with double quotes inside the database name
@@ -407,7 +407,7 @@ public void testDoubleQuotedDatabaseInGetProcedures() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testDoubleQuotedDatabaseInGetTablePrivileges() throws SQLException {
try (Statement statement = connection.createStatement()) {
// Create a database and schema with double quotes inside the database name
@@ -589,7 +589,7 @@ public void testGetColumnsNullable() throws Throwable {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testSessionDatabaseParameter() throws Throwable {
String altdb = "ALTERNATEDB";
String altschema1 = "ALTERNATESCHEMA1";
@@ -756,7 +756,7 @@ public void testSessionDatabaseParameter() throws Throwable {
* returns 1 row per return value and 1 row per input parameter.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetFunctionColumns() throws Exception {
try (Statement statement = connection.createStatement()) {
String database = startingDatabase;
@@ -1667,7 +1667,7 @@ public void testGetStreams() throws SQLException {
* This tests that an empty resultset will be returned for getProcedures when using a reader account.
*/
@Test
- @Ignore
+ @Disabled
public void testGetProceduresWithReaderAccount() throws SQLException {
DatabaseMetaData metadata = connection.getMetaData();
try (ResultSet rs = metadata.getProcedures(null, null, null)) {
@@ -1676,7 +1676,7 @@ public void testGetProceduresWithReaderAccount() throws SQLException {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetProcedureColumns() throws Exception {
try (Statement statement = connection.createStatement()) {
String database = startingDatabase;
@@ -2157,11 +2157,11 @@ public void testPatternSearchAllowedForPrimaryAndForeignKeys() throws Exception
assertEquals(
2, getSizeOfResultSet(dbmd.getPrimaryKeys(database, schema, tablePattern2)));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(dbmd.getPrimaryKeys(database, null, tablePattern1)),
greaterThanOrEqualTo(1));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(dbmd.getPrimaryKeys(database, null, tablePattern2)),
greaterThanOrEqualTo(1));
@@ -2179,11 +2179,11 @@ public void testPatternSearchAllowedForPrimaryAndForeignKeys() throws Exception
assertEquals(
1, getSizeOfResultSet(dbmd.getImportedKeys(database, schemaPattern2, null)));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(dbmd.getImportedKeys(database, null, tablePattern1)),
greaterThanOrEqualTo(1));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(dbmd.getImportedKeys(database, null, tablePattern2)),
greaterThanOrEqualTo(1));
@@ -2198,11 +2198,11 @@ public void testPatternSearchAllowedForPrimaryAndForeignKeys() throws Exception
assertEquals(
1, getSizeOfResultSet(dbmd.getExportedKeys(database, schemaPattern1, table1)));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(dbmd.getExportedKeys(database, null, tablePattern1)),
greaterThanOrEqualTo(1));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(dbmd.getExportedKeys(database, null, tablePattern2)),
greaterThanOrEqualTo(1));
@@ -2265,13 +2265,13 @@ public void testPatternSearchAllowedForPrimaryAndForeignKeys() throws Exception
dbmd.getCrossReference(
database, schema, table1, database, schemaPattern2, null)));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(
dbmd.getCrossReference(
database, null, tablePattern1, database, schema, table2)),
greaterThanOrEqualTo(1));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(
dbmd.getCrossReference(
database, null, tablePattern2, database, schema, table2)),
@@ -2289,13 +2289,13 @@ public void testPatternSearchAllowedForPrimaryAndForeignKeys() throws Exception
dbmd.getCrossReference(
database, schema, tablePattern2, database, schema, table2)));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(
dbmd.getCrossReference(
database, schema, table1, database, null, tablePattern1)),
greaterThanOrEqualTo(1));
- assertThat(
+ MatcherAssert.assertThat(
getSizeOfResultSet(
dbmd.getCrossReference(
database, schema, table1, database, null, tablePattern2)),
diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultSetLatestIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultSetLatestIT.java
index f69260a69..2a62be5a2 100644
--- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultSetLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultSetLatestIT.java
@@ -3,9 +3,10 @@
*/
package net.snowflake.client.jdbc;
-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 java.sql.Connection;
import java.sql.DatabaseMetaData;
@@ -15,14 +16,14 @@
import java.sql.Types;
import java.util.Arrays;
import java.util.List;
-import net.snowflake.client.category.TestCategoryResultSet;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(TestCategoryResultSet.class)
+@Tag(TestTags.RESULT_SET)
public class DatabaseMetaDataResultSetLatestIT extends BaseJDBCTest {
- @Test(expected = SnowflakeLoggedFeatureNotSupportedException.class)
+ @Test
public void testGetObjectNotSupported() throws SQLException {
try (Connection con = getConnection();
Statement st = con.createStatement()) {
@@ -34,7 +35,9 @@ public void testGetObjectNotSupported() throws SQLException {
new SnowflakeDatabaseMetaDataResultSet(
columnNames, columnTypeNames, columnTypes, rows, st)) {
resultSet.next();
- assertEquals(1.2F, resultSet.getObject(1));
+ assertThrows(
+ SnowflakeLoggedFeatureNotSupportedException.class,
+ () -> assertEquals(1.2F, resultSet.getObject(1)));
}
}
}
diff --git a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultsetIT.java b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultsetIT.java
index ccc984e3c..f0a0557b4 100644
--- a/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultsetIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/DatabaseMetaDataResultsetIT.java
@@ -3,9 +3,9 @@
*/
package net.snowflake.client.jdbc;
-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 java.math.BigDecimal;
import java.sql.Date;
@@ -17,11 +17,12 @@
import java.sql.Types;
import java.util.Arrays;
import java.util.List;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class DatabaseMetaDataResultsetIT extends BaseJDBCWithSharedConnectionIT {
private static final int columnCount = 9;
private static final int INT_DATA = 1;
diff --git a/src/test/java/net/snowflake/client/jdbc/DellBoomiCloudIT.java b/src/test/java/net/snowflake/client/jdbc/DellBoomiCloudIT.java
index 794af78df..bd5223870 100644
--- a/src/test/java/net/snowflake/client/jdbc/DellBoomiCloudIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/DellBoomiCloudIT.java
@@ -7,15 +7,17 @@
import java.sql.SQLException;
import java.sql.Statement;
import net.snowflake.client.AbstractDriverIT;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.category.TestTags;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/** A simple run on fetch result under boomi cloud environment's policy file */
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class DellBoomiCloudIT extends AbstractDriverIT {
- @Before
+ @BeforeEach
public void setup() {
File file = new File(DellBoomiCloudIT.class.getResource("boomi.policy").getFile());
@@ -25,6 +27,7 @@ public void setup() {
}
@Test
+ @Disabled // TODO: SNOW-1805239
public void testSelectLargeResultSet() throws SQLException {
try (Connection connection = getConnection();
Statement statement = connection.createStatement();
diff --git a/src/test/java/net/snowflake/client/jdbc/FileConnectionConfigurationLatestIT.java b/src/test/java/net/snowflake/client/jdbc/FileConnectionConfigurationLatestIT.java
index 734446c92..5474488b3 100644
--- a/src/test/java/net/snowflake/client/jdbc/FileConnectionConfigurationLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/FileConnectionConfigurationLatestIT.java
@@ -4,22 +4,23 @@
package net.snowflake.client.jdbc;
import static net.snowflake.client.config.SFConnectionConfigParser.SNOWFLAKE_DEFAULT_CONNECTION_NAME_KEY;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
/** This test could be run only on environment where file connection.toml is configured */
-@Ignore
+@Disabled
public class FileConnectionConfigurationLatestIT {
- @After
+ @AfterEach
public void cleanUp() {
SnowflakeUtil.systemUnsetEnv(SNOWFLAKE_DEFAULT_CONNECTION_NAME_KEY);
}
@@ -27,7 +28,7 @@ public void cleanUp() {
@Test
public void testThrowExceptionIfConfigurationDoesNotExist() {
SnowflakeUtil.systemSetEnv("SNOWFLAKE_DEFAULT_CONNECTION_NAME", "non-existent");
- Assert.assertThrows(SnowflakeSQLException.class, () -> SnowflakeDriver.INSTANCE.connect());
+ assertThrows(SnowflakeSQLException.class, () -> SnowflakeDriver.INSTANCE.connect());
}
@Test
@@ -46,7 +47,7 @@ private static void verifyConnetionToSnowflake(String connectionName) throws SQL
DriverManager.getConnection(SnowflakeDriver.AUTO_CONNECTION_STRING_PREFIX, null);
Statement statement = con.createStatement();
ResultSet resultSet = statement.executeQuery("show parameters")) {
- Assert.assertTrue(resultSet.next());
+ assertTrue(resultSet.next());
}
}
}
diff --git a/src/test/java/net/snowflake/client/jdbc/FileUploaderExpandFileNamesTest.java b/src/test/java/net/snowflake/client/jdbc/FileUploaderExpandFileNamesTest.java
index c874b3e33..8545ca998 100644
--- a/src/test/java/net/snowflake/client/jdbc/FileUploaderExpandFileNamesTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/FileUploaderExpandFileNamesTest.java
@@ -4,9 +4,9 @@
package net.snowflake.client.jdbc;
import static net.snowflake.client.jdbc.SnowflakeUtil.systemGetProperty;
-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 java.io.File;
import java.io.IOException;
@@ -23,23 +23,20 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.IntStream;
import net.snowflake.client.core.OCSPMode;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.io.TempDir;
/** Tests for SnowflakeFileTransferAgent.expandFileNames */
public class FileUploaderExpandFileNamesTest {
- @Rule public TemporaryFolder folder = new TemporaryFolder();
- @Rule public TemporaryFolder secondFolder = new TemporaryFolder();
+ @TempDir private File folder;
private String localFSFileSep = systemGetProperty("file.separator");
@Test
public void testProcessFileNames() throws Exception {
- folder.newFile("TestFileA");
- folder.newFile("TestFileB");
+ new File(folder, "TestFileA").createNewFile();
+ new File(folder, "TestFileB").createNewFile();
- String folderName = folder.getRoot().getCanonicalPath();
+ String folderName = folder.getCanonicalPath();
String originalUserDir = System.getProperty("user.dir");
String originalUserHome = System.getProperty("user.home");
System.setProperty("user.dir", folderName);
@@ -82,8 +79,8 @@ public void testProcessFileNamesException() {
try {
SnowflakeFileTransferAgent.expandFileNames(locations, null);
} catch (SnowflakeSQLException err) {
- Assert.assertEquals(200007, err.getErrorCode());
- Assert.assertEquals("22000", err.getSQLState());
+ assertEquals(200007, err.getErrorCode());
+ assertEquals("22000", err.getSQLState());
}
SnowflakeFileTransferAgent.setInjectedFileTransferException(null);
}
@@ -163,8 +160,8 @@ public int read() throws IOException {
*/
@Test
public void testFileListingDoesNotFailOnMissingFilesOfAnotherPattern() throws Exception {
- folder.newFolder("TestFiles");
- String folderName = folder.getRoot().getCanonicalPath();
+ new File(folder, "TestFiles").mkdirs();
+ String folderName = folder.getCanonicalPath();
int filePatterns = 10;
int filesPerPattern = 100;
@@ -224,8 +221,8 @@ public void testFileListingDoesNotFailOnMissingFilesOfAnotherPattern() throws Ex
@Test
public void testFileListingDoesNotFailOnNotExistingDirectory() throws Exception {
- folder.newFolder("TestFiles");
- String folderName = folder.getRoot().getCanonicalPath();
+ new File(folder, "TestFiles").mkdirs();
+ String folderName = folder.getCanonicalPath();
String[] locations = {
folderName + localFSFileSep + "foo*",
};
diff --git a/src/test/java/net/snowflake/client/jdbc/FileUploaderLatestIT.java b/src/test/java/net/snowflake/client/jdbc/FileUploaderLatestIT.java
index 995832362..d2cfe896a 100644
--- a/src/test/java/net/snowflake/client/jdbc/FileUploaderLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/FileUploaderLatestIT.java
@@ -5,10 +5,10 @@
import static net.snowflake.client.jdbc.SnowflakeUtil.systemGetProperty;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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.assertTrue;
+import static org.junit.jupiter.api.Assertions.fail;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -32,9 +32,8 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.OCSPMode;
import net.snowflake.client.core.SFSession;
import net.snowflake.client.core.SFStatement;
@@ -47,12 +46,12 @@
import net.snowflake.client.jdbc.cloud.storage.StorageProviderException;
import net.snowflake.common.core.RemoteStoreFileEncryptionMaterial;
import org.apache.commons.io.FileUtils;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/** Tests for SnowflakeFileTransferAgent that require an active connection */
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class FileUploaderLatestIT extends FileUploaderPrep {
private static final String OBJ_META_STAGE = "testObjMeta";
private ObjectMapper mapper = new ObjectMapper();
@@ -65,7 +64,7 @@ public class FileUploaderLatestIT extends FileUploaderPrep {
* @throws SQLException
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetS3StageDataWithS3Session() throws SQLException {
try (Connection con = getConnection("s3testaccount")) {
SFSession sfSession = con.unwrap(SnowflakeConnectionV1.class).getSfSession();
@@ -74,16 +73,16 @@ public void testGetS3StageDataWithS3Session() throws SQLException {
// Get sample stage info with session
StageInfo stageInfo = SnowflakeFileTransferAgent.getStageInfo(exampleS3JsonNode, sfSession);
- Assert.assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
+ assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
// Assert that true value from session is reflected in StageInfo
- Assert.assertEquals(true, stageInfo.getUseS3RegionalUrl());
+ assertEquals(true, stageInfo.getUseS3RegionalUrl());
// Set UseRegionalS3EndpointsForPresignedURL to false in session
sfSession.setUseRegionalS3EndpointsForPresignedURL(false);
stageInfo = SnowflakeFileTransferAgent.getStageInfo(exampleS3JsonNode, sfSession);
- Assert.assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
+ assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
// Assert that false value from session is reflected in StageInfo
- Assert.assertEquals(false, stageInfo.getUseS3RegionalUrl());
+ assertEquals(false, stageInfo.getUseS3RegionalUrl());
}
}
@@ -94,7 +93,7 @@ public void testGetS3StageDataWithS3Session() throws SQLException {
* @throws SQLException
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetS3StageDataWithAzureSession() throws SQLException {
try (Connection con = getConnection("azureaccount")) {
SFSession sfSession = con.unwrap(SnowflakeConnectionV1.class).getSfSession();
@@ -106,18 +105,18 @@ public void testGetS3StageDataWithAzureSession() throws SQLException {
// Get sample stage info with session
StageInfo stageInfo =
SnowflakeFileTransferAgent.getStageInfo(exampleAzureJsonNode, sfSession);
- Assert.assertEquals(StageInfo.StageType.AZURE, stageInfo.getStageType());
- Assert.assertEquals("EXAMPLE_LOCATION/", stageInfo.getLocation());
+ assertEquals(StageInfo.StageType.AZURE, stageInfo.getStageType());
+ assertEquals("EXAMPLE_LOCATION/", stageInfo.getLocation());
// Assert that UseRegionalS3EndpointsForPresignedURL is false in StageInfo even if it was set
// to
// true.
// The value should always be false for non-S3 accounts
- Assert.assertEquals(false, stageInfo.getUseS3RegionalUrl());
+ assertEquals(false, stageInfo.getUseS3RegionalUrl());
}
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetObjectMetadataWithGCS() throws Exception {
Properties paramProperties = new Properties();
paramProperties.put("GCS_USE_DOWNSCOPED_CREDENTIAL", true);
@@ -143,7 +142,7 @@ public void testGetObjectMetadataWithGCS() throws Exception {
String remoteStageLocation = location.substring(0, idx);
String path = location.substring(idx + 1) + TEST_DATA_FILE + ".gz";
StorageObjectMetadata metadata = client.getObjectMetadata(remoteStageLocation, path);
- Assert.assertEquals("gzip", metadata.getContentEncoding());
+ assertEquals("gzip", metadata.getContentEncoding());
} finally {
statement.execute("DROP STAGE if exists " + OBJ_META_STAGE);
}
@@ -151,7 +150,7 @@ public void testGetObjectMetadataWithGCS() throws Exception {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetObjectMetadataFileNotFoundWithGCS() throws Exception {
Properties paramProperties = new Properties();
paramProperties.put("GCS_USE_DOWNSCOPED_CREDENTIAL", true);
@@ -180,8 +179,8 @@ public void testGetObjectMetadataFileNotFoundWithGCS() throws Exception {
fail("should raise exception");
} catch (Exception ex) {
assertTrue(
- "Wrong type of exception. Message: " + ex.getMessage(),
- ex instanceof StorageProviderException);
+ ex instanceof StorageProviderException,
+ "Wrong type of exception. Message: " + ex.getMessage());
assertTrue(ex.getMessage().matches(".*Blob.*not found in bucket.*"));
} finally {
statement.execute("DROP STAGE if exists " + OBJ_META_STAGE);
@@ -190,7 +189,7 @@ public void testGetObjectMetadataFileNotFoundWithGCS() throws Exception {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetObjectMetadataStorageExceptionWithGCS() throws Exception {
Properties paramProperties = new Properties();
paramProperties.put("GCS_USE_DOWNSCOPED_CREDENTIAL", true);
@@ -218,8 +217,8 @@ public void testGetObjectMetadataStorageExceptionWithGCS() throws Exception {
fail("should raise exception");
} catch (Exception ex) {
assertTrue(
- "Wrong type of exception. Message: " + ex.getMessage(),
- ex instanceof StorageProviderException);
+ ex instanceof StorageProviderException,
+ "Wrong type of exception. Message: " + ex.getMessage());
assertTrue(ex.getMessage().matches(".*Permission.*denied.*"));
} finally {
statement.execute("DROP STAGE if exists " + OBJ_META_STAGE);
@@ -253,8 +252,8 @@ public void testNullCommand() throws SQLException {
SnowflakeFileTransferAgent sfAgent =
new SnowflakeFileTransferAgent(null, sfSession, new SFStatement(sfSession));
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(
err.getMessage()
.contains("JDBC driver internal error: Missing sql for statement execution"));
} finally {
@@ -294,8 +293,8 @@ public void testCompressStreamWithGzipException() throws Exception {
.setCommand(PUT_COMMAND)
.build());
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(
err.getMessage()
.contains("JDBC driver internal error: error encountered for compression"));
} finally {
@@ -338,8 +337,8 @@ public void testCompressStreamWithGzipNoDigestException() throws Exception {
.setCommand(PUT_COMMAND)
.build());
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(
err.getMessage()
.contains("JDBC driver internal error: error encountered for compression"));
} finally {
@@ -382,7 +381,7 @@ public void testUploadWithoutConnectionException() throws Exception {
.setCommand(PUT_COMMAND)
.build());
} catch (Exception err) {
- Assert.assertTrue(
+ assertTrue(
err.getMessage()
.contains(
"Exception encountered during file upload: failed to push to remote store"));
@@ -405,7 +404,7 @@ public void testInitFileMetadataFileNotFound() throws Exception {
sfAgent.execute();
} catch (SnowflakeSQLException err) {
- Assert.assertEquals(200008, err.getErrorCode());
+ assertEquals(200008, err.getErrorCode());
} finally {
statement.execute("DROP STAGE if exists testStage");
}
@@ -426,7 +425,7 @@ public void testInitFileMetadataFileIsDirectory() throws Exception {
new SnowflakeFileTransferAgent(command, sfSession, new SFStatement(sfSession));
sfAgent.execute();
} catch (SnowflakeSQLException err) {
- Assert.assertEquals(200009, err.getErrorCode());
+ assertEquals(200009, err.getErrorCode());
} finally {
statement.execute("DROP STAGE if exists testStage");
}
@@ -449,8 +448,8 @@ public void testCompareAndSkipFilesException() throws Exception {
sfAgent.execute();
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(err.getMessage().contains("Error reading:"));
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(err.getMessage().contains("Error reading:"));
} finally {
statement.execute("DROP STAGE if exists testStage");
}
@@ -472,8 +471,8 @@ public void testParseCommandException() throws SQLException {
new SnowflakeFileTransferAgent(PUT_COMMAND, sfSession, new SFStatement(sfSession));
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(err.getMessage().contains("Failed to parse the locations"));
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(err.getMessage().contains("Failed to parse the locations"));
} finally {
statement.execute("DROP STAGE if exists testStage");
}
@@ -534,8 +533,8 @@ public void testListObjectsStorageException() throws Exception {
sfAgent.execute();
} catch (SnowflakeSQLException err) {
- Assert.assertEquals(200016, err.getErrorCode());
- Assert.assertTrue(err.getMessage().contains("Encountered exception during listObjects"));
+ assertEquals(200016, err.getErrorCode());
+ assertTrue(err.getMessage().contains("Encountered exception during listObjects"));
} finally {
statement.execute("DROP STAGE if exists testStage");
}
@@ -563,7 +562,7 @@ public void testUploadStreamInterruptedException() throws IOException, SQLExcept
"~", DEST_PREFIX, outputStream.asByteSource().openStream(), "hello.txt", false);
} catch (SnowflakeSQLLoggedException err) {
- Assert.assertEquals(200003, err.getErrorCode());
+ assertEquals(200003, err.getErrorCode());
} finally {
statement.execute("rm @~/" + DEST_PREFIX);
}
@@ -666,7 +665,7 @@ public void testUploadFileStreamWithNoOverwrite() throws Exception {
assertEquals(expectedValue, actualValue);
}
} catch (Exception e) {
- Assert.fail("testUploadFileStreamWithNoOverwrite failed " + e.getMessage());
+ fail("testUploadFileStreamWithNoOverwrite failed " + e.getMessage());
} finally {
statement.execute("DROP STAGE if exists testStage");
}
@@ -696,7 +695,7 @@ public void testUploadFileStreamWithOverwrite() throws Exception {
assertFalse(expectedValue.equals(actualValue));
}
} catch (Exception e) {
- Assert.fail("testUploadFileStreamWithNoOverwrite failed " + e.getMessage());
+ fail("testUploadFileStreamWithNoOverwrite failed " + e.getMessage());
} finally {
statement.execute("DROP STAGE if exists testStage");
}
@@ -704,7 +703,7 @@ public void testUploadFileStreamWithOverwrite() throws Exception {
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testGetS3StorageObjectMetadata() throws Throwable {
try (Connection connection = getConnection("s3testaccount");
Statement statement = connection.createStatement()) {
diff --git a/src/test/java/net/snowflake/client/jdbc/FileUploaderMimeTypeToCompressionTypeTest.java b/src/test/java/net/snowflake/client/jdbc/FileUploaderMimeTypeToCompressionTypeTest.java
index d9ad6d2c1..418c70a05 100644
--- a/src/test/java/net/snowflake/client/jdbc/FileUploaderMimeTypeToCompressionTypeTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/FileUploaderMimeTypeToCompressionTypeTest.java
@@ -3,55 +3,49 @@
*/
package net.snowflake.client.jdbc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.util.Arrays;
-import java.util.Collection;
import java.util.Optional;
+import java.util.stream.Stream;
import net.snowflake.common.core.FileCompressionType;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
/**
* Tests for SnowflakeFileTransferAgent.mimeTypeToCompressionType See
* https://github.com/apache/tika/blob/master/tika-core/src/main/resources/org/apache/tika/mime/tika-mimetypes.xml
* for test cases
*/
-@RunWith(Parameterized.class)
public class FileUploaderMimeTypeToCompressionTypeTest {
- private final String mimeType;
- private final FileCompressionType mimeSubType;
- public FileUploaderMimeTypeToCompressionTypeTest(
- String mimeType, FileCompressionType mimeSubType) {
- this.mimeType = mimeType;
- this.mimeSubType = mimeSubType;
- }
-
- @Parameterized.Parameters(name = "mimeType={0}, mimeSubType={1}")
- public static Collection primeNumbers() {
- return Arrays.asList(
- new Object[][] {
- {"text/", null},
- {"text/csv", null},
- {"snowflake/orc", FileCompressionType.ORC},
- {"snowflake/orc;p=1", FileCompressionType.ORC},
- {"snowflake/parquet", FileCompressionType.PARQUET},
- {"application/zlib", FileCompressionType.DEFLATE},
- {"application/x-bzip2", FileCompressionType.BZIP2},
- {"application/zstd", FileCompressionType.ZSTD},
- {"application/x-brotli", FileCompressionType.BROTLI},
- {"application/x-lzip", FileCompressionType.LZIP},
- {"application/x-lzma", FileCompressionType.LZMA},
- {"application/x-xz", FileCompressionType.XZ},
- {"application/x-compress", FileCompressionType.COMPRESS},
- {"application/x-gzip", FileCompressionType.GZIP}
- });
+ static class MimeTypesProvider implements ArgumentsProvider {
+ @Override
+ public Stream extends Arguments> provideArguments(ExtensionContext context) throws Exception {
+ return Stream.of(
+ Arguments.of("text/", null),
+ Arguments.of("text/csv", null),
+ Arguments.of("snowflake/orc", FileCompressionType.ORC),
+ Arguments.of("snowflake/orc;p=1", FileCompressionType.ORC),
+ Arguments.of("snowflake/parquet", FileCompressionType.PARQUET),
+ Arguments.of("application/zlib", FileCompressionType.DEFLATE),
+ Arguments.of("application/x-bzip2", FileCompressionType.BZIP2),
+ Arguments.of("application/zstd", FileCompressionType.ZSTD),
+ Arguments.of("application/x-brotli", FileCompressionType.BROTLI),
+ Arguments.of("application/x-lzip", FileCompressionType.LZIP),
+ Arguments.of("application/x-lzma", FileCompressionType.LZMA),
+ Arguments.of("application/x-xz", FileCompressionType.XZ),
+ Arguments.of("application/x-compress", FileCompressionType.COMPRESS),
+ Arguments.of("application/x-gzip", FileCompressionType.GZIP));
+ }
}
- @Test
- public void testMimeTypeToCompressionType() throws Throwable {
+ @ParameterizedTest
+ @ArgumentsSource(MimeTypesProvider.class)
+ public void testMimeTypeToCompressionType(String mimeType, FileCompressionType mimeSubType)
+ throws Throwable {
Optional foundCompType =
SnowflakeFileTransferAgent.mimeTypeToCompressionType(mimeType);
if (foundCompType.isPresent()) {
diff --git a/src/test/java/net/snowflake/client/jdbc/FileUploaderPrep.java b/src/test/java/net/snowflake/client/jdbc/FileUploaderPrep.java
index d8aa8143f..ab013c844 100644
--- a/src/test/java/net/snowflake/client/jdbc/FileUploaderPrep.java
+++ b/src/test/java/net/snowflake/client/jdbc/FileUploaderPrep.java
@@ -8,13 +8,10 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import java.util.Arrays;
import java.util.List;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.rules.TemporaryFolder;
+import org.junit.jupiter.api.BeforeEach;
/** File uploader test prep reused by IT/connection tests and sessionless tests */
abstract class FileUploaderPrep extends BaseJDBCTest {
- @Rule public TemporaryFolder folder = new TemporaryFolder();
private ObjectMapper mapper = new ObjectMapper();
private final String exampleS3JsonStringWithStageEndpoint =
@@ -248,7 +245,7 @@ abstract class FileUploaderPrep extends BaseJDBCTest {
protected JsonNode exampleGCSJsonNode;
protected List exampleNodes;
- @Before
+ @BeforeEach
public void setup() throws Exception {
exampleS3JsonNode = mapper.readTree(exampleS3JsonString);
exampleS3StageEndpointJsonNode = mapper.readTree(exampleS3JsonStringWithStageEndpoint);
diff --git a/src/test/java/net/snowflake/client/jdbc/FileUploaderSessionlessTest.java b/src/test/java/net/snowflake/client/jdbc/FileUploaderSessionlessTest.java
index e23800e4e..c21827dfc 100644
--- a/src/test/java/net/snowflake/client/jdbc/FileUploaderSessionlessTest.java
+++ b/src/test/java/net/snowflake/client/jdbc/FileUploaderSessionlessTest.java
@@ -3,6 +3,10 @@
*/
package net.snowflake.client.jdbc;
+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 com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@@ -13,8 +17,7 @@
import java.util.Map;
import net.snowflake.client.jdbc.cloud.storage.StageInfo;
import net.snowflake.common.core.RemoteStoreFileEncryptionMaterial;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
/** Tests for SnowflakeFileTransferAgent.expandFileNames. */
public class FileUploaderSessionlessTest extends FileUploaderPrep {
@@ -31,8 +34,8 @@ public void testGetEncryptionMaterialMissing() throws Exception {
SnowflakeFileTransferAgent.getEncryptionMaterial(
SFBaseFileTransferAgent.CommandType.UPLOAD, modifiedNode);
- Assert.assertEquals(1, encryptionMaterials.size());
- Assert.assertNull(encryptionMaterials.get(0));
+ assertEquals(1, encryptionMaterials.size());
+ assertNull(encryptionMaterials.get(0));
}
@Test
@@ -48,12 +51,12 @@ public void testGetEncryptionMaterial() throws Exception {
SnowflakeFileTransferAgent.getEncryptionMaterial(
SFBaseFileTransferAgent.CommandType.UPLOAD, exampleNode);
- Assert.assertEquals(1, encryptionMaterials.size());
- Assert.assertEquals(
+ assertEquals(1, encryptionMaterials.size());
+ assertEquals(
expected.get(0).getQueryStageMasterKey(),
encryptionMaterials.get(0).getQueryStageMasterKey());
- Assert.assertEquals(expected.get(0).getQueryId(), encryptionMaterials.get(0).getQueryId());
- Assert.assertEquals(expected.get(0).getSmkId(), encryptionMaterials.get(0).getSmkId());
+ assertEquals(expected.get(0).getQueryId(), encryptionMaterials.get(0).getQueryId());
+ assertEquals(expected.get(0).getSmkId(), encryptionMaterials.get(0).getSmkId());
}
}
@@ -67,14 +70,14 @@ public void testGetS3StageData() throws Exception {
expectedCreds.put("AWS_SECRET_KEY", "EXAMPLE_AWS_SECRET_KEY");
expectedCreds.put("AWS_TOKEN", "EXAMPLE_AWS_TOKEN");
- Assert.assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
- Assert.assertEquals("stage/location/foo/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("us-west-2", stageInfo.getRegion());
- Assert.assertEquals("null", stageInfo.getEndPoint());
- Assert.assertEquals(null, stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
- Assert.assertEquals(true, stageInfo.getUseS3RegionalUrl());
+ assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
+ assertEquals("stage/location/foo/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("us-west-2", stageInfo.getRegion());
+ assertEquals("null", stageInfo.getEndPoint());
+ assertEquals(null, stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(true, stageInfo.getUseS3RegionalUrl());
}
@Test
@@ -88,13 +91,13 @@ public void testGetS3StageDataWithStageEndpoint() throws Exception {
expectedCreds.put("AWS_SECRET_KEY", "EXAMPLE_AWS_SECRET_KEY");
expectedCreds.put("AWS_TOKEN", "EXAMPLE_AWS_TOKEN");
- Assert.assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
- Assert.assertEquals("stage/location/foo/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("us-west-2", stageInfo.getRegion());
- Assert.assertEquals("s3-fips.us-east-1.amazonaws.com", stageInfo.getEndPoint());
- Assert.assertEquals(null, stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
+ assertEquals("stage/location/foo/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("us-west-2", stageInfo.getRegion());
+ assertEquals("s3-fips.us-east-1.amazonaws.com", stageInfo.getEndPoint());
+ assertEquals(null, stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
}
@Test
@@ -103,13 +106,13 @@ public void testGetAzureStageData() throws Exception {
Map expectedCreds = new HashMap<>();
expectedCreds.put("AZURE_SAS_TOKEN", "EXAMPLE_AZURE_SAS_TOKEN");
- Assert.assertEquals(StageInfo.StageType.AZURE, stageInfo.getStageType());
- Assert.assertEquals("EXAMPLE_LOCATION/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("westus", stageInfo.getRegion());
- Assert.assertEquals("blob.core.windows.net", stageInfo.getEndPoint());
- Assert.assertEquals("EXAMPLE_STORAGE_ACCOUNT", stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(StageInfo.StageType.AZURE, stageInfo.getStageType());
+ assertEquals("EXAMPLE_LOCATION/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("westus", stageInfo.getRegion());
+ assertEquals("blob.core.windows.net", stageInfo.getEndPoint());
+ assertEquals("EXAMPLE_STORAGE_ACCOUNT", stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
}
@Test
@@ -117,20 +120,20 @@ public void testGetGCSStageData() throws Exception {
StageInfo stageInfo = SnowflakeFileTransferAgent.getStageInfo(exampleGCSJsonNode, null);
Map expectedCreds = new HashMap<>();
- Assert.assertEquals(StageInfo.StageType.GCS, stageInfo.getStageType());
- Assert.assertEquals("foo/tables/9224/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("US-WEST1", stageInfo.getRegion());
- Assert.assertEquals(null, stageInfo.getEndPoint());
- Assert.assertEquals(null, stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(StageInfo.StageType.GCS, stageInfo.getStageType());
+ assertEquals("foo/tables/9224/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("US-WEST1", stageInfo.getRegion());
+ assertEquals(null, stageInfo.getEndPoint());
+ assertEquals(null, stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
}
@Test
public void testGetFileTransferMetadatasS3() throws Exception {
List metadataList =
SnowflakeFileTransferAgent.getFileTransferMetadatas(exampleS3JsonNode);
- Assert.assertEquals(1, metadataList.size());
+ assertEquals(1, metadataList.size());
SnowflakeFileTransferMetadataV1 metadata =
(SnowflakeFileTransferMetadataV1) metadataList.get(0);
@@ -145,25 +148,25 @@ public void testGetFileTransferMetadatasS3() throws Exception {
expectedCreds.put("AWS_SECRET_KEY", "EXAMPLE_AWS_SECRET_KEY");
expectedCreds.put("AWS_TOKEN", "EXAMPLE_AWS_TOKEN");
- Assert.assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
- Assert.assertEquals("stage/location/foo/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("us-west-2", stageInfo.getRegion());
- Assert.assertEquals("null", stageInfo.getEndPoint());
- Assert.assertEquals(null, stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
+ assertEquals("stage/location/foo/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("us-west-2", stageInfo.getRegion());
+ assertEquals("null", stageInfo.getEndPoint());
+ assertEquals(null, stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
// EncryptionMaterial check
- Assert.assertEquals("EXAMPLE_QUERY_ID", metadata.getEncryptionMaterial().getQueryId());
- Assert.assertEquals(
+ assertEquals("EXAMPLE_QUERY_ID", metadata.getEncryptionMaterial().getQueryId());
+ assertEquals(
"EXAMPLE_QUERY_STAGE_MASTER_KEY",
metadata.getEncryptionMaterial().getQueryStageMasterKey());
- Assert.assertEquals(123L, (long) metadata.getEncryptionMaterial().getSmkId());
+ assertEquals(123L, (long) metadata.getEncryptionMaterial().getSmkId());
// Misc check
- Assert.assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
- Assert.assertNull(metadata.getPresignedUrl());
- Assert.assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
+ assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
+ assertNull(metadata.getPresignedUrl());
+ assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
}
@Test
@@ -174,7 +177,7 @@ public void testGetFileTransferMetadatasS3MissingEncryption() throws Exception {
List metadataList =
SnowflakeFileTransferAgent.getFileTransferMetadatas(modifiedNode);
- Assert.assertEquals(1, metadataList.size());
+ assertEquals(1, metadataList.size());
SnowflakeFileTransferMetadataV1 metadata =
(SnowflakeFileTransferMetadataV1) metadataList.get(0);
@@ -189,30 +192,30 @@ public void testGetFileTransferMetadatasS3MissingEncryption() throws Exception {
expectedCreds.put("AWS_SECRET_KEY", "EXAMPLE_AWS_SECRET_KEY");
expectedCreds.put("AWS_TOKEN", "EXAMPLE_AWS_TOKEN");
- Assert.assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
- Assert.assertEquals("stage/location/foo/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("us-west-2", stageInfo.getRegion());
- Assert.assertEquals("null", stageInfo.getEndPoint());
- Assert.assertEquals(null, stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(StageInfo.StageType.S3, stageInfo.getStageType());
+ assertEquals("stage/location/foo/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("us-west-2", stageInfo.getRegion());
+ assertEquals("null", stageInfo.getEndPoint());
+ assertEquals(null, stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
// EncryptionMaterial check
- Assert.assertNull(metadata.getEncryptionMaterial().getQueryId());
- Assert.assertNull(metadata.getEncryptionMaterial().getQueryStageMasterKey());
- Assert.assertNull(metadata.getEncryptionMaterial().getSmkId());
+ assertNull(metadata.getEncryptionMaterial().getQueryId());
+ assertNull(metadata.getEncryptionMaterial().getQueryStageMasterKey());
+ assertNull(metadata.getEncryptionMaterial().getSmkId());
// Misc check
- Assert.assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
- Assert.assertNull(metadata.getPresignedUrl());
- Assert.assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
+ assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
+ assertNull(metadata.getPresignedUrl());
+ assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
}
@Test
public void testGetFileTransferMetadatasAzure() throws Exception {
List metadataList =
SnowflakeFileTransferAgent.getFileTransferMetadatas(exampleAzureJsonNode);
- Assert.assertEquals(1, metadataList.size());
+ assertEquals(1, metadataList.size());
SnowflakeFileTransferMetadataV1 metadata =
(SnowflakeFileTransferMetadataV1) metadataList.get(0);
@@ -223,32 +226,32 @@ public void testGetFileTransferMetadatasAzure() throws Exception {
Map expectedCreds = new HashMap<>();
expectedCreds.put("AZURE_SAS_TOKEN", "EXAMPLE_AZURE_SAS_TOKEN");
- Assert.assertEquals(StageInfo.StageType.AZURE, stageInfo.getStageType());
- Assert.assertEquals("EXAMPLE_LOCATION/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("westus", stageInfo.getRegion());
- Assert.assertEquals("blob.core.windows.net", stageInfo.getEndPoint());
- Assert.assertEquals("EXAMPLE_STORAGE_ACCOUNT", stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(StageInfo.StageType.AZURE, stageInfo.getStageType());
+ assertEquals("EXAMPLE_LOCATION/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("westus", stageInfo.getRegion());
+ assertEquals("blob.core.windows.net", stageInfo.getEndPoint());
+ assertEquals("EXAMPLE_STORAGE_ACCOUNT", stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
// EncryptionMaterial check
- Assert.assertEquals("EXAMPLE_QUERY_ID", metadata.getEncryptionMaterial().getQueryId());
- Assert.assertEquals(
+ assertEquals("EXAMPLE_QUERY_ID", metadata.getEncryptionMaterial().getQueryId());
+ assertEquals(
"EXAMPLE_QUERY_STAGE_MASTER_KEY",
metadata.getEncryptionMaterial().getQueryStageMasterKey());
- Assert.assertEquals(123L, (long) metadata.getEncryptionMaterial().getSmkId());
+ assertEquals(123L, (long) metadata.getEncryptionMaterial().getSmkId());
// Misc check
- Assert.assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
- Assert.assertNull(metadata.getPresignedUrl());
- Assert.assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
+ assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
+ assertNull(metadata.getPresignedUrl());
+ assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
}
@Test
public void testGetFileTransferMetadatasGCS() throws Exception {
List metadataList =
SnowflakeFileTransferAgent.getFileTransferMetadatas(exampleGCSJsonNode);
- Assert.assertEquals(1, metadataList.size());
+ assertEquals(1, metadataList.size());
SnowflakeFileTransferMetadataV1 metadata =
(SnowflakeFileTransferMetadataV1) metadataList.get(0);
@@ -258,25 +261,25 @@ public void testGetFileTransferMetadatasGCS() throws Exception {
Map expectedCreds = new HashMap<>();
- Assert.assertEquals(StageInfo.StageType.GCS, stageInfo.getStageType());
- Assert.assertEquals("foo/tables/9224/", stageInfo.getLocation());
- Assert.assertEquals(expectedCreds, stageInfo.getCredentials());
- Assert.assertEquals("US-WEST1", stageInfo.getRegion());
- Assert.assertEquals(null, stageInfo.getEndPoint());
- Assert.assertEquals(null, stageInfo.getStorageAccount());
- Assert.assertEquals(true, stageInfo.getIsClientSideEncrypted());
+ assertEquals(StageInfo.StageType.GCS, stageInfo.getStageType());
+ assertEquals("foo/tables/9224/", stageInfo.getLocation());
+ assertEquals(expectedCreds, stageInfo.getCredentials());
+ assertEquals("US-WEST1", stageInfo.getRegion());
+ assertEquals(null, stageInfo.getEndPoint());
+ assertEquals(null, stageInfo.getStorageAccount());
+ assertEquals(true, stageInfo.getIsClientSideEncrypted());
// EncryptionMaterial check
- Assert.assertEquals("EXAMPLE_QUERY_ID", metadata.getEncryptionMaterial().getQueryId());
- Assert.assertEquals(
+ assertEquals("EXAMPLE_QUERY_ID", metadata.getEncryptionMaterial().getQueryId());
+ assertEquals(
"EXAMPLE_QUERY_STAGE_MASTER_KEY",
metadata.getEncryptionMaterial().getQueryStageMasterKey());
- Assert.assertEquals(123L, (long) metadata.getEncryptionMaterial().getSmkId());
+ assertEquals(123L, (long) metadata.getEncryptionMaterial().getSmkId());
// Misc check
- Assert.assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
- Assert.assertEquals("EXAMPLE_PRESIGNED_URL", metadata.getPresignedUrl());
- Assert.assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
+ assertEquals(SFBaseFileTransferAgent.CommandType.UPLOAD, metadata.getCommandType());
+ assertEquals("EXAMPLE_PRESIGNED_URL", metadata.getPresignedUrl());
+ assertEquals("orders_100.csv", metadata.getPresignedUrlFileName());
}
@Test
@@ -284,10 +287,10 @@ public void testGetFileTransferMetadatasUploadError() throws Exception {
JsonNode downloadNode = mapper.readTree("{\"data\": {\"command\": \"DOWNLOAD\"}}");
try {
SnowflakeFileTransferAgent.getFileTransferMetadatas(downloadNode);
- Assert.assertTrue(false);
+ assertTrue(false);
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertEquals(
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertEquals(
"JDBC driver internal error: This API only supports PUT commands.", err.getMessage());
}
}
@@ -297,10 +300,10 @@ public void testGetFileTransferMetadatasEncryptionMaterialError() throws Excepti
JsonNode garbageNode = mapper.readTree("{\"data\": {\"src_locations\": [1, 2]}}");
try {
SnowflakeFileTransferAgent.getFileTransferMetadatas(garbageNode);
- Assert.assertTrue(false);
+ assertTrue(false);
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(
err.getMessage().contains("JDBC driver internal error: Failed to parse the credentials"));
}
}
@@ -312,11 +315,10 @@ public void testGetFileTransferMetadatasUnsupportedLocationError() throws Except
foo.put("locationType", "LOCAL_FS");
try {
SnowflakeFileTransferAgent.getFileTransferMetadatas(modifiedNode);
- Assert.assertTrue(false);
+ assertTrue(false);
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(
- err.getMessage().contains("JDBC driver internal error: This API only supports"));
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(err.getMessage().contains("JDBC driver internal error: This API only supports"));
}
}
@@ -325,10 +327,10 @@ public void testGetFileTransferMetadatasSrcLocationsArrayError() throws JsonProc
JsonNode garbageNode = mapper.readTree("{\"data\": {\"src_locations\": \"abc\"}}");
try {
SnowflakeFileTransferAgent.getFileTransferMetadatas(garbageNode);
- Assert.assertTrue(false);
+ assertTrue(false);
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(
err.getMessage().contains("JDBC driver internal error: src_locations must be an array"));
}
}
@@ -340,10 +342,10 @@ public void testGetFileMetadatasEncryptionMaterialsException() {
foo.put("encryptionMaterial", "[1, 2, 3]]");
try {
SnowflakeFileTransferAgent.getFileTransferMetadatas(modifiedNode);
- Assert.assertTrue(false);
+ assertTrue(false);
} catch (SnowflakeSQLException err) {
- Assert.assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
- Assert.assertTrue(err.getMessage().contains("Failed to parse encryptionMaterial"));
+ assertEquals((long) ErrorCode.INTERNAL_ERROR.getMessageCode(), err.getErrorCode());
+ assertTrue(err.getMessage().contains("Failed to parse encryptionMaterial"));
}
}
}
diff --git a/src/test/java/net/snowflake/client/jdbc/GCPLargeResult.java b/src/test/java/net/snowflake/client/jdbc/GCPLargeResult.java
index b2c316d50..44f9b7a48 100644
--- a/src/test/java/net/snowflake/client/jdbc/GCPLargeResult.java
+++ b/src/test/java/net/snowflake/client/jdbc/GCPLargeResult.java
@@ -3,41 +3,37 @@
*/
package net.snowflake.client.jdbc;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
+import net.snowflake.client.providers.SimpleResultFormatProvider;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ArgumentsSource;
-@RunWith(Parameterized.class)
+@Tag(TestTags.RESULT_SET)
public class GCPLargeResult extends BaseJDBCTest {
- private final String queryResultFormat;
- @Parameterized.Parameters(name = "format={0}")
- public static Object[][] data() {
- return new Object[][] {{"JSON"}, {"ARROW"}};
- }
-
- public GCPLargeResult(String queryResultFormat) {
- this.queryResultFormat = queryResultFormat;
- }
-
- Connection init() throws SQLException {
+ Connection init(String queryResultFormat) throws SQLException {
Connection conn = BaseJDBCTest.getConnection("gcpaccount");
+ System.out.println("Connected");
try (Statement stmt = conn.createStatement()) {
stmt.execute("alter session set jdbc_query_result_format = '" + queryResultFormat + "'");
}
return conn;
}
- @Test
- public void testLargeResultSetGCP() throws Throwable {
- try (Connection con = init();
+ @ParameterizedTest
+ @ArgumentsSource(SimpleResultFormatProvider.class)
+ @DontRunOnGithubActions
+ public void testLargeResultSetGCP(String queryResultFormat) throws Throwable {
+ try (Connection con = init(queryResultFormat);
PreparedStatement stmt =
con.prepareStatement(
"select seq8(), randstr(1000, random()) from table(generator(rowcount=>1000))")) {
diff --git a/src/test/java/net/snowflake/client/jdbc/GitRepositoryDownloadLatestIT.java b/src/test/java/net/snowflake/client/jdbc/GitRepositoryDownloadLatestIT.java
index b720591de..975f8ebb7 100644
--- a/src/test/java/net/snowflake/client/jdbc/GitRepositoryDownloadLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/GitRepositoryDownloadLatestIT.java
@@ -3,9 +3,9 @@
*/
package net.snowflake.client.jdbc;
-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 java.io.IOException;
import java.io.InputStream;
@@ -17,14 +17,13 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
import org.apache.commons.io.IOUtils;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
-@Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class GitRepositoryDownloadLatestIT extends BaseJDBCTest {
/**
@@ -32,7 +31,7 @@ public class GitRepositoryDownloadLatestIT extends BaseJDBCTest {
* accountadmin role. Added in > 3.19.0
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void shouldDownloadFileAndStreamFromGitRepository() throws Exception {
try (Connection connection = getConnection()) {
prepareJdbcRepoInSnowflake(connection);
@@ -48,8 +47,8 @@ public void shouldDownloadFileAndStreamFromGitRepository() throws Exception {
List fetchedStreamContent =
getContentFromStream(connection, stageName, filePathInGitRepo);
- assertFalse("File content cannot be empty", fetchedFileContent.isEmpty());
- assertFalse("Stream content cannot be empty", fetchedStreamContent.isEmpty());
+ assertFalse(fetchedFileContent.isEmpty(), "File content cannot be empty");
+ assertFalse(fetchedStreamContent.isEmpty(), "Stream content cannot be empty");
assertEquals(fetchedFileContent, fetchedStreamContent);
}
}
@@ -80,7 +79,7 @@ private static List getContentFromFile(
try (Statement statement = connection.createStatement();
ResultSet rs = statement.executeQuery(command); ) {
// then
- assertTrue("has result", rs.next());
+ assertTrue(rs.next(), "has result");
return Files.readAllLines(downloadedFile);
} finally {
Files.delete(downloadedFile);
diff --git a/src/test/java/net/snowflake/client/jdbc/HeartbeatAsyncLatestIT.java b/src/test/java/net/snowflake/client/jdbc/HeartbeatAsyncLatestIT.java
index e7217f695..350a9faf8 100644
--- a/src/test/java/net/snowflake/client/jdbc/HeartbeatAsyncLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/HeartbeatAsyncLatestIT.java
@@ -1,9 +1,9 @@
package net.snowflake.client.jdbc;
import static org.awaitility.Awaitility.await;
-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 java.sql.Connection;
import java.sql.ResultSet;
@@ -12,18 +12,18 @@
import java.time.Duration;
import java.util.Properties;
import java.util.logging.Logger;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryOthers;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.QueryStatus;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/**
* Test class for using heartbeat with asynchronous querying. This is a "Latest" class because old
* driver versions do not contain the asynchronous querying API.
*/
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class HeartbeatAsyncLatestIT extends HeartbeatIT {
private static Logger logger = Logger.getLogger(HeartbeatAsyncLatestIT.class.getName());
@@ -69,20 +69,20 @@ protected void submitQuery(boolean useKeepAliveSession, int queryIdx)
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testAsynchronousQuerySuccess() throws Exception {
testSuccess();
}
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testAsynchronousQueryFailure() throws Exception {
testFailure();
}
/** Test that isValid() function returns false when session is expired */
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testIsValidWithInvalidSession() throws Exception {
try (Connection connection = getConnection()) {
// assert that connection starts out valid
diff --git a/src/test/java/net/snowflake/client/jdbc/HeartbeatIT.java b/src/test/java/net/snowflake/client/jdbc/HeartbeatIT.java
index eb41ce76f..832fe7a63 100644
--- a/src/test/java/net/snowflake/client/jdbc/HeartbeatIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/HeartbeatIT.java
@@ -5,10 +5,9 @@
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThat;
-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.fail;
import java.sql.Connection;
import java.sql.ResultSet;
@@ -24,16 +23,18 @@
import java.util.concurrent.Future;
import java.util.logging.Logger;
import net.snowflake.client.AbstractDriverIT;
-import net.snowflake.client.ConditionalIgnoreRule;
-import net.snowflake.client.RunningOnGithubAction;
-import net.snowflake.client.category.TestCategoryOthers;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
+import net.snowflake.client.AssumptionUtils;
+import net.snowflake.client.annotations.DontRunOnGithubActions;
+import net.snowflake.client.category.TestTags;
+import org.hamcrest.MatcherAssert;
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.Test;
/** This test assumes that GS has been set up */
-@Category(TestCategoryOthers.class)
+// @Category(TestCategoryOthers.class)
+@Tag(TestTags.OTHERS)
public class HeartbeatIT extends AbstractDriverIT {
private static Logger logger = Logger.getLogger(HeartbeatIT.class.getName());
@@ -43,9 +44,9 @@ public class HeartbeatIT extends AbstractDriverIT {
* change the master token validity to 10 seconds change the session token validity to 5
* seconds change the SESSION_RECORD_ACCESS_INTERVAL_SECS to 1 second
*/
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws Exception {
- if (!RunningOnGithubAction.isRunningOnGithubAction()) {
+ if (!AssumptionUtils.isRunningOnGithubAction()) {
try (Connection connection = getSnowflakeAdminConnection();
Statement statement = connection.createStatement()) {
statement.execute(
@@ -61,9 +62,9 @@ public static void setUpClass() throws Exception {
* Reset master_token_validity, session_token_validity, SESSION_RECORD_ACCESS_INTERVAL_SECS to
* default.
*/
- @AfterClass
+ @AfterAll
public static void tearDownClass() throws Exception {
- if (!RunningOnGithubAction.isRunningOnGithubAction()) {
+ if (!AssumptionUtils.isRunningOnGithubAction()) {
try (Connection connection = getSnowflakeAdminConnection();
Statement statement = connection.createStatement()) {
statement.execute(
@@ -115,7 +116,7 @@ protected void submitQuery(boolean useKeepAliveSession, int queryIdx)
* master token validity and issue a query to make sure the query succeeds.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testSuccess() throws Exception {
int concurrency = 10;
ExecutorService executorService = Executors.newFixedThreadPool(10);
@@ -146,7 +147,7 @@ public void testSuccess() throws Exception {
* master token validity and issue a query to make sure the query fails.
*/
@Test
- @ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubAction.class)
+ @DontRunOnGithubActions
public void testFailure() throws Exception {
ExecutorService executorService = Executors.newFixedThreadPool(1);
try {
@@ -166,12 +167,15 @@ public void testFailure() throws Exception {
fail("should fail and raise an exception");
} catch (ExecutionException ex) {
Throwable rootCause = ex.getCause();
- assertThat("Runtime Exception", rootCause, instanceOf(RuntimeSQLException.class));
+ MatcherAssert.assertThat(
+ "Runtime Exception", rootCause, instanceOf(RuntimeSQLException.class));
rootCause = rootCause.getCause();
- assertThat("Root cause class", rootCause, instanceOf(SnowflakeSQLException.class));
- assertThat("Error code", ((SnowflakeSQLException) rootCause).getErrorCode(), equalTo(390114));
+ MatcherAssert.assertThat(
+ "Root cause class", rootCause, instanceOf(SnowflakeSQLException.class));
+ MatcherAssert.assertThat(
+ "Error code", ((SnowflakeSQLException) rootCause).getErrorCode(), equalTo(390114));
}
}
diff --git a/src/test/java/net/snowflake/client/jdbc/LobSizeLatestIT.java b/src/test/java/net/snowflake/client/jdbc/LobSizeLatestIT.java
index 56f02c6d5..4cc006a2c 100644
--- a/src/test/java/net/snowflake/client/jdbc/LobSizeLatestIT.java
+++ b/src/test/java/net/snowflake/client/jdbc/LobSizeLatestIT.java
@@ -3,8 +3,8 @@
*/
package net.snowflake.client.jdbc;
-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 java.io.File;
import java.io.IOException;
@@ -17,25 +17,27 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
-import net.snowflake.client.category.TestCategoryStatement;
+import java.util.stream.Stream;
+import net.snowflake.client.category.TestTags;
import net.snowflake.client.core.ObjectMapperFactory;
import net.snowflake.client.core.UUIDUtils;
import org.apache.commons.text.RandomStringGenerator;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.experimental.categories.Category;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-
-@RunWith(Parameterized.class)
-@Category(TestCategoryStatement.class)
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Tag;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.ArgumentsProvider;
+import org.junit.jupiter.params.provider.ArgumentsSource;
+
+// @Category(TestCategoryStatement.class)
+@Tag(TestTags.STATEMENT)
public class LobSizeLatestIT extends BaseJDBCTest {
private static final Logger logger = Logger.getLogger(SnowflakeDriverIT.class.getName());
@@ -48,15 +50,16 @@ public class LobSizeLatestIT extends BaseJDBCTest {
private static int smallLobSize = 16;
private static int originLobSize = 16 * 1024 * 1024;
- @BeforeClass
+ @BeforeAll
public static void setUp() throws SQLException {
- System.setProperty(
- // the max json string should be ~1.33 for Arrow response so let's use 1.5 to be sure
- ObjectMapperFactory.MAX_JSON_STRING_LENGTH_JVM, Integer.toString((int) (maxLobSize * 1.5)));
try (Connection con = BaseJDBCTest.getConnection()) {
// get max LOB size from session
maxLobSize = con.getMetaData().getMaxCharLiteralLength();
logger.log(Level.INFO, "Using max lob size: " + maxLobSize);
+ System.setProperty(
+ // the max json string should be ~1.33 for Arrow response so let's use 1.5 to be sure
+ ObjectMapperFactory.MAX_JSON_STRING_LENGTH_JVM,
+ Integer.toString((int) (maxLobSize * 1.5)));
LobSizeStringValues.put(smallLobSize, generateRandomString(smallLobSize));
LobSizeStringValues.put(originLobSize, generateRandomString(originLobSize));
LobSizeStringValues.put(mediumLobSize, generateRandomString(mediumLobSize));
@@ -65,31 +68,20 @@ public static void setUp() throws SQLException {
}
}
- @Parameterized.Parameters(name = "lobSize={0}, resultFormat={1}")
- public static Collection