Search in sources :

Example 6 with JettyClient

use of com.dexels.navajo.client.stream.jetty.JettyClient in project navajo by Dexels.

the class TestHttp method testHttpGet.

@Test
public void testHttpGet() throws Exception {
    JettyClient jc = new JettyClient();
    // jc.c
    String weather = jc.callWithoutBodyToStream("http://api.openweathermap.org/data/2.5/weather?q=Amsterdam&APPID=c9a22840a45f9da6f235c718475c4f08&mode=xml", e -> e).lift(XML.parseFlowable(10)).flatMap(x -> x).filter(e -> e.getType() == XmlEventTypes.START_ELEMENT).filter(e -> e.getText().equals("weather")).firstElement().map(xml -> xml.getAttributes().get("value")).blockingGet();
    logger.info("Weather: {}", weather);
// Not really a good unit test (... or is it?)
}
Also used : JettyClient(com.dexels.navajo.client.stream.jetty.JettyClient) TimeUnit(java.util.concurrent.TimeUnit) Logger(org.slf4j.Logger) Flowable(io.reactivex.Flowable) XmlEventTypes(com.dexels.navajo.document.stream.xml.XMLEvent.XmlEventTypes) LoggerFactory(org.slf4j.LoggerFactory) XML(com.dexels.navajo.document.stream.xml.XML) Test(org.junit.Test) JettyClient(com.dexels.navajo.client.stream.jetty.JettyClient) Assert(org.junit.Assert) Test(org.junit.Test)

Example 7 with JettyClient

use of com.dexels.navajo.client.stream.jetty.JettyClient in project navajo by Dexels.

the class ResourceComponent method deactivate.

public void deactivate() throws Exception {
    logger.debug("Deactivating HTTP connector");
    if (client != null) {
        JettyClient c = client;
        client = null;
        c.close();
    }
    this.authorization = null;
    this.secret = Optional.empty();
    this.url = null;
}
Also used : JettyClient(com.dexels.navajo.client.stream.jetty.JettyClient)

Aggregations

JettyClient (com.dexels.navajo.client.stream.jetty.JettyClient)7 Test (org.junit.Test)4 NavajoReactiveJettyClient (com.dexels.navajo.client.stream.jetty.NavajoReactiveJettyClient)2 Navajo (com.dexels.navajo.document.Navajo)2 NavajoStreamEvent (com.dexels.navajo.document.stream.events.NavajoStreamEvent)2 XML (com.dexels.navajo.document.stream.xml.XML)2 Flowable (io.reactivex.Flowable)2 StringWriter (java.io.StringWriter)2 Assert (org.junit.Assert)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 StreamDocument (com.dexels.navajo.document.stream.StreamDocument)1 XmlEventTypes (com.dexels.navajo.document.stream.xml.XMLEvent.XmlEventTypes)1 TestConfig (com.dexels.navajo.runtime.config.TestConfig)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 StandardCharsets (java.nio.charset.StandardCharsets)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 HttpMethod (org.eclipse.jetty.http.HttpMethod)1