PingbackMethodImpl implements Method { protected String getExcerpt() throws IOException { String html = _http.URLtoString(_sourceURI); Source source = new Source(html); source.fullSequentialParse(); List<Element> elements = source.getAllElements("a"); for (Element element : elements) { String href = GetterUtil.getString( element.getAttributeValue("href")); if (href.equals(_targetURI)) { element = element.getParentElement(); TextExtractor textExtractor = new TextExtractor(element); String body = textExtractor.toString(); if (body.length() < getLinkbackExcerptLength()) { element = element.getParentElement(); if (element != null) { textExtractor = new TextExtractor(element); body = textExtractor.toString(); } } return StringUtil.shorten(body, getLinkbackExcerptLength()); } } return StringPool.BLANK; }  @Override Response execute(long companyId); @Override String getMethodName(); @Override String getToken(); @Override boolean setArguments(Object[] arguments); void setInetAddressLookup(InetAddressLookup inetAddressLookup); void setPingbackProperties(PingbackProperties pingbackProperties); void setPortletIdLookup(PortletIdLookup portletIdLookup); static final int ACCESS_DENIED; static final int GENERIC_FAULT; static final int PINGBACK_ALREADY_REGISTERED; static final int SERVER_ERROR; static final int SOURCE_URI_DOES_NOT_EXIST; static final int SOURCE_URI_INVALID; static final int TARGET_URI_DOES_NOT_EXIST; static final int TARGET_URI_INVALID; }
@Test public void testGetExcerpt() throws Exception { Mockito.doReturn( 4 ).when( _pingbackProperties ).getLinkbackExcerptLength(); whenHttpURLToString( "<body><a href='http: execute(); verifyExcerpt("1..."); }