Update of /cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18121/src/net/sourceforge/jwebunit

Modified Files:
        HttpUnitDialog.java WebTester.java WebTestCase.java 
Removed Files:
        UnableToSetFormException.java 
Log Message:
merged jacobie integration changes from JACOBIE branch to HEAD.

Index: WebTester.java
===================================================================
RCS file: 
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTester.java,v
retrieving revision 1.53
retrieving revision 1.54
diff -C2 -d -r1.53 -r1.54
*** WebTester.java      30 Sep 2004 16:11:57 -0000      1.53
--- WebTester.java      5 Mar 2005 05:48:14 -0000       1.54
***************
*** 11,14 ****
--- 11,15 ----
  import junit.framework.Assert;
  import junit.framework.AssertionFailedError;
+ import net.sourceforge.jwebunit.exception.UnableToSetFormException;
  import net.sourceforge.jwebunit.util.ExceptionUtility;
  
***************
*** 25,1291 ****
   */
  public class WebTester {
[...2768 lines suppressed...]
!        * 
!        * @param testingEngineRegistry
!        *            The testingEngineRegistry to set.
!        */
!       protected void setTestingEngineRegistry(
!                       TestingEngineRegistry testingEngineRegistry) {
!               this.testingEngineRegistry = testingEngineRegistry;
!       }
! 
!       /**
!        * Gets the Testing Engine Registry.
!        * 
!        * @return Returns the testingEngineRegistry.
!        */
!       public TestingEngineRegistry getTestingEngineRegistry() {
!               return testingEngineRegistry;
!       }
  
  }
\ No newline at end of file

Index: HttpUnitDialog.java
===================================================================
RCS file: 
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/HttpUnitDialog.java,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** HttpUnitDialog.java 27 Sep 2004 17:10:22 -0000      1.48
--- HttpUnitDialog.java 5 Mar 2005 05:48:13 -0000       1.49
***************
*** 5,15 ****
  package net.sourceforge.jwebunit;
  
- import com.meterware.httpunit.*;
- import com.meterware.httpunit.cookies.CookieJar;
- 
- import net.sourceforge.jwebunit.util.ExceptionUtility;
- import org.w3c.dom.*;
- import org.xml.sax.SAXException;
- 
  import java.io.IOException;
  import java.io.PrintStream;
--- 5,8 ----
***************
*** 19,86 ****
  import java.util.Map;
  
  /**
!  * Acts as the wrapper for HttpUnit access. A dialog is initialized with a 
given
!  * URL, and maintains conversational state as the dialog progresses through 
link
!  * navigation, form submission, etc. Public access is provided for wrappered
!  * HttpUnit objects.
   * 
   * @author Jim Weaver
   * @author Wilkes Joiner
   */
