Skip to content

Commit 7f9157f

Browse files
committed
simplify
1 parent 84296e0 commit 7f9157f

1 file changed

Lines changed: 5 additions & 9 deletions

File tree

instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/camel/v2_20/TwoServicesWithDirectClientCamelTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@
2626
import com.google.common.collect.ImmutableMap;
2727
import io.opentelemetry.api.trace.SpanKind;
2828
import io.opentelemetry.instrumentation.test.utils.PortUtils;
29+
import io.opentelemetry.instrumentation.testing.internal.AutoCleanupExtension;
2930
import io.opentelemetry.instrumentation.testing.junit.InstrumentationExtension;
3031
import io.opentelemetry.instrumentation.testing.junit.http.AbstractHttpServerUsingTest;
3132
import io.opentelemetry.instrumentation.testing.junit.http.HttpServerInstrumentationExtension;
3233
import org.apache.camel.CamelContext;
3334
import org.apache.camel.ProducerTemplate;
3435
import org.apache.camel.builder.RouteBuilder;
3536
import org.apache.camel.impl.DefaultCamelContext;
36-
import org.junit.jupiter.api.AfterAll;
3737
import org.junit.jupiter.api.BeforeAll;
3838
import org.junit.jupiter.api.Test;
3939
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -45,6 +45,8 @@ class TwoServicesWithDirectClientCamelTest
4545
@RegisterExtension
4646
static final InstrumentationExtension testing = HttpServerInstrumentationExtension.forAgent();
4747

48+
@RegisterExtension static final AutoCleanupExtension cleanup = AutoCleanupExtension.create();
49+
4850
private static CamelContext clientContext;
4951

5052
private static Integer portOne;
@@ -74,14 +76,7 @@ protected String getContextPath() {
7476
@BeforeAll
7577
protected void setUp() {
7678
startServer();
77-
}
78-
79-
@AfterAll
80-
protected void cleanUp() throws Exception {
81-
cleanupServer();
82-
if (clientContext != null) {
83-
clientContext.stop();
84-
}
79+
cleanup.deferAfterAll(this::cleanupServer);
8580
}
8681

8782
void createAndStartClient() throws Exception {
@@ -97,6 +92,7 @@ public void configure() {
9792
}
9893
});
9994
clientContext.start();
95+
cleanup.deferAfterAll(clientContext::stop);
10096
}
10197

10298
@Test

0 commit comments

Comments
 (0)