Update of /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13341/src/net/sourceforge/jwebunit
Modified Files:
HttpUnitDialog.java WebTester.java WebTestCase.java
CompositeJWebUnitDialog.java IJWebUnitDialog.java
Log Message:
more incremental changes for jacobie integration.
Index: WebTester.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTester.java,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** WebTester.java 5 Mar 2005 05:48:14 -0000 1.54
--- WebTester.java 16 Mar 2005 05:56:01 -0000 1.55
***************
*** 11,14 ****
--- 11,15 ----
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
+ import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
import net.sourceforge.jwebunit.exception.UnableToSetFormException;
import net.sourceforge.jwebunit.util.ExceptionUtility;
***************
*** 28,32 ****
private IJWebUnitDialog dialog = null;
! private TestContext context = null;
private boolean tableEmptyCellCompression = true;
--- 29,33 ----
private IJWebUnitDialog dialog = null;
! private TestContext testContext = null;
private boolean tableEmptyCellCompression = true;
***************
*** 97,114 ****
/**
! * Provide access to test context.
*
* @return TestContext
*/
public TestContext getTestContext() {
! if (context == null) {
//defaulting to the original implementation.
! context = new TestContext();
}
! return context;
}
/**
! * Allows setting an external test context class that might be extended
from
* TestContext. Example: setTestContext(new CompanyATestContext());
*
--- 98,115 ----
/**
! * Provide access to test testContext.
*
* @return TestContext
*/
public TestContext getTestContext() {
! if (testContext == null) {
//defaulting to the original implementation.
! testContext = new TestContext();
}
! return testContext;
}
/**
! * Allows setting an external test testContext class that might be
extended from
* TestContext. Example: setTestContext(new CompanyATestContext());
*
***************
*** 118,122 ****
*/
public void setTestContext(TestContext aTestContext) {
! context = aTestContext;
}
--- 119,123 ----
*/
public void setTestContext(TestContext aTestContext) {
! testContext = aTestContext;
}
***************
*** 126,138 ****
* @param relativeURL
*/
! public void beginAt(String relativeURL) {
! String url = createUrl(relativeURL);
! IJWebUnitDialog theInitialDialog = getDialog();
! dialog = theInitialDialog.constructNewDialog(url, context);
}
! private String createUrl(String suffix) {
! suffix = suffix.startsWith("/") ? suffix.substring(1) : suffix;
! return getTestContext().getBaseUrl() + suffix;
}
--- 127,137 ----
* @param relativeURL
*/
! public void beginAt(String aRelativeURL) {
! getDialog().beginAt(createUrl(aRelativeURL), testContext);
}
! private String createUrl(String aSuffix) {
! aSuffix = aSuffix.startsWith("/") ? aSuffix.substring(1) :
aSuffix;
! return getTestContext().getBaseUrl() + aSuffix;
}
***************
*** 147,151 ****
public String getMessage(String key) {
String message = "";
! Locale locale = context.getLocale();
try {
message = ResourceBundle.getBundle(
--- 146,150 ----
public String getMessage(String key) {
String message = "";
! Locale locale = testContext.getLocale();
try {
message = ResourceBundle.getBundle(
***************
*** 158,162 ****
+
ExceptionUtility.stackTraceToString(e));
}
! return context.toEncodedString(message);
}
--- 157,161 ----
+
ExceptionUtility.stackTraceToString(e));
}
! return testContext.toEncodedString(message);
}
***************
*** 426,430 ****
Assert.assertEquals("Expected " +
tableSummaryOrId
+ " value at [" + i + "," + j +
"] not found.",
! expectedString, context
.toEncodedString(actualTableCellValues[i
+ startRow][j].trim()));
--- 425,429 ----
Assert.assertEquals("Expected " +
tableSummaryOrId
+ " value at [" + i + "," + j +
"] not found.",
! expectedString, testContext
.toEncodedString(actualTableCellValues[i
+ startRow][j].trim()));
***************
*** 1254,1262 ****
/**
! * Reset the current form.
*/
public void reset() {
getDialog().reset();
}
/**
--- 1253,1272 ----
/**
! * Reset the current Dialog
! * @see resetForm to reset a form in the response.
*/
public void reset() {
getDialog().reset();
}
+
+ /**
+ * Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
+ * the current form is established.
+ */
+ public void resetForm() {
+ getDialog().resetForm();
+ }
+
+
/**
***************
*** 1409,1414 ****
*/
public void gotoPage(String url) {
! getDialog().gotoPage(createUrl(url));
}
//Debug methods
--- 1419,1436 ----
*/
public void gotoPage(String url) {
! try {
! getDialog().gotoPage(createUrl(url));
! } catch (TestingEngineResponseException
aTestingEngineResponseException) {
!
handleTestingEngineResponseException(aTestingEngineResponseException);
! }
}
+
+ /**
+ * Allows easier coding of exceptions thrown by the testing engines.
+ */
+ private void
handleTestingEngineResponseException(TestingEngineResponseException
aTestingEngineResponseException) {
+ Assert.fail("Method failed due to Exception Thrown: " +
ExceptionUtility.stackTraceToString(aTestingEngineResponseException));
+ }
+
//Debug methods
Index: CompositeJWebUnitDialog.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/CompositeJWebUnitDialog.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** CompositeJWebUnitDialog.java 5 Mar 2005 17:51:46 -0000 1.3
--- CompositeJWebUnitDialog.java 16 Mar 2005 05:56:02 -0000 1.4
***************
*** 7,10 ****
--- 7,12 ----
import java.io.PrintStream;
+ import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
+
import org.w3c.dom.Element;
***************
*** 19,27 ****
* "NotSupportedException".
*
! * Intended uses: -Extend this when a specific engine doesn't care about
! * implementing all of the required methods.
*
* @author Nick Neuberger
- *
*/
public abstract class CompositeJWebUnitDialog implements IJWebUnitDialog {
--- 21,28 ----
* "NotSupportedException".
*
! * Intended uses: -Extend this when a specific engine doesn't care or just
can't
! * provide that functionality due to limitations.
*
* @author Nick Neuberger
*/
public abstract class CompositeJWebUnitDialog implements IJWebUnitDialog {
***************
*** 349,353 ****
throw new UnsupportedOperationException("reset");
}
!
/*
* (non-Javadoc)
--- 350,362 ----
throw new UnsupportedOperationException("reset");
}
!
! /**
! * Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
! * the current form is established.
! */
! public void resetForm() {
! throw new UnsupportedOperationException("resetForm");
! }
!
/*
* (non-Javadoc)
***************
*** 663,667 ****
* @see
net.sourceforge.jwebunit.IJWebUnitDialog#gotoPage(java.lang.String)
*/
! public void gotoPage(String url) {
throw new UnsupportedOperationException("gotoPage");
}
--- 672,676 ----
* @see
net.sourceforge.jwebunit.IJWebUnitDialog#gotoPage(java.lang.String)
*/
! public void gotoPage(String url) throws TestingEngineResponseException {
throw new UnsupportedOperationException("gotoPage");
}
Index: HttpUnitDialog.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/HttpUnitDialog.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** HttpUnitDialog.java 9 Mar 2005 06:10:33 -0000 1.50
--- HttpUnitDialog.java 16 Mar 2005 05:56:01 -0000 1.51
***************
*** 12,15 ****
--- 12,16 ----
import java.util.Map;
+ import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
import net.sourceforge.jwebunit.exception.UnableToSetFormException;
import net.sourceforge.jwebunit.util.ExceptionUtility;
***************
*** 52,56 ****
private WebClient wc;
private WebResponse resp;
! private TestContext context;
private WebForm form;
private Map multiselectMap = new HashMap();
--- 53,57 ----
private WebClient wc;
private WebResponse resp;
! private TestContext testContext;
private WebForm form;
private Map multiselectMap = new HashMap();
***************
*** 72,77 ****
* contains context information for the test client.
*/
! public HttpUnitDialog(String initialURL, TestContext context) {
! this.context = context;
initWebClient();
try {
--- 73,78 ----
* contains context information for the test client.
*/
! public void beginAt(String initialURL, TestContext context) {
! this.setTestContext(context);
initWebClient();
try {
***************
*** 82,91 ****
}
- public IJWebUnitDialog constructNewDialog(String url, TestContext
context) {
- return new HttpUnitDialog(url, context);
- }
-
private void initWebClient() {
! wc = (context != null) ? context.getWebClient() : new
WebConversation();
wc.addClientListener(new WebClientListener() {
--- 83,88 ----
}
private void initWebClient() {
! wc = (getTestContext() != null) ?
getTestContext().getWebClient() : new WebConversation();
wc.addClientListener(new WebClientListener() {
***************
*** 130,134 ****
WebWindow window = webWindows[i];
try {
! if
(context.toEncodedString(window.getCurrentPage().getTitle())
.equals(title)) { return window; }
} catch (SAXException e) {
--- 127,131 ----
WebWindow window = webWindows[i];
try {
! if
(getTestContext().toEncodedString(window.getCurrentPage().getTitle())
.equals(title)) { return window; }
} catch (SAXException e) {
***************
*** 146,150 ****
public String getResponseText() {
try {
! return context.toEncodedString(resp.getText());
} catch (IOException e) {
throw new
RuntimeException(ExceptionUtility.stackTraceToString(e));
--- 143,147 ----
public String getResponseText() {
try {
! return getTestContext().toEncodedString(resp.getText());
} catch (IOException e) {
throw new
RuntimeException(ExceptionUtility.stackTraceToString(e));
***************
*** 158,162 ****
public String getResponsePageTitle() {
try {
! return context.toEncodedString(resp.getTitle());
} catch (SAXException e) {
throw new
RuntimeException(ExceptionUtility.stackTraceToString(e));
--- 155,159 ----
public String getResponsePageTitle() {
try {
! return getTestContext().toEncodedString(resp.getTitle());
} catch (SAXException e) {
throw new
RuntimeException(ExceptionUtility.stackTraceToString(e));
***************
*** 544,548 ****
public boolean isTextInResponse(String text) {
try {
! return (context.toEncodedString(resp.getText()).indexOf(text) >=
0);
} catch (IOException e) {
throw new
RuntimeException(ExceptionUtility.stackTraceToString(e));
--- 541,545 ----
public boolean isTextInResponse(String text) {
try {
! return
(getTestContext().toEncodedString(resp.getText()).indexOf(text) >= 0);
} catch (IOException e) {
throw new
RuntimeException(ExceptionUtility.stackTraceToString(e));
***************
*** 611,615 ****
}
}
! return context.toEncodedString(nodeHtml);
}
--- 608,612 ----
}
}
! return getTestContext().toEncodedString(nodeHtml);
}
***************
*** 1202,1210 ****
* Patch sumbitted by Alex Chaffee.
*/
! public void gotoPage(String url) {
try {
resp = wc.getResponse(url);
} catch (Exception e) {
! throw new
RuntimeException(ExceptionUtility.stackTraceToString(e));
}
}
--- 1199,1207 ----
* Patch sumbitted by Alex Chaffee.
*/
! public void gotoPage(String url) throws TestingEngineResponseException {
try {
resp = wc.getResponse(url);
} catch (Exception e) {
! throw new
TestingEngineResponseException(ExceptionUtility.stackTraceToString(e));
}
}
***************
*** 1291,1293 ****
--- 1288,1305 ----
}
+ /**
+ * @param testContext The testContext to set.
+ */
+ public void setTestContext(TestContext testContext) {
+ this.testContext = testContext;
+ }
+
+ /**
+ * @return Returns the testContext.
+ */
+ public TestContext getTestContext() {
+ return testContext;
+ }
+
+
}
\ No newline at end of file
Index: WebTestCase.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTestCase.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** WebTestCase.java 9 Mar 2005 06:09:03 -0000 1.53
--- WebTestCase.java 16 Mar 2005 05:56:01 -0000 1.54
***************
*** 38,42 ****
//New implementation on choosing a testing engine (dialog).
! //setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_JACOBIE);
//setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTTPUNIT);
}
--- 38,42 ----
//New implementation on choosing a testing engine (dialog).
! setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_JACOBIE);
//setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTTPUNIT);
}
***************
*** 481,484 ****
--- 481,492 ----
}
+ /**
+ * Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
+ * the current form is established.
+ */
+ public void resetForm() {
+ getTester().resetForm();
+ }
+
public void clickLinkWithText(String linkText) {
getTester().clickLinkWithText(linkText);
Index: IJWebUnitDialog.java
===================================================================
RCS file:
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/IJWebUnitDialog.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** IJWebUnitDialog.java 9 Mar 2005 06:09:56 -0000 1.3
--- IJWebUnitDialog.java 16 Mar 2005 05:56:02 -0000 1.4
***************
*** 7,10 ****
--- 7,12 ----
import java.io.PrintStream;
+ import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
+
import org.w3c.dom.Element;
***************
*** 33,36 ****
--- 35,40 ----
public abstract IJWebUnitDialog constructNewDialog(String url,
TestContext context);
+ public abstract void beginAt(String aInitialURL, TestContext
aTestContext);
+
/**
* Return the window with the given name in the current conversation.
***************
*** 240,243 ****
--- 244,253 ----
/**
+ * Reset the current form. See [EMAIL PROTECTED] #getForm}for an
explanation of how
+ * the current form is established.
+ */
+ public abstract void resetForm();
+
+ /**
* Return true if a link is present in the current response containing
the specified text (note that HttpUnit uses
* contains rather than an exact match - if this is a problem consider
using ids on the links to uniquely identify
***************
*** 516,520 ****
* Patch sumbitted by Alex Chaffee.
*/
! public abstract void gotoPage(String url);
/**
--- 526,530 ----
* Patch sumbitted by Alex Chaffee.
*/
! public abstract void gotoPage(String url) throws
TestingEngineResponseException;
/**
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development