Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make camel-quarkus-rest depend on camel-quarkus-platform-http #1496

Merged
merged 1 commit into from
Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/modules/ROOT/pages/extensions/rest.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,8 @@ Please refer to the above links for usage and configuration details.
----

Check the xref:user-guide/index.adoc[User guide] for more information about writing Camel Quarkus applications.

== Additional Camel Quarkus configuration

This extension configures the xref:extensions/platform-http.adoc as the component that provides the REST transport.

4 changes: 4 additions & 0 deletions extensions/rest/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package org.apache.camel.quarkus.component.rest.deployment;

import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
import io.quarkus.deployment.builditem.FeatureBuildItem;
import org.apache.camel.quarkus.component.rest.RestRecorder;
import org.apache.camel.quarkus.core.deployment.spi.CamelContextCustomizerBuildItem;
import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination;
import org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem;

Expand All @@ -37,4 +41,10 @@ CamelServicePatternBuildItem restFactories() {
"META-INF/services/org/apache/camel/rest/*",
"META-INF/services/org/apache/camel/restapi/*");
}

@Record(ExecutionTime.STATIC_INIT)
@BuildStep
CamelContextCustomizerBuildItem customizeCamelContext(RestRecorder recorder) {
return new CamelContextCustomizerBuildItem(recorder.customizeCamelContext());
}
}
4 changes: 4 additions & 0 deletions extensions/rest/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http</artifactId>
</dependency>

<!-- camel -->
<dependency>
Expand Down
1 change: 1 addition & 0 deletions extensions/rest/runtime/src/main/doc/configuration.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This extension configures the xref:extensions/platform-http.adoc as the component that provides the REST transport.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.rest;

import io.quarkus.runtime.RuntimeValue;
import io.quarkus.runtime.annotations.Recorder;
import org.apache.camel.CamelContext;
import org.apache.camel.component.platform.http.PlatformHttpConstants;
import org.apache.camel.quarkus.core.CamelContextCustomizer;
import org.jboss.logging.Logger;

@Recorder
public class RestRecorder {
public RuntimeValue<CamelContextCustomizer> customizeCamelContext() {
return new RuntimeValue<>(new RestCamelContextCustomizer());
}

private static class RestCamelContextCustomizer implements CamelContextCustomizer {
@Override
public void customize(CamelContext context) {
String component = context.getRestConfiguration().getComponent();
if (component == null) {
Logger.getLogger(RestCamelContextCustomizer.class).debugf(
"Set %s as default component for Camel REST DSL", PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME);

context.getRestConfiguration().setComponent(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME);
}
}
}
}
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<module>qute</module>
<module>reactive-streams</module>
<module>ref</module>
<module>rest</module>
<module>rest-binding-mode-xml</module>
<module>rest-openapi</module>
<module>salesforce</module>
Expand Down
4 changes: 0 additions & 4 deletions integration-tests/rest-binding-mode-xml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-platform-http</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
Expand Down
111 changes: 111 additions & 0 deletions integration-tests/rest/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-tests</artifactId>
<version>1.1.0-SNAPSHOT</version>
</parent>

<artifactId>camel-quarkus-integration-test-rest</artifactId>
<name>Camel Quarkus :: Integration Tests :: Rest</name>
<description>Integration tests for Camel Quarkus Rest extension</description>

<properties>
<!-- mvnd, a.k.a. Maven Daemon: https://github.com/gnodet/mvnd -->
<!-- The following rule tells mvnd to build the listed deployment modules before this module. -->
<!-- This is important because mvnd builds modules in parallel by default. The deployment modules are not -->
<!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
<!-- Please update rule whenever you change the dependencies of this module by running -->
<!-- mvn process-resources -Pformat from the root directory -->
<mvnd.builder.rule>camel-quarkus-attachments-deployment,camel-quarkus-log-deployment,camel-quarkus-platform-http-deployment,camel-quarkus-rest-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.package.type>native</quarkus.package.type>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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.rest.it;

import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonObject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.apache.camel.CamelContext;

@Path("/rest")
@ApplicationScoped
public class RestResource {
@Inject
CamelContext camelContext;

@Path("/inspect/configuration")
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject inspectConfiguration() {
return Json.createObjectBuilder()
.add("component", camelContext.getRestConfiguration().getComponent())
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.rest.it;

import io.quarkus.test.junit.NativeImageTest;

@NativeImageTest
class RestIT extends RestTest {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* 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.rest.it;

import io.quarkus.test.junit.QuarkusTest;
import io.restassured.RestAssured;
import org.apache.camel.component.platform.http.PlatformHttpConstants;
import org.junit.jupiter.api.Test;

import static org.hamcrest.Matchers.is;

@QuarkusTest
class RestTest {
@Test
public void inspectConfiguration() {
RestAssured.when()
.get("/rest/inspect/configuration")
.then()
.statusCode(200)
.body("component", is(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public class CamelRoute extends RouteBuilder {

@Override
public void configure() {
// by default the camel-quarkus-rest component sets platform-http
// as the component that provides the transport and since here we
// are testing the servlet component. we have to force it
restConfiguration()
.component("servlet");

rest()
.get("/rest-get")
Expand Down
1 change: 1 addition & 0 deletions tooling/scripts/test-categories.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ platform:
- platform-http
- platform-http-engine
- reactive-streams
- rest
- rest-openapi
saas:
- box
Expand Down