You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by js...@apache.org on 2004/07/27 00:13:08 UTC
svn commit: rev 30732 - in incubator/beehive/trunk: controls/test controls/test/src/driver/org/apache/beehive/controls/test/driver/context controls/test/src/driver/org/apache/beehive/controls/test/driver/instantiate controls/test/src/driver/org/apache/beehive/controls/test/driver/property controls/test/src/junit/org/apache/beehive/controls/test/java/context controls/test/src/junit/org/apache/beehive/controls/test/java/property controls/test/tools controls/test/tools/lib controls/test/tools/milton controls/test/tools/milton/src controls/test/tools/milton/src/org controls/test/tools/milton/src/org/apache controls/test/tools/milton/src/org/apache/beehive controls/test/tools/milton/src/org/apache/beehive/test controls/test/tools/milton/src/org/apache/beehive/test/tools controls/test/tools/milton/src/org/apache/beehive/test/tools/milton controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/client controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit controls/test/tools/peanut controls/test/tools/peanut/src external/httpunit external/junit tools
Author: jsong
Date: Mon Jul 26 15:13:07 2004
New Revision: 30732
Added:
incubator/beehive/trunk/controls/test/tools/build.xml
incubator/beehive/trunk/controls/test/tools/milton/
incubator/beehive/trunk/controls/test/tools/milton/build.xml
incubator/beehive/trunk/controls/test/tools/milton/src/
incubator/beehive/trunk/controls/test/tools/milton/src/org/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/client/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/client/TestContext.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/AbortTestException.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/FailTestException.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/HtmlReportTestCase.java
incubator/beehive/trunk/controls/test/tools/peanut/
- copied from rev 30725, incubator/beehive/trunk/tools/peanut/
incubator/beehive/trunk/controls/test/tools/peanut/build.xml
- copied, changed from rev 30731, incubator/beehive/trunk/tools/peanut/build.xml
incubator/beehive/trunk/controls/test/tools/peanut/peanut-root.xml
- copied unchanged from rev 30731, incubator/beehive/trunk/tools/peanut/peanut-root.xml
incubator/beehive/trunk/controls/test/tools/peanut/src/
- copied from rev 30731, incubator/beehive/trunk/tools/peanut/src/
incubator/beehive/trunk/external/httpunit/
incubator/beehive/trunk/external/httpunit/httpunit.jar (contents, props changed)
incubator/beehive/trunk/external/httpunit/nekohtml.jar (contents, props changed)
incubator/beehive/trunk/external/httpunit/xercesImpl.jar (contents, props changed)
Removed:
incubator/beehive/trunk/controls/test/tools/lib/
incubator/beehive/trunk/controls/test/tools/peanut/junit.jar
incubator/beehive/trunk/tools/
Modified:
incubator/beehive/trunk/controls/test/build.xml
incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/context/DriveBaseContextBean.java
incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/instantiate/DriveHelloControl.java
incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/property/DrivePropsBeans.java
incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/context/ContextTest.java
incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/property/PropTest.java
incubator/beehive/trunk/external/junit/junit.jar
Log:
Adding Changes Proposed by Zach Smith (zsmith@bea.com)
======================================================
1. Update external/junit/junit.jar to 3.8.1 (latest). I have run the
tests using the new version and saw no problems. Controls Test Tools
have a dependecy on interfaces available in the newest version.
2. Move $BEEHIVE_HOME/tools/* to $BEEHIVE_HOME/controls/test/tools
All of the files in the root tool folder are controls specific (at this point)
and having them at the root is confusing.
3. Remove $BEEHIVE_HOME/controls/test/tools/lib/milton.jar and add the source
code. Milton is a testing framework that we have used at BEA and the source
instead of the jar should have been part of the original checkin
4. Add controls/test/tools/build.xml file
5. Update tests and tools to reference peanut and milton from their
new packages and locations in the tree.
6. Add httpunit and supporting jars to external/httpunit/.
Modified: incubator/beehive/trunk/controls/test/build.xml
==============================================================================
--- incubator/beehive/trunk/controls/test/build.xml (original)
+++ incubator/beehive/trunk/controls/test/build.xml Mon Jul 26 15:13:07 2004
@@ -103,7 +103,7 @@
failonerror="true"
>
<classpath>
- <pathelement location="tools/lib/milton.jar"/>
+ <pathelement location="tools/milton/milton.jar"/>
</classpath>
</javac>
<property name="_build.test.drivers.ran" value="true"/>
@@ -120,14 +120,13 @@
verbose="false"
failonerror="true">
<classpath>
- <pathelement location="tools/lib/milton.jar"/>
+ <pathelement location="tools/milton/milton.jar"/>
<pathelement path="${build.tests.driver}"/>
</classpath>
</javac>
<property name="_build.java.tests.ran" value="true"/>
</target>
-
<target name="test" depends="tests"/>
<target name="tests" >
@@ -145,13 +144,13 @@
<!-- =============================================== -->
<property name="junit.src.dir" value="${basedir}/src/junit"/>
- <property name="peanut.home" location="../../tools/peanut"/>
+ <property name="peanut.home" location="tools/peanut"/>
<!-- TODO: relative pathname (should be based on ${beehive.home}, or ${tools.home, or something similar -->
- <property name="peanut.jar" location="../../tools/peanut/peanut.jar"/>
+ <property name="peanut.jar" location="${peanut.home}/peanut.jar"/>
<taskdef name="peanut"
@@ -174,7 +173,7 @@
<pathelement path="${velocitydep14}.jar"/>
<pathelement path="../build/jars/controls.jar"/>
<pathelement location="${build.beans}" />
- <pathelement location="tools/lib/milton.jar"/>
+ <pathelement location="tools/milton/milton.jar"/>
<pathelement path="${build.tests.driver}"/>
<pathelement location="${build.tests}" />
<pathelement location="${peanut.jar}" />
Modified: incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/context/DriveBaseContextBean.java
==============================================================================
--- incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/context/DriveBaseContextBean.java (original)
+++ incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/context/DriveBaseContextBean.java Mon Jul 26 15:13:07 2004
@@ -1,7 +1,7 @@
package org.apache.beehive.controls.test.driver.context;
import java.util.Arrays;
-import com.bea.milton.common.Report;
+import org.apache.beehive.test.tools.milton.common.Report;
import org.apache.beehive.controls.test.controls.util.TestBeanContext;
import org.apache.beehive.controls.test.controls.context.BaseContextBean;
Modified: incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/instantiate/DriveHelloControl.java
==============================================================================
--- incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/instantiate/DriveHelloControl.java (original)
+++ incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/instantiate/DriveHelloControl.java Mon Jul 26 15:13:07 2004
@@ -1,6 +1,6 @@
package org.apache.beehive.controls.test.driver.instantiate;
-import com.bea.milton.common.Report;
+import org.apache.beehive.test.tools.milton.common.Report;
import org.apache.beehive.controls.test.controls.instantiate.HelloControlBean;
/* This class contains the logic to test HelloControlBean
Modified: incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/property/DrivePropsBeans.java
==============================================================================
--- incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/property/DrivePropsBeans.java (original)
+++ incubator/beehive/trunk/controls/test/src/driver/org/apache/beehive/controls/test/driver/property/DrivePropsBeans.java Mon Jul 26 15:13:07 2004
@@ -1,6 +1,6 @@
package org.apache.beehive.controls.test.driver.property;
-import com.bea.milton.common.Report;
+import org.apache.beehive.test.tools.milton.common.Report;
import java.beans.Beans;
Modified: incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/context/ContextTest.java
==============================================================================
--- incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/context/ContextTest.java (original)
+++ incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/context/ContextTest.java Mon Jul 26 15:13:07 2004
@@ -8,7 +8,7 @@
import org.apache.beehive.controls.test.controls.context.BaseContextBean;
import org.apache.beehive.controls.test.driver.context.DriveBaseContextBean;
-import com.bea.milton.common.Report;
+import org.apache.beehive.test.tools.milton.common.Report;
public class ContextTest extends TestCase
Modified: incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/property/PropTest.java
==============================================================================
--- incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/property/PropTest.java (original)
+++ incubator/beehive/trunk/controls/test/src/junit/org/apache/beehive/controls/test/java/property/PropTest.java Mon Jul 26 15:13:07 2004
@@ -13,7 +13,7 @@
import org.apache.beehive.controls.test.driver.property.DrivePropsBeans;
-import com.bea.milton.common.Report;
+import org.apache.beehive.test.tools.milton.common.Report;
public class PropTest extends TestCase
{
Added: incubator/beehive/trunk/controls/test/tools/build.xml
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/build.xml Mon Jul 26 15:13:07 2004
@@ -0,0 +1,33 @@
+<project name="beehive-tools" default="deploy" basedir=".">
+
+
+ <property environment="env"/>
+
+ <property name="peanut.dir" value="${basedir}/peanut"/>
+ <property name="milton.dir" value="${basedir}/milton"/>
+
+ <target name="usage">
+ <echo>
+deploy builds tools
+clean deletes tools
+redeploy rebuilds tools
+ </echo>
+ </target>
+
+ <target name="redeploy" depends="clean,deploy"/>
+ <target name="deploy" depends="deploy_peanut,deploy_milton"/>
+ <target name="deploy_peanut">
+ <ant dir="peanut" target="build_peanut"/>
+ </target>
+ <target name="deploy_milton">
+ <ant dir="milton" target="deploy"/>
+ </target>
+ <target name="clean" depends="clean_peanut,clean_milton"/>
+ <target name="clean_peanut">
+ <ant dir="peanut" target="clean_peanut"/>
+ </target>
+ <target name="clean_milton">
+ <ant dir="milton" target="clean"/>
+ </target>
+
+</project>
Added: incubator/beehive/trunk/controls/test/tools/milton/build.xml
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/milton/build.xml Mon Jul 26 15:13:07 2004
@@ -0,0 +1,51 @@
+<project name="beehive-tools-milton" default="deploy" basedir=".">
+
+
+ <property environment="env"/>
+
+ <property name="src.dir" value="${basedir}/src"/>
+ <property name="build.dir" value="${basedir}/build"/>
+ <property name="milton.jar" value="milton.jar"/>
+
+ <property name="junit.jar" location="../../../../external/junit/junit.jar"/>
+ <property name="httpunit.jar" location="../../../../external/httpunit/httpunit.jar"/>
+
+ <path id="milton.build.classpath">
+ <pathelement location="${junit.jar}"/>
+ <pathelement location="${httpunit.jar}"/>
+ </path>
+
+ <target name="usage">
+ <echo>
+deploy builds milton.jar
+clean deletes milton build artifacts
+redeploy rebuilds milton.jar
+ </echo>
+ </target>
+
+ <target name="redeploy" depends="clean,deploy"/>
+
+ <!-- ========================= -->
+ <!-- builds milton and packages it into a jar -->
+ <!-- ========================= -->
+ <target name="deploy">
+ <mkdir dir="${build.dir}"/>
+ <javac srcdir="${src.dir}"
+ destdir="${build.dir}"
+ failonerror="true"
+ verbose="false"
+ deprecation="true"
+ classpathref="milton.build.classpath"
+ />
+ <jar basedir="${build.dir}" destfile="${milton.jar}"/>
+ </target>
+
+ <!-- ========================= -->
+ <!-- Cleans build artifacts -->
+ <!-- ========================= -->
+ <target name="clean">
+ <delete dir="${build.dir}"/>
+ <delete file="${milton.jar}"/>
+ </target>
+
+</project>
Added: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/client/TestContext.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/client/TestContext.java Mon Jul 26 15:13:07 2004
@@ -0,0 +1,51 @@
+package org.apache.beehive.test.tools.milton.client;
+
+import java.util.Properties;
+
+/**
+ * A (static) set of Properties describing the test environment.
+ */
+public class TestContext
+{
+ private static final Properties _properties =
+ (Properties)System.getProperties().clone();
+
+ private TestContext()
+ {
+ }
+
+ public static String getProperty(String key)
+ {
+ return _properties.getProperty(key);
+ }
+
+ public static String getProperty(String key, String defaultValue)
+ {
+ return _properties.getProperty(key, defaultValue);
+ }
+
+ public static int getPropertyAsInt(String key, String defaultValue)
+ {
+ String prop = _properties.getProperty(key, defaultValue);
+ if (prop == null)
+ return -1;
+
+ try {
+ return Integer.parseInt(prop);
+ }
+ catch (NumberFormatException e) {
+ return -1;
+ }
+ }
+
+ public static void setProperty(String key, String value)
+ {
+ _properties.setProperty(key, value);
+ }
+
+ public static void setProperty(String key, int value)
+ {
+ _properties.setProperty(key, String.valueOf(value));
+ }
+
+}
Added: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/common/Report.java Mon Jul 26 15:13:07 2004
@@ -0,0 +1,125 @@
+package org.apache.beehive.test.tools.milton.common;
+
+import java.io.PrintStream;
+import java.io.ByteArrayOutputStream;
+
+/**
+* Report class used for storing the results of a test. This object is
+* referenced by testResults.jsp (or custom report page) which can displays
+* the results stored in the Result object.
+*/
+public class Report implements java.io.Serializable
+{
+ static final long serialVersionUID = 1L;
+
+ public static final String PASS = "PASS";
+ public static final String FAIL = "FAIL";
+ public static final String ABORT = "ABORT";
+
+ // For PageFlow action annotations
+ public static final String KEY = "milton";
+ public static final String RESULTS = "miltonResults";
+ public static final String RESULTSJSP = "/resources/milton/jsp/miltonResults.jsp";
+
+ // For JSP and client side parsing of results
+ public static final String RESULT_TABLE_ID = "milton.results.table";
+ public static final String STATUS_ID = "milton.status";
+ public static final String MESSAGE_ID = "milton.message";
+ public static final String EXCEPTION_ID = "milton.exception";
+
+ private String status;
+ private String message;
+ private String exceptionStack;
+
+ public Report()
+ {
+ this(Report.FAIL);
+ }
+
+ public Report(String p_status)
+ {
+ this(p_status, "", null);
+ }
+
+ public Report(boolean p_status)
+ {
+ this(p_status == true ? Report.PASS : Report.FAIL);
+ }
+ public Report(String p_status, String p_message)
+ {
+ this(p_status, p_message, null);
+ }
+
+ public Report(String p_status, String p_message, Throwable p_stack)
+ {
+ setStatus(p_status);
+ setMessage(p_message);
+ setExceptionStack(p_stack);
+ }
+
+ public String getStatus()
+ {
+ return this.status;
+ }
+
+ public boolean getStatusAsBoolean()
+ {
+ return this.status == Report.PASS ? true : false;
+ }
+
+ public String getMessage()
+ {
+ return this.message;
+ }
+
+ public String getExceptionStack()
+ {
+ return this.exceptionStack;
+ }
+
+ public void setStatus(String p_status)
+ {
+ if (null == p_status)
+ throw new IllegalArgumentException("Cannot set status to null");
+
+ if (! Report.PASS.equals(p_status) &&
+ ! Report.FAIL.equals(p_status) &&
+ ! Report.ABORT.equals(p_status))
+ throw new IllegalArgumentException("Invalid Status: " + p_status +
+ " Valid Status: PASS|FAIL|ABORT");
+ this.status = p_status;
+ }
+
+ public void setStatus(boolean p_status)
+ {
+ setStatus(p_status == true ? Report.PASS : Report.FAIL);
+ }
+
+ public void setMessage(String p_message)
+ {
+ this.message = p_message == null ? "" : p_message;
+ }
+
+ public void addMessage(String p_message)
+ {
+ this.message += "[( " + p_message + " )]";
+ }
+
+ public void setExceptionStack(Throwable e)
+ {
+ if (null == e) {
+ this.exceptionStack = "";
+ }
+ else {
+ ByteArrayOutputStream ostr = new ByteArrayOutputStream();
+ e.printStackTrace(new PrintStream(ostr));
+
+ setExceptionStack(ostr.toString());
+ }
+ }
+
+ public void setExceptionStack(String es)
+ {
+ this.exceptionStack = es;
+ }
+}
Added: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/AbortTestException.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/AbortTestException.java Mon Jul 26 15:13:07 2004
@@ -0,0 +1,17 @@
+package org.apache.beehive.test.tools.milton.junit;
+
+
+public class AbortTestException extends RuntimeException
+{
+ public AbortTestException() {
+ super();
+ }
+
+ public AbortTestException(String msg) {
+ super(msg);
+ }
+
+ public AbortTestException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
Added: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/FailTestException.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/FailTestException.java Mon Jul 26 15:13:07 2004
@@ -0,0 +1,16 @@
+package org.apache.beehive.test.tools.milton.junit;
+
+public class FailTestException extends RuntimeException
+{
+ public FailTestException() {
+ super();
+ }
+
+ public FailTestException(String msg) {
+ super(msg);
+ }
+
+ public FailTestException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+}
Added: incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/HtmlReportTestCase.java
==============================================================================
--- (empty file)
+++ incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/junit/HtmlReportTestCase.java Mon Jul 26 15:13:07 2004
@@ -0,0 +1,208 @@
+package org.apache.beehive.test.tools.milton.junit;
+
+import junit.framework.TestCase;
+
+import com.meterware.httpunit.WebLink;
+import com.meterware.httpunit.WebResponse;
+import com.meterware.httpunit.WebRequest;
+import com.meterware.httpunit.WebTable;
+import com.meterware.httpunit.TableCell;
+import com.meterware.httpunit.WebConversation;
+
+import org.apache.beehive.test.tools.milton.junit.AbortTestException;
+import org.apache.beehive.test.tools.milton.junit.FailTestException;
+import org.apache.beehive.test.tools.milton.client.TestContext;
+import org.apache.beehive.test.tools.milton.common.Report;
+
+
+public class HtmlReportTestCase extends TestCase
+{
+ private static final String HTTP_PREFIX = "http://";
+ private static final String HTTPS_PREFIX = "https://";
+
+ private String urlPrefix = null;
+
+ public HtmlReportTestCase(String name)
+ {
+ super(name);
+ this.urlPrefix = HTTP_PREFIX + TestContext.getProperty("HOSTNAME");
+ }
+
+ public String getUrlPrefix()
+ {
+ return this.urlPrefix;
+ }
+
+ public void setUrlPrefix(String p_urlPrefix)
+ {
+ if (null == p_urlPrefix)
+ throw new IllegalArgumentException("Cannot set null URI PRefix");
+
+ if (! p_urlPrefix.startsWith(HTTP_PREFIX) ||
+ ! p_urlPrefix.startsWith(HTTPS_PREFIX)) {
+ throw new IllegalArgumentException("URL Prefix must have a valid " +
+ "protocol: " + HTTP_PREFIX +
+ " or " + HTTPS_PREFIX + ": " +
+ p_urlPrefix);
+ }
+
+ this.urlPrefix = p_urlPrefix;
+ }
+
+ public void assertReport(String p_url)
+ throws Exception
+ {
+ assertReport(new WebConversation(), p_url);
+ }
+
+ public void assertReport(String p_url, String p_link)
+ throws Exception
+ {
+ assertReport(new WebConversation(), p_url, p_link);
+ }
+
+ public void assertReport(WebConversation p_wc, String p_url)
+ throws Exception
+ {
+ assertReport(p_wc, p_url, (String)null);
+ }
+
+ public void assertReport(WebConversation p_wc, String p_url, String p_link)
+ throws Exception
+ {
+ String url = null;
+ WebResponse wr = null;
+
+ if (null == p_wc || null == p_url)
+ throw new IllegalArgumentException("WebConversation and URL " +
+ "cannot be null");
+
+ // find out if user has passed an entire url complete with protocol
+ // or if we need to prepend this.urlPrefix
+ if (p_url.startsWith(HTTP_PREFIX) || p_url.startsWith(HTTPS_PREFIX))
+ url = p_url;
+ else {
+ if (p_url.startsWith("/"))
+ url = getUrlPrefix() + p_url;
+ else
+ url = getUrlPrefix() + "/" + p_url;
+ }
+
+ try {
+ wr = p_wc.getResponse(url);
+ }
+ catch(java.net.MalformedURLException mue) {
+ throw new AbortTestException("Error getting WebResponse", mue);
+ }
+ catch(java.io.IOException ioe) {
+ throw new AbortTestException("Error getting WebResponse", ioe);
+ }
+ catch(org.xml.sax.SAXException saxe) {
+ throw new AbortTestException("Error getting WebResponse", saxe);
+ }
+
+ if (null != p_link) {
+ clickLink(wr, p_link);
+ assertReport(p_wc.getCurrentPage());
+ }
+ else {
+ assertReport(wr);
+ }
+ }
+
+ public void assertReport(WebRequest p_wr)
+ throws Exception
+ {
+ assertReport(new WebConversation(), p_wr);
+ }
+
+ public void assertReport(WebConversation wc, WebRequest wr)
+ throws Exception
+ {
+ assertReport(wc.getResponse(wr));
+ }
+
+ public void assertReport(WebResponse p_wr)
+ throws Exception
+ {
+
+ if (null == p_wr)
+ throw new AbortTestException("WebResponse cannot be null");
+
+ if (p_wr.getResponseCode() != 200)
+ throw new AbortTestException("Bad HTTP Response Code: " +
+ p_wr.getResponseCode());
+
+ String status = null;
+ String message = null;
+ String exception = null;
+
+ WebTable wt = p_wr.getTableWithID(Report.RESULT_TABLE_ID);
+
+ if (null == wt)
+ throw new AbortTestException("Table not found: \n" +
+ p_wr.getText());
+
+ TableCell statusCell = wt.getTableCellWithID(Report.STATUS_ID);
+ TableCell messageCell = wt.getTableCellWithID(Report.MESSAGE_ID);
+ TableCell exceptionCell = wt.getTableCellWithID(Report.EXCEPTION_ID);
+
+ if (null != statusCell)
+ status = statusCell.asText().trim();
+
+ if (null != messageCell)
+ message = messageCell.asText().trim();
+
+ if (null != exceptionCell)
+ exception = exceptionCell.asText().trim();
+
+ // Print Messages && Exceptions
+ if (null != message && ! message.equals(""))
+ System.out.println("Message: " + message);
+
+ if (null != exception && ! exception.equals(""))
+ System.out.println("Exception: " + exception);
+
+ // Check the status and report accordingly
+ if (null == status || status.equals(""))
+ throw new AbortTestException("No Status Found!");
+
+ // If it does not PASS, check for other valid statuses or ABORT
+ if (! status.equals(Report.PASS)) {
+
+ if (status.equals(Report.ABORT))
+ throw new AbortTestException("Abort Status Detected: \n" +
+ p_wr.getText());
+ else if (status.equals(Report.FAIL))
+ throw new FailTestException("Failure Status Detected: \n" +
+ p_wr.getText());
+ else
+ throw new AbortTestException("Invalid Status Was Found: \n" +
+ p_wr.getText());
+ }
+ }
+
+ private void clickLink (WebResponse p_wr, String p_link)
+ {
+ WebLink webLink = null;
+
+ try {
+ webLink = p_wr.getLinkWith(p_link);
+ webLink.click();
+ }
+ catch (NullPointerException npe) {
+ throw new AbortTestException("Link '" + p_link + "' not found in " +
+ p_wr.getURL(), npe);
+ }
+ catch(java.io.IOException ioe) {
+ throw new AbortTestException("Error clicking link: " +
+ p_link, ioe);
+ }
+ catch(org.xml.sax.SAXException saxe) {
+ throw new AbortTestException("Error clicking link: " +
+ p_link, saxe);
+ }
+
+ }
+}
+
Copied: incubator/beehive/trunk/controls/test/tools/peanut/build.xml (from rev 30731, incubator/beehive/trunk/tools/peanut/build.xml)
==============================================================================
--- incubator/beehive/trunk/tools/peanut/build.xml (original)
+++ incubator/beehive/trunk/controls/test/tools/peanut/build.xml Mon Jul 26 15:13:07 2004
@@ -1,4 +1,4 @@
-<project name="beehive-tools" default="usage" basedir=".">
+<project name="beehive-tools-peanut" default="usage" basedir=".">
<property environment="env"/>
@@ -8,7 +8,7 @@
<property name="build.dir" value="${basedir}/build"/>
<property name="peanut.jar" value="peanut.jar"/>
<!-- TODO: fix this absolute pathname -->
- <property name="junit.jar" location="junit.jar"/>
+ <property name="junit.jar" location="../../../../external/junit/junit.jar"/>
<path id="peanut.build.classpath">
<pathelement location="${junit.jar}"/>
@@ -52,4 +52,4 @@
<delete file="${peanut.jar}"/>
</target>
-</project>
\ No newline at end of file
+</project>
Added: incubator/beehive/trunk/external/httpunit/httpunit.jar
==============================================================================
Binary file. No diff available.
Added: incubator/beehive/trunk/external/httpunit/nekohtml.jar
==============================================================================
Binary file. No diff available.
Added: incubator/beehive/trunk/external/httpunit/xercesImpl.jar
==============================================================================
Binary file. No diff available.
Modified: incubator/beehive/trunk/external/junit/junit.jar
==============================================================================
Binary files. No diff available.