Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions integration-tests/camel/camel-timer-devmode/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?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>io.quarkus</groupId>
<artifactId>quarkus-universe-integration-tests-camel</artifactId>
<version>999-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>quarkus-universe-integration-tests-camel-timer-devmode</artifactId>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-universe-bom-deployment</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-timer-deployment</artifactId>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-internal</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.quarkus.platform.camel.timer.test.devmode;

/**
* A workaround for https://github.com/quarkusio/quarkus/issues/9299
*
*/
public class Dummy {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.quarkus.platform.camel.timer.test.devmode;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

import io.quarkus.test.QuarkusDevModeTest;
import org.awaitility.Awaitility;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

public class TimerDevModeTest {
private static final Path LOG_FILE = Paths.get("target/" + TimerDevModeTest.class.getSimpleName() + ".log");

@RegisterExtension
static final QuarkusDevModeTest TEST = new QuarkusDevModeTest()
.setArchiveProducer(() -> ShrinkWrap
.create(JavaArchive.class)
.addClasses(TimerRoute.class)
.addAsResource(applicationProperties(), "application.properties"))
.setLogFileName(LOG_FILE.getFileName().toString());

@Test
void logMessageEdit() throws IOException {
Awaitility.await()
.atMost(1, TimeUnit.MINUTES)
.until(() -> {
return Files.exists(LOG_FILE);
});
try (BufferedReader logFileReader = Files.newBufferedReader(LOG_FILE, StandardCharsets.UTF_8)) {
assertLogMessage(logFileReader, "Hello foo", 30000);
TEST.modifySourceFile(TimerRoute.class, oldSource -> oldSource.replace("Hello foo", "Hello bar"));
assertLogMessage(logFileReader, "Hello bar", 30000);
}
}

static void assertLogMessage(BufferedReader logFileReader, String msg, long timeout) throws IOException {
boolean found = false;
final long deadline = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < deadline) {
final String line = logFileReader.readLine();
if (line == null) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new RuntimeException(e);
}
} else if (line.contains(msg)) {
found = true;
break;
}
}
Assertions.assertTrue(found, "Could not find '" + msg + "' in " + LOG_FILE);
}

public static Asset applicationProperties() {
Writer writer = new StringWriter();
Properties props = new Properties();
props.setProperty("quarkus.log.file.enable", "true");
props.setProperty("quarkus.log.file.path", LOG_FILE.toString());
try {
props.store(writer, "");
} catch (IOException e) {
throw new RuntimeException(e);
}

return new StringAsset(writer.toString());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.quarkus.platform.camel.timer.test.devmode;

import org.apache.camel.builder.RouteBuilder;
import org.jboss.logging.Logger;

public class TimerRoute extends RouteBuilder {

private static final Logger LOG = Logger.getLogger(TimerRoute.class);

@Override
public void configure() throws Exception {
from("timer:foo?period=100")
.process(exchange -> LOG.info("Hello foo"));
}
}
1 change: 1 addition & 0 deletions integration-tests/camel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
</dependencyManagement>

<modules>
<module>camel-timer-devmode</module>
<module>rpkgtests</module>
<!-- START: modules generated by rpkgtests-maven-plugin -->
<module>camel-activemq</module>
Expand Down
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<kogito-quarkus.version>0.10.1</kogito-quarkus.version>

<flatten-plugin.version>1.1.0</flatten-plugin.version>
<rpkgtests-maven-plugin.version>0.7.0</rpkgtests-maven-plugin.version>
<rpkgtests-maven-plugin.version>0.8.0</rpkgtests-maven-plugin.version>
<groovy-maven-plugin.version>2.1.1</groovy-maven-plugin.version>
<useReleaseProfile>true</useReleaseProfile>
</properties>
Expand Down Expand Up @@ -182,6 +182,10 @@
<rpkgModulePomXmlPath>integration-tests/camel/rpkgtests/pom.xml</rpkgModulePomXmlPath>
<rpkgtestsPluginVersion>@{rpkgtests-maven-plugin.version}</rpkgtestsPluginVersion>
<templatesUriBase>file:src/rpkg-templates</templatesUriBase>
<cleanExcludes>
<cleanExclude>pom.xml</cleanExclude>
<cleanExclude>camel-timer-devmode/**</cleanExclude>
</cleanExcludes>
</configuration>
</execution>
</executions>
Expand Down