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


Java Page类代码示例

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


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

示例1: clickOk

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Override
@PublicAtsApi
public void clickOk() {

    isProcessed = false;
    webClient.setConfirmHandler(new ConfirmHandler() {

        @Override
        public boolean handleConfirm(
                                      Page currentPage,
                                      String confirmationText ) {

            isProcessed = true;
            return true;
        }
    });
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:18,代码来源:HiddenHtmlConfirm.java

示例2: testSingleLogout_IT_SLO_1

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test
public void testSingleLogout_IT_SLO_1() throws Exception {
	login();
	Page logoutPage = client.getPage(BASE + "/saml/Logout");
	assertEquals(302, logoutPage.getWebResponse().getStatusCode());
	String logoutRedirect = logoutPage.getWebResponse().getResponseHeaderValue("Location");
       assertTrue(logoutRedirect + " did not start with: " + idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation(), logoutRedirect.startsWith(idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation()));

	handler.url = null;
	client.getPage(BASE + "/sp/priv1.jsp");
	assertNotNull(handler.url);
	assertTrue(handler.url.toString().startsWith(idpMetadata.getFirstMetadata().getSingleSignonServiceLocation(SAMLConstants.SAML2_REDIRECT_BINDING_URI)));
	
	Document document = TestHelper.parseBase64Encoded(Utils.getParameter("SAMLRequest", logoutRedirect));
	LogoutRequest lr = (LogoutRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());
	assertEquals("joetest", lr.getNameID().getValue());
	
	OIOLogoutResponse response = OIOLogoutResponse.fromRequest(new OIOLogoutRequest(lr), StatusCode.SUCCESS_URI, null, idpMetadata.getFirstMetadata().getEntityID(), spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
	String redirectURL = response.getRedirectURL(credential, Utils.getParameter("RelayState", handler.url.toString()));
	
	Page responsePage = client.getPage(redirectURL);
	assertEquals(302, responsePage.getWebResponse().getStatusCode());
	assertEquals("http://localhost:8808/saml", responsePage.getWebResponse().getResponseHeaderValue("Location"));
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:LogoutTest.java

示例3: testIdpInitiatedLogout_IT_SLO_2

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test
public void testIdpInitiatedLogout_IT_SLO_2() throws Exception {
	login();

	LogoutRequest lr = SAMLUtil.buildXMLObject(LogoutRequest.class);
	lr.setID(Utils.generateUUID());
	lr.setIssuer(SAMLUtil.createIssuer(idpMetadata.getFirstMetadata().getEntityID()));
	lr.setDestination(spMetadata.getSingleLogoutServiceHTTPRedirectLocation());
	lr.setIssueInstant(new DateTime());
	lr.setNameID(SAMLUtil.createNameID("joetest"));
	OIOLogoutRequest req = new OIOLogoutRequest(lr);
	String redirectUrl = req.getRedirectRequestURL(credential);
	
	System.out.println(redirectUrl);
	Page responsePage = client.getPage(redirectUrl);
	assertEquals(302, responsePage.getWebResponse().getStatusCode());
	
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:19,代码来源:LogoutTest.java

示例4: testSingleLogout_IT_SLO_1

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test
public void testSingleLogout_IT_SLO_1() throws Exception {
	login();
	Page logoutPage = client.getPage(BASE + "/saml/Logout");
	assertEquals(302, logoutPage.getWebResponse().getStatusCode());
	String logoutRedirect = logoutPage.getWebResponse().getResponseHeaderValue("Location");
	assertTrue(logoutRedirect.startsWith(idpMetadata.getFirstMetadata().getSingleLogoutServiceLocation()));
	
	handler.url = null;
	client.getPage(BASE + "/sp/priv1.jsp");
	assertNotNull(handler.url);
	assertTrue(handler.url.toString().startsWith(idpMetadata.getFirstMetadata().getSingleSignonServiceLocation(SAMLConstants.SAML2_REDIRECT_BINDING_URI)));
	
	Document document = TestHelper.parseBase64Encoded(Utils.getParameter("SAMLRequest", logoutRedirect));
	LogoutRequest lr = (LogoutRequest) Configuration.getUnmarshallerFactory().getUnmarshaller(document.getDocumentElement()).unmarshall(document.getDocumentElement());
	assertEquals("joetest", lr.getNameID().getValue());
	
	OIOLogoutResponse response = OIOLogoutResponse.fromRequest(new OIOLogoutRequest(lr), StatusCode.SUCCESS_URI, null, idpMetadata.getFirstMetadata().getEntityID(), spMetadata.getSingleLogoutServiceHTTPRedirectResponseLocation());
	String redirectURL = response.getRedirectURL(credential, Utils.getParameter("RelayState", handler.url.toString()));
	
	Page responsePage = client.getPage(redirectURL);
	assertEquals(302, responsePage.getWebResponse().getStatusCode());
	assertEquals("http://localhost:8808/saml", responsePage.getWebResponse().getResponseHeaderValue("Location"));
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:25,代码来源:LogoutTest.java

示例5: clickOk

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Override
@PublicAtsApi
public void clickOk(
                     final String promptValue ) {

    isProcessed = false;
    webClient.setPromptHandler(new PromptHandler() {

        @Override
        public String handlePrompt(
                                    Page currentPage,
                                    String promptText,
                                    String defaultValue ) {

            isProcessed = true;
            return promptValue;
        }
    });
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:20,代码来源:HiddenHtmlPrompt.java

示例6: clickCancel

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Override
@PublicAtsApi
public void clickCancel() {

    isProcessed = false;
    webClient.setPromptHandler(new PromptHandler() {

        @Override
        public String handlePrompt(
                                    Page currentPage,
                                    String promptText,
                                    String defaultValue ) {

            isProcessed = true;
            return null;
        }
    });
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:19,代码来源:HiddenHtmlPrompt.java

示例7: clickOk

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Override
@PublicAtsApi
public void clickOk() {

    isProcessed = false;
    webClient.setAlertHandler(new AlertHandler() {

        @Override
        public void handleAlert(
                                 Page alertPage,
                                 String alertText ) {

            isProcessed = true;
            //do nothing, by default it clicks the OK button
        }
    });
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:18,代码来源:HiddenHtmlAlert.java

示例8: clickCancel

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Override
@PublicAtsApi
public void clickCancel() {

    isProcessed = false;
    webClient.setConfirmHandler(new ConfirmHandler() {

        @Override
        public boolean handleConfirm(
                                      Page currentPage,
                                      String confirmationText ) {

            isProcessed = true;
            return false;
        }
    });
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:18,代码来源:HiddenHtmlConfirm.java

示例9: verifyExampleInClassLevelJavadoc

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test
public void verifyExampleInClassLevelJavadoc() throws Exception {
	Assume.group(TestGroup.PERFORMANCE);

	WebClient webClient = new WebClient();

	MockMvc mockMvc = MockMvcBuilders.standaloneSetup(TestController.class).build();
	MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc);
	mockConnection.setWebClient(webClient);

	WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");
	WebConnection httpConnection = new HttpWebConnection(webClient);
	WebConnection webConnection = new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection));

	webClient.setWebConnection(webConnection);

	Page page = webClient.getPage("http://code.jquery.com/jquery-1.11.0.min.js");
	assertThat(page.getWebResponse().getStatusCode(), equalTo(200));
	assertThat(page.getWebResponse().getContentAsString(), not(isEmptyString()));
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:21,代码来源:DelegatingWebConnectionTests.java

示例10: getDocumentWithoutGateway

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
private static DownloadableDocument getDocumentWithoutGateway(Page directDownloadPage, String courseName, Term term) {
    String downloadPageURL = directDownloadPage.getUrl().toString();
    WebResponse response = directDownloadPage.getWebResponse();
    String contentDispositionHeader = response.getResponseHeaderValue("Content-Disposition");
    String filename = fetchFileNameFromContentDisposition(contentDispositionHeader);
    String extension = fetchFileExtension(filename);
    String name = filename.substring(0, filename.indexOf(extension));
    long size = fetchFileSizeFromResponse(response);

    //todo find better solution for the zip-name hack
    if (ZIP_EXTENSION.equals(extension)) {
        name = clearZIPName(name);
        name += "-" + size;
    }
    return new DownloadableDocument(name, downloadPageURL, courseName, extension, size, term);
}
 
开发者ID:theovier,项目名称:lernplattform-crawler,代码行数:17,代码来源:DocumentCrawler.java

示例11: loginBySpecialPost

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
protected RespWithTokenJSON loginBySpecialPost() throws FailingHttpStatusCodeException, IOException {
	WebRequest wr = new WebRequest(new URL(MP_WEIXIN_LOGIN), HttpMethod.POST);
	wr.getAdditionalHeaders().put("Accept", "*/*");
	wr.getAdditionalHeaders().put("Accept-Encoding", "gzip, deflate, br");
	wr.getAdditionalHeaders().put("Accept-Language", "en-US,en;q=0.5");
	wr.getAdditionalHeaders().put("Connection", "keep-alive");
	wr.getAdditionalHeaders().put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
	wr.getAdditionalHeaders().put("Host", "mp.weixin.qq.com");
	wr.getAdditionalHeaders().put("Referer", "https://mp.weixin.qq.com/");
	wr.getAdditionalHeaders().put("User-Agent",
			"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0");
	wr.getAdditionalHeaders().put("X-Requested-With", "XMLHttpRequest");
	List<NameValuePair> params = new ArrayList<NameValuePair>();
	params.add(new NameValuePair("f", "json"));
	params.add(new NameValuePair("imgcode", ""));
	//here password should be encrypt by MD5 and to lower case
	params.add(new NameValuePair("pwd", this.securityNP.getPass()));
	params.add(new NameValuePair("username", this.securityNP.getName()));
	wr.setRequestParameters(params);
	Page page = this.webClient.getPage(wr);
	String respJson = page.getWebResponse().getContentAsString();
	return RespWithTokenJSON.fromJson(respJson);
}
 
开发者ID:alexmao86,项目名称:weixinmp4j,代码行数:24,代码来源:WeixinmpWebSession.java

示例12: testAssuranceLevelTooLow_IT_LOA_1

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test
public void testAssuranceLevelTooLow_IT_LOA_1() throws Exception {
	client.getPage(BASE + "/sp/priv1.jsp");

	WebRequestSettings req = buildResponse(StatusCode.SUCCESS_URI, 1);
	Page responsePage = client.getPage(req);
	assertEquals(302, responsePage.getWebResponse().getStatusCode());
	assertEquals(BASE + "/sp/priv1.jsp", responsePage.getWebResponse().getResponseHeaderValue("Location"));
	
	HtmlPage loggedInPage = (HtmlPage) client.getPage(responsePage.getWebResponse().getResponseHeaderValue("Location"));
	WebAssert.assertTextPresent(loggedInPage, "Assurance level too low");
	
	handler.url = null;
	client.getPage(BASE + "/sp/priv1.jsp");
	assertNotNull("User should be logged out", handler.url);
}
 
开发者ID:amagdenko,项目名称:oiosaml.java,代码行数:17,代码来源:LoginTest.java

示例13: run_webPageNotFound

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test
public void run_webPageNotFound() throws IOException {
    MicrodataSourceWebEntity microdataSourceWebEntity = new MicrodataSourceWebEntity();
    microdataSourceWebEntity.setBaseLocation("http://example.org/harvest");
    microdataSourceWebEntity.setIsSitemap(Boolean.FALSE);
    Page mockPage = Mockito.mock(Page.class);
    WebResponse mockResponse = Mockito.mock(WebResponse.class);
    
    resultList.add(microdataSourceWebEntity);
    when(webClient.getPage(Mockito.any(WebRequest.class))).thenReturn(mockPage);
    when(mockPage.getWebResponse()).thenReturn(mockResponse);
    when(mockResponse.getStatusCode()).thenReturn(404);
    
    harversterJob.run();
    
    verify(microdataSourceWebRepository).byLastHarvestLessThan(Matchers.any(Long.class));
    verify(microdataJobRepository, times(0)).save(Matchers.any(MicrodataJobEntity.class));
}
 
开发者ID:gjong,项目名称:web-harvester,代码行数:19,代码来源:MicrodataSourceWebHarversterJobTest.java

示例14: putCustomListsTest

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 2)
@OperateOnDeployment("ear")
@RunAsClient
public void putCustomListsTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/lists/2"), HttpMethod.PUT);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    requestSettings.setRequestBody(
            "[{\"dns_client\":\"10.10.10.10/32\"," +
                    "\"lists\":{\"seznam.cz\":\"W\"," +
                    "\"google.com\":\"B\"," +
                    "\"example.com\":\"L\"}" +
                    "}," +
                    "{\"dns_client\":\"fe80::3ea9:f4ff:fe81:c450/64\"," +
                    "\"lists\":{\"seznam.cz\":\"L\"," +
                    "\"google.com\":\"W\"," +
                    "\"example.com\":\"W\"}" +
                    "}]");
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("putCustomListsTest Response:" + responseBody);
    String expected = "6 CUSTOM LISTS ELEMENTS PROCESSED, 6 PRESENT";
    assertTrue(responseBody.contains(expected), "Expected: " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:27,代码来源:ApiIntegrationTest.java

示例15: getIoCTest

import com.gargoylesoftware.htmlunit.Page; //导入依赖的package包/类
@Test(enabled = false, dataProvider = Arquillian.ARQUILLIAN_DATA_PROVIDER, priority = 6)
@OperateOnDeployment("ear")
@RunAsClient
public void getIoCTest(@ArquillianResource URL context) throws Exception {
    WebClient webClient = new WebClient();
    WebRequest requestSettings = new WebRequest(new URL(context + "rest/blacklist/record/seznam.cz"), HttpMethod.GET);
    requestSettings.setAdditionalHeader("Content-Type", "application/json");
    requestSettings.setAdditionalHeader("X-sinkit-token", TOKEN);
    Page page = webClient.getPage(requestSettings);
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
    String responseBody = page.getWebResponse().getContentAsString();
    LOGGER.info("getIoCTest Response:" + responseBody);
    String expected = "\"black_listed_domain_or_i_p\":\"aed14ad7ed6c543f818a4cfe89cb8f20\""; // md5 of seznam.cz
    assertTrue(responseBody.contains(expected), "IoC response should have contained " + expected + ", but got:" + responseBody);
    expected = "\"sources\":{\"feed2\":{\"a\":\"blacklist\",\"b\":\"myDocumentId\"}}";
    assertTrue(responseBody.contains(expected), "IoC should have contained " + expected + ", but got: " + responseBody);
}
 
开发者ID:whalebone,项目名称:sinkit-core,代码行数:18,代码来源:ApiIntegrationTest.java


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