use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestHttpQuery method getContentEncoding.
@Test
public void getContentEncoding() {
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 ChannelBuffer buf = ChannelBuffers.copiedBuffer("S\u00ED Se\u00F1or", CharsetUtil.UTF_16);
req.setContent(buf);
final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
assertEquals("S\u00ED Se\u00F1or", query.getContent());
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestHttpQuery method getContentDefault.
@Test
public void getContentDefault() {
final Channel channelMock = NettyMocks.fakeChannel();
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
final ChannelBuffer buf = ChannelBuffers.copiedBuffer("S\u00ED Se\u00F1or", CharsetUtil.UTF_8);
req.setContent(buf);
final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
assertEquals("S\u00ED Se\u00F1or", query.getContent());
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestHttpQuery method getAPIMethodPut.
@Test
public void getAPIMethodPut() {
final Channel channelMock = NettyMocks.fakeChannel();
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.PUT, "/");
HttpQuery query = new HttpQuery(tsdb, req, channelMock);
assertEquals(HttpMethod.PUT, query.getAPIMethod());
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestHttpQuery method getCharsetDefault.
@Test
public void getCharsetDefault() {
final Channel channelMock = NettyMocks.fakeChannel();
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
req.headers().add("Content-Type", "text/plain");
final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
assertEquals(Charset.forName("UTF-8"), query.getCharset());
}
use of org.jboss.netty.handler.codec.http.HttpRequest in project opentsdb by OpenTSDB.
the class TestHttpQuery method setSerializerDefaultCT.
@Test
public void setSerializerDefaultCT() throws Exception {
HttpQuery.initializeSerializerMaps(null);
final Channel channelMock = NettyMocks.fakeChannel();
final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, "/");
req.headers().add("Content-Type", "invalid/notfoundtype");
final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
query.setSerializer();
assertEquals(HttpJsonSerializer.class.getCanonicalName(), query.serializer().getClass().getCanonicalName());
}
Aggregations