morgand 01/09/03 00:02:04
Modified: latka/src/java/org/apache/commons/latka
AbstractReporter.java Latka.java
LatkaException.java
latka/src/java/org/apache/commons/latka/event
LatkaEventInfo.java LatkaEventListener.java
Log:
Javadocs
Revision Changes Path
1.7 +6 -1
jakarta-commons/latka/src/java/org/apache/commons/latka/AbstractReporter.java
Index: AbstractReporter.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/AbstractReporter.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- AbstractReporter.java 2001/08/23 16:24:25 1.6
+++ AbstractReporter.java 2001/09/03 07:02:04 1.7
@@ -69,7 +69,12 @@
import org.apache.log4j.Category;
-
+/**
+ * Needs docs.
+ *
+ * @author Rodney Waldhoff
+ * @author Morgan Delagrange
+ */
public abstract class AbstractReporter implements LatkaEventInfo {
protected Map _requestSucceeded = new HashMap();
1.15 +74 -27
jakarta-commons/latka/src/java/org/apache/commons/latka/Latka.java
Index: Latka.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/Latka.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- Latka.java 2001/08/28 15:50:31 1.14
+++ Latka.java 2001/09/03 07:02:04 1.15
@@ -59,7 +59,7 @@
package org.apache.commons.latka;
-import org.apache.commons.latka.event.*;
+import org.apache.commons.latka.event.LatkaEventInfo;
import org.apache.commons.latka.xml.SuiteHandler;
import org.apache.commons.latka.xml.XMLPreprocessor;
@@ -89,18 +89,22 @@
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-
-import org.apache.commons.httpclient.methods.GetMethod;
-
import org.apache.log4j.Category;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
/**
- * Latka class
+ * This is the primary class for executing Latka functional
+ * tests. The main(String aargs[]) class provides a convenient
+ * command-line interface for executing single tests. See the
+ * Latka documentation for details on command-line usage.
+ * There is also a webapp-based Latka interface.
+ *
+ * @see Suite
+ * @see LatkaProperties
+ *
+ * @author Morgan Delagrange
*/
public class Latka {
@@ -111,7 +115,7 @@
protected Properties _props = LatkaProperties.getProperties();
- public static String LATKA_USAGE = null;
+ protected static String LATKA_USAGE = null;
static {
StringBuffer buf = new StringBuffer();
buf.append("\n######################\n");
@@ -123,6 +127,18 @@
LATKA_USAGE = buf.toString();
}
+ /**
+ * Execute a single Latka test suite. The Latka event listner
+ * will receive all the events generated during the test.
+ * The Latka packages contain an implmentation of LatkaEventListener
+ * which can generate an XML report according to a standard
+ * DTD (see documentation).
+ *
+ * @param suite test suite to execute
+ * @param listener target for test events
+ *
+ * @see XMLReporter XML-based implementation of LatkaEventInfo
+ */
public void runTests(Suite suite, LatkaEventInfo listener) throws LatkaException {
InputSource source = null;
@@ -164,10 +180,24 @@
}
+ /**
+ * Set whether or not Latka will validate the XML in
+ * each test.
+ *
+ * @param isValidating whether or not to validate XML
+ */
public void setValidating(boolean isValidating) {
_isValidating = isValidating;
}
+ /**
+ * Use this method to log XML generated by the
+ * XMLReporter class.
+ *
+ * @param xml XML to be logged
+ * @throws IOException
+ * if the XML could not be written to the filesystem
+ */
protected void logXML(String xml) throws IOException {
String logProp = _props.getProperty("latka.writeLog");
@@ -187,6 +217,14 @@
fileWriter.close();
}
+ /**
+ * Transform the XML generated by the XMLReporter using
+ * the default stylesheet.
+ *
+ * @param xml XML generated by XMLReporter
+ * @return transformed report
+ * @throws LatkaException if the XML could not be transformed
+ */
public String transformXML(String xml)
throws LatkaException {
@@ -209,6 +247,17 @@
}
}
+ /**
+ * Processes the command line arguments, executes a single test.
+ * and processes the resulting report. Command line usage is
+ * described in the LATKA_USAGE constant.
+ *
+ * @param args arguments passed into the main(String[]) method
+ *
+ * @throws LatkaException
+ * if any problems are encountered during the execution
+ * of the tests
+ */
protected void runCommandLine(String args[]) throws LatkaException {
if (args.length < 1) {
@@ -254,35 +303,33 @@
}
System.out.println(transformXML(xml));
- }
-
- public void printWrappedExceptions(LatkaException e) {
- Exception wrappedException = e.getException();
-
- if (wrappedException != null) {
- System.out.println("Wraps exception:");
- e.printStackTrace();
- if (wrappedException instanceof SAXException) {
- Exception saxWrappedException =
- ((SAXException) wrappedException).getException();
- if (saxWrappedException != null) {
- System.out.println("Wraps exception:");
- e.printStackTrace();
- }
- }
-
+ if (listener.didSuiteSucceed() == false) {
+ // throw an exception, so the process will
+ // return as a failure
+ throw new LatkaException("SUITE FAILED");
}
}
+ /**
+ * Execute a single test suite via the command line
+ * interface. See the Latka documentation for detailed
+ * usage instructions. The Java process will return
+ * a 0 if all tests succeed and a 1 if any fail
+ * or there is an unrecoverable error in the test
+ * execution.
+ *
+ * @param args arguments containing the test suite location
+ * and any properties or property file references
+ */
public static void main (String args[]) {
-
+
Latka latka = new Latka();
try {
latka.runCommandLine(args);
} catch (LatkaException e) {
e.printStackTrace();
- latka.printWrappedExceptions(e);
+ LatkaException.printWrappedExceptions(e);
System.exit(1);
}
1.4 +21 -0
jakarta-commons/latka/src/java/org/apache/commons/latka/LatkaException.java
Index: LatkaException.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/LatkaException.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- LatkaException.java 2001/08/24 20:50:16 1.3
+++ LatkaException.java 2001/09/03 07:02:04 1.4
@@ -59,6 +59,8 @@
package org.apache.commons.latka;
+import org.xml.sax.SAXException;
+
public class LatkaException extends Exception {
protected Exception _wrappedException = null;
@@ -79,6 +81,25 @@
public Exception getException() {
return _wrappedException;
+ }
+
+ public static void printWrappedExceptions(LatkaException e) {
+ Exception wrappedException = e.getException();
+
+ if (wrappedException != null) {
+ System.out.println("Wraps exception:");
+ e.printStackTrace();
+
+ if (wrappedException instanceof SAXException) {
+ Exception saxWrappedException =
+ ((SAXException) wrappedException).getException();
+ if (saxWrappedException != null) {
+ System.out.println("Wraps exception:");
+ e.printStackTrace();
+ }
+ }
+
+ }
}
}
1.5 +21 -3
jakarta-commons/latka/src/java/org/apache/commons/latka/event/LatkaEventInfo.java
Index: LatkaEventInfo.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/event/LatkaEventInfo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LatkaEventInfo.java 2001/08/23 16:24:25 1.4
+++ LatkaEventInfo.java 2001/09/03 07:02:04 1.5
@@ -63,22 +63,40 @@
import org.apache.commons.latka.http.Session;
/**
+ * An extension to LatkaEventListener that stores the success or
+ * failure of all requests.
* All of these events should report true by default. They
* should only report false once an unsuccessful request
* is reported to the listener.
+ *
+ * @author Morgan Delagrange
*/
public interface LatkaEventInfo extends LatkaEventListener {
+ /**
+ * Check to see if a particular Request succeeded or failed.
+ *
+ * @param request the request to check for success or
+ * failure
+ * @return true if request succeeded
+ */
public boolean didRequestSucceed(Request request);
/**
+ * Check to see if a particular Session succeeded or failed.
* Once a request inside a session fails, the session itself
* is marked as a failure.
- *
- * @param session
- * @return
+ *
+ * @param session the session to check for success or
+ * failure
+ * @return true if all requests in the session succeeded
*/
public boolean didSessionSucceed(Session session);
+ /**
+ * Returns true if all Requests in the suite succeed.
+ *
+ * @return true if all Requests have succeeded
+ */
public boolean didSuiteSucceed();
}
1.5 +3 -5
jakarta-commons/latka/src/java/org/apache/commons/latka/event/LatkaEventListener.java
Index: LatkaEventListener.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/event/LatkaEventListener.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- LatkaEventListener.java 2001/08/23 16:24:25 1.4
+++ LatkaEventListener.java 2001/09/03 07:02:04 1.5
@@ -68,11 +68,9 @@
public void requestError(RequestEvent event);
/**
- * Invoke when all requests completed. It
- * is assumed that the listener is smart enough to track
- * whether or not any of the requests failed.
- *
- * @param event
+ * Invoke when all requests completed.
+ *
+ * @param event suite event
*/
public void suiteCompleted(SuiteEvent event);
}