本文整理汇总了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;
}
示例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";
}
示例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();
}
}
示例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());
}
示例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());
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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());
}
示例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;
}
示例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());
}
示例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;
}
示例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