Skip to content

Commit 239cd3c

Browse files
holly-cumminsdanielsoro
authored andcommitted
Revert "Revert quarkusio#40601 and disable tests enabled by quarkusio#40749"
This reverts commit fc3988b. It has some additional changes which re-revert part of quarkusio#40601, to reintroduce removed guards to avoid cloning things like Quarkus runtime classes. Otherwise we get test failures.
1 parent ebeae4a commit 239cd3c

File tree

14 files changed

+166
-399
lines changed

14 files changed

+166
-399
lines changed

bom/application/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -4858,6 +4858,11 @@
48584858
<type>pom</type>
48594859
</dependency>
48604860

4861+
<dependency>
4862+
<groupId>org.jboss.marshalling</groupId>
4863+
<artifactId>jboss-marshalling</artifactId>
4864+
<version>${jboss-marshalling.version}</version>
4865+
</dependency>
48614866
<dependency>
48624867
<groupId>org.jboss.threads</groupId>
48634868
<artifactId>jboss-threads</artifactId>

integration-tests/test-extension/tests/src/test/java/io/quarkus/it/extension/it/TestParameterDevModeIT.java

-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import org.apache.maven.shared.invoker.MavenInvocationException;
99
import org.junit.jupiter.api.Assertions;
10-
import org.junit.jupiter.api.Disabled;
1110
import org.junit.jupiter.api.Test;
1211
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
1312

