Search in sources :

Example 21 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestPutRpc method executeNullTSDB.

@Test(expected = NullPointerException.class)
public void executeNullTSDB() throws Exception {
    final PutDataPointRpc put = new PutDataPointRpc();
    final Channel chan = NettyMocks.fakeChannel();
    put.execute(null, chan, new String[] { "put", "sys.cpu.nice", "1365465600", "42", "host=web01" });
}
Also used : Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 22 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestHttpQuery method getQueryString.

@Test
public void getQueryString() {
    final Channel channelMock = NettyMocks.fakeChannel();
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/api/v1/put?param=value&param2=value2");
    final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
    Map<String, List<String>> params = query.getQueryString();
    assertNotNull(params);
    assertEquals("value", params.get("param").get(0));
    assertEquals("value2", params.get("param2").get(0));
}
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) Channel(org.jboss.netty.channel.Channel) List(java.util.List) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 23 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestHttpQuery method getCharsetSupplied.

@Test
public void getCharsetSupplied() {
    final Channel channelMock = NettyMocks.fakeChannel();
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
    req.headers().add("Content-Type", "text/plain; charset=UTF-16");
    final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
    assertEquals(Charset.forName("UTF-16"), query.getCharset());
}
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) Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 24 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestHttpQuery method setSerializerDummyCT.

@Test
public void setSerializerDummyCT() throws Exception {
    PluginLoader.loadJAR("plugin_test.jar");
    HttpQuery.initializeSerializerMaps(null);
    final Channel channelMock = NettyMocks.fakeChannel();
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
    req.headers().add("Content-Type", "application/tsdbdummy");
    final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
    query.setSerializer();
    assertEquals("net.opentsdb.tsd.DummyHttpSerializer", query.serializer().getClass().getCanonicalName());
}
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) Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 25 with Channel

use of org.jboss.netty.channel.Channel in project opentsdb by OpenTSDB.

the class TestHttpQuery method getAPIMethodDelete.

@Test
public void getAPIMethodDelete() {
    final Channel channelMock = NettyMocks.fakeChannel();
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.DELETE, "/");
    HttpQuery query = new HttpQuery(tsdb, req, channelMock);
    assertEquals(HttpMethod.DELETE, query.getAPIMethod());
}
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) Channel(org.jboss.netty.channel.Channel) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Channel (org.jboss.netty.channel.Channel)176 InetSocketAddress (java.net.InetSocketAddress)53 Test (org.junit.Test)52 HttpRequest (org.jboss.netty.handler.codec.http.HttpRequest)38 DefaultHttpRequest (org.jboss.netty.handler.codec.http.DefaultHttpRequest)36 DefaultHttpResponse (org.jboss.netty.handler.codec.http.DefaultHttpResponse)34 SocketAddress (java.net.SocketAddress)33 HttpResponse (org.jboss.netty.handler.codec.http.HttpResponse)33 ChannelFuture (org.jboss.netty.channel.ChannelFuture)31 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)30 ChannelPipeline (org.jboss.netty.channel.ChannelPipeline)24 Test (org.testng.annotations.Test)23 ConditionCheck (com.linkedin.databus2.test.ConditionCheck)22 SimpleObjectCaptureHandler (com.linkedin.databus2.test.container.SimpleObjectCaptureHandler)19 IOException (java.io.IOException)19 Logger (org.apache.log4j.Logger)19 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)17 DefaultHttpChunk (org.jboss.netty.handler.codec.http.DefaultHttpChunk)15 ArrayList (java.util.ArrayList)14 HttpChunk (org.jboss.netty.handler.codec.http.HttpChunk)14