Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNOW-1693588 Upgrade to JUnit5 #1909

Open
wants to merge 23 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
fail-fast: false
matrix:
runConfig: [ {cloud: 'AWS', javaVersion: '8'}, {cloud: 'GCP', javaVersion: '11'}, {cloud: 'AZURE', javaVersion: '17'}, {cloud: 'AWS', javaVersion: '21'}]
category: ['TestCategoryResultSet,TestCategoryOthers,TestCategoryLoader,TestCategoryDiagnostic', 'TestCategoryConnection,TestCategoryStatement', 'TestCategoryArrow,TestCategoryCore', 'TestCategoryFips']
category: ['ResultSetTestSuite,OthersTestSuite,LoaderTestSuite,DiagnosticTestSuite', 'ConnectionTestSuite,StatementTestSuite', 'ArrowTestSuite,CoreTestSuite', 'FipsTestSuite']
additionalMavenProfile: ['']
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
fail-fast: false
matrix:
runConfig: [ {cloud: 'AWS', javaVersion: '8'}, {cloud: 'GCP', javaVersion: '11'}, {cloud: 'AZURE', javaVersion: '17'}, {cloud: 'AWS', javaVersion: '21'}]
category: ['TestCategoryResultSet,TestCategoryOthers,TestCategoryLoader,TestCategoryDiagnostic', 'TestCategoryConnection,TestCategoryStatement', 'TestCategoryArrow,TestCategoryCore', 'TestCategoryFips']
category: ['ResultSetTestSuite,OthersTestSuite,LoaderTestSuite,DiagnosticTestSuite', 'ConnectionTestSuite,StatementTestSuite', 'ArrowTestSuite,CoreTestSuite', 'FipsTestSuite']
additionalMavenProfile: ['']
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -107,7 +107,7 @@ jobs:
matrix:
image: [ 'jdbc-centos7-openjdk8', 'jdbc-centos7-openjdk11', 'jdbc-centos7-openjdk17', 'jdbc-centos7-openjdk21' ]
cloud: [ 'AWS', 'AZURE', 'GCP' ]
category: ['TestCategoryResultSet,TestCategoryOthers,TestCategoryLoader,TestCategoryDiagnostic', 'TestCategoryConnection,TestCategoryStatement', 'TestCategoryArrow,TestCategoryCore', 'TestCategoryFips']
category: ['ResultSetTestSuite,OthersTestSuite,LoaderTestSuite,DiagnosticTestSuite', 'ConnectionTestSuite,StatementTestSuite', 'ArrowTestSuite,CoreTestSuite', 'FipsTestSuite']
additionalMavenProfile: ['', '-Dthin-jar']
steps:
- uses: actions/checkout@v1
Expand All @@ -129,7 +129,7 @@ jobs:
matrix:
image: [ 'jdbc-centos7-openjdk8' ]
cloud: [ 'AWS' ]
category: ['TestCategoryResultSet,TestCategoryOthers', 'TestCategoryConnection,TestCategoryStatement', 'TestCategoryCore,TestCategoryLoader']
category: ['ResultSetTestSuite,OthersTestSuite,LoaderTestSuite,DiagnosticTestSuite', 'ConnectionTestSuite,StatementTestSuite', 'ArrowTestSuite,CoreTestSuite']
is_old_driver: ['true']
steps:
- uses: actions/checkout@v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import java.util.TimeZone;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.Rule;

