本文整理汇总了Java中com.gargoylesoftware.htmlunit.WebResponse类的典型用法代码示例。如果您正苦于以下问题:Java WebResponse类的具体用法?Java WebResponse怎么用?Java WebResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WebResponse类属于com.gargoylesoftware.htmlunit包,在下文中一共展示了WebResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 );
}
示例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() );
}
示例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() );
}
示例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() );
}
示例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() );
}
示例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" );
}
示例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" );
}
示例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() );
}
示例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 );
}
示例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() );
}
示例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() );
}
示例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() );
}
示例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() );
}
示例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 );
}
示例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() );
}