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


Java HttpException类代码示例

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


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

示例1: testPutMethod

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
@Test
public void testPutMethod() throws Exception {
    WebConversation conv = new WebConversation();
    conv.setAuthentication("file", "u1", "p1");
    
    byte[] bytes = new byte[10];
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    PutMethodWebRequest putRequest = new PutMethodWebRequest(base + "/SecureServlet", bais, "text/plain");
    try {
        conv.getResponse(putRequest);
    } catch (HttpException e) {
        assertEquals(403, e.getResponseCode());
        return;
    }
    fail("PUT method could be called");
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:17,代码来源:SecureServletTest.java

示例2: testPut

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
@Test
public void testPut() throws IOException, SAXException {
    WebConversation conv = new WebConversation();
    conv.setAuthentication("file", "u1", "p1");
    byte[] bytes = new byte[8];
    ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
    PutMethodWebRequest putRequest = new PutMethodWebRequest(base + "/webresources/myresource", bais, "text/plain");
    try {
        WebResponse response = conv.getResponse(putRequest);
    } catch (HttpException e) {
        assertNotNull(e);
        assertEquals(403, e.getResponseCode());
        return;
    }
    fail("PUT is not authorized and can still be called");
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:17,代码来源:MyResourceTest.java

示例3: test_imageFailsOnUnknownStatsType

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
public void test_imageFailsOnUnknownStatsType() throws Exception {
  try {
    TestHelper.assertPageSmokes(WebuiUtils.makeStatisticsChartURL(TEST_BUILD_ID,
      99999), null);
    TestHelper.failNoExceptionThrown();
  } catch (HttpException e) {
  }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:9,代码来源:SSTestStatisticsImageServlet.java

示例4: errorWhenNoPathPrefix

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
@Test
public void errorWhenNoPathPrefix() throws Exception {
	final String requestUri = "http://localhost/";

	ServletUnitClient servletClient = servletRunner.newClient();
	WebRequest req = new GetMethodWebRequest(requestUri);

	try {
		servletClient.getResponse(req);
	} catch (HttpException e) {
		assertThat(e.getResponseCode()).isEqualTo(HttpServletResponse.SC_NOT_FOUND);
	}
}
 
开发者ID:flaxsearch,项目名称:harahachibu,代码行数:14,代码来源:DiskSpaceProxyServletTest.java

示例5: testJndiAccessServlet

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
/**
 * Test the keep alive case
 */
public void testJndiAccessServlet() throws IOException, InterruptedException, SAXException {
	// Initialise container
	final Map<String, String> args = new HashMap<String, String>();
	args.put("webroot", HttpConnectorTest.WEBROOT);
	args.put("prefix", "/examples");
	args.put("httpPort", "10006");
	args.put("ajp13Port", "-1");
	args.put("controlPort", "-1");
	args.put("debug", "8");
	args.put("logThrowingLineNo", "true");
	args.put("useJNDI", "true");

	args.put("useJNDI", "true");
	args.put("jndi.resource.jdbc/myDatasource", "javax.sql.DataSource");
	args.put("jndi.param.jdbc/myDatasource.url", "jdbc:h2:~/test");

	//
	final Launcher winstone = new Launcher(args);
	winstone.launch();
	// Check for a simple connection
	final WebConversation wc = new WebConversation();
	final WebRequest wreq = new GetMethodWebRequest("http://localhost:10006/examples/JndiDataSourceServlet");
	try {
		final WebResponse wresp1 = wc.getResponse(wreq);
		logger.info("ResponseCode: " + wresp1.getResponseCode());
	} catch (final HttpException exception) {
		Assert.fail("Datasource must be found. " + exception.getMessage());
	}

	winstone.shutdown();
	Thread.sleep(500);
}
 
开发者ID:geronimo-iia,项目名称:winstone,代码行数:36,代码来源:JndiContextAccessTest.java

示例6: testJndiAccessServlet

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
/**
 * Test the keep alive case
 */
public void testJndiAccessServlet() throws IOException, InterruptedException, SAXException {
	// Initialise container
	final Map<String, String> args = new HashMap<String, String>();
	args.put("webroot","../webapp-spring/target/webapp-spring");
	args.put("prefix", "/examples");
	args.put("httpPort", "10009");
	args.put("ajp13Port", "-1");
	args.put("controlPort", "-1");
	args.put("debug", "8");
	args.put("logThrowingLineNo", "true");
	args.put("useJNDI", "true");

	args.put("useJNDI", "true");
	args.put("jndi.resource.jdbc/testDatasource", "javax.sql.DataSource");
	args.put("jndi.param.jdbc/testDatasource.url", "jdbc:h2:~/test");

	//
	final Launcher winstone = new Launcher(args);
	winstone.launch();
	// Check for a simple connection
	final WebConversation wc = new WebConversation();
	final WebRequest wreq = new GetMethodWebRequest("http://localhost:10009/examples/index.html");
	try {
		final WebResponse wresp1 = wc.getResponse(wreq);
		logger.info("ResponseCode: " + wresp1.getResponseCode());
	} catch (final HttpException exception) {
		Assert.fail("Datasource must be found. " + exception.getMessage());
	}

	winstone.shutdown();
	Thread.sleep(500);
}
 
开发者ID:geronimo-iia,项目名称:winstone,代码行数:36,代码来源:SpringAccessTest.java

示例7: testFrontPage

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
public void testFrontPage() throws Exception
{
	if (enabled)
	{
		WebResponse resp = null;
		try
		{
			for (String seed : seedURLs)
			{
				log.info("Testing Seed URL "+seed);
				WebRequest req = new GetMethodWebRequest(BASE_URL + seed);
				resp = wc.getResponse(req);
				clickAll(resp, 0, 10);
			}

		}
		catch (HttpException hex)
		{
			log.error("Failed with ", hex);
			fail(hex.getMessage());
		}
	}
	else
	{
		log.info("Tests Disabled, please start tomcat with sdata installed");
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:28,代码来源:AnonPortalTest.java

示例8: testInvalidLogin

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
@Test
public void testInvalidLogin() throws IOException, SAXException {
    try {
        WebConversation webConversation = new WebConversation();
        GetMethodWebRequest request = new GetMethodWebRequest(deployUrl + "LoginServlet");
        request.setParameter("username", "invalid");
        request.setParameter("password", "invalid");
        webConversation.getResponse(request);
        assertTrue(false);
    } catch (HttpException e) {
        assertEquals(403, e.getResponseCode());
    }
}
 
开发者ID:radcortez,项目名称:wildfly-custom-login-module,代码行数:14,代码来源:CustomLoginModuleTest.java

示例9: testPostMethod

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
@Test
public void testPostMethod() throws Exception {
    WebConversation conv = new WebConversation();
    conv.setAuthentication("file", "u1", "p1");
    
    PostMethodWebRequest postRequest = new PostMethodWebRequest(base + "/SecureServlet");
    try {
        conv.getResponse(postRequest);
    } catch (HttpException e) {
        assertEquals(403, e.getResponseCode());
        return;
    }
    fail("POST method could be called");
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:15,代码来源:SecureServletTest.java

示例10: testPost

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
@Test
public void testPost() throws IOException, SAXException {
    WebConversation conv = new WebConversation();
    conv.setAuthentication("file", "u1", "p1");
    PostMethodWebRequest postRequest = new PostMethodWebRequest(base + "/webresources/myresource");
    try {
        WebResponse response = conv.getResponse(postRequest);
    } catch (HttpException e) {
        assertNotNull(e);
        assertEquals(403, e.getResponseCode());
        return;
    }
    fail("POST is not authorized and can still be called");
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:15,代码来源:MyResourceTest.java

示例11: processLinks

import com.meterware.httpunit.HttpException; //导入依赖的package包/类
/**
 * @param resp
 * @param i
 * @param maxDepth
	 * @throws SAXException 
	 * @throws IOException 
 */
private void processLinks(WebResponse resp, int i, int maxDepth) throws SAXException, IOException
{
	char[] p = new char[i];
	for (int j = 0; j < i; j++)
	{
		p[j] = ' ';
	}
	String pad = new String(p);
	WebLink[] links = resp.getLinks();
	for (WebLink link : links)
	{
		String url = link.getURLString();
		if (visited.get(url) == null)
		{
			visited.put(url, url);
			if (isLocal(url))
			{
				log.info("Getting " + pad + link.getURLString());
				WebResponse response = null;
				try
				{

					response = link.click();
				}
				catch (HttpException ex)
				{
					log.warn("Failed to get Link " + url + " code:"
							+ ex.getResponseCode() + " cause:"
							+ ex.getResponseMessage());
				}
				catch (ConnectException cex)
				{
					log.error("Failed to get Connection to "+url);
				}
				if (response != null)
				{
					clickAll(response, i, maxDepth);
				}

			}
			else
			{
				log.info("Ignoring External URL " + url);
			}
		}
	}
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:55,代码来源:AnonPortalTest.java


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