/** Base test class with common constants, data structures and methods */
public class AbstractDriverIT {
// This is required to use ConditionalIgnore annotation.
@Rule public ConditionalIgnoreRule rule = new ConditionalIgnoreRule();

public static final String DRIVER_CLASS = "net.snowflake.client.jdbc.SnowflakeDriver";
public static final String DRIVER_CLASS_COM = "com.snowflake.client.jdbc.SnowflakeDriver";
Expand Down
125 changes: 0 additions & 125 deletions FIPS/src/test/java/net/snowflake/client/ConditionalIgnoreRule.java

This file was deleted.

12 changes: 12 additions & 0 deletions FIPS/src/test/java/net/snowflake/client/DontRunOnGCP.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.snowflake.client;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@DisabledIfEnvironmentVariable(named = "CLOUD_PROVIDER", matches = "(?i)GCP(?-i)")
public @interface DontRunOnGCP {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package net.snowflake.client;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@DisabledIfEnvironmentVariable(named = "GITHUB_ACTIONS", matches = ".*")
public @interface DontRunOnGithubActions {}
12 changes: 0 additions & 12 deletions FIPS/src/test/java/net/snowflake/client/RunningOnGCP.java

This file was deleted.

This file was deleted.

Empty file.
4 changes: 2 additions & 2 deletions FIPS/src/test/java/net/snowflake/client/TestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import net.snowflake.client.core.SFException;
import net.snowflake.client.log.SFLogger;
import net.snowflake.client.log.SFLoggerFactory;
import org.junit.Assert;
import org.junit.jupiter.api.Assertions;

public class TestUtil {
private static final SFLogger logger = SFLoggerFactory.getLogger(TestUtil.class);
Expand All @@ -22,7 +22,7 @@ public class TestUtil {
public static void assertSFException(int errorCode, TestRunInterface testCode) {
try {
testCode.run();
Assert.fail();
Assertions.fail();
} catch (SFException e) {
assertThat(e.getVendorCode(), is(errorCode));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.snowflake.client.category;

import org.junit.platform.suite.api.IncludeTags;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.junit.platform.suite.api.ExcludePackages;
import org.junit.platform.suite.api.IncludeClassNamePatterns;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.platform.suite.api.Suite;
import org.junit.platform.suite.api.SuiteDisplayName;

@Suite
@SuiteDisplayName("Testowanie")
@SelectPackages("net.snowflake.client")
@ExcludePackages("net.snowflake.client.suites")
@IncludeClassNamePatterns(".+")
public class FipsTestSuite {
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
package net.snowflake.client.jdbc;

import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;

import java.net.URL;
import java.nio.file.Files;
Expand All @@ -20,21 +20,21 @@
import java.util.Properties;
import javax.net.ssl.HttpsURLConnection;
import net.snowflake.client.AbstractDriverIT;
import net.snowflake.client.ConditionalIgnoreRule;
import net.snowflake.client.RunningOnGCP;
import net.snowflake.client.RunningOnGithubActions;
import net.snowflake.client.category.TestCategoryFips;
import net.snowflake.client.DontRunOnGCP;
import net.snowflake.client.DontRunOnGithubActions;
import net.snowflake.client.core.SecurityUtil;
import org.apache.commons.codec.binary.Base64;
import org.bouncycastle.crypto.CryptoServicesRegistrar;
import org.bouncycastle.crypto.fips.FipsStatus;
import org.bouncycastle.jcajce.provider.BouncyCastleFipsProvider;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

@Category(TestCategoryFips.class)

//@Category(TestCategoryFips.class)
@Tag("fips")
public class ConnectionFipsIT extends AbstractDriverIT {
private static final String JCE_PROVIDER_BOUNCY_CASTLE_FIPS = "BCFIPS";
private static final String JCE_PROVIDER_SUN_JCE = "SunJCE";
Expand Down Expand Up @@ -106,7 +106,7 @@ public class ConnectionFipsIT extends AbstractDriverIT {
private static int JCE_PROVIDER_SUN_JCE_PROVIDER_POSITION;
private static int JCE_PROVIDER_SUN_RSA_SIGN_PROVIDER_POSITION;

@BeforeClass
@BeforeAll
public static void setup() throws Exception {
System.setProperty("javax.net.debug", "ssl");
// get keystore types for BouncyCastle libraries
Expand Down Expand Up @@ -166,7 +166,7 @@ public static void setup() throws Exception {
// connectToGoogle();
}

@AfterClass
@AfterAll
public static void teardown() throws Exception {
// Remove BouncyCastle FIPS Provider
Security.removeProvider(JCE_PROVIDER_BOUNCY_CASTLE_FIPS);
Expand Down Expand Up @@ -227,7 +227,7 @@ public void connectWithFips() throws SQLException {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void connectWithFipsKeyPair() throws Exception {
Map<String, String> parameters = getConnectionParameters();
String testUser = parameters.get("user");
Expand Down Expand Up @@ -256,7 +256,7 @@ public void connectWithFipsKeyPair() throws Exception {
}

@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void testConnectUsingKeyPair() throws Exception {
Map<String, String> parameters = getConnectionParameters();
String testUser = parameters.get("user");
Expand Down Expand Up @@ -295,7 +295,7 @@ public void testConnectUsingKeyPair() throws Exception {
* Currently ignored execution on GCP due to exception thrown "SSlException Could not generate XDH keypair"
*/
@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGCP.class)
@DontRunOnGCP
public void connectWithFipsAndQuery() throws SQLException {
try (Connection con = getConnection()) {
Statement statement = con.createStatement();
Expand Down Expand Up @@ -329,15 +329,15 @@ public void connectWithFipsAndPut() throws Exception {

/** Added in > 3.15.1 */
@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void connectWithFipsKeyPairWithBouncyCastle() throws Exception {
System.setProperty(SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM, "true");
connectWithFipsKeyPair();
}

/** Added in > 3.15.1 */
@Test
@ConditionalIgnoreRule.ConditionalIgnore(condition = RunningOnGithubActions.class)
@DontRunOnGithubActions
public void testConnectUsingKeyPairWithBouncyCastle() throws Exception {
System.setProperty(SecurityUtil.ENABLE_BOUNCYCASTLE_PROVIDER_JVM, "true");
testConnectUsingKeyPair();
Expand Down
Loading
Loading