Skip to content

Commit

Permalink
Fix failing Spring 6 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mistborn94 committed Jan 8, 2025
1 parent fac3455 commit de95bb0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package co.elastic.apm.agent.springwebflux;

import co.elastic.apm.agent.testutils.Java17OnlyTest;
import org.junit.jupiter.api.BeforeEach;

public class Spring6ServerAnnotatedInstrumentationTest extends Java17OnlyTest {

Expand All @@ -27,5 +28,10 @@ public Spring6ServerAnnotatedInstrumentationTest() {
}

public static class Impl extends ServerAnnotatedInstrumentationTest {

@BeforeEach
void setUp() {
expectedFrameworkVersion = "6.2.0";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package co.elastic.apm.agent.springwebflux;

import co.elastic.apm.agent.testutils.Java17OnlyTest;
import org.junit.jupiter.api.BeforeEach;

public class Spring6ServerFunctionalInstrumentationTest extends Java17OnlyTest {

Expand All @@ -27,5 +28,9 @@ public Spring6ServerFunctionalInstrumentationTest() {
}

public static class Impl extends ServerFunctionalInstrumentationTest {
@BeforeEach
void setUp() {
expectedFrameworkVersion = "6.2.0";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@
*/
package co.elastic.apm.agent.springwebflux;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;

@EnabledForJreRange(min = JRE.JAVA_17)
public class Spring6ServletContainerTest extends ServletContainerTest {

@BeforeEach
void setUp() {
expectedFrameworkVersion = "6.2.0";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public abstract class AbstractServerInstrumentationTest extends AbstractInstrume
private static final String BASIC_AUTH_HEADER_VALUE = "Basic ZWxhc3RpYzpjaGFuZ2VtZQ==";

protected static WebFluxApplication.App app;
protected String expectedFrameworkVersion = "5.3.30";
protected GreetingWebClient client;

@BeforeAll
Expand Down Expand Up @@ -451,7 +452,11 @@ protected ErrorCaptureImpl getFirstError() {
return reporter.getFirstError(200);
}

static TransactionImpl checkTransaction(TransactionImpl transaction, String expectedName, String expectedMethod, int expectedStatus) {
TransactionImpl checkTransaction(TransactionImpl transaction, String expectedName, String expectedMethod, int expectedStatus) {
return checkTransaction(transaction, expectedName, expectedMethod, expectedStatus, expectedFrameworkVersion);
}

static TransactionImpl checkTransaction(TransactionImpl transaction, String expectedName, String expectedMethod, int expectedStatus, String expectedFrameworkVersion) {
assertThat(transaction.getType()).isEqualTo("request");
assertThat(transaction.getNameAsString()).isEqualTo(expectedName);

Expand All @@ -468,7 +473,7 @@ static TransactionImpl checkTransaction(TransactionImpl transaction, String expe
.isEqualTo("Spring Webflux");

assertThat(transaction.getFrameworkVersion())
.isEqualTo("5.3.30");
.isEqualTo(expectedFrameworkVersion);

return transaction;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class ServletContainerTest extends AbstractInstrumentationTest {

protected static WebFluxApplication.App app;
protected static GreetingWebClient client;
protected String expectedFrameworkVersion = "5.3.30";

@BeforeAll
static void startApp() {
Expand Down Expand Up @@ -74,7 +75,7 @@ void shouldOnlyCreateOneTransaction() throws InterruptedException {
TransactionImpl transaction = reporter.getFirstTransaction(200);

// transaction naming should be set by webflux instrumentation
AbstractServerInstrumentationTest.checkTransaction(transaction, "GET /functional/with-parameters/{id}", "GET", 200);
AbstractServerInstrumentationTest.checkTransaction(transaction, "GET /functional/with-parameters/{id}", "GET", 200, expectedFrameworkVersion);

// transaction HTTP part should be provided by servlet instrumentation
AbstractServerInstrumentationTest.checkUrl(client, transaction, "/with-parameters/42");
Expand Down

0 comments on commit de95bb0

Please sign in to comment.