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


Java TextPage类代码示例

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


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

示例1: isOutOfDate

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
public boolean isOutOfDate() {
	System.out.println("Checking for update");
	try {
		TextPage p = Link.manager
				.getPage("https://dl.dropboxusercontent.com/sh/0p0z1tzqb0l5ap1/ZQoSXXxkem/v.txt");
		double ver = Double.parseDouble(p.getContent());
		System.out.println("Current version: " + Link.version
				+ " | Latest version: " + ver);
		lver = ver;
		Link.manager.closeAllWindows();

		return (ver > Link.version);
	} catch (Exception e) {
		System.out.println(e);
	}
	Link.manager.closeAllWindows();
	return false;
}
 
开发者ID:robinm8,项目名称:RoMessenger,代码行数:19,代码来源:Downloader.java

示例2: checkAllowed

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
public static String checkAllowed() {
	try {
		System.out.println("Checking allowed");
		TextPage p = manager
				.getPage("https://dl.dropboxusercontent.com/sh/0p0z1tzqb0l5ap1/oW0QmQ7gJD/allowed.txt");
		System.out
				.println("https://dl.dropboxusercontent.com/sh/0p0z1tzqb0l5ap1/oW0QmQ7gJD/allowed.txt");

		if (p.getContent() == "0" || p.getContent().equals("0")) {
			return "false";
		}
	} catch (Exception e) {
		return "failed";
	}
	return "true";
}
 
开发者ID:robinm8,项目名称:RoMessenger,代码行数:17,代码来源:Link.java

示例3: getPageSource

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
/**
 * Get source of any page type.
 */
public static String getPageSource(final Page page) {
  if (page instanceof HtmlPage) {
    return ((HtmlPage) page).asXml();
  } else if (page instanceof JavaScriptPage) {
    return ((JavaScriptPage) page).getContent();
  } else if (page instanceof TextPage) {
    return ((TextPage) page).getContent();
  } else {
    // page instanceof UnexpectedPage
    return ((UnexpectedPage) page).getWebResponse().getContentAsString();
  }
}
 
开发者ID:jpschewe,项目名称:fll-sw,代码行数:16,代码来源:WebTestUtils.java

