Examples of BasicTestingServlet


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

     */
    public void testCorrectParameterCount() 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" );

        int parameterCount = 16;
        for ( int i = 0; i < parameterCount; ++i )
        {
            client.addRequestProperty( "k" + i, "v" + i );
        }
        client.connect();
        assertTrue( client.getResponseCode() == 200 );
       
        int headerCount = 0;
        Enumeration e = testServlet.getHeaderNames();
        while (e.hasMoreElements())
        {
            headerCount++;
            System.out.println("header: " + e.nextElement().toString());
        }
View Full Code Here

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

     */
    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

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

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

        httpService.registerServlet( "/", new BasicTestingServlet(), null, null );
    }
View Full Code Here

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

    {

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

        boolean namespaceExceptionThrown = false;
        httpService.registerServlet( "/alias", new BasicTestingServlet(), null, null );

        try
        {
            httpService.registerServlet( "/alias", new BasicTestingServlet(), null, null );
        }
        catch ( NamespaceException e )
        {
            namespaceExceptionThrown = true;
        }
View Full Code Here

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

        for ( int i = 0; i < badAliases.length; ++i )
        {
            boolean namespaceExceptionThrown = false;
            try
            {
                httpService.registerServlet( badAliases[i], new BasicTestingServlet(), null, null );
            }
            catch ( NamespaceException e )
            {
                namespaceExceptionThrown = true;
            }
View Full Code Here

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

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

        httpService.registerServlet( "/alias", new BasicTestingServlet(), null, null );

        httpService.unregister( "/alias" );

        httpService.registerServlet( "/alias", new BasicTestingServlet(), null, null );
    }
View Full Code Here

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

     */
    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 )
        {
            qs.append( "k" + i );
            qs.append( "=" );
            qs.append( "v" + i );
            if ( i != ( parameterCount - 1 ) )
            {
                qs.append( '&' );
            }
        }

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

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

        Map qsm = testServlet.getQueryStringMap();

        assertTrue( qsm.size() == parameterCount );

        for ( int i = 0; i < parameterCount; ++i )
        {
View Full Code Here

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

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

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

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

     */
    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 );
        assertFalse( testServlet.isGetCalled() );
        assertFalse( testServlet.isDeleteCalled() );
        assertTrue( testServlet.isPostCalled() );
        assertFalse( testServlet.isPutCalled() );
    }
View Full Code Here

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

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

        assertTrue( client.getResponseCode() == 200 );
        assertFalse( testServlet.isGetCalled() );
        assertFalse( testServlet.isDeleteCalled() );
        assertFalse( testServlet.isPostCalled() );
        assertTrue( testServlet.isPutCalled() );
    }
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.