add test for reading the systemd-journal-gateway
This commit is contained in:
parent
84453d8d4c
commit
91fd31a85c
4 changed files with 43 additions and 0 deletions
|
@ -18,6 +18,7 @@ test {
|
||||||
'--add-opens=java.base/java.nio=ALL-UNNAMED',
|
'--add-opens=java.base/java.nio=ALL-UNNAMED',
|
||||||
'--add-opens=java.base/java.util=ALL-UNNAMED'
|
'--add-opens=java.base/java.util=ALL-UNNAMED'
|
||||||
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
|
systemProperty 'java.util.logging.config.file', 'src/test/resources/logging.properties'
|
||||||
|
systemProperty 'java.net.preferIPv6Addresses', 'true'
|
||||||
systemProperty 'io.netty.tryReflectionSetAccessible', 'false'
|
systemProperty 'io.netty.tryReflectionSetAccessible', 'false'
|
||||||
systemProperty 'io.netty.allocator.typ', 'pooled'
|
systemProperty 'io.netty.allocator.typ', 'pooled'
|
||||||
systemProperty 'io.netty.noUnsafe', 'true'
|
systemProperty 'io.netty.noUnsafe', 'true'
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
module org.xbib.net.http.client.event.stream.test {
|
||||||
|
requires java.logging;
|
||||||
|
requires java.net.http;
|
||||||
|
requires transitive org.junit.jupiter.api;
|
||||||
|
exports org.xbib.net.http.client.event.stream.test;
|
||||||
|
opens org.xbib.net.http.client.event.stream.test;
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package org.xbib.net.http.client.event.stream.test;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Disabled;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.net.http.HttpClient;
|
||||||
|
import java.net.http.HttpRequest;
|
||||||
|
import java.net.http.HttpResponse;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@Disabled
|
||||||
|
public class EventStreamTest {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(EventStreamTest.class.getName());
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testSimpleJournalGateway() throws URISyntaxException, IOException, InterruptedException {
|
||||||
|
var uri = new URI("http://localhost:19531/entries?follow");
|
||||||
|
try (var client = HttpClient.newHttpClient()) {
|
||||||
|
var request = HttpRequest.newBuilder(uri)
|
||||||
|
.GET()
|
||||||
|
.header("Accept", "text/event-stream")
|
||||||
|
.header("Cache-Control", "no-cache")
|
||||||
|
.header("Range", "entries=:-1:")
|
||||||
|
.build();
|
||||||
|
var lines = client.send(request, HttpResponse.BodyHandlers.ofLines()).body();
|
||||||
|
lines.forEach(line -> logger.log(Level.INFO, line));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -46,6 +46,7 @@ dependencyResolutionManagement {
|
||||||
|
|
||||||
include 'net-http'
|
include 'net-http'
|
||||||
include 'net-http-client'
|
include 'net-http-client'
|
||||||
|
include 'net-http-client-event-stream'
|
||||||
include 'net-http-client-simple'
|
include 'net-http-client-simple'
|
||||||
include 'net-http-client-netty'
|
include 'net-http-client-netty'
|
||||||
include 'net-http-client-netty-secure'
|
include 'net-http-client-netty-secure'
|
||||||
|
|
Loading…
Reference in a new issue