本文整理汇总了Java中com.meterware.httpunit.WebLink类的典型用法代码示例。如果您正苦于以下问题:Java WebLink类的具体用法?Java WebLink怎么用?Java WebLink使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebLink类属于com.meterware.httpunit包,在下文中一共展示了WebLink类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGroupsPreservedOnZoom
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
public void testGroupsPreservedOnZoom() throws IOException, SAXException
{
WebLink theLink = m_response.getLinkWithName("zoomIn");
String linkUrl = theLink.getURLString();
String endOfExpectedUrl = "&resultLimit=5&dynamic=false&view=LOCAL_IP" +
"&selectGroupIndex=Test";
String endOfLinkUrl = linkUrl.substring(linkUrl.indexOf("&res"));
assertEquals(endOfExpectedUrl, endOfLinkUrl);
theLink = m_response.getLinkWithName("zoomOut");
linkUrl = theLink.getURLString();
endOfLinkUrl = linkUrl.substring(linkUrl.indexOf("&res"));
endOfExpectedUrl = "&resultLimit=5&dynamic=false&view=LOCAL_IP" +
"&selectGroupIndex=Test";
assertEquals(endOfExpectedUrl, endOfLinkUrl);
}
示例2: testMain
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Tests the administrator main page (main.jsp), by inspectin the treewidget
* (actually a table) and verifying that there's the corect number of rows in
* it in collapsed and expanded form.
* @throws Exception
*/
@Test
public void testMain() throws Exception {
getPage("index.jsp");
clickOn("Click here to enter the Administrator Main Page.");
login();
// Check that the tree widget (in collapsed form) is of appropriate size.
WebTable table = resp.getTables()[0];
assertEquals( "rows", 5, table.getRowCount());
assertEquals( "columns", 3, table.getColumnCount());
// Expand the tree widget.
WebLink link = table.getTableCell(0, 0).getLinks()[0];
assertNotNull(link);
link.click();
resp = wc.getCurrentPage();
// Check that the tree widget (in expanded form) is of appropriate size.
table = resp.getTables()[0];
assertEquals( "rows", 10, table.getRowCount());
assertEquals( "columns", 3, table.getColumnCount());
}
示例3: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Test link generated using column attributes.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
WebTable[] tables = response.getTables();
Assert.assertEquals("Wrong number of tables.", 1, tables.length);
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of links in result.", 1, links.length);
Assert.assertEquals(
"Parameter in link should be encoded.",
"/context/dynlink?param=1%2B1",
links[0].getURLString());
}
示例4: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Test link generated using column attributes.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of links in result.", 1, links.length);
Assert.assertEquals("Link text is wrong.", "/context/dynlink?param=Raja%26Siva", links[0].getURLString());
}
示例5: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Generated link should be https.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
String httpsUrl = StringUtils.replace(getJspUrl("DISPL-105.jsp"), "http://", "https://");
WebRequest request = new GetMethodWebRequest(httpsUrl);
WebResponse response = runner.getResponse(request);
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of generated links.", 1, links.length);
Assert.assertTrue("Generated link doesn't start with https: " + links[0].getURLString(), links[0]
.getURLString()
.startsWith("https://"));
}
示例6: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Test link generated for paging and export.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
WebTable[] tables = response.getTables();
Assert.assertEquals("Wrong number of tables.", 1, tables.length);
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of links in result.", 8, links.length);
for (int j = 0; j < links.length; j++)
{
String url = links[j].getURLString();
Assert.assertTrue("Invalid url: " + url, url.startsWith("/goforit"));
}
}
示例7: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Test link generated using href="".
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
ParamEncoder encoder = new ParamEncoder("table");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_ORDER), "2");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORT), "0");
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
WebTable[] tables = response.getTables();
Assert.assertEquals("Wrong number of tables.", 1, tables.length);
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of links in result.", 1, links.length);
URLAssert.assertEquals("/context/goforit?param=ant&d-148916-s=0&d-148916-o=2", links[0].getURLString());
}
示例8: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Check the content of the title attribute.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl("DISPL-001.jsp"));
WebResponse response = runner.getResponse(request);
WebTable[] tables = response.getTables();
Assert.assertEquals("Expected 1 table in result.", 1, tables.length);
Assert
.assertEquals("Wrong title in column", "[email protected]", tables[0].getTableCell(1, 0).getTitle());
WebLink[] links = tables[0].getTableCell(1, 0).getLinks();
Assert.assertEquals("Expected link not found", 1, links.length);
Assert.assertEquals("Wrong text in link", "[email protected]", links[0].getText());
Assert.assertEquals("Wrong url in link", "mailto:[email protected]", links[0].getURLString());
}
示例9: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Test link generated using href="".
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
ParamEncoder encoder = new ParamEncoder("table");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_ORDER), "2");
request.setParameter(encoder.encodeParameterName(TableTagParameters.PARAMETER_SORT), "0");
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug(response.getText());
}
WebTable[] tables = response.getTables();
Assert.assertEquals("Wrong number of table in result.", 2, tables.length);
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of links in result.", 2, links.length);
URLAssert.assertEquals("?d-148916-s=0&d-148916-o=1", links[0].getURLString());
URLAssert.assertEquals("?more=true&d-148916-s=0&d-148916-o=1", links[1].getURLString());
}
示例10: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Verifies that the generated page contains a table with the expected number of columns.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
WebResponse response = runner.getResponse(request);
for (int j = 0; j < 4; j++)
{
WebLink[] links = response.getLinks();
response = links[j].click();
if (log.isDebugEnabled())
{
log.debug("After clicking on " + j + ":\n" + response.getText());
}
checkOnlyOneSorted(response, j);
}
}
示例11: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Test that headers are correctly removed.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
// test keep
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
WebResponse response = runner.getResponse(request);
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of export links. ", 4, links.length);
Set<String> linkTexts = new HashSet<String>();
for (int j = 0; j < links.length; j++)
{
String url = links[j].getURLString();
log.debug(url);
if (linkTexts.contains(url))
{
Assert.fail("Found duplicated link in export banner: " + url);
}
linkTexts.add(url);
}
}
示例12: doTest
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/**
* Just a quick test to assure that you can avoid page numbers when displaying one page.
* @param jspName jsp name, with full path
* @throws Exception any axception thrown during test.
*/
@Override
@Test
public void doTest() throws Exception
{
WebRequest request = new GetMethodWebRequest(getJspUrl(getJspName()));
WebResponse response = runner.getResponse(request);
if (log.isDebugEnabled())
{
log.debug("RESPONSE: " + response.getText());
}
WebLink[] links = response.getLinks();
Assert.assertEquals("Wrong number of links in result.", 0, links.length);
Assert.assertFalse(
"Using setProperty you should not see any page number",
StringUtils.contains(response.getText(), ">1<"));
}
示例13: multipleApplicationsLoginAndLogout
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
private void multipleApplicationsLoginAndLogout() throws Exception {
// login 1
WebConversation conversation = new WebConversation();
WebRequest request = new GetMethodWebRequest(webssoClient2URL);
WebResponse response = tryGetResponse(conversation, request);
request = applicationLogin(conversation, response);
response = tryGetResponse(conversation, request);
assertUserInformation(response);
// login 2
WebRequest request2 = new GetMethodWebRequest(webssoClient2URL);// login into application2
WebResponse response2 = tryGetResponse(conversation, request2);
assertUserInformation(response2);
// logout
WebLink link = response.getLinkWith("logout");
link.click(); // logout of the application
WebRequest newRequest = new GetMethodWebRequest(webssoClient1URL);
WebResponse outputResponse = tryGetResponse(conversation, newRequest);
WebTable usersData = outputResponse
.getTableStartingWith("Single Sign On User Data");
assertNull("users data must be null ", usersData); // return null for user data (ie) logged out of second application
}
示例14: testModelCharacteristics
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
public void testModelCharacteristics() throws Exception {
navigateToModelForEditing(myModelName);
WebLink theLink = myWebConversation.getCurrentPage().getFirstMatchingLink(WebLink.MATCH_URL_STRING,
"AnimalModelPopulateAction.do?method=populate");
assertNotNull("Couldn't find link to model characteristics data", theLink);
WebResponse theCurrentPage = theLink.click();
assertCurrentPageContains("Is this model a tool strain?");
WebForm theForm = theCurrentPage.getFormWithName("modelCharacteristicsForm");
theForm.setParameter("description", "Test Description");
theCurrentPage = theForm.submit();
assertCurrentPageContains("You have successfully edited the Model Characteristics.");
}
示例15: testSearchPage
import com.meterware.httpunit.WebLink; //导入依赖的package包/类
/** This method tests the search Page. It also submits a query for cats and
* verifies that the result has at least two items */
private void testSearchPage(WebConversation wc, WebResponse resp) throws Exception {
// Test the search page
WebLink wl = resp.getLinkWith("Search");
wl.click();
resp = wc.getCurrentPage();
// check if the search returns more than one result for "cat
WebForm form = resp.getForms()[0];
assertEquals("on", form.getParameterValue("searchForm:searchTags"));
String searchText = "cat";
form.setParameter("searchForm:searchString", searchText);
form.submit();
resp = wc.getCurrentPage();
WebTable resultTable = resp.getTableStartingWithPrefix("Map");
assertTrue(resultTable.getRowCount() > 2);
}