Package com.gargoylesoftware.htmlunit

Examples of com.gargoylesoftware.htmlunit.WebRequest


    public void testGetInvalidManagedRepositoryInGroupReturnNotFound()
        throws Exception
    {
        String resourceName = "dummy/dummy-no-resource/1.0/dummy-no-resource-1.0.txt";

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

        assertResponseInternalServerError( response );
    }
View Full Code Here


    {
        String resourceName = "dummy/dummy-put-resource/1.0/dummy-put-resource-1.0.txt";
        String putUrl = "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/" + resourceName;
        InputStream is = getClass().getResourceAsStream( "/artifact.jar" );

        WebRequest request = new PutMethodWebRequest( putUrl, is, "text/plain" );
        WebResponse response = getServletUnitClient().getResponse( request );

        assertResponseMethodNotAllowed( response );
    }
View Full Code Here

            + "<metadata><groupId>dummy</groupId><artifactId>dummy-merged-metadata-resource</artifactId>"
            + "<versioning><latest>2.0</latest><release>2.0</release><versions><version>1.0</version>"
            + "<version>1.5</version><version>2.0</version></versions><lastUpdated>20080709095554</lastUpdated>"
            + "</versioning></metadata>", Charset.defaultCharset() );

        WebRequest request = new GetMethodWebRequest(
            "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/"
                + "dummy-merged-metadata-resource/maven-metadata.xml" );
        WebResponse response = getServletUnitClient().getResource( request );

        File returnedMetadata = new File( "target/test-classes/retrievedMetadataFile.xml" );
View Full Code Here

        File dummyReleasesResourceFile = new File( repoRootLast, resourceName );
        dummyReleasesResourceFile.getParentFile().mkdirs();
        FileUtils.writeStringToFile( dummyReleasesResourceFile, "last", Charset.defaultCharset() );

        WebRequest request = new GetMethodWebRequest(
            "http://machine.com/repository/" + REPO_GROUP_WITH_VALID_REPOS + "/dummy/dummy-artifact/" );
        WebResponse response = getServletUnitClient().getResource( request );

        assertResponseOK( response );
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 )
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
        assertResponseOK( response );
        assertEquals( "Expected remote file contents", expectedRemoteContents, response.getContentAsString() );
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 )
View Full Code Here

        for (String cookie: cookies.keySet()) {
            client.getCookieManager().addCookie(new Cookie(domain, cookie, cookies.get(cookie)));
        }
        client.getCookieManager().setCookiesEnabled(applyCookies);
        client.getOptions().setRedirectEnabled(followRedirects);
        WebRequest request = new WebRequest(requestUrl(), method);
        request.setRequestParameters(requestParameters());
        if (body != null) request.setRequestBody(body);
        if (encodingType != null) request.setEncodingType(FormEncodingType.getInstance(encodingType));
        request.setAdditionalHeaders(headers);
        // Clear HtmlUnit internal cache to make sure requests are actually sent
        client.getCache().clear();

        return new HttpResponse(client.loadWebResponse(request));
    }
View Full Code Here

        File artifactFile = new File( repoRootInternal, commonsLangJar );
        artifactFile.getParentFile().mkdirs();

        FileUtils.writeStringToFile( artifactFile, expectedArtifactContents, Charset.defaultCharset()  );

        WebRequest request = new GetMethodWebRequest(
            "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar" );
        WebResponse response = getServletUnitClient().getResponse( request );
        assertResponseOK( response );

        assertEquals( "Expected file contents", expectedArtifactContents, response.getContentAsString() );
View Full Code Here

        File checksumFile = new File( repoRootInternal, dualExtensionPath );
        checksumFile.getParentFile().mkdirs();

        FileUtils.writeStringToFile( checksumFile, expectedContents, Charset.defaultCharset()  );

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

        assertEquals( "Expected file contents", expectedContents, response.getContentAsString() );
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.WebRequest

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.