use of com.dexels.navajo.client.stream.jetty.JettyClient in project navajo by Dexels.
the class TestHttp method testBiggerDownload.
@Test
public void testBiggerDownload() throws Exception {
String url = "https://www.ad.nl/home/rss.xml";
JettyClient jc = new JettyClient();
long l = jc.callWithoutBodyToStream(url, e -> e).lift(XML.parseFlowable(10)).flatMap(x -> x).count().blockingGet();
logger.info("> {}", l);
Assert.assertTrue(l > 1000);
}
use of com.dexels.navajo.client.stream.jetty.JettyClient in project navajo by Dexels.
the class ResourceComponent method activate.
public void activate(Map<String, Object> settings) throws Exception {
client = new JettyClient();
String url = (String) settings.get("url");
String publicurl = (String) settings.get("publicurl");
this.authorization = (String) settings.get("authorization");
this.secret = Optional.ofNullable((String) settings.get("secret"));
if (settings.containsKey("timeout_ms")) {
timeout = Long.parseLong((String) settings.get("timeout_ms"));
}
if (settings.containsKey("timeout_idle_ms")) {
idle_timeout = Long.parseLong((String) settings.get("timeout_idle_ms"));
}
this.url = url.endsWith("/") ? url : url + "/";
if (publicurl != null) {
this.publicUrl = publicurl.endsWith("/") ? publicurl : publicurl + "/";
} else {
this.publicUrl = url.endsWith("/") ? url : url + "/";
}
}
use of com.dexels.navajo.client.stream.jetty.JettyClient in project navajo by Dexels.
the class SwiftReactiveImpl method createClientFromURL.
private JettyClient createClientFromURL(String endpoint) throws Exception {
JettyClient client = new JettyClient();
this.endpoint = endpoint;
// }
return client;
}
use of com.dexels.navajo.client.stream.jetty.JettyClient in project navajo by Dexels.
the class ITJettyClient method testJettyCLient.
@Test
public void testJettyCLient() throws Exception {
JettyClient jc = new JettyClient();
Flowable<byte[]> in = Flowable.<NavajoStreamEvent>empty().compose(StreamDocument.inNavajo(service, Optional.of(username), Optional.of(password))).lift(StreamDocument.serialize());
byte[] result = jc.callWithBodyToStream(uri, req -> req.header("X-Navajo-Reactive", "true").header("X-Navajo-Service", service).header("X-Navajo-Username", username).header("X-Navajo-Password", password).header("Accept-Encoding", null).method(HttpMethod.POST), in, "text/xml;charset=utf-8").reduce(new ByteArrayOutputStream(), (stream, b) -> {
stream.write(b);
return stream;
}).map(stream -> stream.toByteArray()).blockingGet();
logger.info("result: {}", new String(result));
Assert.assertTrue(result.length > 5000);
jc.close();
}
use of com.dexels.navajo.client.stream.jetty.JettyClient in project navajo by Dexels.
the class ITJettyClient method testNavajoClient.
@Test
public void testNavajoClient() throws Exception {
JettyClient client = new JettyClient();
Flowable<NavajoStreamEvent> in = Flowable.<NavajoStreamEvent>empty().compose(StreamDocument.inNavajo(service, Optional.of(username), Optional.of(password)));
Flowable<byte[]> inStream = in.lift(StreamDocument.serialize()).doOnNext(e -> logger.debug("Sending: {}", new String(e, StandardCharsets.UTF_8)));
Navajo n = client.callWithBodyToStream(uri, req -> req.header("X-Navajo-Reactive", "true").header("X-Navajo-Service", service).header("X-Navajo-Instance", "").header("X-Navajo-Username", username).header("X-Navajo-Password", password).method(HttpMethod.POST), inStream, "text/xml;charset=utf-8").lift(XML.parseFlowable(5)).concatMap(e -> e).lift(StreamDocument.parse()).concatMap(e -> e).compose(StreamDocument.inNavajo(service, Optional.of(username), Optional.of(password))).toObservable().compose(StreamDocument.domStreamCollector()).blockingFirst();
StringWriter sw = new StringWriter();
n.write(sw);
logger.info("{}", sw);
client.close();
}
Aggregations