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 22cb13f633fe694f91c806f38574b0bbcdb82a9e Author: lburgazzoli <[email protected]> AuthorDate: Wed Apr 1 14:18:43 2020 +0200 Fix native images issues on Java 11 #1000 #1005 #999 --- .../quarkus/core/deployment/BuildProcessor.java | 46 ------- .../deployment/BytecodeTransformerProcessor.java | 89 +++++++++++++ .../core/deployment/NativeImageProcessor.java | 10 ++ .../xml/jaxb/deployment/XmlJaxbProcessor.java | 9 +- .../quarkus/support/common/CamelCapabilities.java | 1 + .../xalan/graal/SunTemplatesImplSubstitution.java | 19 ++- integration-tests/pom.xml | 1 + integration-tests/rest-binding-mode-xml/pom.xml | 144 +++++++++++++++++++++ .../component/rest/it/RestBindingModeXmlRoute.java | 17 ++- .../quarkus/component/rest/it/UserJaxbPojo.java | 41 ++++-- .../src/main/resources/application.properties | 27 ++++ .../component/rest/it/RestBindingModeXmlIT.java | 10 +- .../component/rest/it/RestBindingModeXmlTest.java | 21 ++- .../camel/quarkus/component/xml/it/XmlTest.java | 4 + 14 files changed, 363 insertions(+), 76 deletions(-) diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java index 5dd208d..7595070 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BuildProcessor.java @@ -16,11 +16,6 @@ */ package org.apache.camel.quarkus.core.deployment; -import static org.objectweb.asm.Opcodes.ATHROW; -import static org.objectweb.asm.Opcodes.DUP; -import static org.objectweb.asm.Opcodes.INVOKESPECIAL; -import static org.objectweb.asm.Opcodes.NEW; - import java.io.IOException; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; @@ -29,7 +24,6 @@ import java.nio.file.Path; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.function.BiFunction; import java.util.stream.Collectors; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; @@ -45,12 +39,10 @@ import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Overridable; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.ApplicationArchivesBuildItem; -import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem; import io.quarkus.deployment.builditem.CombinedIndexBuildItem; import io.quarkus.deployment.builditem.ServiceStartBuildItem; import io.quarkus.deployment.builditem.ShutdownContextBuildItem; import io.quarkus.deployment.recording.RecorderContext; -import io.quarkus.gizmo.Gizmo; import io.quarkus.runtime.RuntimeValue; import org.apache.camel.CamelContext; import org.apache.camel.impl.converter.BaseTypeConverterRegistry; @@ -67,18 +59,12 @@ import org.apache.camel.quarkus.core.UploadAttacher; import org.apache.camel.quarkus.core.deployment.CamelServicePatternBuildItem.CamelServiceDestination; import org.apache.camel.quarkus.core.deployment.util.PathFilter; import org.apache.camel.quarkus.support.common.CamelCapabilities; -import org.apache.camel.reifier.rest.RestBindingReifier; import org.apache.camel.spi.TypeConverterLoader; import org.apache.camel.spi.TypeConverterRegistry; import org.jboss.jandex.ClassInfo; import org.jboss.jandex.DotName; import org.jboss.jandex.IndexView; import org.jboss.jandex.Type; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -199,38 +185,6 @@ class BuildProcessor { } @BuildStep - BytecodeTransformerBuildItem transformClass() { - return new BytecodeTransformerBuildItem(RestBindingReifier.class.getName(), new BiFunction<String, ClassVisitor, ClassVisitor>() { - @Override - public ClassVisitor apply(String s, ClassVisitor classVisitor) { - ClassVisitor cv = new ClassVisitor(Gizmo.ASM_API_VERSION, classVisitor) { - - @Override - public MethodVisitor visitMethod(int access, String name, String descriptor, String signature, String[] exceptions) { - final MethodVisitor target = super.visitMethod(access, name, descriptor, signature, exceptions); - if (name.equals("setupJaxb")) { - return new MethodVisitor(Gizmo.ASM_API_VERSION, null) { - @Override - public void visitCode() { - target.visitCode(); - target.visitTypeInsn(NEW, "java/io/UnsupportedOperationException"); - target.visitInsn(DUP); - target.visitMethodInsn(INVOKESPECIAL,"java/lang/UnsupportedOperationException","<init>","()V",false); - target.visitInsn(ATHROW); - target.visitMaxs(2, 0); - target.visitEnd(); - } - }; - } - return target; - } - }; - return cv; - } - }); - } - - @BuildStep void camelServices( ApplicationArchivesBuildItem applicationArchives, List<CamelServicePatternBuildItem> servicePatterns, diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BytecodeTransformerProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BytecodeTransformerProcessor.java new file mode 100644 index 0000000..ce91b8c --- /dev/null +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/BytecodeTransformerProcessor.java @@ -0,0 +1,89 @@ +/* + * 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.function.BiFunction; + +import io.quarkus.deployment.Capabilities; +import io.quarkus.deployment.annotations.BuildProducer; +import io.quarkus.deployment.annotations.BuildStep; +import io.quarkus.deployment.builditem.BytecodeTransformerBuildItem; +import io.quarkus.gizmo.Gizmo; +import org.apache.camel.quarkus.support.common.CamelCapabilities; +import org.apache.camel.reifier.rest.RestBindingReifier; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.MethodVisitor; + +import static org.objectweb.asm.Opcodes.ATHROW; +import static org.objectweb.asm.Opcodes.DUP; +import static org.objectweb.asm.Opcodes.INVOKESPECIAL; +import static org.objectweb.asm.Opcodes.NEW; + +class BytecodeTransformerProcessor { + @BuildStep + void transformRestBindingReifier(Capabilities capabilities, + BuildProducer<BytecodeTransformerBuildItem> bytecodeTransformer) { + // if jaxb is configured, don't replace the method + if (capabilities.isCapabilityPresent(CamelCapabilities.XML_JAXB)) { + return; + } + + bytecodeTransformer.produce( + new BytecodeTransformerBuildItem( + RestBindingReifier.class.getName(), + new RestBindingReifierTransformer())); + } + + private static class RestBindingReifierTransformer implements BiFunction<String, ClassVisitor, ClassVisitor> { + @Override + public ClassVisitor apply(String s, ClassVisitor classVisitor) { + return new ClassVisitor(Gizmo.ASM_API_VERSION, classVisitor) { + @Override + public MethodVisitor visitMethod( + int access, + String name, + String descriptor, + String signature, + String[] exceptions) { + + final MethodVisitor target = super.visitMethod(access, name, descriptor, signature, exceptions); + + if (name.equals("setupJaxb")) { + return new MethodVisitor(Gizmo.ASM_API_VERSION, null) { + @Override + public void visitCode() { + target.visitCode(); + target.visitTypeInsn(NEW, "java/lang/UnsupportedOperationException"); + target.visitInsn(DUP); + target.visitLdcInsn("Please add a dependency to camel-quarkus-xml-jaxb"); + target.visitMethodInsn( + INVOKESPECIAL, + "java/lang/UnsupportedOperationException", "<init>", + "(Ljava/lang/String;)V", + false); + target.visitInsn(ATHROW); + target.visitMaxs(2, 0); + target.visitEnd(); + } + }; + } + return target; + } + }; + } + } +} diff --git a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/NativeImageProcessor.java b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/NativeImageProcessor.java index 89ce069..b7845e6 100644 --- a/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/NativeImageProcessor.java +++ b/extensions-core/core/deployment/src/main/java/org/apache/camel/quarkus/core/deployment/NativeImageProcessor.java @@ -302,7 +302,17 @@ public class NativeImageProcessor { org.apache.camel.main.DefaultConfigurationProperties.class, org.apache.camel.main.MainConfigurationProperties.class, org.apache.camel.main.HystrixConfigurationProperties.class, + org.apache.camel.main.Resilience4jConfigurationProperties.class, org.apache.camel.main.RestConfigurationProperties.class)); + + // TODO: The classes below are needed to fix https://github.com/apache/camel-quarkus/issues/1005 + // but we need to investigate why it does not fail with Java 1.8 + reflectiveClass.produce(new ReflectiveClassBuildItem( + true, + false, + org.apache.camel.model.Resilience4jConfigurationDefinition.class, + org.apache.camel.model.Resilience4jConfigurationCommon.class, + org.apache.camel.spi.RestConfiguration.class)); } } } diff --git a/extensions-core/xml-jaxb/deployment/src/main/java/org/apache/camel/quarkus/component/xml/jaxb/deployment/XmlJaxbProcessor.java b/extensions-core/xml-jaxb/deployment/src/main/java/org/apache/camel/quarkus/component/xml/jaxb/deployment/XmlJaxbProcessor.java index 6b0d104..1c1c1d5 100644 --- a/extensions-core/xml-jaxb/deployment/src/main/java/org/apache/camel/quarkus/component/xml/jaxb/deployment/XmlJaxbProcessor.java +++ b/extensions-core/xml-jaxb/deployment/src/main/java/org/apache/camel/quarkus/component/xml/jaxb/deployment/XmlJaxbProcessor.java @@ -16,6 +16,9 @@ */ package org.apache.camel.quarkus.component.xml.jaxb.deployment; +import java.util.Arrays; +import java.util.List; + import io.quarkus.deployment.annotations.BuildStep; import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; @@ -44,8 +47,10 @@ class XmlJaxbProcessor { } @BuildStep - CapabilityBuildItem capability() { - return new CapabilityBuildItem(CamelCapabilities.XML); + List<CapabilityBuildItem> capabilities() { + return Arrays.asList( + new CapabilityBuildItem(CamelCapabilities.XML), + new CapabilityBuildItem(CamelCapabilities.XML_JAXB)); } @BuildStep diff --git a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java b/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java index 6c4f76b..677a83b 100644 --- a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java +++ b/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java @@ -19,6 +19,7 @@ package org.apache.camel.quarkus.support.common; public final class CamelCapabilities { public static final String CORE = "org.apache.camel"; public static final String XML = "org.apache.camel.xml"; + public static final String XML_JAXB = "org.apache.camel.xml.jaxb"; private CamelCapabilities() { } diff --git a/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/graal/SunTemplatesImplSubstitution.java b/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/graal/SunTemplatesImplSubstitution.java index 266e0da..74460ed 100644 --- a/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/graal/SunTemplatesImplSubstitution.java +++ b/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/graal/SunTemplatesImplSubstitution.java @@ -16,17 +16,34 @@ */ package org.apache.camel.quarkus.support.xalan.graal; +import java.security.ProtectionDomain; + import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.jdk.JDK11OrLater; +import com.oracle.svm.core.jdk.JDK8OrEarlier; @TargetClass(className = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl") final class SunTemplatesImplSubstitution { - @TargetClass(className = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl", innerClass = "TransletClassLoader") + @TargetClass(className = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl", innerClass = "TransletClassLoader", onlyWith = JDK8OrEarlier.class) static final class TransletClassLoader { @Substitute Class defineClass(final byte[] b) { throw new UnsupportedOperationException(); } } + + @TargetClass(className = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl", innerClass = "TransletClassLoader", onlyWith = JDK11OrLater.class) + static final class TransletClassLoaderJDK11OrLater { + @Substitute + Class defineClass(final byte[] b) { + throw new UnsupportedOperationException(); + } + + @Substitute + Class<?> defineClass(final byte[] b, ProtectionDomain pd) { + throw new UnsupportedOperationException(); + } + } } diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index 467646f..7b791b5 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -102,6 +102,7 @@ <module>qute</module> <module>reactive-streams</module> <module>ref</module> + <module>rest-binding-mode-xml</module> <module>salesforce</module> <module>scheduler</module> <module>seda</module> diff --git a/integration-tests/rest-binding-mode-xml/pom.xml b/integration-tests/rest-binding-mode-xml/pom.xml new file mode 100644 index 0000000..9c473b2 --- /dev/null +++ b/integration-tests/rest-binding-mode-xml/pom.xml @@ -0,0 +1,144 @@ +<?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-binding-mode-xml</artifactId> + <name>Camel Quarkus :: Integration Tests :: Rest :: Binding Mode XML</name> + <description>Integration tests for Camel Quarkus Rest extension with XML binding mode</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> + + <dependencyManagement> + <dependencies> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-bom-test</artifactId> + <version>${project.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> + </dependencyManagement> + + <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> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-xml-jaxb</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-jaxb</artifactId> + </dependency> + <dependency> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-log</artifactId> + </dependency> + <dependency><!-- Leave this one out (and save ~560 kB of the native image) unless you want to attach uploads to the camel message --> + <groupId>org.apache.camel.quarkus</groupId> + <artifactId>camel-quarkus-attachments</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> + <dependency> + <groupId>org.assertj</groupId> + <artifactId>assertj-core</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> diff --git a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java b/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlRoute.java similarity index 61% copy from extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java copy to integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlRoute.java index 6c4f76b..84b63f9 100644 --- a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java +++ b/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlRoute.java @@ -14,12 +14,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.support.common; +package org.apache.camel.quarkus.component.rest.it; -public final class CamelCapabilities { - public static final String CORE = "org.apache.camel"; - public static final String XML = "org.apache.camel.xml"; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.model.rest.RestBindingMode; - private CamelCapabilities() { +public class RestBindingModeXmlRoute extends RouteBuilder { + @Override + public void configure() { + rest() + .post("/platform-http/nameOf") + .bindingMode(RestBindingMode.xml) + .type(UserJaxbPojo.class) + .route() + .transform().body(UserJaxbPojo.class, UserJaxbPojo::getName); } } diff --git a/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/graal/SunTemplatesImplSubstitution.java b/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/UserJaxbPojo.java similarity index 52% copy from extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/graal/SunTemplatesImplSubstitution.java copy to integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/UserJaxbPojo.java index 266e0da..4070b6f 100644 --- a/extensions-support/xalan/runtime/src/main/java/org/apache/camel/quarkus/support/xalan/graal/SunTemplatesImplSubstitution.java +++ b/integration-tests/rest-binding-mode-xml/src/main/java/org/apache/camel/quarkus/component/rest/it/UserJaxbPojo.java @@ -14,19 +14,38 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.support.xalan.graal; +package org.apache.camel.quarkus.component.rest.it; -import com.oracle.svm.core.annotate.Substitute; -import com.oracle.svm.core.annotate.TargetClass; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlRootElement; -@TargetClass(className = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl") -final class SunTemplatesImplSubstitution { +import io.quarkus.runtime.annotations.RegisterForReflection; - @TargetClass(className = "com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl", innerClass = "TransletClassLoader") - static final class TransletClassLoader { - @Substitute - Class defineClass(final byte[] b) { - throw new UnsupportedOperationException(); - } +@RegisterForReflection +@XmlRootElement(name = "user") +@XmlAccessorType(XmlAccessType.FIELD) +public class UserJaxbPojo { + + @XmlAttribute + private int id; + @XmlAttribute + private String name; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; } } diff --git a/integration-tests/rest-binding-mode-xml/src/main/resources/application.properties b/integration-tests/rest-binding-mode-xml/src/main/resources/application.properties new file mode 100644 index 0000000..f6591cf --- /dev/null +++ b/integration-tests/rest-binding-mode-xml/src/main/resources/application.properties @@ -0,0 +1,27 @@ +## --------------------------------------------------------------------------- +## 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. +## --------------------------------------------------------------------------- +# +# Quarkus +# +quarkus.ssl.native=true +quarkus.http.body.uploads-directory=target/uploads +quarkus.log.file.enable = false +quarkus.log.category."org.apache.camel.quarkus.core.deployment".level = INFO +quarkus.log.category."org.apache.camel.quarkus.component.platform.http".level = INFO + +# Required by the encoding() test +quarkus.native.add-all-charsets = true diff --git a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java b/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlIT.java similarity index 76% copy from extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java copy to integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlIT.java index 6c4f76b..0cb43a1 100644 --- a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java +++ b/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlIT.java @@ -14,12 +14,10 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.support.common; +package org.apache.camel.quarkus.component.rest.it; -public final class CamelCapabilities { - public static final String CORE = "org.apache.camel"; - public static final String XML = "org.apache.camel.xml"; +import io.quarkus.test.junit.NativeImageTest; - private CamelCapabilities() { - } +@NativeImageTest +class RestBindingModeXmlIT extends RestBindingModeXmlTest { } diff --git a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java b/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlTest.java similarity index 59% copy from extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java copy to integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlTest.java index 6c4f76b..b3b2892 100644 --- a/extensions-support/common/runtime/src/main/java/org/apache/camel/quarkus/support/common/CamelCapabilities.java +++ b/integration-tests/rest-binding-mode-xml/src/test/java/org/apache/camel/quarkus/component/rest/it/RestBindingModeXmlTest.java @@ -14,12 +14,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.camel.quarkus.support.common; +package org.apache.camel.quarkus.component.rest.it; -public final class CamelCapabilities { - public static final String CORE = "org.apache.camel"; - public static final String XML = "org.apache.camel.xml"; +import io.quarkus.test.junit.QuarkusTest; +import io.restassured.RestAssured; +import org.junit.jupiter.api.Test; - private CamelCapabilities() { +import static org.hamcrest.Matchers.is; + +@QuarkusTest +class RestBindingModeXmlTest { + @Test + public void extractNameFromXml() { + RestAssured.given() + .body("<user name=\"Donald Duck\" id=\"123\"></user>") + .post("/platform-http/nameOf") + .then() + .statusCode(200) + .body(is("Donald Duck")); } } diff --git a/integration-tests/xml/src/test/java/org/apache/camel/quarkus/component/xml/it/XmlTest.java b/integration-tests/xml/src/test/java/org/apache/camel/quarkus/component/xml/it/XmlTest.java index 8ee8a8d..3d093d1 100644 --- a/integration-tests/xml/src/test/java/org/apache/camel/quarkus/component/xml/it/XmlTest.java +++ b/integration-tests/xml/src/test/java/org/apache/camel/quarkus/component/xml/it/XmlTest.java @@ -18,6 +18,7 @@ package org.apache.camel.quarkus.component.xml.it; import java.nio.charset.Charset; +import io.quarkus.test.junit.DisabledOnNativeImage; import io.quarkus.test.junit.QuarkusTest; import io.restassured.RestAssured; import io.restassured.http.ContentType; @@ -30,6 +31,7 @@ import static org.hamcrest.Matchers.is; @QuarkusTest class XmlTest { + @DisabledOnNativeImage("Could not load the propery file 'output_xml.properties' for output method 'xml'") @Test public void htmlParse() throws Exception { String html = IOUtils.toString(getClass().getResourceAsStream("/test.html"), Charset.forName("UTF-8")); @@ -60,6 +62,7 @@ class XmlTest { actual); } + @DisabledOnNativeImage("Could not load the propery file 'output_xml.properties' for output method 'xml'") @Test public void htmlTransform() throws Exception { String html = IOUtils.toString(getClass().getResourceAsStream("/test.html"), Charset.forName("UTF-8")); @@ -78,6 +81,7 @@ class XmlTest { actual); } + @DisabledOnNativeImage("Could not load the propery file 'output_xml.properties' for output method 'xml'") @Test public void htmlToText() throws Exception { String html = IOUtils.toString(getClass().getResourceAsStream("/test.html"), Charset.forName("UTF-8"));
