Skip to content

Commit

Permalink
Unable to determine the status of the running process in LogIT withou…
Browse files Browse the repository at this point in the history
…t resteasy fix #2737
  • Loading branch information
ppalaga committed Jun 8, 2021
1 parent aa087b5 commit e77a43f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,36 @@
*/
package org.apache.camel.quarkus.component.log.it;

import java.util.Optional;

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

import org.apache.camel.ProducerTemplate;
import org.apache.camel.quarkus.main.events.AfterStart;
import org.eclipse.microprofile.config.inject.ConfigProperty;

@ApplicationScoped
public class LogResource {

public static final String LOG_MESSAGE = "Lets's fool io.quarkus.test.common.LauncherUtil.CaptureListeningDataReader: Listening on: http://0.0.0.0:";
@Inject
ProducerTemplate producerTemplate;

@ConfigProperty(name = "quarkus.http.test-port")
Optional<Integer> httpTestPort;
@ConfigProperty(name = "quarkus.http.port")
Optional<Integer> httpPort;

private int getEffectivePort() {
final boolean isNativeMode = "executable".equals(System.getProperty("org.graalvm.nativeimage.kind"));
Optional<Integer> portSource = isNativeMode ? httpPort : httpTestPort;
return portSource.isPresent() ? portSource.get().intValue() : 0;
}

public void info(@Observes AfterStart event) {
producerTemplate.sendBody("log:foo-topic", "Hello foo!");
producerTemplate.sendBody("log:foo-topic", LOG_MESSAGE + getEffectivePort());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class LogTest {
public void info() {
await().atMost(10L, TimeUnit.SECONDS).pollDelay(100, TimeUnit.MILLISECONDS).until(() -> {
String log = new String(Files.readAllBytes(Paths.get("target/quarkus.log")), StandardCharsets.UTF_8);
return log.contains("[foo-topic]") && log.contains("Body: Hello foo!");
return log.contains("[foo-topic]") && log.contains(LogResource.LOG_MESSAGE);
});

}
Expand Down

0 comments on commit e77a43f

Please sign in to comment.