Package org.apache.felix.httplite.osgi.test

Examples of org.apache.felix.httplite.osgi.test.BasicTestingServlet


     */
    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();

        assertTrue( client.getResponseCode() == 200 );
        assertFalse( testServlet.isGetCalled() );
        assertTrue( testServlet.isDeleteCalled() );
        assertFalse( testServlet.isPostCalled() );
        assertFalse( testServlet.isPutCalled() );
    }
View Full Code Here


    {
        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

    {
        HttpService httpService = getHTTPService( registry.getBundleContext() );

        byte[] content = generateRandomBinaryContent();

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

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

        client.connect();
View Full Code Here

    public void testSimpleRequestPath() 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/a/b/c", "GET" );

        client.connect();
        assertTrue( client.getResponseCode() == 200 );
        assertTrue( testServlet.getPathInfo().equals( "/a/b/c" ) );
    }
View Full Code Here

    public void testMultipleSeperatorsRequestPath() 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/a/b//c", "GET" );

        client.connect();
        assertTrue( client.getResponseCode() == 200 );
        assertTrue( testServlet.getPathInfo().equals( "/a/b/c" ) );
    }
View Full Code Here

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

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

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

        int parameterCount = 16;
        for ( int i = 0; i < parameterCount; ++i )
        {
            client.addRequestProperty( "k" + i, "v" + i );
        }
        client.connect();
        assertTrue( client.getResponseCode() == 200 );
        Map rp = new HashMap();
       
        Enumeration e = testServlet.getHeaderNames();
        while (e.hasMoreElements())
        {
            String key = e.nextElement().toString();
            rp.put( key , testServlet.getHeader( key ) );
        }
       
        for ( int i = 0; i < parameterCount; ++i )
        {
             assertTrue( rp.get( "k" + i ).equals( "v" + i ) );
View Full Code Here

TOP

Related Classes of org.apache.felix.httplite.osgi.test.BasicTestingServlet

Copyright © 2018 www.massapicom. 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.