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


Java HttpUnitOptions类代码示例

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


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

示例1: setUp

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * @see junit.framework.TestCase#setUp()
 */
@Before
public void setUp() throws Exception
{
    // need to pass a web.xml file to setup servletunit working directory
    ClassLoader classLoader = getClass().getClassLoader();
    URL webXmlUrl = classLoader.getResource("WEB-INF/web.xml");
    String path = URLDecoder.decode(webXmlUrl.getFile(), "UTF-8");

    HttpUnitOptions.setDefaultCharacterSet("utf-8");
    System.setProperty("file.encoding", "utf-8");

    // start servletRunner
    runner = new ServletRunner(new File(path), CONTEXT);

    Hashtable<String, String> params = new Hashtable<String, String>();
    params.put("javaEncoding", "utf-8");
    runner.registerServlet("*.jsp", "org.apache.jasper.servlet.JspServlet", params);

    log.debug("ServletRunner setup OK");

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:25,代码来源:DisplaytagCase.java

示例2: setUp

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * @see junit.framework.TestCase#setUp()
 * @throws Exception e
 */
@Before
public void setUp() throws Exception
{
    // need to pass a web.xml file to setup servletunit working directory
    Properties p = new Properties();
    p.setProperty("export.pdf.class", "org.displaytag.export.FopExportView");
    TableProperties.setUserProperties(p);

    ClassLoader classLoader = getClass().getClassLoader();
    URL webXmlUrl = classLoader.getResource("WEB-INF/web.xml");
    String path = URLDecoder.decode(webXmlUrl.getFile(), "UTF-8");

    HttpUnitOptions.setDefaultCharacterSet("utf-8");
    System.setProperty("file.encoding", "utf-8");

    // start servletRunner
    runner = new ServletRunner(new File(path), CONTEXT);

    Hashtable<String, String> params = new Hashtable<String, String>();
    params.put("javaEncoding", "utf-8");
    runner.registerServlet("*.jsp", "org.apache.jasper.servlet.JspServlet", params);

    log.debug("ServletRunner setup OK");

}
 
开发者ID:webbfontaine,项目名称:displaytag,代码行数:30,代码来源:ExportExcelTest.java

示例3: testPing

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * Test ping().
 */
@Test
public void testPing() {

    Server server = null;
    String dataDir = "data-test-ping1";

    try {
        String host = "localhost";
        int port = 18983;
        // start Solr
        server = SimpleAnuenueInstanceFactory.createSolrInstance(port,
                dataDir, NODE_CONF_FILE);
        HttpUnitOptions.setExceptionsThrownOnScriptError(false);

        SolrClient client = new SolrClient(host, port);
        client.ping();

    } catch (Exception e) {
        fail();
    } finally {
        AnuenueTestUtil.stopServerQuietly(server);
        assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
    }
}
 
开发者ID:haruyama,项目名称:Anuenue,代码行数:28,代码来源:TestSolrClient.java

示例4: testBrowseCatalog

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
public void testBrowseCatalog() throws Exception {
    try {
        // Disable scripting support until HttpUnit has better support for AJAX, Dojo...
        HttpUnitOptions.setScriptingEnabled(false);
        HttpUnitOptions.setExceptionsThrownOnScriptError(false);
        
        // Start with the home page
        WebConversation wc = new WebConversation();
        WebRequest req = new GetMethodWebRequest("http://" + serverHost + ":" + serverPort + "/" + context);
        WebResponse resp = wc.getResponse(req);
        
        testMainPage(wc, resp);
        testSellerPage(wc, resp);
        testSearchPage(wc, resp);
        testCatalogPage(wc, resp);
        testMapPage(wc, resp);
        testTagsPage(wc, resp);
    } catch (ConnectException e) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        fail("Could not connect to the server. Received Exception: \n" + sw.toString());
    }
}
 
开发者ID:sugar-lang,项目名称:case-studies,代码行数:25,代码来源:PetStoreWebBlackBoxTest.java

示例5: getAccesToken

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
private String getAccesToken(
        final String applicationKey,
        final String username,
        final String password) throws IOException {

    try {
        HttpUnitOptions.setScriptingEnabled(false);
        WebConversation wc = new WebConversation();
        WebResponse resp = wc.getResponse(String.format(OAUTH_GET_ACCESS_TOKEN_URL, applicationKey));
        WebForm form = findLoginForm(resp.getForms());
        form.setParameter("login", username);
        form.setParameter("password", password);
        resp = form.submit();
        if(!resp.getURL().toString().contains("code=")) {
            resp = resp.getLinkWith("Allow").click();
        }
        return resp.getURL().toString().split("code=")[1];
    } catch (SAXException ex) {
        throw new IOException(ex);
    }
}
 
开发者ID:finn-no,项目名称:Yammer-Java-SDK,代码行数:22,代码来源:YammerClient.java

示例6: setUp

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    String configuration = getConfiguration();
    InputStream is = this.getClass().getResourceAsStream(configuration);
    sr = new ServletRunner(is, CONTEXT);

    HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:9,代码来源:ServletUnitTest.java

