From ffc1e7be2a37a58ed5cb8b50d213207052375846 Mon Sep 17 00:00:00 2001 From: Yi Hu Date: Tue, 19 Sep 2023 20:41:45 -0400 Subject: [PATCH] spotless and checkstyle; exclude not-sync file --- .../org/apache/beam/it/gcp/JDBCBaseIT.java | 161 ------------------ .../gcp/bigtable/BigtableResourceManager.java | 1 + .../gcp/dataflow/DefaultPipelineLauncher.java | 4 +- .../src/main/resources/test-artifact.txt | 1 - .../beam/it/neo4j/Neo4jResourceManagerIT.java | 1 - .../it/neo4j/Neo4jResourceManagerTest.java | 1 - .../neo4j/Neo4jResourceManagerUtilsTest.java | 1 - .../beam/it/splunk/SplunkClientFactory.java | 1 - .../beam/it/splunk/SplunkContainer.java | 1 - .../SplunkResourceManagerException.java | 1 - .../it/splunk/SplunkResourceManagerUtils.java | 1 - .../splunk/conditions/SplunkEventsCheck.java | 1 - .../it/splunk/matchers/SplunkAsserts.java | 1 - .../it/splunk/SplunkResourceManagerIT.java | 1 - .../it/splunk/SplunkResourceManagerTest.java | 1 - .../SplunkResourceManagerUtilsTest.java | 1 - ...TestContainerResourceManagerException.java | 1 - .../TestContainersIntegrationTest.java | 1 - .../it/truthmatchers/ListAccumulator.java | 4 +- 19 files changed, 4 insertions(+), 181 deletions(-) delete mode 100644 it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/JDBCBaseIT.java delete mode 100644 it/google-cloud-platform/src/main/resources/test-artifact.txt diff --git a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/JDBCBaseIT.java b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/JDBCBaseIT.java deleted file mode 100644 index 17529f8caad1..000000000000 --- a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/JDBCBaseIT.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.beam.it.gcp; - -import java.io.IOException; -import java.io.InputStream; -import java.nio.charset.StandardCharsets; -import org.apache.beam.it.common.utils.IORedirectUtil; -import org.junit.Before; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public abstract class JDBCBaseIT extends TemplateTestBase { - - private static final Logger LOG = LoggerFactory.getLogger(JDBCBaseIT.class); - - // The sub-folder to store the jars in GCS. - private static final String GCS_PREFIX = "jars/"; - - // The .jar suffix for generating JDBC jar names - private static final String JAR_SUFFIX = ".jar"; - - // The JDBC Driver fully-qualified class names - protected static final String MYSQL_DRIVER = "com.mysql.jdbc.Driver"; - protected static final String POSTGRES_DRIVER = "org.postgresql.Driver"; - protected static final String ORACLE_DRIVER = "oracle.jdbc.driver.OracleDriver"; - protected static final String MSSQL_DRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; - - // The relative path to the JDBC drivers under Maven's `.m2/repository` directory - private static final String MYSQL_LOCAL_PATH = "mysql/mysql-connector-java"; - private static final String POSTGRES_LOCAL_PATH = "org/postgresql/postgresql"; - private static final String ORACLE_LOCAL_PATH = "com/oracle/database/jdbc/ojdbc8"; - private static final String MSSQL_LOCAL_PATH = "com/microsoft/sqlserver/mssql-jdbc"; - - // The name of the JDBC driver jars sans the .jar suffix - private static final String MYSQL_JAR_PREFIX = "mysql-connector-java"; - private static final String POSTGRES_JAR_PREFIX = "postgresql"; - private static final String ORACLE_JAR_PREFIX = "ojdbc8"; - private static final String MSSQL_JAR_PREFIX = "mssql-jdbc"; - - // The versions of each of the JDBC drivers to use. - // NOTE: These versions must correspond to the versions declared in the `it/pom.xml` file. - private static final String MYSQL_VERSION = "8.0.30"; - private static final String POSTGRES_VERSION = "42.6.0"; - private static final String ORACLE_VERSION = "23.2.0.0"; - private static final String MSSQL_VERSION = "12.2.0.jre11"; - - @Before - public void setUpJDBC() throws IOException { - - String basePath = getMvnBaseRepoPath(); - - String mySqlDriverGCSRelativePath = GCS_PREFIX + mySqlDriverLocalJar(); - String postgresDriverGCSRelativePath = GCS_PREFIX + postgresDriverLocalJar(); - String oracleDriverGCSRelativePath = GCS_PREFIX + oracleDriverLocalJar(); - String msSqlDriverGCSRelativePath = GCS_PREFIX + msSqlDriverLocalJar(); - - gcsClient.uploadArtifact(mySqlDriverGCSRelativePath, mySqlDriverLocalPath(basePath)); - gcsClient.uploadArtifact(postgresDriverGCSRelativePath, postgresDriverLocalPath(basePath)); - gcsClient.uploadArtifact(oracleDriverGCSRelativePath, oracleDriverLocalPath(basePath)); - gcsClient.uploadArtifact(msSqlDriverGCSRelativePath, msSqlDriverLocalPath(basePath)); - } - - protected String mySqlDriverGCSPath() { - return getGcsPath(GCS_PREFIX + mySqlDriverLocalJar()); - } - - protected String postgresDriverGCSPath() { - return getGcsPath(GCS_PREFIX + postgresDriverLocalJar()); - } - - protected String oracleDriverGCSPath() { - return getGcsPath(GCS_PREFIX + oracleDriverLocalJar()); - } - - protected String msSqlDriverGCSPath() { - return getGcsPath(GCS_PREFIX + msSqlDriverLocalJar()); - } - - private static String mySqlDriverLocalJar() { - return String.join("-", MYSQL_JAR_PREFIX, MYSQL_VERSION) + JAR_SUFFIX; - } - - private static String postgresDriverLocalJar() { - return String.join("-", POSTGRES_JAR_PREFIX, POSTGRES_VERSION) + JAR_SUFFIX; - } - - private static String oracleDriverLocalJar() { - return String.join("-", ORACLE_JAR_PREFIX, ORACLE_VERSION) + JAR_SUFFIX; - } - - private static String msSqlDriverLocalJar() { - return String.join("-", MSSQL_JAR_PREFIX, MSSQL_VERSION) + JAR_SUFFIX; - } - - private static String mySqlDriverLocalPath(String basePath) { - return String.join("/", basePath, MYSQL_LOCAL_PATH, MYSQL_VERSION, mySqlDriverLocalJar()); - } - - private static String postgresDriverLocalPath(String basePath) { - return String.join( - "/", basePath, POSTGRES_LOCAL_PATH, POSTGRES_VERSION, postgresDriverLocalJar()); - } - - private static String oracleDriverLocalPath(String basePath) { - return String.join("/", basePath, ORACLE_LOCAL_PATH, ORACLE_VERSION, oracleDriverLocalJar()); - } - - private static String msSqlDriverLocalPath(String basePath) { - return String.join("/", basePath, MSSQL_LOCAL_PATH, MSSQL_VERSION, msSqlDriverLocalJar()); - } - - private String getMvnBaseRepoPath() { - // Try to get specified maven repo path from args - if (System.getProperty("mavenRepository") != null) { - String basePath = System.getProperty("mavenRepository"); - return basePath.endsWith("/") ? basePath.substring(0, basePath.length() - 1) : basePath; - } - - // Default to Maven settings.localRepository - String mavenCmd = "mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout"; - try { - Process exec = Runtime.getRuntime().exec(mavenCmd); - IORedirectUtil.redirectLinesLog(exec.getErrorStream(), LOG); - InputStream inStream = exec.getInputStream(); - - if (exec.waitFor() != 0) { - throw new RuntimeException("Error retrieving Maven repo path, check Maven logs."); - } - - byte[] allBytes = inStream.readAllBytes(); - String basePath = new String(allBytes, StandardCharsets.UTF_8); - - // Remove color reset chars "\033[0m" sent to terminal output - basePath = - basePath.replace(new String(new byte[] {27, 91, 48, 109}, StandardCharsets.UTF_8), ""); - - inStream.close(); - - return basePath; - - } catch (Exception e) { - throw new IllegalArgumentException("Error retrieving Maven repo path", e); - } - } -} diff --git a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java index bccdaa1e1f55..713880229281 100644 --- a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java +++ b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/bigtable/BigtableResourceManager.java @@ -116,6 +116,7 @@ private BigtableResourceManager(Builder builder) throws IOException { this.createdTables = new ArrayList<>(); this.createdAppProfiles = new ArrayList<>(); this.cdcEnabledTables = new HashSet<>(); + this.clusters = new ArrayList<>(); // Check if RM was configured to use static Bigtable instance. if (builder.useStaticInstance) { diff --git a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/dataflow/DefaultPipelineLauncher.java b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/dataflow/DefaultPipelineLauncher.java index c34c5b007fe7..ad2dcafc007b 100644 --- a/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/dataflow/DefaultPipelineLauncher.java +++ b/it/google-cloud-platform/src/main/java/org/apache/beam/it/gcp/dataflow/DefaultPipelineLauncher.java @@ -416,8 +416,8 @@ private List extractOptions(String project, String region, LaunchConfig // add pipeline options from beamTestPipelineOptions system property to preserve the // pipeline options already set in TestPipeline. - @Nullable String beamTestPipelineOptions = - System.getProperty(PROPERTY_BEAM_TEST_PIPELINE_OPTIONS); + @Nullable + String beamTestPipelineOptions = System.getProperty(PROPERTY_BEAM_TEST_PIPELINE_OPTIONS); if (!Strings.isNullOrEmpty(beamTestPipelineOptions)) { try { additionalOptions.addAll(MAPPER.readValue(beamTestPipelineOptions, List.class)); diff --git a/it/google-cloud-platform/src/main/resources/test-artifact.txt b/it/google-cloud-platform/src/main/resources/test-artifact.txt deleted file mode 100644 index 22c4e1d122a7..000000000000 --- a/it/google-cloud-platform/src/main/resources/test-artifact.txt +++ /dev/null @@ -1 +0,0 @@ -This is a test artifact. \ No newline at end of file diff --git a/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerIT.java b/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerIT.java index d341102f64ec..c1038c2e12c9 100644 --- a/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerIT.java +++ b/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerIT.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.neo4j; import static com.google.common.truth.Truth.assertThat; diff --git a/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerTest.java b/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerTest.java index bf5b3b75a6ec..5014505ece9c 100644 --- a/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerTest.java +++ b/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerTest.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.neo4j; import static com.google.common.truth.Truth.assertThat; diff --git a/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerUtilsTest.java b/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerUtilsTest.java index 61094000029c..b3d37408f88b 100644 --- a/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerUtilsTest.java +++ b/it/neo4j/src/test/java/org/apache/beam/it/neo4j/Neo4jResourceManagerUtilsTest.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.neo4j; import static com.google.common.truth.Truth.assertThat; diff --git a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkClientFactory.java b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkClientFactory.java index 06af2d01f3ca..086e9c9f9656 100644 --- a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkClientFactory.java +++ b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkClientFactory.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk; import com.splunk.Service; diff --git a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkContainer.java b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkContainer.java index 896e3155e0e4..68950a2628a2 100644 --- a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkContainer.java +++ b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkContainer.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk; import java.time.Duration; diff --git a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerException.java b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerException.java index c48812c76329..3e0b57ffd1d8 100644 --- a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerException.java +++ b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerException.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk; /** Custom exception for {@link SplunkResourceManager} implementations. */ diff --git a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerUtils.java b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerUtils.java index 52ebf744d08a..dbf70d5481c0 100644 --- a/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerUtils.java +++ b/it/splunk/src/main/java/org/apache/beam/it/splunk/SplunkResourceManagerUtils.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk; import static org.apache.beam.it.common.utils.ResourceManagerUtils.generatePassword; diff --git a/it/splunk/src/main/java/org/apache/beam/it/splunk/conditions/SplunkEventsCheck.java b/it/splunk/src/main/java/org/apache/beam/it/splunk/conditions/SplunkEventsCheck.java index bb8a6a3c3794..e9ae4f68c90f 100644 --- a/it/splunk/src/main/java/org/apache/beam/it/splunk/conditions/SplunkEventsCheck.java +++ b/it/splunk/src/main/java/org/apache/beam/it/splunk/conditions/SplunkEventsCheck.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk.conditions; import com.google.auto.value.AutoValue; diff --git a/it/splunk/src/main/java/org/apache/beam/it/splunk/matchers/SplunkAsserts.java b/it/splunk/src/main/java/org/apache/beam/it/splunk/matchers/SplunkAsserts.java index 7215b5ea47eb..62a11f5ab7c6 100644 --- a/it/splunk/src/main/java/org/apache/beam/it/splunk/matchers/SplunkAsserts.java +++ b/it/splunk/src/main/java/org/apache/beam/it/splunk/matchers/SplunkAsserts.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk.matchers; import static org.apache.beam.it.splunk.SplunkResourceManagerUtils.splunkEventToMap; diff --git a/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerIT.java b/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerIT.java index a0a7cf368b2f..d11f01a70b0a 100644 --- a/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerIT.java +++ b/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerIT.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk; import static org.apache.beam.it.splunk.matchers.SplunkAsserts.assertThatSplunkEvents; diff --git a/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerTest.java b/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerTest.java index 29728a8d14be..ed97bd9f3674 100644 --- a/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerTest.java +++ b/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerTest.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk; import static com.google.common.truth.Truth.assertThat; diff --git a/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerUtilsTest.java b/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerUtilsTest.java index af22bee3a4a0..b4aaec3b45c4 100644 --- a/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerUtilsTest.java +++ b/it/splunk/src/test/java/org/apache/beam/it/splunk/SplunkResourceManagerUtilsTest.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.splunk; import static com.google.common.truth.Truth.assertThat; diff --git a/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainerResourceManagerException.java b/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainerResourceManagerException.java index 27d82e2c279f..a617e008ce94 100644 --- a/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainerResourceManagerException.java +++ b/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainerResourceManagerException.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.testcontainers; /** Custom exception for {@link TestContainerResourceManager} implementations. */ diff --git a/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainersIntegrationTest.java b/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainersIntegrationTest.java index f15472c2e608..1fb8f707bce2 100644 --- a/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainersIntegrationTest.java +++ b/it/testcontainers/src/main/java/org/apache/beam/it/testcontainers/TestContainersIntegrationTest.java @@ -15,7 +15,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.apache.beam.it.testcontainers; import java.lang.annotation.ElementType; diff --git a/it/truthmatchers/src/main/java/org/apache/beam/it/truthmatchers/ListAccumulator.java b/it/truthmatchers/src/main/java/org/apache/beam/it/truthmatchers/ListAccumulator.java index 1d6fe39cc52b..5e8f8c4aff8f 100644 --- a/it/truthmatchers/src/main/java/org/apache/beam/it/truthmatchers/ListAccumulator.java +++ b/it/truthmatchers/src/main/java/org/apache/beam/it/truthmatchers/ListAccumulator.java @@ -54,9 +54,7 @@ public int count() { return this.backingList.size(); } - /** - * @return the internal backing list being accumulated. - */ + /** @return the internal backing list being accumulated. */ public List getBackingList() { return this.backingList; }