You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by re...@apache.org on 2021/04/02 14:45:38 UTC
[cxf] 01/02: CXF-8393: Umbrella issue to address fixing flaky tests
(#760)
This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit a61e6ced65033628902e91c92b70fe1e938565d0
Author: Andriy Redko <dr...@gmail.com>
AuthorDate: Wed Mar 24 19:15:58 2021 -0400
CXF-8393: Umbrella issue to address fixing flaky tests (#760)
(cherry picked from commit 372b8eb5f28e9ea118c29d030fbd07613fb55b48)
(cherry picked from commit 8c2708058fe3084828af42269e284242cdeec525)
---
parent/pom.xml | 5 +++
systests/microprofile/client/async/pom.xml | 6 ++++
.../cxf/microprofile/AnnotationTransformer.java | 33 ++++++++++++++++++
.../org/apache/cxf/microprofile/RetryAnalyzer.java | 39 ++++++++++++++++++++++
systests/microprofile/client/weld/testng.xml | 3 ++
5 files changed, 86 insertions(+)
diff --git a/parent/pom.xml b/parent/pom.xml
index be30de2..61de436 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -1663,6 +1663,11 @@
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlets</artifactId>
+ <version>${cxf.jetty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>${cxf.jetty.version}</version>
</dependency>
diff --git a/systests/microprofile/client/async/pom.xml b/systests/microprofile/client/async/pom.xml
index 8ef50bf..7951024 100644
--- a/systests/microprofile/client/async/pom.xml
+++ b/systests/microprofile/client/async/pom.xml
@@ -117,6 +117,12 @@
<artifactId>microprofile-rest-client-tck</artifactId>
<version>${cxf.microprofile.rest.client.version}</version>
<scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>com.github.tomakehurst</groupId>
diff --git a/systests/microprofile/client/weld/src/test/java/org/apache/cxf/microprofile/AnnotationTransformer.java b/systests/microprofile/client/weld/src/test/java/org/apache/cxf/microprofile/AnnotationTransformer.java
new file mode 100644
index 0000000..d00c18f
--- /dev/null
+++ b/systests/microprofile/client/weld/src/test/java/org/apache/cxf/microprofile/AnnotationTransformer.java
@@ -0,0 +1,33 @@
+/**
+ * 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.cxf.microprofile;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+
+import org.testng.IAnnotationTransformer;
+import org.testng.annotations.ITestAnnotation;
+
+public class AnnotationTransformer implements IAnnotationTransformer {
+ @Override
+ public void transform(ITestAnnotation annotation, Class test, Constructor constructor, Method method) {
+ annotation.setRetryAnalyzer(RetryAnalyzer.class);
+ }
+}
diff --git a/systests/microprofile/client/weld/src/test/java/org/apache/cxf/microprofile/RetryAnalyzer.java b/systests/microprofile/client/weld/src/test/java/org/apache/cxf/microprofile/RetryAnalyzer.java
new file mode 100644
index 0000000..2fa1fc5
--- /dev/null
+++ b/systests/microprofile/client/weld/src/test/java/org/apache/cxf/microprofile/RetryAnalyzer.java
@@ -0,0 +1,39 @@
+/**
+ * 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.cxf.microprofile;
+
+import org.testng.IRetryAnalyzer;
+import org.testng.ITestResult;
+import org.testng.Reporter;
+
+public class RetryAnalyzer implements IRetryAnalyzer {
+ private static final int RETRIES = 3;
+ private int counter;
+
+ @Override
+ public boolean retry(ITestResult result) {
+ if (++counter < RETRIES) {
+ Reporter.log("Retrying test case '" + result.getName() + "', attempt " + counter);
+ return true;
+ } else {
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/systests/microprofile/client/weld/testng.xml b/systests/microprofile/client/weld/testng.xml
index b75f7aa..b37b584 100644
--- a/systests/microprofile/client/weld/testng.xml
+++ b/systests/microprofile/client/weld/testng.xml
@@ -1,6 +1,9 @@
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="MPRestClientTCK1.3">
+ <listeners>
+ <listener class-name="org.apache.cxf.microprofile.AnnotationTransformer"/>
+ </listeners>
<test name="All TCK Tests">
<packages>
<package name="org.eclipse.microprofile.rest.client.tck" />