示例7: setUp

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    InputStream is = this.getClass().getResourceAsStream(getConfiguration());
    assertNotNull("The configuration input stream should not be null", is);
    sr = new ServletRunner(is, CONTEXT);
    
    HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
    if (startCamelContext) {        
        super.setUp();
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:ServletCamelRouterTestSupport.java

示例8: setUp

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    InputStream is =  this.getClass().getResourceAsStream(getConfiguration());
    assertNotNull("The configuration input stream should not be null", is);
    sr = new ServletRunner(is, CONTEXT);

    HttpUnitOptions.setExceptionsThrownOnErrorStatus(true);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:ServletCamelTestSupport.java

示例9: testInvalidInput

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * Test of adding file including invalid line.
 */
@Test
public void testInvalidInput() {

    Server server = null;
    String dataDir = "data-test-invalid-input";

    try {
        int port = 18983;

        server = SimpleAnuenueInstanceFactory.createSolrInstance(port, dataDir, NODE_CONF_FILE);

        HttpUnitOptions.setExceptionsThrownOnScriptError(false);
        assertSame("initial size", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port));

        NodeDatabase database = new NodeDatabaseBuilder("resources/anuenue-nodes-single.xml").build();

        AnuenueDistCommandFactory.createDistCommand("addDir", "resources/example-failure-docs", database).execute();
        assertSame("addDir, before commit", 0, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port));
        AnuenueDistCommandFactory.createDistCommand("commit", "", database).execute();
        assertSame("addDir and commit", 2, AnuenueTestUtil.getNumberOfIndexedDocumentViaLocalhostSolr(port));

    } catch (Exception e) {
        fail();
    } finally {
        AnuenueTestUtil.stopServerQuietly(server);
        assertTrue(FileUtils.deleteQuietly(new File(dataDir)));
    }
}
 
开发者ID:haruyama,项目名称:Anuenue,代码行数:32,代码来源:TestAnuenueDistCommands.java

示例10: getMessageEncoding

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
private String getMessageEncoding() {
	 return _messageEncoding == null ?
	    /* Fixing 1705925: HttpUnitUtils.DEFAULT_CHARACTER_SET */
			HttpUnitOptions.getDefaultCharacterSet() : _messageEncoding;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:RequestContext.java

示例11: getContentType

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * Returns the content type of this message body.
 **/
public String getContentType() {
    return "application/x-www-form-urlencoded" +
              (!HttpUnitOptions.isPostIncludesCharset() ? ""
                                                        : "; charset=" + getCharacterSet());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:URLEncodedMessageBody.java

示例12: testParse

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * Test of parse method, of class StreamParser.
 * @throws Exception
 */
@Test
public void testParse() throws Exception {
    System.out.println("parse");

    HttpUnitOptions.setDefaultCharacterSet("utf-8");
    ServletRunner sr = new ServletRunner();
    sr.registerServlet("ExampleServlet", ExampleServlet.class.getName());
    ServletUnitClient sc = sr.newClient();
    PostMethodWebRequest postRequest = new PostMethodWebRequest("http://zoeey.org/ExampleServlet", true);
    postRequest.setParameter("name1", new String[]{"name1_value"});
    postRequest.setParameter("name2", new String[]{"name2_value"});
    postRequest.setParameter("name3", new String[]{"name3_value"});
    postRequest.setParameter("name5", new String[]{"中文字符串"});
    postRequest.setParameter("name6", new String[]{"路人甲"});
    postRequest.setParameter("MAX_FILE_SIZE", new String[]{"30000"});
    postRequest.selectFile("bugFile", new File(TestUtil.getBugPng()));
    postRequest.selectFile("bugFile2", new File(TestUtil.getBugPng()));
    //
    InvocationContext ic = sc.newInvocation(postRequest);
    HttpServletRequest request = ic.getRequest();
    String contentType = request.getContentType();
    String boundary = contentType.substring(contentType.indexOf('=') + 1);
    InputStream inStream = request.getInputStream();
    //
    UploadConfig config = new UploadConfig();
    File tempDir = new File(TestUtil.getResourceDir().concat("/temp"));
    FileHelper.tryMakeDirs(tempDir);
    config.setTempFileDir(tempDir);
    StreamParser sp = new StreamParser(boundary, config);
    sp.parse(inStream);
    assertEquals("{name5=[中文字符串], name6=[路人甲], name3=[name3_value], name1=[name1_value], name2=[name2_value], MAX_FILE_SIZE=[30000]}",//
            sp.getParamMap().toString());
    for (List<FileItem> fileItemList : sp.getFileMap().values()) {
        for (FileItem fileItem : fileItemList) {
            assertEquals("bug.png", fileItem.getOriginalName());
            assertEquals(fileItem.getError(), FileError.OK);
        }
    }
    FileHelper.tryDelete(tempDir, true);
}
 
开发者ID:eixom,项目名称:zoeey,代码行数:45,代码来源:StreamParserTest.java

示例13: setDefaultContentType

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * Sets the default content type for pages which do not specify one.
 **/
public void setDefaultContentType(String contentType) {
	HttpUnitOptions.setDefaultContentType(contentType);
}
 
开发者ID:Amsoft-Systems,项目名称:xmltestsuiteR12,代码行数:7,代码来源:BrowserResource.java

示例14: setLoggingHttpHeaders

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * If true, tells HttpUnit to log HTTP headers to system output. The default is false.
 **/
public void setLoggingHttpHeaders(String enabled) {
	HttpUnitOptions.setLoggingHttpHeaders(Boolean.getBoolean(enabled));
}
 
开发者ID:Amsoft-Systems,项目名称:xmltestsuiteR12,代码行数:7,代码来源:BrowserResource.java

示例15: setScriptingEnabled

import com.meterware.httpunit.HttpUnitOptions; //导入依赖的package包/类
/**
 * Method setScriptingEnabled.
 * @param scriptingEnabled
 */
public void setScriptingEnabled(String scriptingEnabled) {
	boolean enabled = (scriptingEnabled.equalsIgnoreCase("true")) ? true : false;
	HttpUnitOptions.setScriptingEnabled(enabled);
	verbose("ScriptingEnabled: " + HttpUnitOptions.isScriptingEnabled());
}
 
开发者ID:Amsoft-Systems,项目名称:xmltestsuiteR12,代码行数:10,代码来源:BrowserResource.java


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