public boolean matchesCriteria( Object htmlElement, Object criteria ) { return HttpUnitUtils.contains( ((WebLink) htmlElement).getURLString(), (String) criteria ); } };
public boolean matchesCriteria( Object htmlElement, Object criteria ) { return HttpUnitUtils.contains( ((WebLink) htmlElement).getURLString(), (String) criteria ); } };
public boolean matchesCriteria( Object htmlElement, Object criteria ) { return HttpUnitUtils.contains( ((WebLink) htmlElement).getURLString(), (String) criteria ); } };
/** * Finds a hyper-link that has the specified text and whose * target URL starts with the given prefix. */ static WebLink findLink( WebConversation wc, String text, String urlPrefix ) throws ProcessingException, SAXException { WebLink[] links = wc.getCurrentPage().getLinks(); for( int i=0; i<links.length; i++ ) { if( links[i].asText().indexOf(text)==-1 ) continue; if( !links[i].getURLString().startsWith(urlPrefix)) continue; return links[i]; } throw new ProcessingException("no link found for '"+text+'\''); }
private void parse() throws ProcessingException { lists = new ArrayList<JNMailingList>(); try { WebResponse response = goTo(project._getURL()+"/servlets/ProjectMailingListList"); for( WebLink link : response.getLinks() ) { String linkTxt = link.getURLString(); if (linkTxt.startsWith(project._getURL() + "/servlets/SummarizeList?listName=")) { String listName = linkTxt.substring(linkTxt.lastIndexOf('=')+1, linkTxt.length()); lists.add(new JNMailingList(project,listName)); } } } catch( SAXException e ) { throw new ProcessingException(e); } catch( IOException e ) { throw new ProcessingException(e); } catch( DOMException e ) { throw new ProcessingException(e); } catch(HttpException e) { throw new ProcessingException(e); } }
@Test public void testGetServiceList() throws Exception { WebConversation client = new WebConversation(); WebResponse res = client.getResponse(serviceURL + "/services"); WebLink[] links = res.getLinks(); Set<String> s = new HashSet<>(); for (WebLink l : links) { s.add(l.getURLString()); } assertEquals("There should be 3 links for the service", 3, links.length); assertTrue(s.contains(serviceURL + "Greeter?wsdl")); assertTrue(s.contains(serviceURL + "Hello?wsdl")); assertTrue(s.contains(serviceURL + "?wsdl")); assertEquals("text/html", res.getContentType()); } }
@Test public void testGetServiceList() throws Exception { ServletUnitClient client = newClient(); client.setExceptionsThrownOnErrorStatus(false); //test the '/' context get service list WebResponse res = client.getResponse(CONTEXT_URL + "/"); WebLink[] links = res.getLinks(); assertEquals("Wrong number of service links", 3, links.length); Set<String> links2 = new HashSet<>(); for (WebLink l : links) { links2.add(l.getURLString()); } assertEquals("text/html", res.getContentType()); }
@Test public void testGetServiceList() throws Exception { ServletUnitClient client = newClient(); client.setExceptionsThrownOnErrorStatus(false); WebResponse res = client.getResponse(CONTEXT_URL + "/services"); WebLink[] links = res.getLinks(); assertEquals("Wrong number of service links", 6, links.length); Set<String> links2 = new HashSet<>(); for (WebLink l : links) { links2.add(l.getURLString()); } assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl")); assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl")); assertTrue(links2.contains("http://cxf.apache.org/MyGreeter?wsdl")); assertEquals("text/html", res.getContentType()); res = client.getResponse(CONTEXT_URL + "/services/"); links = res.getLinks(); links2.clear(); for (WebLink l : links) { links2.add(l.getURLString()); } assertEquals("Wrong number of service links", 6, links.length); assertTrue(links2.contains(CONTEXT_URL + "/services/greeter?wsdl")); assertTrue(links2.contains(CONTEXT_URL + "/services/greeter2?wsdl")); assertTrue(links2.contains("http://cxf.apache.org/MyGreeter?wsdl")); assertEquals("text/html", res.getContentType()); // Ensure that the Bus is available for people doing an Endpoint.publish() or similar. assertNotNull(BusFactory.getDefaultBus(false)); }
@Test public void testGetServiceList() throws Exception { ServletUnitClient client = newClient(); client.setExceptionsThrownOnErrorStatus(false); //test the '/' context get service list WebResponse res = client.getResponse(CONTEXT_URL + "/"); WebLink[] links = res.getLinks(); assertEquals("Wrong number of service links", 6, links.length); Set<String> links2 = new HashSet<>(); for (WebLink l : links) { links2.add(l.getURLString()); } assertTrue(links2.contains(FORCED_BASE_ADDRESS + "/greeter?wsdl")); assertTrue(links2.contains(FORCED_BASE_ADDRESS + "/greeter2?wsdl")); assertEquals("text/html", res.getContentType()); //HTTPUnit do not support require url with "" /* res = client.getResponse(CONTEXT_URL); links = res.getLinks(); assertEquals("There should get two links for the services", 1, links.length); assertEquals(CONTEXT_URL + "/greeter?wsdl", links[0].getURLString()); assertEquals(CONTEXT_URL + "/greeter2?wsdl", links[1].getURLString()); assertEquals("text/html", res.getContentType());*/ }
protected Object scrape() throws IOException, SAXException, ProcessingException { WebResponse response = goTo(_getURL()+"/servlets/ProjectApproval"); WebTable table = response.getTableStartingWith("Project"); int rows = table.getRowCount(); boolean found = false; String approveElementName = null; for (int r = 1; r < rows && !found; r++ ) { TableCell c1 = table.getTableCell(r, 0); if (c1.getLinks().length > 0) { String link = c1.getLinks()[0].getURLString(); if (link.equals(_getURL()+'/')) { TableCell c2 = table.getTableCell(r, 3); String[] names = c2.getElementNames(); if (names.length > 0) { approveElementName = names[0]; found = true; } } } } if (!found) throw new ProcessingException("Unable to find project "+projectName+" in the approval page"); // we already have the info we need to approve the project, now, do it WebForm form = Util.getFormWithAction(response,"ProjectApproval"); form.setParameter(approveElementName, approve ? "Approve" : "Disapprove"); form.setParameter("disapprovalReason",reason); checkError(form.submit()); return null; } }
String[] parts = fileLink.getURLString().split("/"); String id = parts[4]; WebLink[] links = r.getLinks(); WebLink editFileLink = null; for (WebLink link : links) { if (link.getURLString().contains("ProjectDocumentEdit?documentID="+id)) { editFileLink = link; break;