Revision: 915
http://jwebunit.svn.sourceforge.net/jwebunit/?rev=915&view=rev
Author: henryju
Date: 2011-09-22 09:18:05 +0000 (Thu, 22 Sep 2011)
Log Message:
-----------
Use tempus-fugit instead of custom code to run parallel test.
Modified Paths:
--------------
trunk/jwebunit-commons-tests/pom.xml
Added Paths:
-----------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ConcurrentJWebUnitTest.java
Removed Paths:
-------------
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JUnitPerfTest.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/Concurrent.java
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ConcurrentRule.java
Modified: trunk/jwebunit-commons-tests/pom.xml
===================================================================
--- trunk/jwebunit-commons-tests/pom.xml 2011-08-22 09:27:38 UTC (rev
914)
+++ trunk/jwebunit-commons-tests/pom.xml 2011-09-22 09:18:05 UTC (rev
915)
@@ -30,11 +30,18 @@
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
+ <version>1.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
+ <version>2.0.1</version>
</dependency>
+ <dependency>
+ <groupId>com.google.code.tempus-fugit</groupId>
+ <artifactId>tempus-fugit</artifactId>
+ <version>1.1</version>
+ </dependency>
</dependencies>
<properties>
<topDirectoryLocation>..</topDirectoryLocation>
Copied:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ConcurrentJWebUnitTest.java
(from rev 913,
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JUnitPerfTest.java)
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ConcurrentJWebUnitTest.java
(rev 0)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/ConcurrentJWebUnitTest.java
2011-09-22 09:18:05 UTC (rev 915)
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2011, JWebUnit team.
+ *
+ * This file is part of JWebUnit.
+ *
+ * JWebUnit is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * JWebUnit is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package net.sourceforge.jwebunit.tests;
+
+import static net.sourceforge.jwebunit.junit.JWebUnit.assertTitleEquals;
+import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
+import static net.sourceforge.jwebunit.junit.JWebUnit.clickLinkWithText;
+import static net.sourceforge.jwebunit.junit.JWebUnit.setBaseUrl;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import com.google.code.tempusfugit.concurrency.annotations.Repeating;
+
+import com.google.code.tempusfugit.concurrency.annotations.Concurrent;
+
+import com.google.code.tempusfugit.concurrency.ConcurrentRule;
+
+import com.google.code.tempusfugit.concurrency.RepeatingRule;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.Timeout;
+
+
+/**
+ * Test parallel execution of JWebUnit.
+ *
+ * @author Julien Henry
+ */
+public class ConcurrentJWebUnitTest extends JWebUnitAPITestCase {
+
+ public void setUp() throws Exception {
+ super.setUp();
+ setBaseUrl(HOST_PATH + "/NavigationTest");
+ }
+
+ @Rule public Timeout timeoutRule = new Timeout(2000);
+
+ @Rule public ConcurrentRule concurrently = new ConcurrentRule();
+ @Rule public RepeatingRule repeatedly = new RepeatingRule();
+
+ @Test
+ @Concurrent(count = 5)
+ @Repeating (repetition = 10)
+ public void testClickLinkWithTextN() {
+ beginAt("/pageWithLink.html");
+ assertTitleEquals("pageWithLink");
+
+ clickLinkWithText("an active link", 0);
+ assertTitleEquals("targetPage");
+
+ beginAt("/pageWithLink.html");
+ clickLinkWithText("an active link", 1);
+
+ assertTitleEquals("targetPage2");
+ beginAt("/pageWithLink.html");
+ try {
+ clickLinkWithText("an active link", 2);
+ fail();
+ } catch (AssertionError expected) {
+ assertEquals("Link with text [an active link] and index [2] "
+ + "not found in response.", expected.getMessage());
+ }
+ assertTitleEquals("pageWithLink");
+ }
+
+}
\ No newline at end of file
Deleted:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JUnitPerfTest.java
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JUnitPerfTest.java
2011-08-22 09:27:38 UTC (rev 914)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/JUnitPerfTest.java
2011-09-22 09:18:05 UTC (rev 915)
@@ -1,78 +0,0 @@
-/**
- * Copyright (c) 2011, JWebUnit team.
- *
- * This file is part of JWebUnit.
- *
- * JWebUnit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * JWebUnit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package net.sourceforge.jwebunit.tests;
-
-import static net.sourceforge.jwebunit.junit.JWebUnit.assertTitleEquals;
-import static net.sourceforge.jwebunit.junit.JWebUnit.beginAt;
-import static net.sourceforge.jwebunit.junit.JWebUnit.clickLinkWithText;
-import static net.sourceforge.jwebunit.junit.JWebUnit.setBaseUrl;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import net.sourceforge.jwebunit.tests.util.Concurrent;
-import net.sourceforge.jwebunit.tests.util.ConcurrentRule;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.Timeout;
-
-
-/**
- * Test junit perf integration.
- *
- * @author Julien Henry
- */
-public class JUnitPerfTest extends JWebUnitAPITestCase {
-
- public void setUp() throws Exception {
- super.setUp();
- setBaseUrl(HOST_PATH + "/NavigationTest");
- }
-
- @Rule
- public Timeout timeoutRule = new Timeout(1000);
-
- @Rule
- public ConcurrentRule concurrentRule = new ConcurrentRule();
-
- @Test
- @Concurrent(5)
- public void testClickLinkWithTextN() {
- beginAt("/pageWithLink.html");
- assertTitleEquals("pageWithLink");
-
- clickLinkWithText("an active link", 0);
- assertTitleEquals("targetPage");
-
- beginAt("/pageWithLink.html");
- clickLinkWithText("an active link", 1);
-
- assertTitleEquals("targetPage2");
- beginAt("/pageWithLink.html");
- try {
- clickLinkWithText("an active link", 2);
- fail();
- } catch (AssertionError expected) {
- assertEquals("Link with text [an active link] and index [2] "
- + "not found in response.", expected.getMessage());
- }
- assertTitleEquals("pageWithLink");
- }
-
-}
\ No newline at end of file
Deleted:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/Concurrent.java
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/Concurrent.java
2011-08-22 09:27:38 UTC (rev 914)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/Concurrent.java
2011-09-22 09:18:05 UTC (rev 915)
@@ -1,33 +0,0 @@
-/**
- * Copyright (c) 2011, JWebUnit team.
- *
- * This file is part of JWebUnit.
- *
- * JWebUnit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * JWebUnit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
- */
-package net.sourceforge.jwebunit.tests.util;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Mathieu Carbou ([email protected])
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.METHOD})
-public @interface Concurrent {
- int value() default 10;
-}
Deleted:
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ConcurrentRule.java
===================================================================
---
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ConcurrentRule.java
2011-08-22 09:27:38 UTC (rev 914)
+++
trunk/jwebunit-commons-tests/src/main/java/net/sourceforge/jwebunit/tests/util/ConcurrentRule.java
2011-09-22 09:18:05 UTC (rev 915)
@@ -1,96 +0,0 @@
-/**
- * Copyright (c) 2011, JWebUnit team.
- *
- * This file is part of JWebUnit.
- *
- * JWebUnit is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * JWebUnit is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with JWebUnit. If not, see <http://www.gnu.org/licenses/>.
- */
-package net.sourceforge.jwebunit.tests.util;
-
-import org.junit.rules.MethodRule;
-import org.junit.runners.model.FrameworkMethod;
-import org.junit.runners.model.Statement;
-
-import java.util.concurrent.CountDownLatch;
-
-/**
- * @author Mathieu Carbou ([email protected])
- */
-public final class ConcurrentRule implements MethodRule {
-
- public Statement apply(final Statement statement, final FrameworkMethod
frameworkMethod, final Object o) {
- return new Statement() {
- @Override
- public void evaluate() throws Throwable {
- Concurrent concurrent =
frameworkMethod.getAnnotation(Concurrent.class);
- if (concurrent == null)
- statement.evaluate();
- else {
- final String name = frameworkMethod.getName();
- final Thread[] threads = new Thread[concurrent.value()];
- final CountDownLatch go = new CountDownLatch(1);
- final CountDownLatch finished = new
CountDownLatch(threads.length);
- final Throwable[] fThrown = new Throwable[threads.length];
- for (int i = 0; i < threads.length; i++) {
- threads[i] = new Thread(new MyIndexedRunnable(i) {
-
- public void run() {
- try {
- go.await();
- statement.evaluate();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- } catch (Throwable throwable) {
- fThrown[getIndex()] = throwable;
- if (throwable instanceof RuntimeException)
- throw (RuntimeException) throwable;
- if (throwable instanceof Error)
- throw (Error) throwable;
- RuntimeException r = new
RuntimeException(throwable.getMessage(), throwable);
- r.setStackTrace(throwable.getStackTrace());
- throw r;
- } finally {
- finished.countDown();
- }
- }
- }, name + "-Thread-" + i);
- threads[i].start();
- }
- go.countDown();
- finished.await();
- //Check exceptions
- for (int i = 0; i < threads.length; i++) {
- if (fThrown[i] != null) {
- throw fThrown[i];
- }
- }
- }
- }
- };
- }
-
- private abstract class MyIndexedRunnable implements Runnable {
-
- private int index;
-
- public MyIndexedRunnable(int index) {
- this.index = index;
- }
-
- public int getIndex() {
- return index;
- }
-
- }
-}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
JWebUnit-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-development