示例4: testPutWithCorrectCredentials

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testPutWithCorrectCredentials() throws Exception {
	logger.info("start put with correct credentials");
	webClient.setCredentialsProvider(correctCreds);
	WebRequest request = new WebRequest(new URL(base + "SecureDenyUncoveredServlet"), PUT);
	try {
		TextPage p = webClient.getPage(request);
		logger.info(p.getContent());
	} catch (FailingHttpStatusCodeException e) {
		assertNotNull(e);
		assertEquals(405, e.getStatusCode());
		return;
	}
	fail("PUT method could be called even with deny-unocovered-http-methods");
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:16,代码来源:SecureServletTestCase.java

示例5: testPostWithCorrectCredentials

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testPostWithCorrectCredentials() throws Exception {
    webClient.setCredentialsProvider(correctCreds);
    WebRequest request = new WebRequest(new URL(base + "/SecureServlet"), HttpMethod.POST);
    TextPage page = webClient.getPage(request);
    assertEquals("my POST", page.getContent());
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:8,代码来源:SecureServletTest.java

示例6: testPost

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testPost() throws IOException, SAXException {
    WebRequest request = new WebRequest(new URL(base + "/TestServlet"), HttpMethod.POST);
    TextPage page = webClient.getPage(request);
    assertEquals("my POST", page.getContent());
}
 
开发者ID:ftomassetti,项目名称:JavaIncrementalParser,代码行数:7,代码来源:TestServletTest.java

示例7: uebersichtsart

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
private TextPage uebersichtsart(HtmlPage page, String elementID) throws Exception {
	HtmlRadioButtonInput rbutton = (HtmlRadioButtonInput) page.getElementById(elementID);
	page = rbutton.click();
	//writePage(page, "Value1");
	HtmlImageInput i = page.getElementByName("submit");
	page = (HtmlPage) i.click();
	//writePage(page,"Res1");
	page = ((HtmlAnchor) page.getElementById("export")).click();
	// Select the Export-Link
	//writePage(page,"Export");
	TextPage p = ((HtmlAnchor) page.getElementByName("export")).click();
	return p;
}
 
开发者ID:littleyoda,项目名称:hibiscus.airplus,代码行数:14,代码来源:AirPlusSynchronizeJobKontoauszug.java

示例8: testMyServlet

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testMyServlet() throws IOException, ServletException {
    SimpleServletServer server = new SimpleServletServer();
    server.start();
    WebClient webClient = new WebClient();
    TextPage page = webClient.getPage(BASE + "/MyServlet");
    assertEquals("Hello World from GET", page.getContent());
    
    WebRequest request = new WebRequest(new URL(BASE + "/MyServlet"), HttpMethod.POST);
    page = webClient.getPage(request);
    assertEquals("Hello World from POST", page.getContent());
    server.stop();
}
 
开发者ID:arun-gupta,项目名称:wildfly-samples,代码行数:14,代码来源:SimpleServletServerTest.java

示例9: testMyAnotherServlet

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testMyAnotherServlet() throws IOException, ServletException {
    SimpleServletServer server = new SimpleServletServer();
    server.start();
    WebClient webClient = new WebClient();
    TextPage page = webClient.getPage(BASE + "/MyAnotherServlet");
    assertEquals("Howdy World from GET", page.getContent());
    
    WebRequest request = new WebRequest(new URL(BASE + "/MyAnotherServlet"), HttpMethod.POST);
    page = webClient.getPage(request);
    assertEquals("Howdy World from POST", page.getContent());
    server.stop();
}
 
开发者ID:arun-gupta,项目名称:wildfly-samples,代码行数:14,代码来源:SimpleServletServerTest.java

示例10: testApp

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testApp() throws IOException {
    HelloWorldServer server = new HelloWorldServer();
    server.start();
    WebClient webClient = new WebClient();
    TextPage page = webClient.getPage("http://localhost:8080");
    assertEquals("Hello World", page.getContent());
    server.stop();
}
 
开发者ID:arun-gupta,项目名称:wildfly-samples,代码行数:10,代码来源:HelloWorldServerTest.java

示例11: testRequestLocaleSupport

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testRequestLocaleSupport()
        throws FailingHttpStatusCodeException, MalformedURLException,
        IOException {
    WebClient webClient = new WebClient();
    WebRequest request = new WebRequest(new URL(contextPath, "test"));
    request.setAdditionalHeader("Accept-Language", "cs");
    TextPage page = webClient.getPage(request);
    assertEquals("cs:::fr", page.getContent());
}
 
开发者ID:trimou,项目名称:trimou,代码行数:11,代码来源:RequestLocaleSupportTest.java

示例12: getTorrents

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public synchronized List<TorrentData> getTorrents() throws IOException {
    //todo check alive status
    if (webClient == null) {
        connect();
    }

    TextPage tp = webClient.getPage(url + "/?list=1&token=" + token);
    List<List> tc = JSONArray.toList(JSONObject.fromObject(tp.getContent()).getJSONArray("torrents"));
    List<TorrentData> result = new ArrayList<>();
    for (List ti : tc) {
        if (ti.size() >= 8) {
            TorrentData torrentData = new TorrentData();
            torrentData.setHash(String.valueOf(ti.get(0)));
            try {
                torrentData.setRatio(Double.parseDouble(String.valueOf(ti.get(7))) / 1000);
                torrentData.setStatus(Integer.parseInt(String.valueOf(ti.get(1))));
                torrentData.setUploadSpeed(Integer.parseInt(String.valueOf(ti.get(8))));
                torrentData.setPercentProgress(Integer.parseInt(String.valueOf(ti.get(4))));
            } catch (NumberFormatException nfe) {
                throw new IOException("Unable to parse data");
            }
            result.add(torrentData);
        } else {
            throw new IOException("Received unknown structure of torrent's list");
        }
    }
    LOG.debug(Thread.currentThread() + ":" + super.toString() + " Torrents retrieved: " + result);
    return result;
}
 
开发者ID:stegan,项目名称:TorrentCleaner,代码行数:32,代码来源:UTorrentClient.java

示例13: delete

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Override
public synchronized void delete(String hash) throws IOException {
    if (webClient == null) {
        connect();
    }
    LOG.debug(Thread.currentThread() + ":" + super.toString() + " Delete torrent by hash: " + hash);
    //todo possible to check deletion status!?
    TextPage tp = webClient.getPage(url + "/?action=remove&hash=" + hash + "&token=" + token);
    LOG.debug("Content: " + tp.getContent());
}
 
开发者ID:stegan,项目名称:TorrentCleaner,代码行数:11,代码来源:UTorrentClient.java

示例14: executeSimpleRest

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
private String executeSimpleRest(String command) throws IOException {
    final String startUrl = base.toExternalForm() + "jbatch/rest/" + command;
    final WebClient webClient = newWebClient();
    final TextPage page = webClient.getPage(startUrl);
    String textContent = page.getContent();
    assertNotNull(textContent);
    assertTrue(textContent.contains("\nOK\n"));
    extractExecutionId(textContent);

    return textContent;
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:12,代码来源:ServletTest.java

示例15: testChildServlet

import com.gargoylesoftware.htmlunit.TextPage; //导入依赖的package包/类
@Test
public void testChildServlet() throws IOException, SAXException {
	TextPage page = webClient.getPage(base + "dynamic");
	assertEquals("dynamic GET", page.getContent());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:6,代码来源:RegistrationServletTestCase.java


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