@@ -22,7 +21,6 @@
2221
* mvn install -Dit.test=DevMojoIT#methodName
2322
*/
2423
@DisabledIfSystemProperty(named = "quarkus.test.native", matches = "true")
25-
@Disabled("Needs https://github.com/junit-team/junit5/pull/3820 and #40601")
2624
public class TestParameterDevModeIT extends RunAndCheckMojoTestBase {
2725

2826
protected int getPort() {

test-framework/junit5/pom.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@
4949
<artifactId>quarkus-core</artifactId>
5050
</dependency>
5151
<dependency>
52-
<groupId>com.thoughtworks.xstream</groupId>
53-
<artifactId>xstream</artifactId>
54-
<!-- Avoid adding this to the BOM -->
55-
<version>1.4.20</version>
52+
<groupId>org.jboss.marshalling</groupId>
53+
<artifactId>jboss-marshalling</artifactId>
5654
</dependency>
5755

5856
<dependency>

test-framework/junit5/src/main/java/io/quarkus/test/junit/QuarkusTestExtension.java

+9-50
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
import java.util.function.Consumer;
4141
import java.util.function.Function;
4242
import java.util.function.Predicate;
43-
import java.util.function.Supplier;
44-
import java.util.regex.Pattern;
4543

4644
import org.eclipse.microprofile.config.spi.ConfigProviderResolver;
4745
import org.jboss.jandex.AnnotationInstance;
@@ -52,7 +50,6 @@
5250
import org.jboss.jandex.Type;
5351
import org.jboss.logging.Logger;
5452
import org.junit.jupiter.api.Nested;
55-
import org.junit.jupiter.api.TestInfo;
5653
import org.junit.jupiter.api.extension.AfterAllCallback;
5754
import org.junit.jupiter.api.extension.AfterEachCallback;
5855
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
@@ -106,7 +103,7 @@
106103
import io.quarkus.test.junit.callback.QuarkusTestContext;
107104
import io.quarkus.test.junit.callback.QuarkusTestMethodContext;
108105
import io.quarkus.test.junit.internal.DeepClone;
109-
import io.quarkus.test.junit.internal.SerializationWithXStreamFallbackDeepClone;
106+
import io.quarkus.test.junit.internal.NewSerializingDeepClone;
110107

111108
public class QuarkusTestExtension extends AbstractJvmQuarkusTestExtension
112109
implements BeforeEachCallback, BeforeTestExecutionCallback, AfterTestExecutionCallback, AfterEachCallback,
@@ -124,7 +121,6 @@ public class QuarkusTestExtension extends AbstractJvmQuarkusTestExtension
124121
// needed for @Nested
125122
private static final Deque<Object> outerInstances = new ArrayDeque<>(1);
126123
private static RunningQuarkusApplication runningQuarkusApplication;
127-
private static Pattern clonePattern;
128124
private static Throwable firstException; //if this is set then it will be thrown from the very first test that is run, the rest are aborted
129125

130126
private static Class<?> quarkusTestMethodContextClass;
@@ -260,11 +256,11 @@ public Thread newThread(Runnable r) {
260256
runningQuarkusApplication = startupAction
261257
.runMainClass(profileInstance.commandLineParameters());
262258
}
263-
String patternString = runningQuarkusApplication.getConfigValue("quarkus.test.class-clone-pattern", String.class)
264-
.orElse("java\\..*");
265-
clonePattern = Pattern.compile(patternString);
259+
266260
TracingHandler.quarkusStarted();
267261

262+
deepClone.setRunningQuarkusApplication(runningQuarkusApplication);
263+
268264
//now we have full config reset the hang timer
269265

270266
if (hangTaskKey != null) {
@@ -351,7 +347,7 @@ private void shutdownHangDetection() {
351347
}
352348

353349
private void populateDeepCloneField(StartupAction startupAction) {
354-
deepClone = new SerializationWithXStreamFallbackDeepClone(startupAction.getClassLoader());
350+
deepClone = new NewSerializingDeepClone(originalCl, startupAction.getClassLoader());
355351
}
356352

357353
private void populateTestMethodInvokers(ClassLoader quarkusClassLoader) {
@@ -957,50 +953,14 @@ private Object runExtensionMethod(ReflectiveInvocationContext<Method> invocation
957953
List<Object> argumentsFromTccl = new ArrayList<>();
958954
Parameter[] parameters = invocationContext.getExecutable().getParameters();
959955
for (int i = 0; i < originalArguments.size(); i++) {
960-
Object arg = originalArguments.get(i);
961-
boolean cloneRequired = false;
962-
Object replacement = null;
963-
Class<?> argClass = parameters[i].getType();
964-
if (arg != null) {
965-
Class<?> theclass = argClass;
966-
while (theclass.isArray()) {
967-
theclass = theclass.getComponentType();
968-
}
969-
if (theclass.isPrimitive()) {
970-
cloneRequired = false;
971-
} else if (TestInfo.class.isAssignableFrom(theclass)) {
972-
TestInfo info = (TestInfo) arg;
973-
Method newTestMethod = info.getTestMethod().isPresent()
974-
? determineTCCLExtensionMethod(info.getTestMethod().get(), testClassFromTCCL)
975-
: null;
976-
replacement = new TestInfoImpl(info.getDisplayName(), info.getTags(),
977-
Optional.of(testClassFromTCCL),
978-
Optional.ofNullable(newTestMethod));
979-
} else if (clonePattern.matcher(theclass.getName()).matches()) {
980-
cloneRequired = true;
981-
} else {
982-
try {
983-
cloneRequired = runningQuarkusApplication.getClassLoader()
984-
.loadClass(theclass.getName()) != theclass;
985-
} catch (ClassNotFoundException e) {
986-
if (arg instanceof Supplier) {
987-
cloneRequired = true;
988-
} else {
989-
throw e;
990-
}
991-
}
992-
}
993-
}
956+
if (testMethodInvokerToUse != null) {
957+
Class<?> argClass = parameters[i].getType();
994958

995-
if (replacement != null) {
996-
argumentsFromTccl.add(replacement);
997-
} else if (cloneRequired) {
998-
argumentsFromTccl.add(deepClone.clone(arg));
999-
} else if (testMethodInvokerToUse != null) {
1000959
argumentsFromTccl.add(testMethodInvokerToUse.getClass().getMethod("methodParamInstance", String.class)
1001960
.invoke(testMethodInvokerToUse, argClass.getName()));
1002961
} else {
1003-
argumentsFromTccl.add(arg);
962+
Object arg = originalArguments.get(i);
963+
argumentsFromTccl.add(deepClone.clone(arg));
1004964
}
1005965
}
1006966

@@ -1235,7 +1195,6 @@ protected void doClose() throws IOException {
12351195
log.error("Failed to shutdown Quarkus", e);
12361196
} finally {
12371197
runningQuarkusApplication = null;
1238-
clonePattern = null;
12391198
Thread.currentThread().setContextClassLoader(old);
12401199
ConfigProviderResolver.setInstance(null);
12411200
}

test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/CustomListConverter.java

-63
This file was deleted.

test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/CustomMapConverter.java

-41
This file was deleted.

test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/CustomMapEntryConverter.java

-55
This file was deleted.

test-framework/junit5/src/main/java/io/quarkus/test/junit/internal/CustomSetConverter.java

-40
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package io.quarkus.test.junit.internal;
22

3+
import io.quarkus.bootstrap.app.RunningQuarkusApplication;
4+
35
/**
46
* Strategy to deep clone an object
5-
*
7+
* <p>
68
* Used in order to clone an object loaded from one ClassLoader into another
79
*/
810
public interface DeepClone {
911

1012
Object clone(Object objectToClone);
13+
14+
void setRunningQuarkusApplication(RunningQuarkusApplication runningQuarkusApplication);
1115
}

0 commit comments

Comments
 (0)