Examples of HttpService


Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testSimpleCookie() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );
        CookieServlet servlet = new CookieServlet( MODE_SIMPLE );
        httpService.registerServlet( "/test", servlet, null, null );

        //Test that no cookies are currently set.
        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        //Set the cookie in the response
View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testMultipleCookies() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );
        CookieServlet servlet = new CookieServlet( MODE_MULTI );
        httpService.registerServlet( "/test", servlet, null, null );

        //Test that no cookies are currently set.
        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        //Set the cookie in the response
View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testQueryString() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        StringBuffer qs = new StringBuffer( "?" );
        int parameterCount = 16;
        for ( int i = 0; i < parameterCount; ++i )
        {
View Full Code Here

Examples of org.osgi.service.http.HttpService

            }
        }
        initInternalPlugins();

        // might update HTTP service registration
        HttpService httpService = this.httpService;
        if (httpService != null)
        {
            // unbind old location first
            unbindHttpService(httpService);
View Full Code Here

Examples of org.osgi.service.http.HttpService

     *
     * @throws NamespaceException
     */
    public void testCanRegisterResources() throws NamespaceException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        httpService.registerResources( "/restest", "/webroot/", null );
    }
View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testExecuteGET() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        client.connect();

View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testExecutePOST() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "POST" );
        client.connect();

        assertTrue( client.getResponseCode() == 200 );
View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testExecutePUT() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "PUT" );

        client.connect();

View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testExecuteDELETE() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        BasicTestingServlet testServlet = new BasicTestingServlet();
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "DELETE" );

        client.connect();

View Full Code Here

Examples of org.osgi.service.http.HttpService

     * @throws NamespaceException
     * @throws IOException
     */
    public void testGETResponseStringContent() throws ServletException, NamespaceException, IOException
    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        String content = "test content";

        BasicTestingServlet testServlet = new BasicTestingServlet( content, false );
        httpService.registerServlet( "/test", testServlet, null, null );

        HttpURLConnection client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        client.connect();

        assertTrue( client.getResponseCode() == 200 );

        String response = readInputAsString( client.getInputStream() );

        printBytes( content.getBytes() );
        printBytes( response.getBytes() );
        assertTrue( content.equals( response ) );

        httpService.unregister( "/test" );

        content = "test content";
        testServlet = new BasicTestingServlet( content, true );
        httpService.registerServlet( "/test", testServlet, null, null );

        client = getConnection( DEFAULT_BASE_URL + "/test", "GET" );

        client.connect();

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.