当前位置: 首页>>代码示例>>Java>>正文


Java WebResponse类代码示例

本文整理汇总了Java中com.gargoylesoftware.htmlunit.WebResponse的典型用法代码示例。如果您正苦于以下问题:Java WebResponse类的具体用法?Java WebResponse怎么用?Java WebResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

WebResponse类属于com.gargoylesoftware.htmlunit包,在下文中一共展示了WebResponse类的40个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testBrowse

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@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 );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletBrowseTest.java


示例2: testGetVersionMetadataDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetVersionMetadataDefaultLayout()
    throws Exception
{
    String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
    String expectedMetadataContents = "metadata-for-commons-lang-version-2.1";

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

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

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

    assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyMetadataTest.java


示例3: testGetGroupMetadataDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetGroupMetadataDefaultLayout()
    throws Exception
{
    String commonsLangMetadata = "commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "metadata-for-commons-lang-group";

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

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

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

    assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyMetadataTest.java


示例4: testGetSnapshotVersionMetadataDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetSnapshotVersionMetadataDefaultLayout()
    throws Exception
{
    String assemblyPluginMetadata =
        "org/apache/maven/plugins/maven-assembly-plugin/2.2-beta-2-SNAPSHOT/maven-metadata.xml";
    String expectedMetadataContents = "metadata-for-assembly-plugin-version-2.2-beta-2-SNAPSHOT";

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

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

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

    assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:21,代码来源:RepositoryServletNoProxyMetadataTest.java


示例5: testGetDirectoryWhichHasMatchingFile

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetDirectoryWhichHasMatchingFile() //MRM-893
    throws Exception
{
    new File( repoRootInternal, "org/apache/archiva/artifactId/1.0" ).mkdirs();
    new File( repoRootInternal, "org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" ).createNewFile();

    WebRequest request =
        new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId" );
    WebResponse response = getServletUnitClient().getResponse( request, true );
    assertEquals( "1st Response", HttpServletResponse.SC_OK, response.getStatusCode() );

    request = new GetMethodWebRequest( "http://machine.com/repository/internal/org/apache/archiva/artifactId/" );
    response = getServletUnitClient().getResponse( request );
    assertEquals( "2nd Response", HttpServletResponse.SC_OK, response.getStatusCode() );

    request = new GetMethodWebRequest(
        "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar" );
    response = getServletUnitClient().getResponse( request );
    assertEquals( "3rd Response", HttpServletResponse.SC_OK, response.getStatusCode() );

    request = new GetMethodWebRequest(
        "http://machine.com/repository/internal/org/apache/archiva/artifactId/1.0/artifactId-1.0.jar/" );
    response = getServletUnitClient().getResponse( request );
    assertEquals( "4th Response", HttpServletResponse.SC_NOT_FOUND, response.getStatusCode() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:27,代码来源:RepositoryServletBrowseTest.java


示例6: testGetFromFirstManagedRepositoryReturnOk

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetFromFirstManagedRepositoryReturnOk()
    throws Exception
{
    String resourceName = "dummy/dummy-first-resource/1.0/dummy-first-resource-1.0.txt";

    File dummyInternalResourceFile = new File( repoRootFirst, resourceName );
    dummyInternalResourceFile.getParentFile().mkdirs();
    FileUtils.writeStringToFile( dummyInternalResourceFile, "first", Charset.defaultCharset() );

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

    assertResponseOK( response );
    assertThat( response.getContentAsString() ).isEqualTo( "first" );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletRepositoryGroupTest.java


示例7: testGetFromLastManagedRepositoryReturnOk

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetFromLastManagedRepositoryReturnOk()
    throws Exception
{
    String resourceName = "dummy/dummy-last-resource/1.0/dummy-last-resource-1.0.txt";

    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 + "/" + resourceName );
    WebResponse response = getServletUnitClient().getResponse( request );

    assertResponseOK( response );

    assertThat( response.getContentAsString() ).isEqualTo( "last" );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletRepositoryGroupTest.java


示例8: testGetNoProxyChecksumDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyChecksumDefaultLayout()
    throws Exception
{
    String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";

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

    FileUtils.writeStringToFile( checksumFile, "dummy-checksum", Charset.defaultCharset() );

    //WebRequest request = new WebRequest( "http://machine.com/repository/internal/" + commonsLangSha1 );
    WebResponse response = getWebResponse( "/repository/internal/" + commonsLangSha1 );
    assertResponseOK( response );

    assertEquals( "Expected file contents", "dummy-checksum", response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletNoProxyTest.java


示例9: testGetNoProxyChecksumLegacyLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyChecksumLegacyLayout()
    throws Exception
{
    String commonsLangSha1 = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar.sha1";

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

    FileUtils.writeStringToFile( checksumFile, "dummy-checksum", Charset.defaultCharset() );

    //WebRequest request = new GetMethodWebRequest(
    //    "http://machine.com/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar.sha1" );
    WebResponse response =
        getWebResponse( "/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar.sha1" );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletNoProxyTest.java


示例10: testGetNoProxyVersionedMetadataDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyVersionedMetadataDefaultLayout()
    throws Exception
{
    String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
    String expectedMetadataContents = "dummy-versioned-metadata";

    File metadataFile = new File( repoRootInternal, commonsLangMetadata );
    metadataFile.getParentFile().mkdirs();

    FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.defaultCharset() );

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

    assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例11: testGetNoProxyProjectMetadataDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyProjectMetadataDefaultLayout()
    throws Exception
{
    String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "dummy-project-metadata";

    File metadataFile = new File( repoRootInternal, commonsLangMetadata );
    metadataFile.getParentFile().mkdirs();

    FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.defaultCharset() );

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

    assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例12: testGetNoProxyGroupMetadataDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyGroupMetadataDefaultLayout()
    throws Exception
{
    String commonsLangMetadata = "commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "dummy-group-metadata";

    File metadataFile = new File( repoRootInternal, commonsLangMetadata );
    metadataFile.getParentFile().mkdirs();

    FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.defaultCharset() );

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

    assertEquals( "Expected file contents", expectedMetadataContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例13: testGetNoProxyArtifactDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyArtifactDefaultLayout()
    throws Exception
{
    String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
    String expectedArtifactContents = "dummy-commons-lang-artifact";

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

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

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

    assertEquals( "Expected file contents", expectedArtifactContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例14: testGetNoProxyArtifactLegacyLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyArtifactLegacyLayout()
    throws Exception
{
    String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
    String expectedArtifactContents = "dummy-commons-lang-artifact";

    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.jar" );
    WebResponse response = getWebResponse( "/repository/internal/" + "commons-lang/jars/commons-lang-2.1.jar" );
    assertResponseNotFound( response );

}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例15: testGetNoProxySnapshotArtifactDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxySnapshotArtifactDefaultLayout()
    throws Exception
{
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";

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

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

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

    assertEquals( "Expected file contents", expectedArtifactContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例16: testGetNoProxySnapshotArtifactLegacyLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxySnapshotArtifactLegacyLayout()
    throws Exception
{
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";

    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-SNAPSHOT.jar" );
    WebResponse response = getWebResponse( "/repository/internal/commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletNoProxyTest.java


示例17: testGetNoProxyTimestampedSnapshotArtifactDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayout()
    throws Exception
{
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-20050821.023400-1.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";

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

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

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

    assertEquals( "Expected file contents", expectedArtifactContents, response.getContentAsString() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例18: testGetNoProxyDualExtensionDefaultLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
/**
 * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
 */
@Test
public void testGetNoProxyDualExtensionDefaultLayout()
    throws Exception
{
    String expectedContents = "the-contents-of-the-dual-extension";
    String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";

    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() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:22,代码来源:RepositoryServletNoProxyTest.java


示例19: testGetNoProxyDistributionLegacyLayout

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyDistributionLegacyLayout()
    throws Exception
{
    String expectedContents = "the-contents-of-the-dual-extension";
    String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.zip";

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

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

    WebRequest request = new GetMethodWebRequest(
        "http://machine.com/repository/internal/" + "org.project/distributions/example-presentation-3.2.zip" );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );

}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:19,代码来源:RepositoryServletNoProxyTest.java


示例20: testGetNoProxyVersionedMetadataDefaultLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyVersionedMetadataDefaultLayoutManagedLegacy()
    throws Exception
{
    String commonsLangMetadata = "commons-lang/commons-lang/2.1/maven-metadata.xml";
    String expectedMetadataContents = "dummy-versioned-metadata";

    // TODO: find out what this should be from maven-artifact
    File metadataFile = new File( repoRootLegacy, commonsLangMetadata );
    metadataFile.getParentFile().mkdirs();

    FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.defaultCharset() );

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletNoProxyTest.java


示例21: testGetNoProxyProjectMetadataDefaultLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyProjectMetadataDefaultLayoutManagedLegacy()
    throws Exception
{
    // TODO: find out what it is meant to be from maven-artifact
    String commonsLangMetadata = "commons-lang/commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "dummy-project-metadata";

    File metadataFile = new File( repoRootLegacy, commonsLangMetadata );
    metadataFile.getParentFile().mkdirs();

    FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.defaultCharset() );

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletNoProxyTest.java


示例22: testGetNoProxyGroupMetadataDefaultLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyGroupMetadataDefaultLayoutManagedLegacy()
    throws Exception
{
    String commonsLangMetadata = "commons-lang/maven-metadata.xml";
    String expectedMetadataContents = "dummy-group-metadata";

    File metadataFile = new File( repoRootLegacy, commonsLangMetadata );
    metadataFile.getParentFile().mkdirs();

    FileUtils.writeStringToFile( metadataFile, expectedMetadataContents, Charset.defaultCharset() );

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangMetadata );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RepositoryServletNoProxyTest.java


示例23: testGetNoProxyArtifactDefaultLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyArtifactDefaultLayoutManagedLegacy()
    throws Exception
{
    String commonsLangJar = "commons-lang/commons-lang/2.1/commons-lang-2.1.jar";
    String expectedArtifactContents = "dummy-commons-lang-artifact";

    File artifactFile = new File( repoRootLegacy, "commons-lang/jars/commons-lang-2.1.jar" );
    artifactFile.getParentFile().mkdirs();

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RepositoryServletNoProxyTest.java


示例24: testGetNoProxyArtifactLegacyLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyArtifactLegacyLayoutManagedLegacy()
    throws Exception
{
    String commonsLangJar = "commons-lang/jars/commons-lang-2.1.jar";
    String expectedArtifactContents = "dummy-commons-lang-artifact";

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

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RepositoryServletNoProxyTest.java


示例25: testGetNoProxySnapshotArtifactDefaultLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxySnapshotArtifactDefaultLayoutManagedLegacy()
    throws Exception
{
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/commons-lang-2.1-SNAPSHOT.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";

    File artifactFile = new File( repoRootLegacy, "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar" );
    artifactFile.getParentFile().mkdirs();

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RepositoryServletNoProxyTest.java


示例26: testGetNoProxySnapshotArtifactLegacyLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxySnapshotArtifactLegacyLayoutManagedLegacy()
    throws Exception
{
    String commonsLangJar = "commons-lang/jars/commons-lang-2.1-SNAPSHOT.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";

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

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RepositoryServletNoProxyTest.java


示例27: testGetNoProxyTimestampedSnapshotArtifactDefaultLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyTimestampedSnapshotArtifactDefaultLayoutManagedLegacy()
    throws Exception
{
    String filename = "commons-lang-2.1-20050821.023400-1.jar";
    String commonsLangJar = "commons-lang/commons-lang/2.1-SNAPSHOT/" + filename;
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";

    File artifactFile = new File( repoRootLegacy, "commons-lang/jars/" + filename );
    artifactFile.getParentFile().mkdirs();

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletNoProxyTest.java


示例28: testGetNoProxyTimestampedSnapshotArtifactLegacyLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyTimestampedSnapshotArtifactLegacyLayoutManagedLegacy()
    throws Exception
{
    String commonsLangJar = "commons-lang/jars/commons-lang-2.1-20050821.023400-1.jar";
    String expectedArtifactContents = "dummy-commons-lang-snapshot-artifact";

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

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + commonsLangJar );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RepositoryServletNoProxyTest.java


示例29: testGetNoProxyDualExtensionDefaultLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
/**
 * [MRM-481] Artifact requests with a .xml.zip extension fail with a 404 Error
 */
@Test
public void testGetNoProxyDualExtensionDefaultLayoutManagedLegacy()
    throws Exception
{
    String expectedContents = "the-contents-of-the-dual-extension";
    String dualExtensionPath = "org/project/example-presentation/3.2/example-presentation-3.2.xml.zip";

    File checksumFile = new File( repoRootLegacy, "org.project/distributions/example-presentation-3.2.xml.zip" );
    checksumFile.getParentFile().mkdirs();

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:20,代码来源:RepositoryServletNoProxyTest.java


示例30: testGetNoProxyDistributionLegacyLayoutManagedLegacy

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetNoProxyDistributionLegacyLayoutManagedLegacy()
    throws Exception
{
    String expectedContents = "the-contents-of-the-dual-extension";
    String dualExtensionPath = "org.project/distributions/example-presentation-3.2.zip";

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

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

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/legacy/" + dualExtensionPath );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseNotFound( response );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:17,代码来源:RepositoryServletNoProxyTest.java


示例31: testPutWithMissingParentCollection

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testPutWithMissingParentCollection()
    throws Exception
{
    setupCleanRepo( repoRootInternal );

    String putUrl = "http://machine.com/repository/internal" + ARTIFACT_DEFAULT_LAYOUT;
    InputStream is = getClass().getResourceAsStream( "/artifact.jar" );
    // 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 );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletDeployTest.java


示例32: testMkColWithMissingParentCollectionFails

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testMkColWithMissingParentCollectionFails()
    throws Exception
{
    setupCleanRepo( repoRootInternal );

    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());
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:18,代码来源:RepositoryServletDeployTest.java


示例33: getAccessToken

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
private OAuthToken getAccessToken(String refreshToken) throws IOException {
    final String tokenUrl = String.format(ACCESS_TOKEN_URL, refreshToken,
        oAuthParams.getRedirectUri(), oAuthParams.getClientId(), oAuthParams.getClientSecret());
    final WebRequest webRequest = new WebRequest(new URL(tokenUrl), HttpMethod.POST);

    final WebResponse webResponse = webClient.loadWebResponse(webRequest);
    if (webResponse.getStatusCode() != HttpStatus.SC_OK) {
        throw new IOException(String.format("Error getting access token: [%s: %s]",
            webResponse.getStatusCode(), webResponse.getStatusMessage()));
    }
    final long currentTime = System.currentTimeMillis();
    final ObjectMapper mapper = new ObjectMapper();
    final Map map = mapper.readValue(webResponse.getContentAsStream(), Map.class);
    final String accessToken = map.get("access_token").toString();
    final Integer expiresIn = Integer.valueOf(map.get("expires_in").toString());
    return new OAuthToken(refreshToken, accessToken,
        currentTime + TimeUnit.MILLISECONDS.convert(expiresIn, TimeUnit.SECONDS));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:LinkedInOAuthRequestFilter.java


示例34: getDocumentWithoutGateway

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
private static DownloadableDocument getDocumentWithoutGateway(Page directDownloadPage, String courseName, Term term) {
    String downloadPageURL = directDownloadPage.getUrl().toString();
    WebResponse response = directDownloadPage.getWebResponse();
    String contentDispositionHeader = response.getResponseHeaderValue("Content-Disposition");
    String filename = fetchFileNameFromContentDisposition(contentDispositionHeader);
    String extension = fetchFileExtension(filename);
    String name = filename.substring(0, filename.indexOf(extension));
    long size = fetchFileSizeFromResponse(response);

    //todo find better solution for the zip-name hack
    if (ZIP_EXTENSION.equals(extension)) {
        name = clearZIPName(name);
        name += "-" + size;
    }
    return new DownloadableDocument(name, downloadPageURL, courseName, extension, size, term);
}
 
开发者ID:theovier,项目名称:lernplattform-crawler,代码行数:17,代码来源:DocumentCrawler.java


示例35: testFormHeaderOk

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
/**
 * Checks that CSRF validation works if token sent as header instead of
 * form field.
 *
 * @throws Exception an error occurs or validation fails.
 */
@Test
public void testFormHeaderOk() throws Exception {
    HtmlPage page1 = webClient.getPage(webUrl + "resources/csrf");

    // Check response and CSRF header
    WebResponse res = page1.getWebResponse();
    assertEquals(Response.Status.OK.getStatusCode(), res.getStatusCode());
    assertNotNull(res.getResponseHeaderValue(CSRF_HEADER));

    WebRequest req = new WebRequest(new URL(webUrl + "resources/csrf"));
    req.setHttpMethod(HttpMethod.POST);
    req.setAdditionalHeader(CSRF_HEADER, res.getResponseHeaderValue(CSRF_HEADER));
    res = webClient.loadWebResponse(req);
    assertEquals(Response.Status.OK.getStatusCode(), res.getStatusCode());
}
 
开发者ID:mvc-spec,项目名称:ozark,代码行数:22,代码来源:CsrfIT.java


示例36: testAuthenticatedRequest

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testAuthenticatedRequest() throws IOException, SAXException {
	logger.info("start authenticated request");
	WebRequest request = new WebRequest(new URL(base + "LoginServlet?user=u1&password=p1"), HttpMethod.GET);
	WebResponse response = webClient.getWebConnection().getResponse(request);
	String responseText = response.getContentAsString();
	logger.info(responseText);

	assertTrue("Is user in Role", responseText.contains("isUserInRole?true"));
	assertTrue("Get Remote User", responseText.contains("getRemoteUser?u1"));
	assertTrue("Get User Principal", responseText.contains("getUserPrincipal?u1"));
	assertTrue("Get Auth Type", responseText.contains("getAuthType?BASIC"));
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:14,代码来源:SecureServletTestCase.java


示例37: testBrowseSubdirectory

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testBrowseSubdirectory()
    throws Exception
{
    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/org" );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertEquals( "Response", HttpServletResponse.SC_OK, response.getStatusCode() );

    List<String> expectedLinks = Arrays.asList( "../", "apache/", "codehaus/" );

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

    assertLinks( expectedLinks, elements );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:16,代码来源:RepositoryServletBrowseTest.java


示例38: requestMetadataOK

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
protected String requestMetadataOK( String path )
    throws Exception
{
    // process the response code later, not via an exception.
    //HttpUnitOptions.setExceptionsThrownOnErrorStatus( false );

    WebRequest request = new GetMethodWebRequest( "http://machine.com/repository/internal/" + path );
    WebResponse response = getServletUnitClient().getResponse( request );
    assertResponseOK( response );
    return response.getContentAsString();
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:12,代码来源:AbstractRepositoryServletProxiedMetadataTestCase.java


示例39: testGetRepositoryInvalidPathPassthroughPresent

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetRepositoryInvalidPathPassthroughPresent()
    throws Exception
{
    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() );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:14,代码来源:RepositoryServletTest.java


示例40: testGetRepositoryInvalidPathPassthroughMissing

import com.gargoylesoftware.htmlunit.WebResponse; //导入依赖的package包/类
@Test
public void testGetRepositoryInvalidPathPassthroughMissing()
    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( "Legacy Maven1 repository not supported anymore." );
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:13,代码来源:RepositoryServletTest.java



注:本文中的com.gargoylesoftware.htmlunit.WebResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。