Revision: 557
Author: henryju
Date: 2006-08-07 13:46:43 -0700 (Mon, 07 Aug 2006)
ViewCVS: http://svn.sourceforge.net/jwebunit/?rev=557&view=rev
Log Message:
-----------
Refactor TestingEngineRegistry: now fully static and use JDK 1.5.
It is now easier to add a custom plugin in registry.
Perhaps it will be enougth to solve the loading failure some people have in
multithreaded context.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/pom.xml
trunk/jwebunit-core/pom.xml
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/TestingEngineRegistry.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java
trunk/jwebunit-htmlunit-plugin/pom.xml
trunk/src/changes/changes.xml
Removed Paths:
-------------
trunk/README-1.3.txt
Deleted: trunk/README-1.3.txt
===================================================================
--- trunk/README-1.3.txt 2006-08-02 13:44:47 UTC (rev 556)
+++ trunk/README-1.3.txt 2006-08-07 20:46:43 UTC (rev 557)
@@ -1,37 +0,0 @@
-The jWebUnit team is pleased to announce the jWebUnit 1.3 release!
-
-http://jwebunit.sourceforge.net
-
-jWebUnit is a Java framework that facilitates creation of acceptance tests for
-web applications. It evolved from a project where we were using HttpUnit and
-JUnit to create acceptance tests. As the tests were being written, they were
-continuously refactored to remove duplication and other bad smells in the test
-code. jWebUnit is the result of these refactorings.
-
-Changes in this version include:
-
- New Features:
-
-o Added ability to navigate to windows / assert presence by window id.
-o Refactoring of Table assertions to handle perfectly colspan and rowspan.
-o Added XPath methods to core API.
-o Added Maven 2 support. There are many reports available on the website.
-o Added new method clickButtonWithText.
-o Integrated patch for multiple submit buttons with different values. API
change - assertSubmitButtonValue(button, value) now
assertSubmitButtonPresent(button, value).
-o Assert button (not) present with text added.
-o Added ability to navigate to windows / assert presence by window title.
-o Added assert select option present / not present.
-
-
- Fixed bugs:
-o Javascript better support thanks to HtmlUnit
-
- Changes:
-o Remove HttpUnit testing engine.
-o Updated to Jetty 6 for running tests. Need less dependencies and run faster.
-o Add HtmlUnit as testing engine, that provide better Javascript support.
-
-
-Have fun!
--The jWebUnit team
-
\ No newline at end of file
Modified: trunk/jwebunit-commons-tests/pom.xml
===================================================================
--- trunk/jwebunit-commons-tests/pom.xml 2006-08-02 13:44:47 UTC (rev
556)
+++ trunk/jwebunit-commons-tests/pom.xml 2006-08-07 20:46:43 UTC (rev
557)
@@ -22,7 +22,7 @@
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
- <version>1.3</version>
+ <version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
Modified: trunk/jwebunit-core/pom.xml
===================================================================
--- trunk/jwebunit-core/pom.xml 2006-08-02 13:44:47 UTC (rev 556)
+++ trunk/jwebunit-core/pom.xml 2006-08-07 20:46:43 UTC (rev 557)
@@ -25,6 +25,11 @@
<artifactId>servlet-api</artifactId>
<version>2.4</version>
</dependency>
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
<properties>
<topDirectoryLocation>..</topDirectoryLocation>
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/TestingEngineRegistry.java
===================================================================
---
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/TestingEngineRegistry.java
2006-08-02 13:44:47 UTC (rev 556)
+++
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/TestingEngineRegistry.java
2006-08-07 20:46:43 UTC (rev 557)
@@ -6,68 +6,126 @@
import java.util.Hashtable;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
import net.sourceforge.jwebunit.exception.TestingEngineRegistryException;
/**
* This will maintain a registry of known testing engines to be used by
- * jWebUnit.
+ * jWebUnit. TestingEngineRegistry try to load official plugins from classpath.
+ * You can also add you're own.
*
* @author Nicholas Neuberger
* @author Julien Henry
*/
public class TestingEngineRegistry {
- // TODO Move this to a JDK1.5 typesafe enum
+ private static final Log LOGGER = LogFactory
+ .getLog(TestingEngineRegistry.class);
+
+ /**
+ * String that identify HtmlUnit plugin.
+ */
public final static String TESTING_ENGINE_HTMLUNIT =
"TestingEngineHtmlUnit";
+ /**
+ * String that identify Selenium plugin.
+ */
public final static String TESTING_ENGINE_SELENIUM =
"TestingEngineSelenium";
- private static Hashtable testingEngineMap = null;
- public TestingEngineRegistry() {
+ private static Hashtable<String, Class<? extends IJWebUnitDialog>>
testingEngineMap = new Hashtable<String, Class<? extends IJWebUnitDialog>>();
+
+ static {
+ try {
+ addTestingEngine(TESTING_ENGINE_HTMLUNIT,
+ "net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog");
+ } catch (Exception e) {
+ LOGGER
+ .warn("HtmlUnitDialog can't be loaded. Check your
classpath.");
+ }
+ try {
+ addTestingEngine(TESTING_ENGINE_SELENIUM,
+ "net.sourceforge.jwebunit.selenium.SeleniumDialog");
+ } catch (Exception e) {
+ LOGGER
+ .warn("SeleniumDialog can't be loaded. Check your
classpath.");
+ }
}
/**
- * Gets the map of testing engines defined within jwebunit.
+ * Add a testing engine class to the registry.
*
- * @return
+ * @param name
+ * Identifier of the plugin
+ * @param dialogClass
+ * The class of the plugin
*/
- public static Hashtable getTestingEngineMap() {
- if (testingEngineMap == null) {
- testingEngineMap = new Hashtable();
- try {
- String cp = "net.sourceforge.jwebunit.htmlunit.HtmlUnitDialog";
- Class.forName(cp);
- testingEngineMap.put(TESTING_ENGINE_HTMLUNIT, cp);
- } catch (ClassNotFoundException e) {
- //Nothing to do
- }
- try {
- String cp = "net.sourceforge.jwebunit.selenium.SeleniumDialog";
- Class.forName(cp);
- testingEngineMap.put(TESTING_ENGINE_SELENIUM, cp);
- } catch (ClassNotFoundException e) {
- //Nothing to do
- }
+ public static void addTestingEngine(String name,
+ Class<? extends IJWebUnitDialog> dialogClass) {
+ testingEngineMap.put(name, dialogClass);
+ }
+
+ /**
+ * Add a testing engine to the registry by loading it from classpath.
+ *
+ * @param name
+ * Identifier of the plugin
+ * @param classPath
+ * Fully qualified name of the testing engine's class
+ * @throws ClassNotFoundException
+ * If the class was not found
+ * @throws TestingEngineRegistryException
+ */
+ public static void addTestingEngine(String name, String classPath)
+ throws ClassNotFoundException, TestingEngineRegistryException {
+ // Class c = Class.forName(classPath, true, ClassLoader
+ // .getSystemClassLoader()); // DON'T WORK WITH MAVEN
+ Class c = Class.forName(classPath);
+ Object d = null;
+ try {
+ d = c.newInstance();
+ } catch (Exception e) {
+ throw new TestingEngineRegistryException(
+ "Unable to create a new instance of " + c.getName(), e);
}
- return testingEngineMap;
+ IJWebUnitDialog dial = null;
+ try {
+ dial = (IJWebUnitDialog) d;
+ } catch (ClassCastException e) {
+ throw new TestingEngineRegistryException(c.getName()
+ + " doesn't implement IJWebUnitDialog", e);
+ }
+
+ addTestingEngine(name, dial.getClass());
}
+ public TestingEngineRegistry() {
+ }
+
/**
- * Gets the class based on the key of the class.
+ * Gets the class based on the name of the testing engine.
*
- * @param aKey
- * @return
+ * @param name
+ * Name of the testing engine
+ * @return A testing engine.
*/
- public static Class getTestingEngineClass(String aKey)
- throws ClassNotFoundException {
- Class theClass = Class
- .forName((String) getTestingEngineMap().get(aKey));
- if (theClass == null) {
+ public static Class<? extends IJWebUnitDialog> getTestingEngineClass(
+ String name) throws TestingEngineRegistryException {
+ if (!testingEngineMap.containsKey(name)) {
throw new TestingEngineRegistryException(
- "Testing Engine with Key: [" + aKey
+ "Testing Engine with Key: [" + name
+ "] not defined for jWebUnit.");
}
- return theClass;
+ return testingEngineMap.get(name);
}
+ public static boolean isEmpty() {
+ return testingEngineMap.isEmpty();
+ }
+
+ public static String getFirstTestingEngineKey() {
+ return testingEngineMap.keys().nextElement();
+ }
+
}
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
===================================================================
--- trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
2006-08-02 13:44:47 UTC (rev 556)
+++ trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/WebTester.java
2006-08-07 20:46:43 UTC (rev 557)
@@ -10,6 +10,7 @@
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
+import net.sourceforge.jwebunit.exception.TestingEngineRegistryException;
import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
import net.sourceforge.jwebunit.exception.UnableToSetFormException;
import net.sourceforge.jwebunit.html.Table;
@@ -73,7 +74,7 @@
try {
theClass = TestingEngineRegistry
.getTestingEngineClass(theTestingEngineKey);
- } catch (ClassNotFoundException e1) {
+ } catch (TestingEngineRegistryException e1) {
throw new RuntimeException(e1);
}
try {
@@ -2093,10 +2094,9 @@
public String getTestingEngineKey() {
if (testingEngineKey == null) {
// use first available dialog
- if (TestingEngineRegistry.getTestingEngineMap().keys()
- .hasMoreElements()) {
- setTestingEngineKey((String) TestingEngineRegistry
- .getTestingEngineMap().keys().nextElement());
+ if (!TestingEngineRegistry.isEmpty()) {
+ setTestingEngineKey(TestingEngineRegistry
+ .getFirstTestingEngineKey());
} else {
throw new RuntimeException(
"TestingEngineRegistry contains no dialog. Check you
put at least one plugin in the classpath.");
Modified:
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java
===================================================================
---
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java
2006-08-02 13:44:47 UTC (rev 556)
+++
trunk/jwebunit-core/src/main/java/net/sourceforge/jwebunit/exception/TestingEngineRegistryException.java
2006-08-07 20:46:43 UTC (rev 557)
@@ -10,11 +10,13 @@
* appropriat key for a specific testing engine, etc.
* @author Nick Neuberger
*/
-public class TestingEngineRegistryException extends RuntimeException {
- public TestingEngineRegistryException() {
- }
+public class TestingEngineRegistryException extends JWebUnitException {
public TestingEngineRegistryException(String s) {
super(s);
}
+
+ public TestingEngineRegistryException(String s, Exception e) {
+ super(s, e);
+ }
}
Modified: trunk/jwebunit-htmlunit-plugin/pom.xml
===================================================================
--- trunk/jwebunit-htmlunit-plugin/pom.xml 2006-08-02 13:44:47 UTC (rev
556)
+++ trunk/jwebunit-htmlunit-plugin/pom.xml 2006-08-07 20:46:43 UTC (rev
557)
@@ -98,12 +98,12 @@
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-core</artifactId>
- <version>1.3</version>
+ <version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.sourceforge.jwebunit</groupId>
<artifactId>jwebunit-commons-tests</artifactId>
- <version>1.3</version>
+ <version>2.0-SNAPSHOT</version>
<scope>test</scope>
</dependency>
<dependency>
Modified: trunk/src/changes/changes.xml
===================================================================
--- trunk/src/changes/changes.xml 2006-08-02 13:44:47 UTC (rev 556)
+++ trunk/src/changes/changes.xml 2006-08-07 20:46:43 UTC (rev 557)
@@ -5,6 +5,12 @@
<author email="dashorst at users.sourceforge.net">Martijn
Dashorst</author>
</properties>
<body>
+ <release version="2.0" date="unknow">
+ <action type="update" dev="Julien Henry">
+ Refactor TestingEngineRegistry: now fully static and
use JDK 1.5.
+ It is now easier to add a custom plugin in registry.
+ </action>
+ </release>
<release version="1.3" date="july 28, 2006">
<action type="remove" dev="Julien Henry" due-to="Fred Burlet">
assertFormParameterValue is now deprecated. Please use more
specific method, like
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jwebunit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development