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

Quarkus.camel.disable jaxb.1 #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
165 changes: 165 additions & 0 deletions integration-tests/camel-jdbc/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2018 Red Hat, Inc.
~
~ Licensed 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">
<parent>
<artifactId>quarkus-integration-tests-parent</artifactId>
<groupId>io.quarkus</groupId>
<version>999-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-integration-test-camel-jdbc</artifactId>
<name>Quarkus - Integration Tests - Camel - JDBC</name>
<description>Integration tests for Camel JDBC component</description>
<dependencies>
<!-- Enables the JPA capabilities -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm</artifactId>
</dependency>
<!-- We'll be using the H2 database -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-h2</artifactId>
</dependency>
<!-- .. and some REST endpoints -->
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-camel-core</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.security.jacc</groupId>
<artifactId>jboss-jacc-api_1.5_spec</artifactId>
</dependency>

<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jdbc</artifactId>
<version>3.0.0-M2</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-csv</artifactId>
<version>3.0.0-M2</version>
</dependency>
<dependency>
<groupId>org.jboss.slf4j</groupId>
<artifactId>slf4j-jboss-logging</artifactId>
<scope>provided</scope>
</dependency>

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

<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native-image</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<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>
<configuration>
<systemProperties>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>${project.groupId}</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<id>native-image</id>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<reportErrorsAtRuntime>true</reportErrorsAtRuntime>
<cleanupServer>true</cleanupServer>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
<graalvmHome>${graalvmHome}</graalvmHome>
<enableJni>false</enableJni>
<debugBuildProcess>false</debugBuildProcess>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package io.quarkus.it.camel.jdbc;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes;
import javax.inject.Inject;
import javax.sql.DataSource;

import org.jboss.logging.Logger;

import io.quarkus.camel.core.runtime.CamelRuntime;
import io.quarkus.camel.core.runtime.InitializingEvent;
import io.quarkus.camel.core.runtime.StartingEvent;

@ApplicationScoped
public class CamelLifecycle {

private static final Logger log = Logger.getLogger(CamelLifecycle.class);

@Inject
CamelRuntime runtime;

@Inject
DataSource dataSource;

public void initializing(@Observes InitializingEvent event) {
log.debug("Binding camelsDs");
runtime.getRegistry().bind("camelsDs", dataSource);
}

public void starting(@Observes StartingEvent event) throws SQLException {
log.debug("Initializing camels table");
try (Connection con = dataSource.getConnection()) {
try (Statement statement = con.createStatement()) {
try {
statement.execute("drop table camels");
} catch (Exception ignored) {
}
statement.execute("create table camels (id int primary key, species varchar(255))");
statement.execute("insert into camels (id, species) values (1, 'Camelus dromedarius')");
statement.execute("insert into camels (id, species) values (2, 'Camelus bactrianus')");
statement.execute("insert into camels (id, species) values (3, 'Camelus ferus')");
}
log.warn("Initialized camels table");
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.quarkus.it.camel.jdbc;

import javax.enterprise.context.ApplicationScoped;

import org.apache.camel.builder.RouteBuilder;

@ApplicationScoped
public class CamelRoute extends RouteBuilder {

@Override
public void configure() {
from("timer:jdbc?repeatCount=1")
.setBody(constant("select * from camels"))
.to("jdbc:camelsDs")
.marshal().csv()
.to("file:target?fileName=out.csv");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
quarkus.camel.disable-xml=true
quarkus.camel.disable-jaxb=true
quarkus.datasource.url=jdbc:h2:tcp://localhost/mem:test
quarkus.datasource.driver=org.h2.Driver
quarkus.datasource.max-size=8
quarkus.datasource.min-size=2
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package io.quarkus.it.camel.jdbc;

import io.quarkus.test.junit.SubstrateTest;

@SubstrateTest
public class CamelJdbcIT extends CamelJdbcTest {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.quarkus.it.camel.jdbc;

import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
public class CamelJdbcTest {

@Test
public void selectCamelsToCsv() throws Throwable {
final long timeoutMs = 10000;
final long deadline = System.currentTimeMillis() + timeoutMs;
final Path outCsv = Paths.get("target/out.csv");
Throwable lastException = null;
final String expectedCsv = "1,Camelus dromedarius\r\n2,Camelus bactrianus\r\n3,Camelus ferus\r\n";
while (System.currentTimeMillis() <= deadline) {
try {
Thread.sleep(100);
if (!Files.exists(outCsv)) {
lastException = new AssertionError(String.format("%s does not exist", outCsv));
} else {
final String actual = new String(Files.readAllBytes(outCsv), StandardCharsets.UTF_8);
if (expectedCsv.equals(actual)) {
/* Test passed */
return;
} else {
lastException = new AssertionError(String.format("expected: <%s> but was: <%s>", expectedCsv, actual));
}
}
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw e;
} catch (Exception e) {
lastException = e;
}
}
throw lastException;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2019 Red Hat, Inc.
*
* Licensed 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 io.quarkus.it.camel.jdbc;

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.h2.H2DatabaseTestResource;

@QuarkusTestResource(H2DatabaseTestResource.class)
public class TestResources {
}
1 change: 1 addition & 0 deletions integration-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<module>infinispan-cache-jpa</module>
<module>elytron-security</module>
<module>camel-core</module>
<module>camel-jdbc</module>
<module>camel-salesforce</module>
<module>camel-aws-s3</module>
<module>flyway</module>
Expand Down