From b37b7197bd3c4ff1f316541feacae4f8ec894c95 Mon Sep 17 00:00:00 2001 From: James Netherton Date: Tue, 27 Aug 2024 08:58:01 +0100 Subject: [PATCH] Combine knative tests into a single module Fixes #6376 --- .../knative-channel-consumer/Readme.adoc | 8 - .../knative-channel-consumer/pom.xml | 132 ------------- .../it/KnativeChannelConsumerResource.java | 36 ---- .../src/main/resources/application.properties | 21 --- .../knative-endpoint-consumer/Readme.adoc | 8 - .../knative-endpoint-consumer/pom.xml | 131 ------------- .../src/main/resources/application.properties | 22 --- .../knative-event-consumer/Readme.adoc | 11 -- .../knative-event-consumer/pom.xml | 131 ------------- .../src/main/resources/application.properties | 21 --- .../knative-producer/Readme.adoc | 11 -- integration-tests/knative-producer/pom.xml | 174 ------------------ .../src/main/resources/application.properties | 40 ---- integration-tests/knative/README.adoc | 39 ++++ integration-tests/knative/pom.xml | 118 +++++++++++- .../it/KnativeChannelConsumerResource.java} | 31 +++- .../knative/channel/consumer/it/Routes.java} | 6 +- .../it/KnativeEndpointConsumerResource.java | 4 +- .../knative/endpoint/consumer/it/Routes.java} | 6 +- .../it/KnativeEventConsumerResource.java} | 8 +- .../knative/event/consumer/it/Routes.java} | 6 +- .../producer/it/KnativeProducerResource.java | 4 - .../component/knative/producer/it/Routes.java | 20 +- .../src/main/resources/application.properties | 81 ++++++++ .../consumer/it/KnativeChannelConsumerIT.java | 2 +- .../it/KnativeChannelConsumerTest.java | 29 ++- .../it/KnativeEndpointConsumerIT.java | 4 +- .../it/KnativeEndpointConsumerTest.java | 23 ++- .../consumer/it/KnativeEventConsumerIT.java | 4 +- .../consumer/it/KnativeEventConsumerTest.java | 25 ++- .../component/knative/it/KnativeIT.java | 24 --- .../component/knative/it/KnativeTest.java | 49 ----- .../producer/it/KnativeProducerIT.java | 0 .../producer/it/KnativeProducerTest.java | 22 ++- .../producer/it/KnativeTestResource.java | 0 .../test/resources/mappings/sendToBroker.json | 0 .../resources/mappings/sendToChannel.json | 0 .../resources/mappings/sendToService.json | 0 integration-tests/pom.xml | 4 - tooling/scripts/test-categories.yaml | 4 - 40 files changed, 357 insertions(+), 902 deletions(-) delete mode 100644 integration-tests/knative-channel-consumer/Readme.adoc delete mode 100644 integration-tests/knative-channel-consumer/pom.xml delete mode 100644 integration-tests/knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java delete mode 100644 integration-tests/knative-channel-consumer/src/main/resources/application.properties delete mode 100644 integration-tests/knative-endpoint-consumer/Readme.adoc delete mode 100644 integration-tests/knative-endpoint-consumer/pom.xml delete mode 100644 integration-tests/knative-endpoint-consumer/src/src/main/resources/application.properties delete mode 100644 integration-tests/knative-event-consumer/Readme.adoc delete mode 100644 integration-tests/knative-event-consumer/pom.xml delete mode 100644 integration-tests/knative-event-consumer/src/src/main/resources/application.properties delete mode 100644 integration-tests/knative-producer/Readme.adoc delete mode 100644 integration-tests/knative-producer/pom.xml delete mode 100644 integration-tests/knative-producer/src/main/resources/application.properties create mode 100644 integration-tests/knative/README.adoc rename integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/{it/KnativeResource.java => channel/consumer/it/KnativeChannelConsumerResource.java} (63%) rename integration-tests/{knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java => knative/src/main/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/Routes.java} (84%) rename integration-tests/{knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative => knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint}/consumer/it/KnativeEndpointConsumerResource.java (92%) rename integration-tests/{knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java => knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/Routes.java} (84%) rename integration-tests/{knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java => knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerResource.java} (87%) rename integration-tests/{knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java => knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/Routes.java} (84%) rename integration-tests/{knative-producer => knative}/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerResource.java (96%) rename integration-tests/{knative-producer => knative}/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/Routes.java (64%) create mode 100644 integration-tests/knative/src/main/resources/application.properties rename integration-tests/{knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative => knative/src/test/java/org/apache/camel/quarkus/component/knative/channel}/consumer/it/KnativeChannelConsumerIT.java (93%) rename integration-tests/{knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative => knative/src/test/java/org/apache/camel/quarkus/component/knative/channel}/consumer/it/KnativeChannelConsumerTest.java (64%) rename integration-tests/{knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative => knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint}/consumer/it/KnativeEndpointConsumerIT.java (81%) rename integration-tests/{knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative => knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint}/consumer/it/KnativeEndpointConsumerTest.java (76%) rename integration-tests/{knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative => knative/src/test/java/org/apache/camel/quarkus/component/knative/event}/consumer/it/KnativeEventConsumerIT.java (82%) rename integration-tests/{knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative => knative/src/test/java/org/apache/camel/quarkus/component/knative/event}/consumer/it/KnativeEventConsumerTest.java (75%) delete mode 100644 integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeIT.java delete mode 100644 integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeTest.java rename integration-tests/{knative-producer => knative}/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerIT.java (100%) rename integration-tests/{knative-producer => knative}/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerTest.java (86%) rename integration-tests/{knative-producer => knative}/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeTestResource.java (100%) rename integration-tests/{knative-producer => knative}/src/test/resources/mappings/sendToBroker.json (100%) rename integration-tests/{knative-producer => knative}/src/test/resources/mappings/sendToChannel.json (100%) rename integration-tests/{knative-producer => knative}/src/test/resources/mappings/sendToService.json (100%) diff --git a/integration-tests/knative-channel-consumer/Readme.adoc b/integration-tests/knative-channel-consumer/Readme.adoc deleted file mode 100644 index 9eaa64af5d1..00000000000 --- a/integration-tests/knative-channel-consumer/Readme.adoc +++ /dev/null @@ -1,8 +0,0 @@ -= Knative Channel Consumer tests - -These integration tests the HTTP routes only. - -If you wish to test this application in real Knative environment, follow the next steps. -* Create an InMemory Knative Channel named `channel-test` -* Deploy the app https://quarkus.io/guides/deploying-to-kubernetes#knative[as a Serverless deployment]. -* Send CloudEvents to the channel. diff --git a/integration-tests/knative-channel-consumer/pom.xml b/integration-tests/knative-channel-consumer/pom.xml deleted file mode 100644 index d3b5fc82e2e..00000000000 --- a/integration-tests/knative-channel-consumer/pom.xml +++ /dev/null @@ -1,132 +0,0 @@ - - - - 4.0.0 - - org.apache.camel.quarkus - camel-quarkus-build-parent-it - 3.15.0-SNAPSHOT - ../../poms/build-parent-it/pom.xml - - - camel-quarkus-integration-test-knative-channel-consumer - Camel Quarkus :: Integration Tests :: Knative Consumer - Integration tests for Camel Quarkus Knative Consumer extension - Channel consumer - - - - org.apache.camel.quarkus - camel-quarkus-knative-consumer - - - org.apache.camel.quarkus - camel-quarkus-seda - - - io.quarkus - quarkus-resteasy - - - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - org.awaitility - awaitility - test - - - - - - native - - - native - - - - true - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - - - - virtualDependencies - - - !noVirtualDependencies - - - - - - org.apache.camel.quarkus - camel-quarkus-knative-consumer-deployment - ${project.version} - pom - test - - - * - * - - - - - org.apache.camel.quarkus - camel-quarkus-seda-deployment - ${project.version} - pom - test - - - * - * - - - - - - - - \ No newline at end of file diff --git a/integration-tests/knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java b/integration-tests/knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java deleted file mode 100644 index b6b102d9ee8..00000000000 --- a/integration-tests/knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.knative.consumer.it; - -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import org.apache.camel.ConsumerTemplate; - -@Path("/knative-channel-consumer") -@ApplicationScoped -public class KnativeChannelConsumerResource { - @Inject - ConsumerTemplate consumerTemplate; - - @GET - public String readReceivedMessages() { - return consumerTemplate.receiveBody("seda:queue-channel", 1000, String.class); - } - -} diff --git a/integration-tests/knative-channel-consumer/src/main/resources/application.properties b/integration-tests/knative-channel-consumer/src/main/resources/application.properties deleted file mode 100644 index e5124a339b2..00000000000 --- a/integration-tests/knative-channel-consumer/src/main/resources/application.properties +++ /dev/null @@ -1,21 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- - -# channel configuration -camel.component.knative.environment.resources[0].name = channel-test -camel.component.knative.environment.resources[0].type = channel -camel.component.knative.environment.resources[0].endpoint-kind = source \ No newline at end of file diff --git a/integration-tests/knative-endpoint-consumer/Readme.adoc b/integration-tests/knative-endpoint-consumer/Readme.adoc deleted file mode 100644 index 24630a99dde..00000000000 --- a/integration-tests/knative-endpoint-consumer/Readme.adoc +++ /dev/null @@ -1,8 +0,0 @@ -= Knative Endpoint Consumer tests - -These integration tests the HTTP routes only. - -If you wish to test this application in real Knative environment, follow the next steps. - -* Deploy the app https://knative.dev/docs/getting-started/first-service/[as a Knative Service] named `endpoint-test`. -* Send CloudEvents to the URL of the service. diff --git a/integration-tests/knative-endpoint-consumer/pom.xml b/integration-tests/knative-endpoint-consumer/pom.xml deleted file mode 100644 index eea691223cf..00000000000 --- a/integration-tests/knative-endpoint-consumer/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - 4.0.0 - - org.apache.camel.quarkus - camel-quarkus-build-parent-it - 3.15.0-SNAPSHOT - ../../poms/build-parent-it/pom.xml - - - camel-quarkus-integration-test-knative-endpoint-consumer - Camel Quarkus :: Integration Tests :: Knative Consumer - Integration tests for Camel Quarkus Knative Consumer extension - Endpoint consumer - - - - org.apache.camel.quarkus - camel-quarkus-knative-consumer - - - org.apache.camel.quarkus - camel-quarkus-seda - - - io.quarkus - quarkus-resteasy - - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - org.awaitility - awaitility - test - - - - - - native - - - native - - - - true - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - - - - virtualDependencies - - - !noVirtualDependencies - - - - - - org.apache.camel.quarkus - camel-quarkus-knative-consumer-deployment - ${project.version} - pom - test - - - * - * - - - - - org.apache.camel.quarkus - camel-quarkus-seda-deployment - ${project.version} - pom - test - - - * - * - - - - - - - - \ No newline at end of file diff --git a/integration-tests/knative-endpoint-consumer/src/src/main/resources/application.properties b/integration-tests/knative-endpoint-consumer/src/src/main/resources/application.properties deleted file mode 100644 index f2818944633..00000000000 --- a/integration-tests/knative-endpoint-consumer/src/src/main/resources/application.properties +++ /dev/null @@ -1,22 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- - -# endpoint configuration -camel.component.knative.environment.resources[0].name = endpoint-test -camel.component.knative.environment.resources[0].type = endpoint -camel.component.knative.environment.resources[0].endpoint-kind = source -camel.component.knative.environment.resources[0].path = /my-endpoint \ No newline at end of file diff --git a/integration-tests/knative-event-consumer/Readme.adoc b/integration-tests/knative-event-consumer/Readme.adoc deleted file mode 100644 index deb83cd84a4..00000000000 --- a/integration-tests/knative-event-consumer/Readme.adoc +++ /dev/null @@ -1,11 +0,0 @@ -= Knative Event Consumer tests - -These integration tests the HTTP routes only. - -If you wish to test this application in real Knative environment, follow the next steps. - -* Create an InMemory Knative Broker named `broker-test` -* Deploy the app https://quarkus.io/guides/deploying-to-kubernetes#knative[as a Serverless deployment] -* Send CloudEvents to the broker. - - diff --git a/integration-tests/knative-event-consumer/pom.xml b/integration-tests/knative-event-consumer/pom.xml deleted file mode 100644 index 179cb557ba6..00000000000 --- a/integration-tests/knative-event-consumer/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - 4.0.0 - - org.apache.camel.quarkus - camel-quarkus-build-parent-it - 3.15.0-SNAPSHOT - ../../poms/build-parent-it/pom.xml - - - camel-quarkus-integration-test-knative-event-consumer - Camel Quarkus :: Integration Tests :: Knative Consumer Event - Integration tests for Camel Quarkus Knative Consumer extension - Consuming events - - - - org.apache.camel.quarkus - camel-quarkus-knative-consumer - - - org.apache.camel.quarkus - camel-quarkus-seda - - - io.quarkus - quarkus-resteasy - - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - org.awaitility - awaitility - test - - - - - - native - - - native - - - - true - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - - - - virtualDependencies - - - !noVirtualDependencies - - - - - - org.apache.camel.quarkus - camel-quarkus-knative-consumer-deployment - ${project.version} - pom - test - - - * - * - - - - - org.apache.camel.quarkus - camel-quarkus-seda-deployment - ${project.version} - pom - test - - - * - * - - - - - - - - \ No newline at end of file diff --git a/integration-tests/knative-event-consumer/src/src/main/resources/application.properties b/integration-tests/knative-event-consumer/src/src/main/resources/application.properties deleted file mode 100644 index 3a4c8d6ec05..00000000000 --- a/integration-tests/knative-event-consumer/src/src/main/resources/application.properties +++ /dev/null @@ -1,21 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- - -# event configuration -camel.component.knative.environment.resources[0].name = event-test -camel.component.knative.environment.resources[0].type = event -camel.component.knative.environment.resources[0].endpoint-kind = source diff --git a/integration-tests/knative-producer/Readme.adoc b/integration-tests/knative-producer/Readme.adoc deleted file mode 100644 index c38ab36fa88..00000000000 --- a/integration-tests/knative-producer/Readme.adoc +++ /dev/null @@ -1,11 +0,0 @@ -= Knative Producer tests - -The tests able to run against Mocked Knative HTTP API. - -If you wish to test this application in knative environment, follow these steps : -* Create an InMemory Knative Channel named `channel-test` -* Create an InMemory Knative Broker named `broker-test` -* Deploy a Knative Service named `endpoint-test` -* Deploy this application within the Kubernetes cluster -* Make sure the application can use secrets containing the URLs : KNATIVE_CHANNEL_URL, KNATIVE_CHANNEL_URL, KNATIVE_SERVICE_URL -* On native mode, you may need to set `quarkus.ssl.native=true` in case one those URLs uses `https` instead of `http` \ No newline at end of file diff --git a/integration-tests/knative-producer/pom.xml b/integration-tests/knative-producer/pom.xml deleted file mode 100644 index bc645689311..00000000000 --- a/integration-tests/knative-producer/pom.xml +++ /dev/null @@ -1,174 +0,0 @@ - - - - 4.0.0 - - org.apache.camel.quarkus - camel-quarkus-build-parent-it - 3.15.0-SNAPSHOT - ../../poms/build-parent-it/pom.xml - - - camel-quarkus-integration-test-knative-producer - Camel Quarkus :: Integration Tests :: Knative Producer - Integration tests for Camel Quarkus Knative Producer extension - - - - org.apache.camel.quarkus - camel-quarkus-knative-producer - - - - - io.quarkus - quarkus-resteasy-jsonb - - - org.apache.camel.quarkus - camel-quarkus-mock - - - org.apache.camel.quarkus - camel-quarkus-direct - - - org.apache.camel.quarkus - camel-quarkus-timer - - - - - io.quarkus - quarkus-junit5 - test - - - io.rest-assured - rest-assured - test - - - org.awaitility - awaitility - test - - - - org.apache.camel.quarkus - camel-quarkus-integration-wiremock-support - test - - - - - - native - - - native - - - - true - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - - integration-test - verify - - - - - - - - - virtualDependencies - - - !noVirtualDependencies - - - - - - org.apache.camel.quarkus - camel-quarkus-direct-deployment - ${project.version} - pom - test - - - * - * - - - - - org.apache.camel.quarkus - camel-quarkus-knative-producer-deployment - ${project.version} - pom - test - - - * - * - - - - - org.apache.camel.quarkus - camel-quarkus-mock-deployment - ${project.version} - pom - test - - - * - * - - - - - org.apache.camel.quarkus - camel-quarkus-timer-deployment - ${project.version} - pom - test - - - * - * - - - - - - - - \ No newline at end of file diff --git a/integration-tests/knative-producer/src/main/resources/application.properties b/integration-tests/knative-producer/src/main/resources/application.properties deleted file mode 100644 index f1ac9d3f427..00000000000 --- a/integration-tests/knative-producer/src/main/resources/application.properties +++ /dev/null @@ -1,40 +0,0 @@ -## --------------------------------------------------------------------------- -## Licensed to the Apache Software Foundation (ASF) under one or more -## contributor license agreements. See the NOTICE file distributed with -## this work for additional information regarding copyright ownership. -## The ASF licenses this file to You under the Apache License, Version 2.0 -## (the "License"); you may not use this file except in compliance with -## the License. You may obtain a copy of the License at -## -## http://www.apache.org/licenses/LICENSE-2.0 -## -## Unless required by applicable law or agreed to in writing, software -## distributed under the License is distributed on an "AS IS" BASIS, -## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -## See the License for the specific language governing permissions and -## limitations under the License. -## --------------------------------------------------------------------------- - - -channel.test.url = TODO -broker.test.url = TODO -service.test.url = TODO - -# channel configuration -camel.component.knative.environment.resources[0].name = channel-test -camel.component.knative.environment.resources[0].type = channel -camel.component.knative.environment.resources[0].endpoint-kind = sink -camel.component.knative.environment.resources[0].url = ${KNATIVE_CHANNEL_URL:{{channel.test.url}}} - -# broker configuration -camel.component.knative.environment.resources[1].name = broker-test -camel.component.knative.environment.resources[1].type = event -camel.component.knative.environment.resources[1].endpoint-kind = sink -camel.component.knative.environment.resources[1].url = ${KNATIVE_CHANNEL_URL:{{broker.test.url}}} -camel.component.knative.environment.resources[1].cloudEventType = org.apache.camel.event - -# endpoint configuration -camel.component.knative.environment.resources[2].name = endpoint-test -camel.component.knative.environment.resources[2].type = endpoint -camel.component.knative.environment.resources[2].endpoint-kind = sink -camel.component.knative.environment.resources[2].url = ${KNATIVE_SERVICE_URL:{{service.test.url}}} \ No newline at end of file diff --git a/integration-tests/knative/README.adoc b/integration-tests/knative/README.adoc new file mode 100644 index 00000000000..e4633edc5ab --- /dev/null +++ b/integration-tests/knative/README.adoc @@ -0,0 +1,39 @@ +== Camel Quarkus Knative integration tests + +These integration test exercise HTTP routes only. + +If you wish to test this application in real Knative environment, follow the next steps. + +== Knative Channel Consumer tests + +* Create an InMemory Knative Channel named `channel-test` +* Deploy the app https://quarkus.io/guides/deploying-to-kubernetes#knative[as a Serverless deployment]. Ensure `quarkus.profile=knative-channel-consumer` +* Send CloudEvents to the channel + +== Knative Endpoint Consumer tests + +* Deploy the app https://knative.dev/docs/getting-started/first-service/[as a Knative Service] named `endpoint-test`. Ensure `quarkus.profile=knative-endpoint-consumer` +* Send CloudEvents to the URL of the service. + +== Knative Event Consumer tests + +These integration tests the HTTP routes only. + +If you wish to test this application in real Knative environment, follow the next steps. + +* Create an InMemory Knative Broker named `broker-test` +* Deploy the app https://quarkus.io/guides/deploying-to-kubernetes#knative[as a Serverless deployment] Ensure `quarkus.profile=knative-event-consumer` +* Send CloudEvents to the broker. + +== Knative Producer tests + +The tests run against a Mocked Knative HTTP API. + +If you wish to test this application in knative environment, follow these steps: + +* Create an InMemory Knative Channel named `channel-test` +* Create an InMemory Knative Broker named `broker-test` +* Deploy a Knative Service named `endpoint-test` +* Deploy this application within the Kubernetes cluster. Ensure `quarkus.profile=knative-producer` +* Make sure the application can use secrets containing the URLs : KNATIVE_CHANNEL_URL, KNATIVE_CHANNEL_URL, KNATIVE_SERVICE_URL +* On native mode, you may need to set `quarkus.ssl.native=true` in case one those URLs uses `https` instead of `http` \ No newline at end of file diff --git a/integration-tests/knative/pom.xml b/integration-tests/knative/pom.xml index 71c5449c58f..256e98495ca 100644 --- a/integration-tests/knative/pom.xml +++ b/integration-tests/knative/pom.xml @@ -31,10 +31,38 @@ Integration tests for Camel Quarkus Knative extension + + org.apache.camel.quarkus + camel-quarkus-direct + org.apache.camel.quarkus camel-quarkus-knative + + org.apache.camel.quarkus + camel-quarkus-knative-consumer + + + org.apache.camel.quarkus + camel-quarkus-knative-producer + + + org.apache.camel.quarkus + camel-quarkus-mock + + + org.apache.camel.quarkus + camel-quarkus-seda + + + org.apache.camel.quarkus + camel-quarkus-timer + + + io.quarkus + quarkus-resteasy + io.quarkus quarkus-resteasy-jsonb @@ -51,6 +79,17 @@ rest-assured test + + org.awaitility + awaitility + test + + + + org.apache.camel.quarkus + camel-quarkus-integration-wiremock-support + test + @@ -103,7 +142,84 @@ - + + org.apache.camel.quarkus + camel-quarkus-knative-consumer-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-seda-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-direct-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-knative-producer-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-mock-deployment + ${project.version} + pom + test + + + * + * + + + + + org.apache.camel.quarkus + camel-quarkus-timer-deployment + ${project.version} + pom + test + + + * + * + + + diff --git a/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/it/KnativeResource.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerResource.java similarity index 63% rename from integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/it/KnativeResource.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerResource.java index bc5241a2375..358b59491c4 100644 --- a/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/it/KnativeResource.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerResource.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.it; +package org.apache.camel.quarkus.component.knative.channel.consumer.it; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; @@ -25,24 +25,35 @@ import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import org.apache.camel.CamelContext; +import org.apache.camel.ConsumerTemplate; import org.apache.camel.component.knative.KnativeComponent; -@Path("/knative") +@Path("/knative-channel-consumer") @ApplicationScoped -public class KnativeResource { +public class KnativeChannelConsumerResource { + @Inject + ConsumerTemplate consumerTemplate; @Inject CamelContext context; @GET - @Path("/inspect") + public String readReceivedMessages() { + return consumerTemplate.receiveBody("seda:queue-channel", 1000, String.class); + } + + @GET + @Path("inspect") @Produces(MediaType.APPLICATION_JSON) public JsonObject inspect() { - return Json.createObjectBuilder() - .add("producer-factory", - context.getComponent("knative", KnativeComponent.class).getProducerFactory().getClass().getName()) - .add("consumer-factory", - context.getComponent("knative", KnativeComponent.class).getConsumerFactory().getClass().getName()) - .build(); + var component = context.getComponent("knative", KnativeComponent.class); + var builder = Json.createObjectBuilder(); + + if (component.getConsumerFactory() != null) { + builder.add("consumer-factory", component.getConsumerFactory().getClass().getName()); + } + + return builder.build(); } + } diff --git a/integration-tests/knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/Routes.java similarity index 84% rename from integration-tests/knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/Routes.java index 4bc9efec8a0..fddbf2f3fa3 100644 --- a/integration-tests/knative-channel-consumer/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/Routes.java @@ -14,11 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.channel.consumer.it; +import jakarta.enterprise.context.ApplicationScoped; import org.apache.camel.builder.RouteBuilder; -public class Route extends RouteBuilder { +@ApplicationScoped +public class Routes extends RouteBuilder { @Override public void configure() throws Exception { from("knative:channel/channel-test") diff --git a/integration-tests/knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerResource.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerResource.java similarity index 92% rename from integration-tests/knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerResource.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerResource.java index fe9b341d268..d929ce2feff 100644 --- a/integration-tests/knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerResource.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerResource.java @@ -14,14 +14,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.endpoint.consumer.it; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; - import org.apache.camel.ConsumerTemplate; @Path("/knative-endpoint-consumer") diff --git a/integration-tests/knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/Routes.java similarity index 84% rename from integration-tests/knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/Routes.java index ee888b3328e..896965a0c46 100644 --- a/integration-tests/knative-endpoint-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/Routes.java @@ -14,11 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.endpoint.consumer.it; +import jakarta.enterprise.context.ApplicationScoped; import org.apache.camel.builder.RouteBuilder; -public class Route extends RouteBuilder { +@ApplicationScoped +public class Routes extends RouteBuilder { @Override public void configure() throws Exception { from("knative:endpoint/endpoint-test") diff --git a/integration-tests/knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerResource.java similarity index 87% rename from integration-tests/knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerResource.java index 65542a1f321..469403732c6 100644 --- a/integration-tests/knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerResource.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerResource.java @@ -14,19 +14,17 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.event.consumer.it; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; -import jakarta.ws.rs.PathParam; - import org.apache.camel.ConsumerTemplate; -@Path("/knative-channel-consumer") +@Path("/knative-event-consumer") @ApplicationScoped -public class KnativeChannelConsumerResource { +public class KnativeEventConsumerResource { @Inject ConsumerTemplate consumerTemplate; diff --git a/integration-tests/knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/Routes.java similarity index 84% rename from integration-tests/knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/Routes.java index 721248a5fd4..3045f6814a6 100644 --- a/integration-tests/knative-event-consumer/src/src/main/java/org/apache/camel/quarkus/component/knative/consumer/it/Route.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/event/consumer/it/Routes.java @@ -14,11 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.event.consumer.it; +import jakarta.enterprise.context.ApplicationScoped; import org.apache.camel.builder.RouteBuilder; -public class Route extends RouteBuilder { +@ApplicationScoped +public class Routes extends RouteBuilder { @Override public void configure() throws Exception { from("knative:event/event-test?reply=false") diff --git a/integration-tests/knative-producer/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerResource.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerResource.java similarity index 96% rename from integration-tests/knative-producer/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerResource.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerResource.java index 1112cf1c42c..41ba9513cef 100644 --- a/integration-tests/knative-producer/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerResource.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerResource.java @@ -56,10 +56,6 @@ public JsonObject inspect() { if (component.getProducerFactory() != null) { builder.add("producer-factory", component.getProducerFactory().getClass().getName()); } - if (component.getConsumerFactory() != null) { - builder.add("consumer-factory", component.getConsumerFactory().getClass().getName()); - } - return builder.build(); } diff --git a/integration-tests/knative-producer/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/Routes.java b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/Routes.java similarity index 64% rename from integration-tests/knative-producer/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/Routes.java rename to integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/Routes.java index f9240e3c11c..995b9ca1c85 100644 --- a/integration-tests/knative-producer/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/Routes.java +++ b/integration-tests/knative/src/main/java/org/apache/camel/quarkus/component/knative/producer/it/Routes.java @@ -16,9 +16,11 @@ */ package org.apache.camel.quarkus.component.knative.producer.it; +import jakarta.enterprise.context.ApplicationScoped; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.cloudevents.CloudEvent; +@ApplicationScoped public class Routes extends RouteBuilder { private static final String TIME = "2018-04-05T17:31:00Z"; @@ -28,44 +30,32 @@ public void configure() throws Exception { // Routes using ProducerTemplate, need to specify the header CloudEvent.CAMEL_CLOUD_EVENT_SOURCE from("direct:channel") .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE, constant("camel")) - // temporary fix until the issue is available https://issues.apache.org/jira/browse/CAMEL-18473 on camel-quarkus - .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_TIME, constant(TIME)) .to("knative:channel/channel-test") .to("mock:channel"); from("direct:event") .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE, constant("camel")) - // temporary fix until the issue is available https://issues.apache.org/jira/browse/CAMEL-18473 on camel-quarkus - .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_TIME, constant(TIME)) .to("knative:event/broker-test") .to("mock:event"); from("direct:endpoint") .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_SOURCE, constant("camel")) - // temporary fix until the issue is available https://issues.apache.org/jira/browse/CAMEL-18473 on camel-quarkus - .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_TIME, constant(TIME)) .to("knative:endpoint/endpoint-test") .to("mock:endpoint"); // Routes not using ProducerTemplate, the cloud event source header is managed by the consumer - from("timer:channelTimer?period=1") + from("timer:channelTimer?period=1&repeatCount=1") .setBody(constant("Hello World From channelTimer!")) - // temporary fix until the issue is available https://issues.apache.org/jira/browse/CAMEL-18473 on camel-quarkus - .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_TIME, constant(TIME)) .to("knative:channel/channel-test") .to("mock:channel-timer"); - from("timer:eventTimer?period=1") + from("timer:eventTimer?period=1&repeatCount=1") .setBody(constant("Hello World From eventTimer!")) - // temporary fix until the issue is available https://issues.apache.org/jira/browse/CAMEL-18473 on camel-quarkus - .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_TIME, constant(TIME)) .to("knative:event/broker-test") .to("mock:event-timer"); - from("timer:endpointTimer?period=1") + from("timer:endpointTimer?period=1&repeatCount=1") .setBody(constant("Hello World From endpointTimer!")) - // temporary fix until the issue is available https://issues.apache.org/jira/browse/CAMEL-18473 on camel-quarkus - .setHeader(CloudEvent.CAMEL_CLOUD_EVENT_TIME, constant(TIME)) .to("knative:endpoint/endpoint-test") .to("mock:endpoint-timer"); } diff --git a/integration-tests/knative/src/main/resources/application.properties b/integration-tests/knative/src/main/resources/application.properties new file mode 100644 index 00000000000..2d754f9fdae --- /dev/null +++ b/integration-tests/knative/src/main/resources/application.properties @@ -0,0 +1,81 @@ +## --------------------------------------------------------------------------- +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## --------------------------------------------------------------------------- + +########################################## +# +# knative channel consumer configuration +# +########################################## + +%knative-channel-consumer.camel.component.knative.environment.resources[0].name = channel-test +%knative-channel-consumer.camel.component.knative.environment.resources[0].type = channel +%knative-channel-consumer.camel.component.knative.environment.resources[0].endpoint-kind = source +%knative-channel-consumer.camel.main.java-routes-include-pattern=org/apache/camel/quarkus/component/knative/channel/consumer/it/Routes + +########################################## +# +# knative endpoint consumer configuration +# +########################################## + +%knative-endpoint-consumer.camel.component.knative.environment.resources[0].name = endpoint-test +%knative-endpoint-consumer.camel.component.knative.environment.resources[0].type = endpoint +%knative-endpoint-consumer.camel.component.knative.environment.resources[0].endpoint-kind = source +%knative-endpoint-consumer.camel.component.knative.environment.resources[0].path = /my-endpoint +%knative-endpoint-consumer.camel.main.java-routes-include-pattern=org/apache/camel/quarkus/component/knative/endpoint/consumer/it/Routes + +########################################## +# +# knative event consumer configuration +# +########################################## + +%knative-event-consumer.camel.component.knative.environment.resources[0].name = event-test +%knative-event-consumer.camel.component.knative.environment.resources[0].type = event +%knative-event-consumer.camel.component.knative.environment.resources[0].endpoint-kind = source +%knative-event-consumer.camel.main.java-routes-include-pattern=org/apache/camel/quarkus/component/knative/event/consumer/it/Routes + +########################################## +# +# knative producer configuration +# +########################################## + +channel.test.url = TODO +broker.test.url = TODO +service.test.url = TODO + +%knative-producer.camel.main.java-routes-include-pattern=org/apache/camel/quarkus/component/knative/producer/it/Routes + +# knative-producer channel configuration +%knative-producer.camel.component.knative.environment.resources[0].name = channel-test +%knative-producer.camel.component.knative.environment.resources[0].type = channel +%knative-producer.camel.component.knative.environment.resources[0].endpoint-kind = sink +%knative-producer.camel.component.knative.environment.resources[0].url = ${KNATIVE_CHANNEL_URL:{{channel.test.url}}} + +# knative-producer broker configuration +%knative-producer.camel.component.knative.environment.resources[1].name = broker-test +%knative-producer.camel.component.knative.environment.resources[1].type = event +%knative-producer.camel.component.knative.environment.resources[1].endpoint-kind = sink +%knative-producer.camel.component.knative.environment.resources[1].url = ${KNATIVE_CHANNEL_URL:{{broker.test.url}}} +%knative-producer.camel.component.knative.environment.resources[1].cloudEventType = org.apache.camel.event + +# knative-producer endpoint configuration +%knative-producer.camel.component.knative.environment.resources[2].name = endpoint-test +%knative-producer.camel.component.knative.environment.resources[2].type = endpoint +%knative-producer.camel.component.knative.environment.resources[2].endpoint-kind = sink +%knative-producer.camel.component.knative.environment.resources[2].url = ${KNATIVE_SERVICE_URL:{{service.test.url}}} diff --git a/integration-tests/knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerIT.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerIT.java similarity index 93% rename from integration-tests/knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerIT.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerIT.java index 14040a76f87..e433a535a85 100644 --- a/integration-tests/knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerIT.java +++ b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerIT.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.channel.consumer.it; import io.quarkus.test.junit.QuarkusIntegrationTest; diff --git a/integration-tests/knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerTest.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerTest.java similarity index 64% rename from integration-tests/knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerTest.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerTest.java index 696db79d9c2..c041239a2fe 100644 --- a/integration-tests/knative-channel-consumer/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeChannelConsumerTest.java +++ b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/channel/consumer/it/KnativeChannelConsumerTest.java @@ -14,21 +14,42 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.channel.consumer.it; import java.util.UUID; import java.util.concurrent.TimeUnit; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.TestProfile; +import io.restassured.path.json.JsonPath; import jakarta.ws.rs.core.MediaType; import org.apache.camel.cloudevents.CloudEvents; +import org.apache.camel.component.knative.http.KnativeHttpConsumerFactory; import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import static io.restassured.RestAssured.given; +import static org.apache.camel.quarkus.component.knative.channel.consumer.it.KnativeChannelConsumerTest.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +@TestProfile(KnativeChannelConsumerTestProfile.class) @QuarkusTest public class KnativeChannelConsumerTest { + @Test + void inspect() { + JsonPath p = given() + .contentType(MediaType.TEXT_PLAIN) + .accept(MediaType.APPLICATION_JSON) + .get("/knative-channel-consumer/inspect") + .then() + .statusCode(200) + .extract() + .body() + .jsonPath(); + + assertEquals(KnativeHttpConsumerFactory.class.getName(), p.getString("consumer-factory")); + } @Test void consumeEventsFromChannel() { @@ -56,4 +77,10 @@ void consumeEventsFromChannel() { } + public static final class KnativeChannelConsumerTestProfile implements QuarkusTestProfile { + @Override + public String getConfigProfile() { + return "knative-channel-consumer"; + } + } } diff --git a/integration-tests/knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerIT.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerIT.java similarity index 81% rename from integration-tests/knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerIT.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerIT.java index a9cd6118e26..e032d725fdc 100644 --- a/integration-tests/knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerIT.java +++ b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerIT.java @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.endpoint.consumer.it; import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusIntegrationTest -public class KnativeEndpointConsumerIT extends org.apache.camel.quarkus.component.knative.consumer.it.KnativeEndpointConsumerTest { +public class KnativeEndpointConsumerIT extends KnativeEndpointConsumerTest { } diff --git a/integration-tests/knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerTest.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerTest.java similarity index 76% rename from integration-tests/knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerTest.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerTest.java index 3cee239d931..f1face3c6e4 100644 --- a/integration-tests/knative-endpoint-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEndpointConsumerTest.java +++ b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/endpoint/consumer/it/KnativeEndpointConsumerTest.java @@ -14,24 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.endpoint.consumer.it; import java.util.UUID; import java.util.concurrent.TimeUnit; -import jakarta.ws.rs.core.MediaType; - -import io.quarkus.test.common.http.TestHTTPEndpoint; import io.quarkus.test.junit.QuarkusTest; -import io.restassured.path.json.JsonPath; -import org.apache.camel.component.cloudevents.CloudEvents; -import org.apache.camel.component.knative.http.KnativeHttpConsumerFactory; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.TestProfile; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.cloudevents.CloudEvents; import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import static io.restassured.RestAssured.given; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.apache.camel.quarkus.component.knative.endpoint.consumer.it.KnativeEndpointConsumerTest.*; +@TestProfile(KnativeEndpointConsumerTestProfile.class) @QuarkusTest public class KnativeEndpointConsumerTest { @Test @@ -51,11 +50,17 @@ void consumeFromCamelService() { Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS).until(() -> { final String body = given() - .get("/") + .get("/knative-endpoint-consumer") .then() .extract().body().asString(); return body != null && body.contains("Hello World - Testing Knative Services Camel consumer"); }); } + public static final class KnativeEndpointConsumerTestProfile implements QuarkusTestProfile { + @Override + public String getConfigProfile() { + return "knative-endpoint-consumer"; + } + } } diff --git a/integration-tests/knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEventConsumerIT.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerIT.java similarity index 82% rename from integration-tests/knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEventConsumerIT.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerIT.java index 0148488373c..74453ed57a2 100644 --- a/integration-tests/knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEventConsumerIT.java +++ b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerIT.java @@ -14,10 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.event.consumer.it; import io.quarkus.test.junit.QuarkusIntegrationTest; @QuarkusIntegrationTest -public class KnativeEventConsumerIT extends org.apache.camel.quarkus.component.knative.consumer.it.KnativeEventConsumerTest { +public class KnativeEventConsumerIT extends KnativeEventConsumerTest { } diff --git a/integration-tests/knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEventConsumerTest.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerTest.java similarity index 75% rename from integration-tests/knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEventConsumerTest.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerTest.java index 5d3cc654689..c307f88e700 100644 --- a/integration-tests/knative-event-consumer/src/src/test/java/org/apache/camel/quarkus/component/knative/consumer/it/KnativeEventConsumerTest.java +++ b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/event/consumer/it/KnativeEventConsumerTest.java @@ -14,23 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.component.knative.consumer.it; +package org.apache.camel.quarkus.component.knative.event.consumer.it; import java.util.UUID; import java.util.concurrent.TimeUnit; -import jakarta.ws.rs.core.MediaType; - import io.quarkus.test.junit.QuarkusTest; -import io.restassured.path.json.JsonPath; -import org.apache.camel.component.cloudevents.CloudEvents; -import org.apache.camel.component.knative.http.KnativeHttpConsumerFactory; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.TestProfile; +import jakarta.ws.rs.core.MediaType; +import org.apache.camel.cloudevents.CloudEvents; import org.awaitility.Awaitility; import org.junit.jupiter.api.Test; import static io.restassured.RestAssured.given; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.apache.camel.quarkus.component.knative.event.consumer.it.KnativeEventConsumerTest.*; +@TestProfile(KnativeEventConsumerTestProfile.class) @QuarkusTest public class KnativeEventConsumerTest { @@ -48,16 +48,21 @@ void consumeFromBroker() { .when() .post("/") .then() - .statusCode(200); + .statusCode(204); Awaitility.await().pollInterval(1, TimeUnit.SECONDS).atMost(10, TimeUnit.SECONDS).until(() -> { final String body = given() - .get("/") + .get("/knative-event-consumer") .then() .extract().body().asString(); return body != null && body.contains("Hello World - Testing Knative Broker Camel consumer"); }); } - + public static final class KnativeEventConsumerTestProfile implements QuarkusTestProfile { + @Override + public String getConfigProfile() { + return "knative-event-consumer"; + } + } } diff --git a/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeIT.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeIT.java deleted file mode 100644 index ec51d807e44..00000000000 --- a/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeIT.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.knative.it; - -import io.quarkus.test.junit.QuarkusIntegrationTest; - -@QuarkusIntegrationTest -class KnativeIT extends KnativeTest { - -} diff --git a/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeTest.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeTest.java deleted file mode 100644 index a1244214800..00000000000 --- a/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/it/KnativeTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.camel.quarkus.component.knative.it; - -import io.quarkus.test.common.http.TestHTTPEndpoint; -import io.quarkus.test.junit.QuarkusTest; -import io.restassured.RestAssured; -import io.restassured.path.json.JsonPath; -import jakarta.ws.rs.core.MediaType; -import org.apache.camel.component.knative.http.KnativeHttpConsumerFactory; -import org.apache.camel.component.knative.http.KnativeHttpProducerFactory; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -@QuarkusTest -@TestHTTPEndpoint(KnativeResource.class) -class KnativeTest { - - @Test - public void inspect() { - JsonPath p = RestAssured.given() - .accept(MediaType.APPLICATION_JSON) - .get("/inspect") - .then() - .statusCode(200) - .extract() - .body() - .jsonPath(); - - assertEquals(KnativeHttpConsumerFactory.class.getName(), p.getString("consumer-factory")); - assertEquals(KnativeHttpProducerFactory.class.getName(), p.getString("producer-factory")); - } - -} diff --git a/integration-tests/knative-producer/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerIT.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerIT.java similarity index 100% rename from integration-tests/knative-producer/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerIT.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerIT.java diff --git a/integration-tests/knative-producer/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerTest.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerTest.java similarity index 86% rename from integration-tests/knative-producer/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerTest.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerTest.java index 1e1ff58dbec..c04bd01646f 100644 --- a/integration-tests/knative-producer/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerTest.java +++ b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeProducerTest.java @@ -21,6 +21,8 @@ import io.quarkus.test.common.WithTestResource; import io.quarkus.test.common.http.TestHTTPEndpoint; import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.TestProfile; import io.restassured.path.json.JsonPath; import jakarta.ws.rs.core.MediaType; import org.apache.camel.component.knative.http.KnativeHttpProducerFactory; @@ -28,8 +30,10 @@ import org.junit.jupiter.api.Test; import static io.restassured.RestAssured.given; +import static org.apache.camel.quarkus.component.knative.producer.it.KnativeProducerTest.*; import static org.junit.jupiter.api.Assertions.assertEquals; +@TestProfile(KnativeProducerTestProfile.class) @QuarkusTest @TestHTTPEndpoint(KnativeProducerResource.class) @WithTestResource(KnativeTestResource.class) @@ -61,7 +65,7 @@ void sendToChannelWithProducerTemplate() { .get("/mock/channel") .then() .extract().body().asString(); - return body != null && "true".equals(body); + return "true".equals(body); }); } @@ -77,7 +81,7 @@ void sendToBrokerWithProducerTemplate() { .get("/mock/event") .then() .extract().body().asString(); - return body != null && "true".equals(body); + return "true".equals(body); }); } @@ -93,7 +97,7 @@ void sendToEndpointWithProducerTemplate() { .get("/mock/endpoint") .then() .extract().body().asString(); - return body != null && "true".equals(body); + return "true".equals(body); }); } @@ -104,7 +108,7 @@ void sendToChannelWithTimer() { .get("/mock/channel-timer") .then() .extract().body().asString(); - return body != null && "true".equals(body); + return "true".equals(body); }); } @@ -115,7 +119,7 @@ void sendToBrokerWithTimer() { .get("/mock/event-timer") .then() .extract().body().asString(); - return body != null && "true".equals(body); + return "true".equals(body); }); } @@ -126,8 +130,14 @@ void sendToServiceWithTimer() { .get("/mock/endpoint-timer") .then() .extract().body().asString(); - return body != null && "true".equals(body); + return "true".equals(body); }); } + public static final class KnativeProducerTestProfile implements QuarkusTestProfile { + @Override + public String getConfigProfile() { + return "knative-producer"; + } + } } diff --git a/integration-tests/knative-producer/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeTestResource.java b/integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeTestResource.java similarity index 100% rename from integration-tests/knative-producer/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeTestResource.java rename to integration-tests/knative/src/test/java/org/apache/camel/quarkus/component/knative/producer/it/KnativeTestResource.java diff --git a/integration-tests/knative-producer/src/test/resources/mappings/sendToBroker.json b/integration-tests/knative/src/test/resources/mappings/sendToBroker.json similarity index 100% rename from integration-tests/knative-producer/src/test/resources/mappings/sendToBroker.json rename to integration-tests/knative/src/test/resources/mappings/sendToBroker.json diff --git a/integration-tests/knative-producer/src/test/resources/mappings/sendToChannel.json b/integration-tests/knative/src/test/resources/mappings/sendToChannel.json similarity index 100% rename from integration-tests/knative-producer/src/test/resources/mappings/sendToChannel.json rename to integration-tests/knative/src/test/resources/mappings/sendToChannel.json diff --git a/integration-tests/knative-producer/src/test/resources/mappings/sendToService.json b/integration-tests/knative/src/test/resources/mappings/sendToService.json similarity index 100% rename from integration-tests/knative-producer/src/test/resources/mappings/sendToService.json rename to integration-tests/knative/src/test/resources/mappings/sendToService.json diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 998f6fa67af..7fce163b900 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -150,10 +150,6 @@ kafka-ssl kamelet knative - knative-channel-consumer - knative-endpoint-consumer - knative-event-consumer - knative-producer kotlin kotlin-dsl kubernetes diff --git a/tooling/scripts/test-categories.yaml b/tooling/scripts/test-categories.yaml index 99a8eebcf1e..81841472b66 100644 --- a/tooling/scripts/test-categories.yaml +++ b/tooling/scripts/test-categories.yaml @@ -207,10 +207,6 @@ group-12: - csimple - quartz-clustered - knative - - knative-channel-consumer - - knative-endpoint-consumer - - knative-event-consumer - - knative-producer - openapi-java - paho-mqtt5 - platform-http