Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebResponse


        String path = REQUEST_PATH + ".index/filecontent/segments.gen";

        populateRepo( repoRootInternal, ".index/filecontent/segments.gen", "index file" );

        WebRequest request = new GetMethodWebRequest( path );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseOK( response );
        assertEquals( "index file", response.getContentAsString() );
    }
View Full Code Here


        throws Exception
    {
        String path = REQUEST_PATH + ".index/filecontent/foo.bar";

        WebRequest request = new GetMethodWebRequest( path );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseNotFound( response );
        assertThat( response.getContentAsString() ).contains(
            "Invalid path to Artifact: legacy paths should have an expected type ending in [s] in the second part of the path." );
    }
View Full Code Here

        // verify that the file exists in resources-dir
        assertNotNull( "artifact.jar inputstream", is );

        WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );

        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseCreated( response );
        assertFileContents( "artifact.jar\n", repoRootInternal, ARTIFACT_DEFAULT_LAYOUT );
    }   
View Full Code Here

        // verify that the file exists in resources-dir
        assertNotNull( "artifact.jar inputstream", is );

        // send request #1 and verify it's successful
        WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseCreated( response );
       
        is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
        request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
        response = getServletUnitClient().getResponse( request );
View Full Code Here

        // verify that the file exists in resources-dir
        assertNotNull( "artifact.jar inputstream", is );
   
        // send request #1 and verify it's successful
        WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseCreated( response );
       
        is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
        request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
        response = getServletUnitClient().getResponse( request );
View Full Code Here

        // verify that the file exists in resources-dir
        assertNotNull( "artifact.jar inputstream", is );

        // send request #1 and verify it's successful
        WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseCreated( response );
       
        is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
        request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
        response = getServletUnitClient().getResponse( request );
View Full Code Here

        // verify that the file exists in resources-dir
        assertNotNull( "artifact.jar inputstream", is );

        // send request #1 and verify it's successful
        WebRequest request = new PutMethodWebRequest( putUrl, is, "application/octet-stream" );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseCreated( response );
       
        is = getClass().getResourceAsStream( "/artifact.jar.sha1" );
        request = new PutMethodWebRequest( checksumUrl, is, "application/octet-stream" );
        response = getServletUnitClient().getResponse( request );
View Full Code Here

        String putUrl = "http://machine.com/repository/internal/path/to/";

        WebRequest request = new MkColMethodWebRequest( putUrl );

        WebResponse response = getServletUnitClient().getResponse( request );
       
        assertEquals(HttpServletResponse.SC_CONFLICT, response.getStatusCode());
       
        File mkColLocalPath = new File(repoRootInternal, "path/to/");
        assertFalse(mkColLocalPath.exists());
    }
View Full Code Here

        // --- Execution
        // process the response code later, not via an exception.
        //HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );

        WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + resourcePath );
        WebResponse response = getServletUnitClient().getResponse( request );

        // --- Verification

        switch ( expectation )
        {
            case EXPECT_MANAGED_CONTENTS:
                assertResponseOK( response );
                assertTrue( "Invalid Test Case: Can't expect managed contents with "
                                + "test that doesn't have a managed copy in the first place.", hasManagedCopy );
                assertEquals( "Expected managed file contents", expectedManagedContents, response.getContentAsString() );
                break;
            case EXPECT_REMOTE_CONTENTS:
                assertResponseOK( response );
                assertEquals( "Expected remote file contents", expectedRemoteContents, response.getContentAsString() );
                break;
            case EXPECT_NOT_FOUND:
                assertResponseNotFound( response );
                assertManagedFileNotExists( repoRootInternal, resourcePath );
                break;
View Full Code Here

    @Test
    public void testBrowse()
        throws Exception
    {
        WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertEquals( "Response", HttpServletResponse.SC_OK, response.getStatusCode() );

        // dumpResponse( response );

        List<String> expectedLinks = Arrays.asList( ".indexer/", "commons-lang/", "net/", "org/" );

        Document document = Jsoup.parse( response.getContentAsString() );
        Elements elements = document.getElementsByTag( "a" );

        assertLinks( expectedLinks, elements );
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.WebResponse

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.