jamesnetherton commented on code in PR #9535:
URL: https://github.com/apache/camel-quarkus/pull/9535#discussion_r4639549378
##########
integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerTest.java:
##########
@@ -505,6 +505,51 @@ void testStoppingRefusedResourceKeepsApplicationResource()
{
.thenAssertResults();
}
+ @Test
+ void testAnnotatedResourceWithoutClashCoexistsWithCamelResources() {
+ client().when()
+ .resourcesList(page -> assertThat(resourceUris(page))
+ .contains("camel:///annotated/no-clash",
"camel:///config/app.json"))
+ .resourcesRead("camel:///annotated/no-clash",
+ response ->
assertThat(response.contents().get(0).asText().text())
+
.isEqualTo(QuarkusDefinedResources.NO_CLASH_CONTENT))
+ .thenAssertResults();
+ }
+
+ @Test
+ void testCamelResourceCollidingWithAnnotatedResourceUriIsRefused() {
+
assertThat(routeStatus("annotated-uri-clash-route")).isEqualTo("Started");
+ client().when()
+ .resourcesRead("camel:///annotated/uri-clash",
+ response ->
assertThat(response.contents().get(0).asText().text())
+
.isEqualTo(QuarkusDefinedResources.URI_CLASH_CONTENT))
+ .thenAssertResults();
+
+ // stopping the refused route must leave the annotated resource in
place
+ controlRoute("annotated-uri-clash-route", "stop");
+
assertThat(routeStatus("annotated-uri-clash-route")).isEqualTo("Stopped");
+ try {
+ client().when()
+ .resourcesRead("camel:///annotated/uri-clash",
+ response ->
assertThat(response.contents().get(0).asText().text())
+
.isEqualTo(QuarkusDefinedResources.URI_CLASH_CONTENT))
+ .thenAssertResults();
+ } finally {
+ controlRoute("annotated-uri-clash-route", "start");
+ }
+ }
+
+ @Test
+ void testCamelResourceCollidingWithAnnotatedResourceNameIsRefused() {
+
assertThat(routeStatus("annotated-name-clash-route")).isEqualTo("Started");
+ client().when()
+ .resourcesList(page ->
assertThat(resourceUris(page)).doesNotContain("camel:///camel/name-clash"))
+ .resourcesRead("camel:///annotated/name-clash",
+ response ->
assertThat(response.contents().get(0).asText().text())
+
.isEqualTo(QuarkusDefinedResources.NAME_CLASH_CONTENT))
+ .thenAssertResults();
+ }
Review Comment:
Nit: the uri-clash test also stops the refused route and checks the
annotated resource survives, but this one does not. Removal is keyed by uri and
this route's uri is free, so it should already be a no-op, but stopping
`annotated-name-clash-route` and re-reading `camel:///annotated/name-clash`
would cover the name branch the same way as the uri branch.
##########
integration-tests/mcp-server/src/test/java/org/apache/camel/quarkus/component/mcp/server/it/McpServerTest.java:
##########
@@ -505,6 +505,51 @@ void testStoppingRefusedResourceKeepsApplicationResource()
{
.thenAssertResults();
}
+ @Test
+ void testAnnotatedResourceWithoutClashCoexistsWithCamelResources() {
+ client().when()
+ .resourcesList(page -> assertThat(resourceUris(page))
+ .contains("camel:///annotated/no-clash",
"camel:///config/app.json"))
+ .resourcesRead("camel:///annotated/no-clash",
+ response ->
assertThat(response.contents().get(0).asText().text())
+
.isEqualTo(QuarkusDefinedResources.NO_CLASH_CONTENT))
+ .thenAssertResults();
+ }
+
+ @Test
+ void testCamelResourceCollidingWithAnnotatedResourceUriIsRefused() {
+
assertThat(routeStatus("annotated-uri-clash-route")).isEqualTo("Started");
+ client().when()
+ .resourcesRead("camel:///annotated/uri-clash",
+ response ->
assertThat(response.contents().get(0).asText().text())
+
.isEqualTo(QuarkusDefinedResources.URI_CLASH_CONTENT))
+ .thenAssertResults();
+
+ // stopping the refused route must leave the annotated resource in
place
+ controlRoute("annotated-uri-clash-route", "stop");
+
assertThat(routeStatus("annotated-uri-clash-route")).isEqualTo("Stopped");
+ try {
+ client().when()
+ .resourcesRead("camel:///annotated/uri-clash",
+ response ->
assertThat(response.contents().get(0).asText().text())
+
.isEqualTo(QuarkusDefinedResources.URI_CLASH_CONTENT))
+ .thenAssertResults();
+ } finally {
+ controlRoute("annotated-uri-clash-route", "start");
Review Comment:
Nit: the other stop/start tests assert the route is back to `Started` after
restarting it. Worth doing the same here, so a failed restart surfaces in this
test rather than leaking into later ones:
```java
} finally {
controlRoute("annotated-uri-clash-route", "start");
assertThat(routeStatus("annotated-uri-clash-route")).isEqualTo("Started");
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]