Package org.webbitserver.netty

Source Code of org.webbitserver.netty.NettyHttpRequestTest

package org.webbitserver.netty;

import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
import org.jboss.netty.handler.codec.http.HttpMethod;
import org.jboss.netty.handler.codec.http.HttpRequest;
import org.jboss.netty.handler.codec.http.HttpVersion;
import org.junit.Test;
import org.webbitserver.netty.NettyHttpRequest;

import static org.junit.Assert.assertEquals;

public class NettyHttpRequestTest {

    @Test
    public void decodesQueryParams() {
        HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "http://example.com/?foo=bar");
        NettyHttpRequest nhr = new NettyHttpRequest(null, httpRequest, null, 0L);
        assertEquals(nhr.queryParam("foo"), "bar");
    }

    @Test
    public void decodesQueryParamsContainingEncodedEquals() {
        HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_0, HttpMethod.GET, "http://example.com/?foo=a%2Bb%3Dc");
        NettyHttpRequest nhr = new NettyHttpRequest(null, httpRequest, null, 0L);
        assertEquals(nhr.queryParam("foo"), "a+b=c");
    }
}
TOP

Related Classes of org.webbitserver.netty.NettyHttpRequestTest

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.