Skip to content

Commit

Permalink
Fix and test serviceCall EIP #2628, fix #2952
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Jul 28, 2021
1 parent f88e56b commit cb2f7a2
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.core.cloud.deployment;

import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.builditem.CombinedIndexBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
import org.apache.camel.model.cloud.ServiceCallConfiguration;
import org.apache.camel.quarkus.core.deployment.spi.CamelServiceDestination;
import org.apache.camel.quarkus.core.deployment.spi.CamelServicePatternBuildItem;
import org.jboss.jandex.DotName;
import org.jboss.jandex.IndexView;

class CloudProcessor {
@BuildStep
void servicePatterns(BuildProducer<CamelServicePatternBuildItem> services) {
services.produce(new CamelServicePatternBuildItem(
CamelServiceDestination.DISCOVERY,
true,
"META-INF/services/org/apache/camel/cloud/*"));

}

@BuildStep
void reflectiveClasses(BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
CombinedIndexBuildItem combinedIndexBuildItem) {
// TODO: remove when https://github.com/apache/camel-quarkus/issues/2955 is fixed
IndexView index = combinedIndexBuildItem.getIndex();
index.getAllKnownSubclasses(DotName.createSimple(ServiceCallConfiguration.class.getName()))
.stream()
.map(classInfo -> new ReflectiveClassBuildItem(true, false, classInfo.name().toString()))
.forEach(reflectiveClass::produce);
}

}
4 changes: 4 additions & 0 deletions extensions-core/http-common/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-core-cloud-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-http-common</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-core/http-common/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-cloud</artifactId>
</dependency>

<!-- camel -->
<dependency>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/dns/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-core-cloud-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-dns</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/dns/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-core-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-dns</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/etcd/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-core-cloud-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-etcd</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/etcd/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-core-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-etcd</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/ribbon/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-core-cloud-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-ribbon</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/ribbon/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-core-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-ribbon</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/zookeeper/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-core-cloud-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-zookeeper</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions-jvm/zookeeper/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-core-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-zookeeper</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/kubernetes/deployment/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-cloud-deployment</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-commons-logging-deployment</artifactId>
Expand Down
4 changes: 4 additions & 0 deletions extensions/kubernetes/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-core-cloud</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-commons-logging</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ public void process(Exchange exchange) throws Exception {
}
}
});

from("netty-http:http://0.0.0.0:{{camel.netty-http.test-port}}/test/server/serviceCall")
.serviceCall()
.name("myService/test/server/myService")
.component("netty-http")
.staticServiceDiscovery()
.servers("myService@localhost:{{camel.netty-http.test-port}}")
.end();
from("netty-http:http://0.0.0.0:{{camel.netty-http.test-port}}/test/server/myService")
.transform().constant("Hello from myService");

}

@Named
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.eclipse.microprofile.config.ConfigProvider;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
Expand Down Expand Up @@ -199,6 +200,19 @@ public void sendDynamic() {
"fq", is(not(empty())));
}

@Test
public void serviceCall() {
final int port = ConfigProvider.getConfig().getValue("camel.netty-http.test-port", Integer.class);
RestAssured
.given()
.port(port)
.when()
.get("/test/server/serviceCall")
.then()
.statusCode(200)
.body(Matchers.is("Hello from myService"));
}

private static String[] getHttpComponentNames() {
return HTTP_COMPONENTS;
}
Expand Down

0 comments on commit cb2f7a2

Please sign in to comment.