You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2023/03/17 16:32:24 UTC
[camel-quarkus] branch main updated: Make AWS test class names in grouped testing unique
This is an automated email from the ASF dual-hosted git repository.
aldettinger pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push:
new 1b6fbb4642 Make AWS test class names in grouped testing unique
1b6fbb4642 is described below
commit 1b6fbb4642efa9e3ed7bfa3b4c4662976a73823e
Author: James Netherton <ja...@gmail.com>
AuthorDate: Fri Mar 17 10:43:49 2023 +0000
Make AWS test class names in grouped testing unique
Fixes #4664
---
.../aws2-quarkus-client/aws2-ddb/pom.xml | 5 +++
.../aws2-quarkus-client/aws2-s3/pom.xml | 5 +++
.../aws2-quarkus-client/aws2-ses/pom.xml | 5 +++
.../aws2-quarkus-client/aws2-sqs-sns/pom.xml | 5 +++
.../aws2-quarkus-client/aws2-sqs/pom.xml | 5 +++
integration-tests/aws2-grouped/pom.xml | 5 +++
.../aws2-quarkus-client-grouped/pom.xml | 10 ++++++
tooling/scripts/copy-tests.groovy | 11 ++++--
tooling/scripts/group-test-utils.groovy | 42 ++++++++++++++++++++++
tooling/scripts/group-tests.groovy | 7 ++++
10 files changed, 98 insertions(+), 2 deletions(-)
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml b/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
index b09ffd2f50..4d045c0a6c 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-ddb/pom.xml
@@ -30,6 +30,10 @@
<name>Camel Quarkus :: Integration Tests :: AWS 2 DynamoDB Quarkus Client</name>
<description>Integration tests for Camel Quarkus AWS 2 DynamoDB extension with the Quarkus AWS DynamoDB client</description>
+ <properties>
+ <test.class.name.prefix>QuarkusClient</test.class.name.prefix>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
@@ -124,6 +128,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-ddb</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties, **/*Stream*</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml b/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml
index f7d00ef6e6..217a29d737 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-s3/pom.xml
@@ -30,6 +30,10 @@
<name>Camel Quarkus :: Integration Tests :: AWS 2 S3 Quarkus Client</name>
<description>Integration tests for Camel Quarkus AWS 2 S3 extension with the Quarkus AWS S3 client</description>
+ <properties>
+ <test.class.name.prefix>QuarkusClient</test.class.name.prefix>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
@@ -128,6 +132,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-s3</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml b/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml
index 65d9f38039..52483b3975 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-ses/pom.xml
@@ -30,6 +30,10 @@
<name>Camel Quarkus :: Integration Tests :: Simple Email Service (SES) Quarkus Client</name>
<description>Integration tests for Camel Quarkus AWS Simple Email Service (SES) extension with the Quarkus AWS SES client</description>
+ <properties>
+ <test.class.name.prefix>QuarkusClient</test.class.name.prefix>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
@@ -129,6 +133,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-ses</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml b/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml
index f702a22661..b7a3e40590 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-sqs-sns/pom.xml
@@ -30,6 +30,10 @@
<name>Camel Quarkus :: Integration Tests :: AWS 2 SQS and SNS Quarkus Client</name>
<description>Integration tests for SQS and SNS extensions with the Quarkus AWS clients</description>
+ <properties>
+ <test.class.name.prefix>QuarkusClient</test.class.name.prefix>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
@@ -132,6 +136,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-sqs-sns</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
diff --git a/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml b/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml
index 2980f3b83d..9602099585 100644
--- a/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml
+++ b/integration-test-groups/aws2-quarkus-client/aws2-sqs/pom.xml
@@ -30,6 +30,10 @@
<name>Camel Quarkus :: Integration Tests :: AWS 2 SQS Quarkus Client</name>
<description>Integration tests for SQS extensions with the Quarkus AWS clients</description>
+ <properties>
+ <test.class.name.prefix>QuarkusClient</test.class.name.prefix>
+ </properties>
+
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
@@ -129,6 +133,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-sqs</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
diff --git a/integration-tests/aws2-grouped/pom.xml b/integration-tests/aws2-grouped/pom.xml
index 82abb97953..508e995b08 100644
--- a/integration-tests/aws2-grouped/pom.xml
+++ b/integration-tests/aws2-grouped/pom.xml
@@ -30,6 +30,10 @@
<name>Camel Quarkus :: Integration Tests :: AWS2 Grouped</name>
<description>AWS 2 tests from ../integration-test-groups/aws2 merged together</description>
+ <properties>
+ <test.class.name.prefix>Grouped</test.class.name.prefix>
+ </properties>
+
<!-- Regenerate the dependencies via `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependencies>
<dependency>
@@ -145,6 +149,7 @@
<group-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2</group-tests.source.dir>
<group-tests.dest.module.dir>${project.basedir}</group-tests.dest.module.dir>
<group-tests.concat.rel.paths>src/main/resources/application.properties,src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer</group-tests.concat.rel.paths>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
diff --git a/integration-tests/aws2-quarkus-client-grouped/pom.xml b/integration-tests/aws2-quarkus-client-grouped/pom.xml
index e22c0440ea..dc25b9750f 100644
--- a/integration-tests/aws2-quarkus-client-grouped/pom.xml
+++ b/integration-tests/aws2-quarkus-client-grouped/pom.xml
@@ -30,6 +30,10 @@
<name>Camel Quarkus :: Integration Tests :: AWS2 Quarkus Client Grouped</name>
<description>AWS 2 tests from ../integration-test-groups/aws2-quarkus-client merged together</description>
+ <properties>
+ <test.class.name.prefix>GroupedQuarkusClient</test.class.name.prefix>
+ </properties>
+
<!-- Regenerate the dependencies via `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependencies>
<dependency>
@@ -164,6 +168,7 @@
<group-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2-quarkus-client</group-tests.source.dir>
<group-tests.dest.module.dir>${project.basedir}</group-tests.dest.module.dir>
<group-tests.concat.rel.paths>src/main/resources/application.properties,src/test/resources/META-INF/services/org.apache.camel.quarkus.test.support.aws2.Aws2TestEnvCustomizer</group-tests.concat.rel.paths>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
@@ -179,6 +184,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-ses</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
@@ -194,6 +200,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-ddb</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties,**/*Stream*</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
@@ -209,6 +216,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-s3</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
@@ -224,6 +232,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-sqs</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
@@ -239,6 +248,7 @@
<copy-tests.source.dir>${maven.multiModuleProjectDirectory}/integration-test-groups/aws2/aws2-sqs-sns</copy-tests.source.dir>
<copy-tests.dest.module.dir>${project.basedir}</copy-tests.dest.module.dir>
<copy-tests.excludes>**/*TestEnvCustomizer,**/*application.properties</copy-tests.excludes>
+ <group-tests.class.name.prefix>${test.class.name.prefix}</group-tests.class.name.prefix>
</properties>
</configuration>
</execution>
diff --git a/tooling/scripts/copy-tests.groovy b/tooling/scripts/copy-tests.groovy
index 2120b73c1c..4c00f779a4 100644
--- a/tooling/scripts/copy-tests.groovy
+++ b/tooling/scripts/copy-tests.groovy
@@ -27,19 +27,26 @@ import java.util.regex.Pattern
import java.util.regex.Matcher
import groovy.ant.AntBuilder
-/* Copies source files from one source test modulesinto one destination module (`copy-tests.dest.module.dir`)
+/* Copies source files from one source test modules into one destination module (`copy-tests.dest.module.dir`)
* so that the tests can be executed. Use of ('copy-tests.exclude') allows to exclude files.
*/
final Path sourceDir = Paths.get(properties['copy-tests.source.dir'])
final Path destinationModuleDir = Paths.get(properties['copy-tests.dest.module.dir'])
final String excl = properties['copy-tests.excludes']
+final String classNamePrefix = properties['group-tests.class.name.prefix'] ?: ""
copyResources(sourceDir.resolve('src/main/resources'), destinationModuleDir.resolve('target/classes'), excl)
copyResources(sourceDir.resolve('src/main/java'), destinationModuleDir.resolve('target/src/main/java'), excl)
copyResources(sourceDir.resolve('src/test/java'), destinationModuleDir.resolve('target/src/test/java'), excl)
copyResources(sourceDir.resolve('src/test/resources'), destinationModuleDir.resolve('target/test-classes'), excl)
-
+
+String scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent
+File sourceFile = new File("${scriptDir}/group-test-utils.groovy")
+Class groovyClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(sourceFile);
+GroovyObject utils = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance();
+utils.makeTestClassNamesUnique(destinationModuleDir.resolve('target/src/test/java').toFile(), classNamePrefix)
+
static void copyResources(Path source, Path dest, String excl) {
if (Files.exists(source)) {
new AntBuilder().copy(todir: dest) {
diff --git a/tooling/scripts/group-test-utils.groovy b/tooling/scripts/group-test-utils.groovy
new file mode 100644
index 0000000000..420bd2ed84
--- /dev/null
+++ b/tooling/scripts/group-test-utils.groovy
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+def makeTestClassNamesUnique(File sourceDir, String classNamePrefix) {
+ if (!classNamePrefix.isEmpty()) {
+ sourceDir.eachFileRecurse { file ->
+ String originalName = file.name
+ if ((originalName.endsWith("Test.java") || originalName.endsWith("IT.java")) && !originalName.startsWith(classNamePrefix)) {
+ String className = originalName.replace(".java", "")
+ String newClassName = "${classNamePrefix}${className}"
+
+ String content = file.text
+ content = content.replaceAll(className, "${classNamePrefix}${className}")
+
+ if (originalName.endsWith("IT.java")) {
+ String originalExtendsClassName = className.replace("IT", "Test")
+ String extendsClassName = newClassName.replace("IT", "Test")
+ content = content.replaceAll(originalExtendsClassName, extendsClassName)
+ }
+
+ file.write(content)
+
+ String path = file.absolutePath.replace(originalName, "${classNamePrefix}${originalName}")
+ file.renameTo(path)
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/tooling/scripts/group-tests.groovy b/tooling/scripts/group-tests.groovy
index 2960e39aad..509dc07744 100644
--- a/tooling/scripts/group-tests.groovy
+++ b/tooling/scripts/group-tests.groovy
@@ -35,6 +35,7 @@ final Path sourceDir = Paths.get(properties['group-tests.source.dir'])
final String[] concatRelPaths = properties['group-tests.concat.rel.paths'].split('[\\s,]+')
final Path destinationModuleDir = Paths.get(properties['group-tests.dest.module.dir'])
final String excludes = properties['group-tests.files.excludes'] ?: ""
+final String classNamePrefix = properties['group-tests.class.name.prefix'] ?: ""
final List<String> fileExcludes = excludes.split('[\\s,]+') as List
/* Property names whose values originating from distinct application.properties files can be concatenated using comma as a separator */
final Set<String> commaConcatenatePropertyNames = ["quarkus.native.resources.includes", "quarkus.native.resources.excludes"] as Set
@@ -56,6 +57,12 @@ Files.list(sourceDir)
copyResources(p.resolve('src/test/resources'), destinationModuleDir.resolve('src/test/resources'))
}
+String scriptDir = new File(getClass().protectionDomain.codeSource.location.path).parent
+File sourceFile = new File("${scriptDir}/group-test-utils.groovy")
+Class groovyClass = new GroovyClassLoader(getClass().getClassLoader()).parseClass(sourceFile)
+GroovyObject utils = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance()
+utils.makeTestClassNamesUnique(destinationModuleDir.resolve('src/test/java').toFile(), classNamePrefix)
+
Path gitignorePath = destinationModuleDir.resolve('.gitignore')
String gitignoreContent = ''
if (Files.isRegularFile(gitignorePath)) {