! public class HttpUnitDialog {
! 
!     private WebClient wc;
! 
!     private WebResponse resp;
! 
!     private TestContext context;
! 
!     private WebForm form;
  
!     private Map multiselectMap = new HashMap();
  
!     /**
!      * Begin a dialog with an initial URL and test client context.
!      * 
!      * @param initialURL
!      *            absolute url at which to begin dialog.
!      * @param context
!      *            contains context information for the test client.
!      */
!     public HttpUnitDialog(String initialURL, TestContext context) {
!         this.context = context;
!         initWebClient();
!         try {
!             resp = wc.getResponse(new GetMethodWebRequest(initialURL));
!         } catch (Exception e) {
!             throw new 
RuntimeException(ExceptionUtility.stackTraceToString(e));
!         }
      }
  
!     private void initWebClient() {
!         wc = (context != null) ? context.getWebClient() : new 
WebConversation();
! 
!         wc.addClientListener(new WebClientListener() {
! 
!             public void requestSent(WebClient webClient, WebRequest 
webRequest) {
!             }
  
!             public void responseReceived(WebClient webClient,
!                     WebResponse webResponse) {
!                 //                    System.out.println("**** Recieved 
notification of response
!                 // receipt ****");
!                 //                    
System.out.println(webResponse.getContentType());
!                 //                    if (webResponse.isHTML()) {
!                 //                            resp = webResponse;
!                 //                    }
!                 resp = webClient.getCurrentPage();
!                 //                            dumpResponse(System.out);
!                 //                            try {
!                 //                                    System.out.println("New 
Response:\n"
!                 //                                                    + 
webResponse.getText());
!                 //                            } catch (Exception e) {
!                 //                                    // TODO: handle 
exception
!                 //                            }
!                 //                            
System.out.println("****************************************");
                  form = null;
                  multiselectMap.clear();
--- 12,98 ----
  import java.util.Map;
  
+ import net.sourceforge.jwebunit.exception.UnableToSetFormException;
+ import net.sourceforge.jwebunit.util.ExceptionUtility;
+ 
+ import org.w3c.dom.Attr;
+ import org.w3c.dom.Document;
+ import org.w3c.dom.Element;
+ import org.w3c.dom.NamedNodeMap;
+ import org.w3c.dom.Node;
+ import org.w3c.dom.NodeList;
+ import org.w3c.dom.Text;
+ import org.xml.sax.SAXException;
+ 
+ import com.meterware.httpunit.Button;
+ import com.meterware.httpunit.GetMethodWebRequest;
+ import com.meterware.httpunit.HTMLElementPredicate;
+ import com.meterware.httpunit.SubmitButton;
+ import com.meterware.httpunit.TableCell;
+ import com.meterware.httpunit.WebClient;
+ import com.meterware.httpunit.WebClientListener;
+ import com.meterware.httpunit.WebConversation;
+ import com.meterware.httpunit.WebForm;
+ import com.meterware.httpunit.WebLink;
+ import com.meterware.httpunit.WebRequest;
+ import com.meterware.httpunit.WebResponse;
+ import com.meterware.httpunit.WebTable;
+ import com.meterware.httpunit.WebWindow;
+ import com.meterware.httpunit.cookies.CookieJar;
+ 
  /**
!  * Acts as the wrapper for HttpUnit access. A dialog is initialized with a 
given URL, and maintains conversational
!  * state as the dialog progresses through link navigation, form submission, 
etc. Public access is provided for
!  * wrappered HttpUnit objects.
   * 
   * @author Jim Weaver
   * @author Wilkes Joiner
   */
! public class HttpUnitDialog extends CompositeJWebUnitDialog {
!       
!       private WebClient wc;
!       private WebResponse resp;
!       private TestContext context;
!       private WebForm form;
!       private Map multiselectMap = new HashMap();
  
!       /**
!        * Constructor for creating a default testing engine for jWebUnit.
!        * If the dialog is not specified then jWebUnit will default to using 
httpunit.
!        */
!       public HttpUnitDialog() {
!           super();
!       }
!       
!       /**
!        * Begin a dialog with an initial URL and test client context.
!        * 
!        * @param initialURL
!        *            absolute url at which to begin dialog.
!        * @param context
!        *            contains context information for the test client.
!        */
!       public HttpUnitDialog(String initialURL, TestContext context) {
!               this.context = context;
!               initWebClient();
!               try {
!                       resp = wc.getResponse(new 
GetMethodWebRequest(initialURL));
!               } catch (Exception e) {
!                       throw new 
RuntimeException(ExceptionUtility.stackTraceToString(e));
!               }
!       }
  
!     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() {
!                       public void requestSent(WebClient webClient, WebRequest 
webRequest) {
!                       }
  
!             public void responseReceived(WebClient webClient, WebResponse 
webResponse) {
!                               resp = webClient.getCurrentPage();
                  form = null;
                  multiselectMap.clear();
***************
*** 88,100 ****
          });
      }
  
!     /**
!      * Return the window with the given name in the current conversation.
!      * 
!      * @param windowName
!      */
!     public WebWindow getWindow(String windowName) {
!         return wc.getOpenWindow(windowName);
!     }
  
      /**
--- 100,124 ----
          });
      }
+       /**
+        * Return the window with the given name in the current conversation.
+        * 
+        * @param windowName
+        */
+       public WebWindow getWindow(String windowName) {
+               return wc.getOpenWindow(windowName);
+       }
+       /**
+        * Return the HttpUnit WebClient object for this dialog.
+        */
+       public WebClient getWebClient() {
+               return wc;
+       }
  
!       /**
!        * Return the HttpUnit object which represents the current response.
!        */
!       public WebResponse getResponse() {
!               return resp;
!       }
  
      /**
***************
*** 117,134 ****
  
      /**
-      * Return the HttpUnit WebClient object for this dialog.
-      */
-     public WebClient getWebClient() {
-         return wc;
-     }
- 
-     /**
-      * Return the HttpUnit object which represents the current response.
-      */
-     public WebResponse getResponse() {
-         return resp;
-     }
- 
-     /**
       * Return the string representation of the current response, encoded as
       * specified by the current [EMAIL PROTECTED] 
net.sourceforge.jwebunit.TestContext}.
--- 141,144 ----
***************
*** 540,543 ****
--- 550,571 ----
      }
  
+       
+     public boolean isCheckboxSelected(String checkBoxName) {
+         boolean bReturn = false;
+         String theFormParameterValue = getFormParameterValue(checkBoxName); 
+         if(theFormParameterValue != null && 
theFormParameterValue.equalsIgnoreCase("on")) {
+             bReturn = true;
+         }
+         return bReturn;
+     }
+ 
+     public boolean isCheckboxNotSelected(String checkBoxName) {
+         boolean bReturn = false;
+         if(getFormParameterValue(checkBoxName) == null) {
+             bReturn = true;
+         }
+         return bReturn;
+     }
+       
      /**
       * Return true if given text is present in a specified table of the
***************
*** 800,803 ****
--- 828,878 ----
          submitRequest(link);
      }
+     
+     /**
+      * Select a specified checkbox.  If the checkbox is already checked then 
the checkbox
+      * will stay checked.
+      * @param checkBoxName name of checkbox to be deselected.
+      */
+     public void checkCheckbox(String checkBoxName) {
+         setFormParameter(checkBoxName, "on");
+     }
+ 
+     public void checkCheckbox(String checkBoxName, String value) {
+         updateFormParameter(checkBoxName, value);
+     }
+ 
+ 
+     /**
+      * Deselect a specified checkbox.  If the checkbox is already unchecked 
then the checkbox
+      * will stay unchecked.
+      *
+      * @param checkBoxName name of checkbox to be deselected.
+      */
+     public void uncheckCheckbox(String checkBoxName) {
+         removeFormParameter(checkBoxName);
+     }
+ 
+     public void uncheckCheckbox(String checkBoxName, String value) {
+         removeFormParameterWithValue(checkBoxName, value);
+     }
+       
+       /**
+        * Navigate by submitting a request based on a link with a given ID. A 
RuntimeException is thrown if no such link
+        * can be found.
+        * 
+        * @param anID
+        *            id of link to be navigated.
+        */
+       public void clickLink(String anID) {
+               WebLink link = null;
+               try {
+                       link = resp.getLinkWithID(anID);
+               } catch (SAXException e) {
+                       throw new 
RuntimeException(ExceptionUtility.stackTraceToString(e));
+               }
+               if (link == null)
+                       throw new RuntimeException("No Link found with ID \"" + 
anID + "\"");
+               submitRequest(link);
+       }
  
      private WebLink getLinkWithText(String linkText, int index) {
***************
*** 873,896 ****
      }
  
-     /**
-      * Navigate by submitting a request based on a link with a given ID. A
-      * RuntimeException is thrown if no such link can be found.
-      * 
-      * @param anID
-      *            id of link to be navigated.
-      */
-     public void clickLink(String anID) {
-         WebLink link = null;
-         try {
-             link = resp.getLinkWithID(anID);
-         } catch (SAXException e) {
-             throw new 
RuntimeException(ExceptionUtility.stackTraceToString(e));
-         }
-         if (link == null)
-                 throw new RuntimeException("No Link found with ID \"" + anID
-                         + "\"");
-         submitRequest(link);
- 
-     }
  
      /**
--- 948,951 ----

Index: WebTestCase.java
===================================================================
RCS file: 
/cvsroot/jwebunit/jWebUnit/src/net/sourceforge/jwebunit/WebTestCase.java,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** WebTestCase.java    30 Sep 2004 16:11:57 -0000      1.50
--- WebTestCase.java    5 Mar 2005 05:48:15 -0000       1.51
***************
*** 6,14 ****
  package net.sourceforge.jwebunit;
  
- import net.sourceforge.jwebunit.HttpUnitDialog;
- import junit.framework.TestCase;
- 
  import java.io.PrintStream;
  
  /**
   * Superclass for Junit TestCases which provides web application navigation 
and
--- 6,13 ----
[...983 lines suppressed...]
!         getTester().dumpTable(tableNameOrId, stream);
      }
  
      protected void dumpTable(String tableNameOrId, String[][] table) {
!         getTester().dumpTable(tableNameOrId, table);
      }
      
***************
*** 469,473 ****
      
      public void setTableEmptyCellCompression(boolean bool) {
!         tester.setTableEmptyCellCompression(bool);
      }
  
--- 552,556 ----
      
      public void setTableEmptyCellCompression(boolean bool) {
!         getTester().setTableEmptyCellCompression(bool);
      }
  

--- UnableToSetFormException.java DELETED ---



-------------------------------------------------------
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

Reply via email to