This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 596eb4c75ee8096cbd2e8559a258ee1abf4795ed Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Tue Aug 20 01:12:36 2019 +0200 Basic impl for #147 --- build-parent/pom.xml | 3 - extensions/core/deployment/pom.xml | 2 - .../core/deployment/CamelInitProcessor.java | 82 +++++++++++++++++----- .../core/deployment/CamelRegistryBuildItem.java | 51 ++++++++++++++ .../camel/quarkus/core/runtime/CamelRecorder.java | 9 +++ integration-tests/core-support/deployment/pom.xml | 49 +++++++++++++ .../quarkus/core/support/deployment/Feature.java | 29 ++++++++ .../core/support/deployment/SupportBuildStep.java | 30 ++++++++ .../core/support/deployment/SupportRecorder.java | 40 +++++++++++ integration-tests/core-support/pom.xml | 21 ++++++ .../core-support/runtime}/pom.xml | 43 ++++-------- integration-tests/core/pom.xml | 11 ++- .../apache/camel/quarkus/core/CamelServlet.java | 20 ++++++ .../org/apache/camel/quarkus/core/CamelTest.java | 14 ++++ integration-tests/pom.xml | 2 + 15 files changed, 352 insertions(+), 54 deletions(-) diff --git a/build-parent/pom.xml b/build-parent/pom.xml index 3585b8c..f5f0f58 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -71,19 +71,16 @@ <artifactId>camel-quarkus-core-deployment</artifactId> <version>${project.version}</version> </dependency> - <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-http-common-deployment</artifactId> <version>${project.version}</version> </dependency> - <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-jetty-common-deployment</artifactId> <version>${project.version}</version> </dependency> - <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-xml-common-deployment</artifactId> diff --git a/extensions/core/deployment/pom.xml b/extensions/core/deployment/pom.xml index c52249c..e06445f 100644 --- a/extensions/core/deployment/pom.xml +++ b/extensions/core/deployment/pom.xml @@ -52,8 +52,6 @@ <scope>test</scope> </dependency> - - <dependency> <groupId>org.assertj</groupId> <artifactId>assertj-core</artifactId> diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelInitProcessor.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelInitProcessor.java index c890819..ab6aaf3 100644 --- a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelInitProcessor.java +++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelInitProcessor.java @@ -20,12 +20,13 @@ import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; +import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Properties; import java.util.Set; -import java.util.function.BiConsumer; import java.util.stream.Collectors; import java.util.stream.Stream; import javax.inject.Inject; @@ -56,9 +57,11 @@ import org.eclipse.microprofile.config.Config; import org.eclipse.microprofile.config.ConfigProvider; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; +import org.slf4j.Logger; import org.slf4j.LoggerFactory; class CamelInitProcessor { + private static final Logger LOGGER = LoggerFactory.getLogger(CamelInitProcessor.class); @Inject ApplicationArchivesBuildItem applicationArchivesBuildItem; @@ -69,8 +72,12 @@ class CamelInitProcessor { @Record(ExecutionTime.STATIC_INIT) @BuildStep(applicationArchiveMarkers = { CamelSupport.CAMEL_SERVICE_BASE_PATH, CamelSupport.CAMEL_ROOT_PACKAGE_DIRECTORY }) - CamelRuntimeBuildItem createInitTask(RecorderContext recorderContext, CamelRecorder recorder, + CamelRuntimeBuildItem createInitTask( + RecorderContext recorderContext, + CamelRecorder recorder, + List<CamelRegistryBuildItem> registryItems, BuildProducer<RuntimeBeanBuildItem> runtimeBeans) { + Properties properties = new Properties(); Config configProvider = ConfigProvider.getConfig(); for (String property : configProvider.getPropertyNames()) { @@ -85,22 +92,37 @@ class CamelInitProcessor { RuntimeRegistry registry = new RuntimeRegistry(); final List<RuntimeValue<?>> builders; if (buildTimeConfig.deferInitPhase) { - builders = getBuildTimeRouteBuilderClasses().map(recorderContext::newInstance) - .collect(Collectors.toList()); + builders = getBuildTimeRouteBuilderClasses() + .map(recorderContext::newInstance) + .collect(Collectors.toList()); } else { builders = new ArrayList<>(); } - visitServices((name, type) -> { - LoggerFactory.getLogger(CamelInitProcessor.class).debug("Binding camel service {} with type {}", name, type); - registry.bind(name, type, - recorderContext.newInstance(type.getName())); - }); + services().filter( + si -> registryItems.stream().noneMatch( + c -> Objects.equals(si.name, c.getName()) && c.getType().isAssignableFrom(si.type) + ) + ).forEach( + si -> { + LOGGER.debug("Binding camel service {} with type {}", si.name, si.type); + + registry.bind( + si.name, + si.type, + recorderContext.newInstance(si.type.getName()) + ); + } + ); RuntimeValue<CamelRuntime> camelRuntime = recorder.create(registry, properties, builders, buildTimeConfig); - runtimeBeans - .produce(RuntimeBeanBuildItem.builder(CamelRuntime.class).setRuntimeValue(camelRuntime).build()); + runtimeBeans.produce(RuntimeBeanBuildItem.builder(CamelRuntime.class).setRuntimeValue(camelRuntime).build()); + + for (CamelRegistryBuildItem item: registryItems) { + LOGGER.debug("Binding item with name: {}, type {}", item.getName(), item.getType()); + recorder.bind(camelRuntime, item.getName(), item.getType(), item.getValue()); + } return new CamelRuntimeBuildItem(camelRuntime); } @@ -113,8 +135,7 @@ class CamelInitProcessor { CamelRecorder recorder, BuildProducer<BeanContainerListenerBuildItem> listeners) { - listeners - .produce(new BeanContainerListenerBuildItem(recorder.initRuntimeInjection(runtime.getRuntime()))); + listeners.produce(new BeanContainerListenerBuildItem(recorder.initRuntimeInjection(runtime.getRuntime()))); return AdditionalBeanBuildItem.unremovableOf(CamelProducers.class); } @@ -163,12 +184,15 @@ class CamelInitProcessor { .map(ClassInfo::toString); } - protected void visitServices(BiConsumer<String, Class<?>> consumer) { - CamelSupport.resources(applicationArchivesBuildItem, CamelSupport.CAMEL_SERVICE_BASE_PATH) - .forEach(p -> visitService(p, consumer)); + protected Stream<ServiceInfo> services() { + return CamelSupport.resources(applicationArchivesBuildItem, CamelSupport.CAMEL_SERVICE_BASE_PATH) + .map(this::services) + .flatMap(Collection::stream); } - protected void visitService(Path p, BiConsumer<String, Class<?>> consumer) { + protected List<ServiceInfo> services(Path p) { + List<ServiceInfo> answer = new ArrayList<>(); + String name = p.getFileName().toString(); try (InputStream is = Files.newInputStream(p)) { Properties props = new Properties(); @@ -179,11 +203,33 @@ class CamelInitProcessor { String clazz = entry.getValue().toString(); Class<?> cl = Class.forName(clazz); - consumer.accept(name, cl); + answer.add(new ServiceInfo(name, cl)); } } } catch (Exception e) { throw new RuntimeException(e); } + + return answer; + } + + static class ServiceInfo { + final String name; + final Class<?> type; + + public ServiceInfo(String name, Class<?> type) { + this.name = name; + this.type = type; + } + + @Override + public String toString() { + return "ServiceInfo{" + + "name='" + name + '\'' + + ", type=" + type + + '}'; + } } + + } diff --git a/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRegistryBuildItem.java b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRegistryBuildItem.java new file mode 100644 index 0000000..17e556f --- /dev/null +++ b/extensions/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/CamelRegistryBuildItem.java @@ -0,0 +1,51 @@ +/* + * 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.deployment; + +import java.util.Objects; + +import io.quarkus.builder.item.MultiBuildItem; + +public final class CamelRegistryBuildItem extends MultiBuildItem { + private final String name; + private final Class<?> type; + private final Object value; + + public CamelRegistryBuildItem(String name, Object value) { + this.name = Objects.requireNonNull(name); + this.value = Objects.requireNonNull(value); + this.type = Objects.requireNonNull(value).getClass(); + } + + public CamelRegistryBuildItem(String name, Class<?> type, Object value) { + this.name = Objects.requireNonNull(name); + this.type = Objects.requireNonNull(type); + this.value = Objects.requireNonNull(value); + } + + public String getName() { + return name; + } + + public Class<?> getType() { + return type; + } + + public Object getValue() { + return value; + } +} diff --git a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/CamelRecorder.java b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/CamelRecorder.java index 9a9acf5..43a2217 100644 --- a/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/CamelRecorder.java +++ b/extensions/core/runtime/src/main/java/org/apache/camel/quarkus/core/runtime/CamelRecorder.java @@ -49,6 +49,15 @@ public class CamelRecorder { return new RuntimeValue<>(runtime); } + public void bind( + RuntimeValue<CamelRuntime> runtime, + String name, + Class<?> type, + Object instance) { + + runtime.getValue().getRegistry().bind(name, type, instance); + } + public void init( BeanContainer beanContainer, RuntimeValue<CamelRuntime> runtime, diff --git a/integration-tests/core-support/deployment/pom.xml b/integration-tests/core-support/deployment/pom.xml new file mode 100644 index 0000000..b6b5dcd --- /dev/null +++ b/integration-tests/core-support/deployment/pom.xml @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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"> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-test-core-support-parent</artifactId> + <version>0.1.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>camel-quarkus-integration-test-core-support-deployment</artifactId> + <name>Camel Quarkus :: Integration Tests :: Core :: Support :: Deployment</name> + <description>The camel integration tests</description> + + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-core-deployment</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-log-deployment</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-test-core-support</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <annotationProcessorPaths> + <path> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-extension-processor</artifactId> + <version>${quarkus.version}</version> + </path> + </annotationProcessorPaths> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/Feature.java b/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/Feature.java new file mode 100644 index 0000000..922fb0d --- /dev/null +++ b/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/Feature.java @@ -0,0 +1,29 @@ +/* + * 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.support.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.FeatureBuildItem; + +public class Feature { + private static final String FEATURE = "camel-core-support"; + + @BuildStep + FeatureBuildItem feature() { + return new FeatureBuildItem(FEATURE); + } +} diff --git a/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/SupportBuildStep.java b/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/SupportBuildStep.java new file mode 100644 index 0000000..329bbf7 --- /dev/null +++ b/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/SupportBuildStep.java @@ -0,0 +1,30 @@ +/* + * 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.support.deployment; + +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.annotations.ExecutionTime; +import io.quarkus.deployment.annotations.Record; +import org.apache.camel.quarkus.core.deployment.CamelRegistryBuildItem; + +public class SupportBuildStep { + @Record(ExecutionTime.STATIC_INIT) + @BuildStep + CamelRegistryBuildItem logComponent(SupportRecorder recorder) { + return recorder.logComponent(); + } +} diff --git a/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/SupportRecorder.java b/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/SupportRecorder.java new file mode 100644 index 0000000..2340b21 --- /dev/null +++ b/integration-tests/core-support/deployment/src/main/java/org/apache/camel/quarkus/core/support/deployment/SupportRecorder.java @@ -0,0 +1,40 @@ +/* + * 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.support.deployment; + +import io.quarkus.runtime.annotations.Recorder; +import org.apache.camel.component.log.LogComponent; +import org.apache.camel.quarkus.core.deployment.CamelRegistryBuildItem; +import org.apache.camel.support.processor.DefaultExchangeFormatter; + +@Recorder +public class SupportRecorder { + CamelRegistryBuildItem logComponent() { + DefaultExchangeFormatter def = new DefaultExchangeFormatter(); + def.setShowAll(true); + def.setMultiline(true); + + LogComponent component = new LogComponent(); + component.setExchangeFormatter(def); + + return new CamelRegistryBuildItem( + "log", + LogComponent.class, + component + ); + } +} diff --git a/integration-tests/core-support/pom.xml b/integration-tests/core-support/pom.xml new file mode 100644 index 0000000..7c702ff --- /dev/null +++ b/integration-tests/core-support/pom.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<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"> + <parent> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-build-parent</artifactId> + <version>0.1.1-SNAPSHOT</version> + <relativePath>../../build-parent/pom.xml</relativePath> + </parent> + + <modelVersion>4.0.0</modelVersion> + <packaging>pom</packaging> + + <artifactId>camel-quarkus-integration-test-core-support-parent</artifactId> + <name>Camel Quarkus :: Integration Tests :: Core :: Support</name> + + <modules> + <module>deployment</module> + <module>runtime</module> + </modules> + +</project> diff --git a/extensions/core/deployment/pom.xml b/integration-tests/core-support/runtime/pom.xml similarity index 67% copy from extensions/core/deployment/pom.xml copy to integration-tests/core-support/runtime/pom.xml index c52249c..76f29cf 100644 --- a/extensions/core/deployment/pom.xml +++ b/integration-tests/core-support/runtime/pom.xml @@ -20,50 +20,33 @@ <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"> <parent> <groupId>org.apache.camel.quarkus</groupId> - <artifactId>camel-quarkus-core-parent</artifactId> + <artifactId>camel-quarkus-integration-test-core-support-parent</artifactId> <version>0.1.1-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> - <artifactId>camel-quarkus-core-deployment</artifactId> - <name>Camel Quarkus :: Core :: Deployment</name> + + <artifactId>camel-quarkus-integration-test-core-support</artifactId> + <name>Camel Quarkus :: Integration Tests :: Core :: Support</name> + <description>The camel integration tests</description> + <dependencies> - <!-- quarkus --> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-core-deployment</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-arc-deployment</artifactId> - </dependency> - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-jaxb-deployment</artifactId> - </dependency> - <!-- camel --> <dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-core</artifactId> </dependency> - - <dependency> - <groupId>io.quarkus</groupId> - <artifactId>quarkus-junit5-internal</artifactId> - <scope>test</scope> - </dependency> - - - <dependency> - <groupId>org.assertj</groupId> - <artifactId>assertj-core</artifactId> - <version>${assertj.version}</version> - <scope>test</scope> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-log</artifactId> </dependency> </dependencies> + <build> <plugins> <plugin> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-bootstrap-maven-plugin</artifactId> + </plugin> + <plugin> <artifactId>maven-compiler-plugin</artifactId> <configuration> <annotationProcessorPaths> diff --git a/integration-tests/core/pom.xml b/integration-tests/core/pom.xml index c67e2c1..4af1826 100644 --- a/integration-tests/core/pom.xml +++ b/integration-tests/core/pom.xml @@ -42,10 +42,19 @@ <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-timer</artifactId> </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-integration-test-core-support</artifactId> + <version>${project.version}</version> + </dependency> <dependency> <groupId>io.quarkus</groupId> - <artifactId>quarkus-resteasy</artifactId> + <artifactId>quarkus-jsonb</artifactId> + </dependency> + <dependency> + <groupId>io.quarkus</groupId> + <artifactId>quarkus-resteasy-jsonb</artifactId> </dependency> <!-- test dependencies --> diff --git a/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java b/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java index fe7d1be..2e3728a 100644 --- a/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java +++ b/integration-tests/core/src/main/java/org/apache/camel/quarkus/core/CamelServlet.java @@ -21,6 +21,8 @@ import java.util.Set; import java.util.stream.Collectors; 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.PathParam; @@ -28,9 +30,11 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import org.apache.camel.Route; +import org.apache.camel.component.log.LogComponent; import org.apache.camel.component.timer.TimerComponent; import org.apache.camel.quarkus.core.runtime.CamelConfig; import org.apache.camel.quarkus.core.runtime.CamelRuntime; +import org.apache.camel.support.processor.DefaultExchangeFormatter; @Path("/test") @ApplicationScoped @@ -62,6 +66,22 @@ public class CamelServlet { return runtime.getContext().getComponent("timer", TimerComponent.class).isResolvePropertyPlaceholders(); } + + @Path("/registry/log/exchange-formatter") + @GET + @Produces(MediaType.APPLICATION_JSON) + public JsonObject exchangeFormatterConfig() { + LogComponent component = runtime.getRegistry().lookupByNameAndType("log", LogComponent.class); + DefaultExchangeFormatter def = (DefaultExchangeFormatter)component.getExchangeFormatter(); + + JsonObject result = Json.createObjectBuilder() + .add("show-all", def.isShowAll()) + .add("multi-line", def.isMultiline()) + .build(); + + return result; + } + @Path("/registry/produces-config-build") @GET @Produces(MediaType.TEXT_PLAIN) diff --git a/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CamelTest.java b/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CamelTest.java index d3e1325..4c6673d 100644 --- a/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CamelTest.java +++ b/integration-tests/core/src/test/java/org/apache/camel/quarkus/core/CamelTest.java @@ -16,12 +16,17 @@ */ package org.apache.camel.quarkus.core; +import java.net.HttpURLConnection; + import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; +import io.restassured.response.Response; import org.junit.jupiter.api.Test; import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.is; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; @QuarkusTest public class CamelTest { @@ -47,4 +52,13 @@ public class CamelTest { RestAssured.when().get("/test/registry/produces-config-build").then().body(is("true")); RestAssured.when().get("/test/registry/produces-config-runtime").then().body(is("true")); } + + @Test + public void testRegistryBuildItem() { + Response response = RestAssured.get("/test/registry/log/exchange-formatter").andReturn(); + + assertEquals(HttpURLConnection.HTTP_OK, response.getStatusCode()); + assertTrue(response.jsonPath().getBoolean("show-all")); + assertTrue(response.jsonPath().getBoolean("multi-line")); + } } diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index bbbcdb6..29fa011 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -32,8 +32,10 @@ <name>Camel Quarkus :: Integration Tests</name> + <modules> <!-- build those first --> + <module>core-support</module> <module>core</module> <module>core-impl</module> <module>core-cdi</module>