Skip to content

Commit bed5ce2

Browse files
authored
Merge pull request #48423 from geoand/junit-autocloseable
Replace the use of CloseableResource with AutoCloseable
2 parents 8241eb8 + 915997d commit bed5ce2

File tree

8 files changed

+10
-30
lines changed

8 files changed

+10
-30
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ public void beforeEach(ExtensionContext extensionContext) throws Exception {
264264
TestResourceManager tm = testResourceManager;
265265

266266
store.put(TestResourceManager.class.getName(), testResourceManager);
267-
store.put(TestResourceManager.CLOSEABLE_NAME, (ExtensionContext.Store.CloseableResource) tm::close);
267+
store.put(TestResourceManager.CLOSEABLE_NAME, tm);
268268
}
269269
TestResourceManager tm = (TestResourceManager) store.get(TestResourceManager.class.getName());
270270
//dev mode tests just use system properties

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ public void beforeAll(ExtensionContext extensionContext) throws Exception {
369369
manager.init(null);
370370
testResourceProperties = manager.start();
371371
store.put(TestResourceManager.class.getName(), manager);
372-
store.put(TestResourceManager.CLOSEABLE_NAME, new ExtensionContext.Store.CloseableResource() {
372+
store.put(TestResourceManager.CLOSEABLE_NAME, new AutoCloseable() {
373373

374374
@Override
375-
public void close() throws Throwable {
375+
public void close() throws Exception {
376376
manager.close();
377377
}
378378
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,10 +591,10 @@ public void run() {
591591
testResourceManager.start();
592592
TestResourceManager tm = testResourceManager;
593593
store.put(TestResourceManager.class.getName(), testResourceManager);
594-
store.put(TestResourceManager.CLOSEABLE_NAME, new ExtensionContext.Store.CloseableResource() {
594+
store.put(TestResourceManager.CLOSEABLE_NAME, new AutoCloseable() {
595595

596596
@Override
597-
public void close() throws Throwable {
597+
public void close() throws Exception {
598598
tm.close();
599599
}
600600
});

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ private QuarkusTestExtensionState doProcessStart(Properties quarkusArtifactPrope
256256
}
257257
context.getStore(ExtensionContext.Namespace.GLOBAL).put(
258258
QuarkusIntegrationTestExtension.class.getName() + ".systemProps",
259-
new ExtensionContext.Store.CloseableResource() {
259+
new AutoCloseable() {
260260
@Override
261-
public void close() throws Throwable {
261+
public void close() throws Exception {
262262
for (Map.Entry<String, String> i : old.entrySet()) {
263263
old.put(i.getKey(), System.getProperty(i.getKey()));
264264
if (i.getValue() == null) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import io.quarkus.test.junit.main.Launch;
3939
import io.quarkus.test.junit.main.LaunchResult;
4040
import io.quarkus.test.junit.main.QuarkusMainLauncher;
41-
import io.quarkus.test.junit.util.CloseAdaptor;
4241
import io.smallrye.config.SmallRyeConfig;
4342

4443
public class QuarkusMainIntegrationTestExtension extends AbstractQuarkusTestWithContextExtension
@@ -115,7 +114,7 @@ private void prepare(ExtensionContext extensionContext) throws Exception {
115114
devServicesProps = devServicesLaunchResult.properties();
116115

117116
ExtensionContext root = extensionContext.getRoot();
118-
root.getStore(NAMESPACE).put("devServicesLaunchResult", new CloseAdaptor(devServicesLaunchResult));
117+
root.getStore(NAMESPACE).put("devServicesLaunchResult", devServicesLaunchResult);
119118
}
120119

121120
private ArtifactLauncher.LaunchResult doProcessStart(ExtensionContext context, String[] args) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ protected void doClose() {
11901190
}
11911191
}
11921192

1193-
class FailedCleanup implements ExtensionContext.Store.CloseableResource {
1193+
class FailedCleanup implements AutoCloseable {
11941194
@Override
11951195
public void close() {
11961196
shutdownHangDetection();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
import java.lang.reflect.Method;
77
import java.util.concurrent.atomic.AtomicBoolean;
88

9-
import org.junit.jupiter.api.extension.ExtensionContext;
10-
119
import io.quarkus.test.common.TestResourceManager;
1210

13-
public class QuarkusTestExtensionState implements ExtensionContext.Store.CloseableResource {
11+
public class QuarkusTestExtensionState implements AutoCloseable {
1412

1513
private final AtomicBoolean closed = new AtomicBoolean();
1614

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

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)