Skip to content

Commit a26cdfc

Browse files
committed
Fix TestHTTPEndpoint without TestHTTPResource
1 parent ff06083 commit a26cdfc

File tree

3 files changed

+11
-12
lines changed

3 files changed

+11
-12
lines changed

integration-tests/main/src/test/java/io/quarkus/it/main/TestHTTPResourceClassTestCase.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class TestHTTPResourceClassTestCase {
1919

2020
URL testRootEndpoint;
2121

22-
@TestHTTPResource("service")
22+
@TestHTTPResource("int/10")
2323
URL testServiceEndpoint;
2424

2525
@TestHTTPEndpoint(GreetingEndpoint.class)
@@ -40,19 +40,18 @@ public void shouldConfigURLWithTestHTTPEndpointOnClass() {
4040
public void shouldConfigURLWithTestHTTPEndpointOnClassAndTestHTTPResourceOnField() {
4141
given()
4242
.when().get(testServiceEndpoint).then()
43-
.body(is("external"));
43+
.body(is("11"));
4444
}
4545

4646
@Test
4747
public void shouldConfigURLAndOverrideTestHTTPEndpointOnClass() {
4848
given()
49-
.pathParam("name", "some-random-name")
50-
.when().get(externalGreetingEndpoint).then()
51-
.body(is("some-random-name"));
49+
.when().get(externalGreetingEndpoint.toString() + "/anotherName").then()
50+
.body(is("Hello anotherName"));
5251

5352
given()
5453
.when().get(externalGreetingNameEndpoint).then()
55-
.body(is("name"));
54+
.body(is("Hello name"));
5655
}
5756

5857
}

integration-tests/main/src/test/java/io/quarkus/it/main/TestHTTPResourceFieldTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class TestHTTPResourceFieldTestCase {
1919
URL testRootEndpoint;
2020

2121
@TestHTTPEndpoint(TestResource.class)
22-
@TestHTTPResource("service")
22+
@TestHTTPResource("int/10")
2323
URL testServiceEndpoint;
2424

2525
@Test
@@ -33,7 +33,7 @@ public void shouldConfigURLWithTestHTTPEndpointOnField() {
3333
public void shouldConfigURLWithTestHTTPEndpointAndTestHTTPResourceOnField() {
3434
given()
3535
.when().get(testServiceEndpoint).then()
36-
.body(is("external"));
36+
.body(is("11"));
3737
}
3838

3939
}

test-framework/common/src/main/java/io/quarkus/test/common/http/TestHTTPResourceManager.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ public static void inject(Object testCase, List<Function<Class<?>, String>> endp
5555
TestHTTPEndpoint classEndpointAnnotation = c.getAnnotation(TestHTTPEndpoint.class);
5656
for (Field f : c.getDeclaredFields()) {
5757
TestHTTPResource resource = f.getAnnotation(TestHTTPResource.class);
58-
if (resource != null) {
58+
TestHTTPEndpoint endpointAnnotation = f.getAnnotation(TestHTTPEndpoint.class);
59+
if (resource != null || classEndpointAnnotation != null || endpointAnnotation != null) {
5960
TestHTTPResourceProvider<?> provider = providers.get(f.getType());
6061
if (provider == null) {
6162
throw new RuntimeException(
6263
"Unable to inject TestHTTPResource field " + f + " as no provider exists for the type");
6364
}
64-
String path = resource.value();
65+
String path = resource != null ? resource.value() : "";
6566
String endpointPath = null;
66-
TestHTTPEndpoint endpointAnnotation = f.getAnnotation(TestHTTPEndpoint.class);
6767
if (endpointAnnotation != null) {
6868
for (Function<Class<?>, String> func : endpointProviders) {
6969
endpointPath = func.apply(endpointAnnotation.value());
@@ -99,7 +99,7 @@ public static void inject(Object testCase, List<Function<Class<?>, String>> endp
9999
path = endpointPath;
100100
}
101101
String val;
102-
if (resource.ssl()) {
102+
if (resource != null && resource.ssl()) {
103103
if (path.startsWith("/")) {
104104
val = getSslUri() + path;
105105
} else {

0 commit comments

Comments
 (0)