Package org.jboss.netty.handler.codec.http

Examples of org.jboss.netty.handler.codec.http.DefaultHttpRequest.headers()


 
  @Test
  public void httpOptionsCORSSpecific() {
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
        HttpMethod.OPTIONS, "/api/v1/version");
    req.headers().add(HttpHeaders.ORIGIN, "42.com");
   
    handleHttpRpc(req,
      new Answer<ChannelFuture>() {
        public ChannelFuture answer(final InvocationOnMock args)
          throws Throwable {
View Full Code Here


 
  @Test
  public void httpOptionsCORSNotAllowed() {
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
        HttpMethod.OPTIONS, "/api/v1/version");
    req.headers().add(HttpHeaders.ORIGIN, "42.com");
   
    handleHttpRpc(req,
      new Answer<ChannelFuture>() {
        public ChannelFuture answer(final InvocationOnMock args)
          throws Throwable {
View Full Code Here

  @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());
  }
 
  @Test
View Full Code Here

  @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());
  }
 
  @Test (expected = UnsupportedCharsetException.class)
View Full Code Here

  @Test (expected = UnsupportedCharsetException.class)
  public void getCharsetInvalid() {
    final Channel channelMock = NettyMocks.fakeChannel();
    final HttpRequest req = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
        HttpMethod.GET, "/");
    req.headers().add("Content-Type", "text/plain; charset=foobar");
    final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
    assertEquals(Charset.forName("UTF-16"), query.getCharset());
  }
 
  @Test
View Full Code Here

  @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());
View Full Code Here

  public void setSerializerCT() 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", "application/json");
    final HttpQuery query = new HttpQuery(tsdb, req, channelMock);
    query.setSerializer();
    assertEquals(HttpJsonSerializer.class.getCanonicalName(),
        query.serializer().getClass().getCanonicalName());
  }
View Full Code Here

    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());
  }
View Full Code Here

  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());
  }
View Full Code Here

        method, uri);
    if (content != null) {
      req.setContent(ChannelBuffers.copiedBuffer(content,
          Charset.forName("UTF-8")));
    }
    req.headers().set("Content-Type", type);
    return new HttpQuery(tsdb, req, channelMock);
  }
 
  /**
   * Returns a simple pipeline with an HttpRequestDecoder and an
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.