Search in sources :

Example 56 with DefaultHttpRequest

use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.

the class AppFabricClient method getProgramSchedules.

public List<ScheduleDetail> getProgramSchedules(String namespace, String app, String workflow) throws NotFoundException {
    MockResponder responder = new MockResponder();
    String uri = String.format("%s/apps/%s/workflows/%s/schedules", getNamespacePath(namespace), app, workflow);
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
    try {
        workflowHttpHandler.getWorkflowSchedules(request, responder, namespace, app, workflow, null);
    } catch (BadRequestException e) {
        // cannot happen
        throw Throwables.propagate(e);
    }
    List<ScheduleDetail> schedules = responder.decodeResponseContent(SCHEDULE_DETAILS_TYPE, GSON);
    verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Getting workflow schedules failed");
    return schedules;
}
Also used : HttpRequest(org.jboss.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) BadRequestException(co.cask.cdap.common.BadRequestException) ScheduleDetail(co.cask.cdap.proto.ScheduleDetail)

Example 57 with DefaultHttpRequest

use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.

the class AppFabricClient method getWorkerInstances.

public Instances getWorkerInstances(String namespaceId, String appId, String workerId) throws Exception {
    MockResponder responder = new MockResponder();
    String uri = String.format("%s/apps/%s/worker/%s/instances", getNamespacePath(namespaceId), appId, workerId);
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, uri);
    programLifecycleHttpHandler.getWorkerInstances(request, responder, namespaceId, appId, workerId);
    verifyResponse(HttpResponseStatus.OK, responder.getStatus(), "Get worker instances failed");
    return responder.decodeResponseContent(Instances.class);
}
Also used : HttpRequest(org.jboss.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest)

Example 58 with DefaultHttpRequest

use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project load-balancer by RestComm.

the class Client method createRequest.

private HttpRequest createRequest(String packetType, Packet packet) {
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
    ChannelBuffer buf = ChannelBuffers.copiedBuffer(getStringFromJson(packetType, packet), Charset.forName("UTF-8"));
    request.setHeader(HttpHeaders.Names.CONTENT_TYPE, APPLICATION_JSON);
    request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, buf.readableBytes());
    request.setContent(buf);
    return request;
}
Also used : HttpRequest(org.jboss.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 59 with DefaultHttpRequest

use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project load-balancer by RestComm.

the class Server method createRequest.

private HttpRequest createRequest(String command) {
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/");
    ChannelBuffer buf = ChannelBuffers.copiedBuffer(getStringFromJson(command), Charset.forName("UTF-8"));
    request.setHeader(HttpHeaders.Names.CONTENT_TYPE, APPLICATION_JSON);
    request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, buf.readableBytes());
    request.setContent(buf);
    return request;
}
Also used : HttpRequest(org.jboss.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer)

Example 60 with DefaultHttpRequest

use of org.jboss.netty.handler.codec.http.DefaultHttpRequest in project traccar by tananaev.

the class ProtocolTest method request.

protected DefaultHttpRequest request(HttpMethod method, String url, ChannelBuffer data) {
    DefaultHttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1, method, url);
    request.setContent(data);
    return request;
}
Also used : DefaultHttpRequest(org.jboss.netty.handler.codec.http.DefaultHttpRequest)

Aggregations

DefaultHttpRequest (org.jboss.netty.handler.codec.http.DefaultHttpRequest)128 HttpRequest (org.jboss.netty.handler.codec.http.HttpRequest)101 Test (org.junit.Test)53 Channel (org.jboss.netty.channel.Channel)37 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)33 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)25 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)24 Test (org.testng.annotations.Test)23 HttpMethod (org.jboss.netty.handler.codec.http.HttpMethod)21 ChannelFuture (org.jboss.netty.channel.ChannelFuture)19 SimpleHttpResponseHandler (com.linkedin.databus.core.test.netty.SimpleHttpResponseHandler)12 SimpleTestHttpClient (com.linkedin.databus.core.test.netty.SimpleTestHttpClient)12 ConditionCheck (com.linkedin.databus2.test.ConditionCheck)11 InetSocketAddress (java.net.InetSocketAddress)11 Logger (org.apache.log4j.Logger)11 ByteArrayInputStream (java.io.ByteArrayInputStream)10 ObjectMapper (org.codehaus.jackson.map.ObjectMapper)10 SucceededChannelFuture (org.jboss.netty.channel.SucceededChannelFuture)10 InvocationOnMock (org.mockito.invocation.InvocationOnMock)10 SocketAddress (java.net.SocketAddress)9