Author: kkolinko
Date: Tue Nov 13 00:42:33 2012
New Revision: 1408520
URL: http://svn.apache.org/viewvc?rev=1408520&view=rev
Log:
Merged revisions r1408513 r1408517 from tomcat/trunk:
For https://issues.apache.org/bugzilla/show_bug.cgi?id=53960
Review of r1402846, r1408157
- Correct typo in a field name.
- Remove call to extractUriElements() from processBody() method.
If someone needs the extractUriElements() method, one has to call it
explicitly. The method was made public.
So that
a) we do not waste time in 90% of tests where this info is not needed,
b) we do not waste time if the response is not HTML.
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1408513-1408517
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java?rev=1408520&r1=1408519&r2=1408520&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/SimpleHttpClient.java
Tue Nov 13 00:42:33 2012
@@ -93,7 +93,7 @@ public abstract class SimpleHttpClient {
private String redirectUri;
private String responseBody;
- private List<String> bodyUriElments = new ArrayList<String>();
+ private List<String> bodyUriElements = null;
protected void setPort(int thePort) {
port = thePort;
@@ -138,8 +138,19 @@ public abstract class SimpleHttpClient {
return responseBody;
}
+ /**
+ * Return opening tags of HTML elements that were extracted by the
+ * {@link #extractUriElements()} method.
+ *
+ * <p>
+ * Note, that {@link #extractUriElements()} method has to be called
+ * explicitly.
+ *
+ * @return List of HTML tags, accumulated by {@link #extractUriElements()}
+ * method, or {@code null} if the method has not been called yet.
+ */
public List<String> getResponseBodyUriElements() {
- return bodyUriElments;
+ return bodyUriElements;
}
public void setUseContentLength(boolean b) {
@@ -211,7 +222,7 @@ public abstract class SimpleHttpClient {
// clear any residual data before starting on this response
responseHeaders.clear();
responseBody = null;
- bodyUriElments.clear();
+ bodyUriElements.clear();
// Read the response status line
responseLine = readLine();
@@ -292,20 +303,29 @@ public abstract class SimpleHttpClient {
}
}
responseBody = builder.toString();
- extractUriElements(responseBody);
}
- /*
- * Scan an html body for useful html uri elements. If any are found,
- * then accumulate them. Test classes might not use them, but they
- * are collected anyway.
+ /**
+ * Scan the response body for opening tags of certain HTML elements
+ * (<a>, <form>). If any are found, then accumulate them.
+ *
+ * <p>
+ * Note: This method has the following limitations: a) It assumes that the
+ * response is HTML. b) It searches for lowercase tags only.
+ *
+ * @see #getResponseBodyUriElements()
*/
- private void extractUriElements(String body) {
- if (body.length() > 0) {
+ public void extractUriElements() {
+ bodyUriElements = new ArrayList<String>();
+ if (responseBody.length() > 0) {
int ix = 0;
- while ((ix = extractUriElement(body, ix, RESOURCE_TAG)) > 0){}
+ while ((ix = extractUriElement(responseBody, ix, RESOURCE_TAG)) >
0){
+ // loop
+ }
ix = 0;
- while ((ix = extractUriElement(body, ix, LOGIN_TAG)) > 0){}
+ while ((ix = extractUriElement(responseBody, ix, LOGIN_TAG)) > 0){
+ // loop
+ }
}
}
@@ -332,7 +352,7 @@ public abstract class SimpleHttpClient {
+ ELEMENT_TAIL + "]\nActual: [" + body + "]");
}
String element = body.substring(iStart, iEnd);
- bodyUriElments.add(element);
+ bodyUriElements.add(element);
iStart += element.length();
}
return iStart;
Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1408520&r1=1408519&r2=1408520&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Tue Nov 13 00:42:33 2012
@@ -57,8 +57,8 @@
<subsection name="Catalina">
<changelog>
<add>
- <bug>53960</bug>: Extensions to HttpClient test helper class. Patch by
- Brian Burch. (markt)
+ <bug>53960</bug>, <bug>54115</bug>: Extensions to HttpClient test
+ helper class. Patches by Brian Burch. (markt/kkolinko)
</add>
<fix>
<bug>53993</bug>: Avoid a possible NPE in the AccessLogValve when the
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]