You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by sv...@apache.org on 2018/07/17 21:50:25 UTC
[1/2] wicket git commit: fixed wicket-threadtest
Repository: wicket
Updated Branches:
refs/heads/wicket-8.x 58c0dcf6c -> dfe9cf011
fixed wicket-threadtest
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/06295eb8
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/06295eb8
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/06295eb8
Branch: refs/heads/wicket-8.x
Commit: 06295eb810995d70efdb947a5c76506be9003bd4
Parents: 58c0dcf
Author: Sven Meier <sv...@apache.org>
Authored: Tue Jul 17 21:27:34 2018 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Tue Jul 17 21:27:34 2018 +0200
----------------------------------------------------------------------
testing/wicket-threadtest/pom.xml | 28 +++++++++++++++++---
.../org/apache/wicket/threadtest/App1Test1.java | 13 +++++++--
.../org/apache/wicket/threadtest/App1Test3.java | 2 +-
.../wicket/threadtest/apps/app1/Home.java | 20 +++-----------
.../wicket/threadtest/apps/app1/TestApp1.java | 4 +--
.../wicket/threadtest/apps/app2/TestApp2.java | 2 +-
.../threadtest/tester/AbstractGetCommand.java | 18 ++++++++++---
.../apache/wicket/threadtest/tester/Tester.java | 1 +
8 files changed, 58 insertions(+), 30 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/pom.xml
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/pom.xml b/testing/wicket-threadtest/pom.xml
index a1f594f..6367c17 100644
--- a/testing/wicket-threadtest/pom.xml
+++ b/testing/wicket-threadtest/pom.xml
@@ -20,7 +20,7 @@
<parent>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-parent</artifactId>
- <version>8.0.0-SNAPSHOT</version>
+ <version>8.1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>wicket-threadtest</artifactId>
@@ -42,16 +42,36 @@
<artifactId>wicket-extensions</artifactId>
</dependency>
<dependency>
- <groupId>org.eclipse.jetty.aggregate</groupId>
- <artifactId>jetty-all-server</artifactId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-webapp</artifactId>
+ <scope>compile</scope>
</dependency>
<dependency>
- <groupId>httpunit</groupId>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-server</artifactId>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.httpunit</groupId>
<artifactId>httpunit</artifactId>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
+ <version>3.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java
index d954612..413e887 100644
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java
+++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java
@@ -36,12 +36,21 @@ public class App1Test1
List<String> gets = Arrays.asList(
"/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.Home",
- "/app1/wicket/page?0-${iteration}.ILinkListener-link");
+ "/app1/wicket/page?${id}-1.-link");
// you can turn this on if you e.g. want to attach to a profiler
// Thread.sleep(5000);
- SimpleGetCommand getCmd = new SimpleGetCommand(gets, 10);
+ SimpleGetCommand getCmd = new SimpleGetCommand(gets, 10) {
+ @Override
+ protected String getValue(String name, int iteration) {
+ if ("id".equals(name)) {
+ // page id increases by one on each render
+ return "" + (iteration * 2);
+ }
+ return super.getValue(name, iteration);
+ }
+ };
// getCmd.setPrintResponse(true);
Tester tester = new Tester(getCmd, 100, true);
tester.run();
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java
index ec562f3..244c9d4 100644
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java
+++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java
@@ -39,7 +39,7 @@ public class App1Test3
gets.add("/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.ResourceTestPage");
for (int i = 0; i < ResourceTestPage.IMAGES_PER_PAGE; i++)
{
- gets.add("/app1/wicket/page?0-IResourceListener-listView-${iteration}-image");
+ gets.add("/app1/wicket/page?${iteration}--listView-${iteration}-image");
}
SimpleGetCommand getCmd = new SimpleGetCommand(gets, 5);
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java
index da31448..7f2c186 100644
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java
+++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/Home.java
@@ -34,6 +34,7 @@ import org.apache.wicket.markup.html.form.CheckGroup;
import org.apache.wicket.markup.html.form.ChoiceRenderer;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
+import org.apache.wicket.markup.html.form.FormComponentUpdatingBehavior;
import org.apache.wicket.markup.html.form.ListMultipleChoice;
import org.apache.wicket.markup.html.form.Radio;
import org.apache.wicket.markup.html.form.RadioChoice;
@@ -318,23 +319,8 @@ public class Home extends WebPage
{
super(id, LOCALES, new LocaleChoiceRenderer());
setDefaultModel(new PropertyModel<Locale>(Home.this, "locale"));
- }
-
- /**
- * @see org.apache.wicket.markup.html.form.DropDownChoice#onSelectionChanged(java.lang.Object)
- */
- @Override
- public void onSelectionChanged(Locale newSelection)
- {
- }
-
- /**
- * @see org.apache.wicket.markup.html.form.DropDownChoice#wantOnSelectionChangedNotifications()
- */
- @Override
- protected boolean wantOnSelectionChangedNotifications()
- {
- return true;
+
+ add(new FormComponentUpdatingBehavior());
}
}
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/TestApp1.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/TestApp1.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/TestApp1.java
index 8fdb5cf..a9c75a9 100644
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/TestApp1.java
+++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app1/TestApp1.java
@@ -75,10 +75,10 @@ public class TestApp1 extends WebApplication
setPageManagerProvider(new DefaultPageManagerProvider(this)
{
@Override
- public IPageManager get(IPageManagerContext pageManagerContext)
+ public IPageManager apply(IPageManagerContext pageManagerContext)
{
IDataStore dataStore = new HttpSessionDataStore(pageManagerContext,
- new PageNumberEvictionStrategy(100));
+ new PageNumberEvictionStrategy(500));
IPageStore pageStore = new DefaultPageStore(
new JavaSerializer(getApplicationKey()), dataStore,
getStoreSettings().getInmemoryCacheSize());
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app2/TestApp2.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app2/TestApp2.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app2/TestApp2.java
index f18a4dc..d702087 100644
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app2/TestApp2.java
+++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/apps/app2/TestApp2.java
@@ -63,7 +63,7 @@ public class TestApp2 extends WebApplication
setPageManagerProvider(new DefaultPageManagerProvider(this)
{
@Override
- public IPageManager get(IPageManagerContext pageManagerContext)
+ public IPageManager apply(IPageManagerContext pageManagerContext)
{
IDataStore dataStore = new HttpSessionDataStore(pageManagerContext,
new PageNumberEvictionStrategy(100));
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
index 89b928d..d7c0387 100644
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
+++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
@@ -20,6 +20,7 @@ import java.util.List;
import org.apache.commons.httpclient.HttpClient;
import org.apache.wicket.util.string.Strings;
+import org.apache.wicket.util.string.interpolator.VariableInterpolator;
/**
* TODO javadoc
@@ -52,14 +53,25 @@ public abstract class AbstractGetCommand extends AbstractCommand
List<String> urls = getUrls();
for (String url : urls)
{
-
- String modUrl = Strings.replaceAll(url, "${iteration}", String.valueOf(i))
- .toString();
+ final int iteration = i;
+ String modUrl = new VariableInterpolator(url, false) {
+ @Override
+ protected String getValue(String variableName) {
+ return AbstractGetCommand.this.getValue(variableName, iteration);
+ }
+ }.toString();
doGet(runner.getClient(), modUrl);
}
}
}
+ protected String getValue(String name, int iteration) {
+ if ("iteration".equals(name)) {
+ return String.valueOf(iteration);
+ }
+ return null;
+ }
+
/**
* Execute a GET request using the provided url.
*
http://git-wip-us.apache.org/repos/asf/wicket/blob/06295eb8/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java
index 03512d0..6ef6b80 100644
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java
+++ b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java
@@ -31,6 +31,7 @@ import org.eclipse.jetty.webapp.WebAppContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* @author eelcohillenius
*/
[2/2] wicket git commit: make wicket-threadtest tests
Posted by sv...@apache.org.
make wicket-threadtest tests
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/dfe9cf01
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/dfe9cf01
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/dfe9cf01
Branch: refs/heads/wicket-8.x
Commit: dfe9cf011a37fc64d9b9822c3ae1ef824a13cf66
Parents: 06295eb
Author: Sven Meier <sv...@apache.org>
Authored: Tue Jul 17 23:49:35 2018 +0200
Committer: Sven Meier <sv...@apache.org>
Committed: Tue Jul 17 23:49:35 2018 +0200
----------------------------------------------------------------------
testing/wicket-threadtest/pom.xml | 4 +
.../org/apache/wicket/threadtest/App1Test1.java | 58 ----
.../org/apache/wicket/threadtest/App1Test2.java | 45 ---
.../org/apache/wicket/threadtest/App1Test3.java | 51 ---
.../org/apache/wicket/threadtest/App2Test1.java | 53 ----
.../threadtest/tester/AbstractCommand.java | 66 ----
.../threadtest/tester/AbstractGetCommand.java | 85 -----
.../wicket/threadtest/tester/Command.java | 36 ---
.../wicket/threadtest/tester/CommandRunner.java | 105 -------
.../threadtest/tester/SimpleGetCommand.java | 119 -------
.../apache/wicket/threadtest/tester/Tester.java | 303 ------------------
.../org/apache/wicket/threadtest/App1Test.java | 90 ++++++
.../org/apache/wicket/threadtest/App2Test.java | 51 +++
.../threadtest/tester/AbstractCommand.java | 66 ++++
.../threadtest/tester/AbstractGetCommand.java | 85 +++++
.../wicket/threadtest/tester/Command.java | 36 +++
.../wicket/threadtest/tester/CommandRunner.java | 105 +++++++
.../threadtest/tester/SimpleGetCommand.java | 117 +++++++
.../apache/wicket/threadtest/tester/Tester.java | 313 +++++++++++++++++++
19 files changed, 867 insertions(+), 921 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/pom.xml
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/pom.xml b/testing/wicket-threadtest/pom.xml
index 6367c17..601831a 100644
--- a/testing/wicket-threadtest/pom.xml
+++ b/testing/wicket-threadtest/pom.xml
@@ -81,5 +81,9 @@
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
</dependencies>
</project>
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java
deleted file mode 100644
index 413e887..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test1.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.wicket.threadtest.tester.SimpleGetCommand;
-import org.apache.wicket.threadtest.tester.Tester;
-
-/**
- * @author eelcohillenius
- */
-public class App1Test1
-{
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception
- {
-
- List<String> gets = Arrays.asList(
- "/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.Home",
- "/app1/wicket/page?${id}-1.-link");
-
- // you can turn this on if you e.g. want to attach to a profiler
-// Thread.sleep(5000);
-
- SimpleGetCommand getCmd = new SimpleGetCommand(gets, 10) {
- @Override
- protected String getValue(String name, int iteration) {
- if ("id".equals(name)) {
- // page id increases by one on each render
- return "" + (iteration * 2);
- }
- return super.getValue(name, iteration);
- }
- };
- // getCmd.setPrintResponse(true);
- Tester tester = new Tester(getCmd, 100, true);
- tester.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test2.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test2.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test2.java
deleted file mode 100644
index 074f0a2..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test2.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.wicket.threadtest.tester.SimpleGetCommand;
-import org.apache.wicket.threadtest.tester.Tester;
-
-/**
- * @author eelcohillenius
- */
-public class App1Test2
-{
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception
- {
-
- List<String> gets = Arrays.asList("/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.Home");
-
- SimpleGetCommand getCmd = new SimpleGetCommand(gets, 5);
-
- // getCmd.setPrintResponse(true);
- Tester tester = new Tester(getCmd, 100, false);
- tester.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java
deleted file mode 100644
index 244c9d4..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App1Test3.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.wicket.threadtest.apps.app1.ResourceTestPage;
-import org.apache.wicket.threadtest.tester.SimpleGetCommand;
-import org.apache.wicket.threadtest.tester.Tester;
-
-/**
- * @author almaw
- */
-public class App1Test3
-{
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception
- {
-
- List<String> gets = new ArrayList<String>();
- gets.add("/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.ResourceTestPage");
- for (int i = 0; i < ResourceTestPage.IMAGES_PER_PAGE; i++)
- {
- gets.add("/app1/wicket/page?${iteration}--listView-${iteration}-image");
- }
-
- SimpleGetCommand getCmd = new SimpleGetCommand(gets, 5);
-
- // getCmd.setPrintResponse(true);
- Tester tester = new Tester(getCmd, 100, false);
- tester.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App2Test1.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App2Test1.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App2Test1.java
deleted file mode 100644
index 7266ce5..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/App2Test1.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.wicket.threadtest.tester.SimpleGetCommand;
-import org.apache.wicket.threadtest.tester.Tester;
-
-/**
- * @author eelcohillenius
- */
-public class App2Test1
-{
-
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception
- {
-
- List<String> gets = Arrays.asList("/app2/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app2.Home");
-
- SimpleGetCommand getCmd = new SimpleGetCommand(gets, 5);
-
- // getCmd.setPrintResponse(true);
-
- // AS OF OCTOBER 9 2006, THIS TYPICALLY RESULTS IN A DEADLOCK
- // FIXED now... keep this test
- Tester tester = new Tester(getCmd, 50, false);
-
- // new Tester(.., .., false) would not give a deadlock, as then
- // all threads point to seperate sessions
-
- tester.run();
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractCommand.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractCommand.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractCommand.java
deleted file mode 100644
index 728b8dc..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractCommand.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest.tester;
-
-import java.util.List;
-
-/**
- * TODO javadoc
- */
-public abstract class AbstractCommand implements Command
-{
-
- /** number of executions of the urls. */
- private final int iterations;
-
- /** URLs to visit. */
- private final List<String> urls;
-
- /**
- * Construct.
- *
- * @param urls
- * URLs to visit
- * @param iterations
- * number of executions of the urls
- */
- public AbstractCommand(List<String> urls, int iterations)
- {
- this.urls = urls;
- this.iterations = iterations;
- }
-
- /**
- * Gets iterations.
- *
- * @return iterations
- */
- public int getIterations()
- {
- return iterations;
- }
-
- /**
- * Gets urls.
- *
- * @return urls
- */
- public List<String> getUrls()
- {
- return urls;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
deleted file mode 100644
index d7c0387..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest.tester;
-
-import java.util.List;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.wicket.util.string.Strings;
-import org.apache.wicket.util.string.interpolator.VariableInterpolator;
-
-/**
- * TODO javadoc
- */
-public abstract class AbstractGetCommand extends AbstractCommand
-{
-
- /**
- * Construct.
- *
- * @param urls
- * URLs to visit
- * @param iterations
- * number of executions of the urls
- */
- public AbstractGetCommand(List<String> urls, int iterations)
- {
- super(urls, iterations);
- }
-
- /**
- * @see org.apache.wicket.threadtest.tester.Command#execute(CommandRunner)
- */
- public void execute(CommandRunner runner) throws Exception
- {
-
- int iterations = getIterations();
- for (int i = 0; i < iterations; i++)
- {
- List<String> urls = getUrls();
- for (String url : urls)
- {
- final int iteration = i;
- String modUrl = new VariableInterpolator(url, false) {
- @Override
- protected String getValue(String variableName) {
- return AbstractGetCommand.this.getValue(variableName, iteration);
- }
- }.toString();
- doGet(runner.getClient(), modUrl);
- }
- }
- }
-
- protected String getValue(String name, int iteration) {
- if ("iteration".equals(name)) {
- return String.valueOf(iteration);
- }
- return null;
- }
-
- /**
- * Execute a GET request using the provided url.
- *
- * @param url
- * The url to GET
- * @param client
- * the http client
- * @throws Exception
- */
- protected abstract void doGet(HttpClient client, String url) throws Exception;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Command.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Command.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Command.java
deleted file mode 100644
index 1cc4e3a..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Command.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest.tester;
-
-/**
- * Command interface.
- *
- * @author eelcohillenius
- */
-public interface Command
-{
-
- /**
- * Execute one iteration.
- *
- * @param runner
- * command runner that executes this command
- *
- * @throws Exception
- */
- void execute(CommandRunner runner) throws Exception;
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/CommandRunner.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/CommandRunner.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/CommandRunner.java
deleted file mode 100644
index b315697..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/CommandRunner.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest.tester;
-
-import java.util.List;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Runs a command.
- *
- * @author eelcohillenius
- */
-public class CommandRunner implements Runnable
-{
-
- /**
- * TODO javadoc
- */
- public static interface CommandRunnerObserver
- {
-
- /**
- * @param runner
- */
- void onDone(CommandRunner runner);
-
- /**
- * @param runner
- * @param e
- */
- void onError(CommandRunner runner, Exception e);
- }
-
- private static final Logger log = LoggerFactory.getLogger(CommandRunner.class);
-
- private HttpClient client;
-
- private final List<Command> commands;
-
- private final CommandRunnerObserver observer;
-
- /**
- * Construct.
- *
- * @param commands
- * @param client
- * @param observer
- */
- public CommandRunner(List<Command> commands, HttpClient client, CommandRunnerObserver observer)
- {
- this.commands = commands;
- this.client = client;
- this.observer = observer;
- }
-
- /**
- * Gets the HTTP client.
- *
- * @return the HTTP client
- */
- public HttpClient getClient()
- {
- return client;
- }
-
- /**
- * @see java.lang.Runnable#run()
- */
- public void run()
- {
-
- for (Command command : commands)
- {
- try
- {
- command.execute(this);
- }
- catch (Exception e)
- {
- log.error("execution of command " + command + ", thread " + Thread.currentThread() +
- " failed", e);
- observer.onError(this, e);
- return;
- }
- }
- observer.onDone(this);
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java
deleted file mode 100644
index b9eebbb..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest.tester;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.wicket.util.io.Streams;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * TODO javadoc
- */
-public class SimpleGetCommand extends AbstractGetCommand
-{
- private static final Logger log = LoggerFactory.getLogger(SimpleGetCommand.class);
-
- private boolean printResponse = false;
-
- /**
- * Construct.
- *
- * @param urls
- * URLs to visit
- * @param iterations
- * number of executions of the urls
- */
- public SimpleGetCommand(List<String> urls, int iterations)
- {
- super(urls, iterations);
- }
-
- /**
- * Construct.
- *
- * @param url
- * URL to visit
- * @param iterations
- * number of executions of the urls
- */
- public SimpleGetCommand(String url, int iterations)
- {
- super(Arrays.asList(url), iterations);
- }
-
- /**
- * Gets printResponse.
- *
- * @return printResponse
- */
- public boolean getPrintResponse()
- {
- return printResponse;
- }
-
- /**
- * Sets printResponse.
- *
- * @param printResponse
- * printResponse
- */
- public void setPrintResponse(boolean printResponse)
- {
- this.printResponse = printResponse;
- }
-
- /**
- * @see org.apache.wicket.threadtest.tester.AbstractGetCommand#doGet(org.apache.commons.httpclient.HttpClient,
- * String)
- */
- @Override
- protected void doGet(HttpClient client, String url) throws Exception
- {
-
- GetMethod method = new GetMethod(url);
- method.setFollowRedirects(true);
- try
- {
- if (url.contains("bookmarkable"))
- {
- log.info(url);
- }
- int code = client.executeMethod(method);
- if (code != 200)
- {
- log.error("ERROR! code: " + code);
- log.error(url);
-// log.error(Streams.readString(method.getResponseBodyAsStream()));
- // TODO rather than failing, just gather statistics
- // throw new Exception(new String(method.getResponseBody()));
- }
- if (getPrintResponse())
- {
- log.info("\n" + Streams.readString(method.getResponseBodyAsStream()));
- }
- }
- finally
- {
- method.releaseConnection();
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java b/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java
deleted file mode 100644
index 6ef6b80..0000000
--- a/testing/wicket-threadtest/src/main/java/org/apache/wicket/threadtest/tester/Tester.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.wicket.threadtest.tester;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
-import org.apache.wicket.threadtest.tester.CommandRunner.CommandRunnerObserver;
-import org.apache.wicket.util.time.Duration;
-import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.webapp.WebAppContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-
-/**
- * @author eelcohillenius
- */
-public final class Tester implements CommandRunnerObserver
-{
- private static final Logger log = LoggerFactory.getLogger(Tester.class);
-
- private static HttpClientParams params;
-
- static
- {
- params = new HttpClientParams();
- params.setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
- }
-
- /**
- * Main method for just starting the server
- *
- * @param args
- */
- public static void main(String[] args)
- {
- // start server on its own
- int port = 8090;
- if (args.length > 0)
- {
- port = Integer.valueOf(args[0]);
- }
- Server server = startServer(port);
- try
- {
- server.start();
- }
- catch (Exception e)
- {
- e.printStackTrace();
- try
- {
- server.stop();
- }
- catch (Exception e1)
- {
- e1.printStackTrace();
- }
- System.exit(1);
- }
- }
-
- /**
- * Start Jetty server instance and return the handle.
- *
- * @param port
- * @return server handle
- */
- private static Server startServer(int port)
- {
- Server server;
- // start up server
- server = new Server(port);
- WebAppContext ctx = new WebAppContext("./src/main/webapp", "/");
- server.setHandler(ctx);
- try
- {
- server.start();
- }
- catch (Exception e)
- {
- throw new RuntimeException(e);
- }
- return server;
- }
-
- private int activeThreads = 0;
-
- private final List<Command> commands;
-
- private String host = "localhost";
-
- /**
- * if true, each thread will represent a seperate session. If false, the test behaves like one
- * client issuing multiple concurrent requests.
- */
- private final boolean multipleSessions;
-
- private final int numberOfThreads;
-
- private int port = 8090;
-
- /**
- * Construct.
- *
- * @param command
- * Command to execute
- * @param numberOfThreads
- * Number of threads to run the commands. Each thread runs all commands
- * @param multipleSessions
- * if true, each thread will represent a seperate session. If false, the test behaves
- * like one client issuing multiple concurrent requests
- */
- public Tester(Command command, int numberOfThreads, boolean multipleSessions)
- {
- this(Arrays.asList(command), numberOfThreads, multipleSessions);
- }
-
- /**
- * Construct.
- *
- * @param commands
- * Commands to execute
- * @param numberOfThreads
- * Number of threads to run the commands. Each thread runs all commands
- * @param multipleSessions
- * if true, each thread will represent a separate session. If false, the test behaves
- * like one client issuing multiple concurrent requests
- */
- public Tester(List<Command> commands, int numberOfThreads, boolean multipleSessions)
- {
- this.commands = commands;
- this.numberOfThreads = numberOfThreads;
- this.multipleSessions = multipleSessions;
- }
-
- /**
- * Gets host.
- *
- * @return host
- */
- public String getHost()
- {
- return host;
- }
-
- /**
- * Gets port.
- *
- * @return port
- */
- public int getPort()
- {
- return port;
- }
-
- public synchronized void onDone(CommandRunner runner)
- {
- activeThreads--;
- notifyAll();
- }
-
- public synchronized void onError(CommandRunner runner, Exception e)
- {
- activeThreads--;
- notifyAll();
- }
-
- /**
- * Runs the test.
- *
- * @throws Exception
- */
- public void run() throws Exception
- {
-
- activeThreads = 0;
-
- HttpConnectionManagerParams connManagerParams = new HttpConnectionManagerParams();
- connManagerParams.setDefaultMaxConnectionsPerHost(numberOfThreads * 2);
- MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
- manager.setParams(connManagerParams);
-
- Server server = null;
- GetMethod getMethod = new GetMethod("http://localhost:" + port + "/");
- try
- {
- getMethod.setFollowRedirects(true);
- HttpClient httpClient = new HttpClient(params, manager);
- int code = httpClient.executeMethod(getMethod);
- if (code != 200)
- {
- server = startServer(port);
- }
- }
- catch (Exception e)
- {
- server = startServer(port);
- }
- finally
- {
- getMethod.releaseConnection();
- }
-
- try
- {
-
- ThreadGroup g = new ThreadGroup("runners");
- Thread[] threads = new Thread[numberOfThreads];
- HttpClient client = null;
- for (int i = 0; i < numberOfThreads; i++)
- {
-
- if (multipleSessions)
- {
- client = new HttpClient(params, manager);
- client.getHostConfiguration().setHost(host, port);
- }
- else
- {
- if (client == null)
- {
- client = new HttpClient(params, manager);
- client.getHostConfiguration().setHost(host, port);
- }
- }
- threads[i] = new Thread(g, new CommandRunner(commands, client, this));
- }
-
- long start = System.currentTimeMillis();
-
- for (int i = 0; i < numberOfThreads; i++)
- {
- activeThreads++;
- threads[i].start();
- }
-
- while (activeThreads > 0)
- {
- synchronized (this)
- {
- wait();
- }
- }
-
- long end = System.currentTimeMillis();
- long time = end - start;
- log.info("\n******** finished in " + Duration.milliseconds(time) + " (" + time +
- " milis)");
-
- }
- finally
- {
- MultiThreadedHttpConnectionManager.shutdownAll();
- if (server != null)
- {
- server.stop();
- }
- }
- }
-
- /**
- * Sets host.
- *
- * @param host
- * host
- */
- public void setHost(String host)
- {
- this.host = host;
- }
-
- /**
- * Sets port.
- *
- * @param port
- * port
- */
- public void setPort(int port)
- {
- this.port = port;
- }
-}
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App1Test.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App1Test.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App1Test.java
new file mode 100644
index 0000000..88e4874
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App1Test.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.wicket.threadtest.apps.app1.ResourceTestPage;
+import org.apache.wicket.threadtest.tester.SimpleGetCommand;
+import org.apache.wicket.threadtest.tester.Tester;
+import org.junit.Test;
+
+/**
+ * @author eelcohillenius
+ */
+public class App1Test
+{
+
+ @Test
+ public void test1() throws Exception
+ {
+
+ List<String> gets = Arrays.asList(
+ "/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.Home",
+ "/app1/wicket/page?${id}-1.-link");
+
+ // you can turn this on if you e.g. want to attach to a profiler
+// Thread.sleep(5000);
+
+ SimpleGetCommand getCmd = new SimpleGetCommand(gets, 10) {
+ @Override
+ protected String getValue(String name, int iteration) {
+ if ("id".equals(name)) {
+ // page id increases by one on each render
+ return "" + (iteration * 2);
+ }
+ return super.getValue(name, iteration);
+ }
+ };
+ // getCmd.setPrintResponse(true);
+ Tester tester = new Tester(getCmd, 100, true);
+ tester.run();
+ }
+
+ @Test
+ public void test2() throws Exception
+ {
+
+ List<String> gets = Arrays.asList("/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.Home");
+
+ SimpleGetCommand getCmd = new SimpleGetCommand(gets, 5);
+
+ // getCmd.setPrintResponse(true);
+ Tester tester = new Tester(getCmd, 100, false);
+ tester.run();
+ }
+
+ @Test
+ public void test3() throws Exception
+ {
+
+ List<String> gets = new ArrayList<String>();
+ gets.add("/app1/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app1.ResourceTestPage");
+ for (int i = 0; i < ResourceTestPage.IMAGES_PER_PAGE; i++)
+ {
+ gets.add("/app1/wicket/page?${iteration}--listView-${iteration}-image");
+ }
+
+ SimpleGetCommand getCmd = new SimpleGetCommand(gets, 5);
+
+ // getCmd.setPrintResponse(true);
+ Tester tester = new Tester(getCmd, 100, false);
+ tester.run();
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App2Test.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App2Test.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App2Test.java
new file mode 100644
index 0000000..f23d1d4
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/App2Test.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.wicket.threadtest.tester.SimpleGetCommand;
+import org.apache.wicket.threadtest.tester.Tester;
+import org.junit.Test;
+
+/**
+ * @author eelcohillenius
+ */
+public class App2Test
+{
+
+ @Test
+ public void test1() throws Exception
+ {
+
+ List<String> gets = Arrays.asList("/app2/wicket/bookmarkable/org.apache.wicket.threadtest.apps.app2.Home");
+
+ SimpleGetCommand getCmd = new SimpleGetCommand(gets, 5);
+
+ // getCmd.setPrintResponse(true);
+
+ // AS OF OCTOBER 9 2006, THIS TYPICALLY RESULTS IN A DEADLOCK
+ // FIXED now... keep this test
+ Tester tester = new Tester(getCmd, 50, false);
+
+ // new Tester(.., .., false) would not give a deadlock, as then
+ // all threads point to seperate sessions
+
+ tester.run();
+ }
+}
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractCommand.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractCommand.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractCommand.java
new file mode 100644
index 0000000..728b8dc
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractCommand.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest.tester;
+
+import java.util.List;
+
+/**
+ * TODO javadoc
+ */
+public abstract class AbstractCommand implements Command
+{
+
+ /** number of executions of the urls. */
+ private final int iterations;
+
+ /** URLs to visit. */
+ private final List<String> urls;
+
+ /**
+ * Construct.
+ *
+ * @param urls
+ * URLs to visit
+ * @param iterations
+ * number of executions of the urls
+ */
+ public AbstractCommand(List<String> urls, int iterations)
+ {
+ this.urls = urls;
+ this.iterations = iterations;
+ }
+
+ /**
+ * Gets iterations.
+ *
+ * @return iterations
+ */
+ public int getIterations()
+ {
+ return iterations;
+ }
+
+ /**
+ * Gets urls.
+ *
+ * @return urls
+ */
+ public List<String> getUrls()
+ {
+ return urls;
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
new file mode 100644
index 0000000..d7c0387
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/AbstractGetCommand.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest.tester;
+
+import java.util.List;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.wicket.util.string.Strings;
+import org.apache.wicket.util.string.interpolator.VariableInterpolator;
+
+/**
+ * TODO javadoc
+ */
+public abstract class AbstractGetCommand extends AbstractCommand
+{
+
+ /**
+ * Construct.
+ *
+ * @param urls
+ * URLs to visit
+ * @param iterations
+ * number of executions of the urls
+ */
+ public AbstractGetCommand(List<String> urls, int iterations)
+ {
+ super(urls, iterations);
+ }
+
+ /**
+ * @see org.apache.wicket.threadtest.tester.Command#execute(CommandRunner)
+ */
+ public void execute(CommandRunner runner) throws Exception
+ {
+
+ int iterations = getIterations();
+ for (int i = 0; i < iterations; i++)
+ {
+ List<String> urls = getUrls();
+ for (String url : urls)
+ {
+ final int iteration = i;
+ String modUrl = new VariableInterpolator(url, false) {
+ @Override
+ protected String getValue(String variableName) {
+ return AbstractGetCommand.this.getValue(variableName, iteration);
+ }
+ }.toString();
+ doGet(runner.getClient(), modUrl);
+ }
+ }
+ }
+
+ protected String getValue(String name, int iteration) {
+ if ("iteration".equals(name)) {
+ return String.valueOf(iteration);
+ }
+ return null;
+ }
+
+ /**
+ * Execute a GET request using the provided url.
+ *
+ * @param url
+ * The url to GET
+ * @param client
+ * the http client
+ * @throws Exception
+ */
+ protected abstract void doGet(HttpClient client, String url) throws Exception;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Command.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Command.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Command.java
new file mode 100644
index 0000000..1cc4e3a
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Command.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest.tester;
+
+/**
+ * Command interface.
+ *
+ * @author eelcohillenius
+ */
+public interface Command
+{
+
+ /**
+ * Execute one iteration.
+ *
+ * @param runner
+ * command runner that executes this command
+ *
+ * @throws Exception
+ */
+ void execute(CommandRunner runner) throws Exception;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/CommandRunner.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/CommandRunner.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/CommandRunner.java
new file mode 100644
index 0000000..b315697
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/CommandRunner.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest.tester;
+
+import java.util.List;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Runs a command.
+ *
+ * @author eelcohillenius
+ */
+public class CommandRunner implements Runnable
+{
+
+ /**
+ * TODO javadoc
+ */
+ public static interface CommandRunnerObserver
+ {
+
+ /**
+ * @param runner
+ */
+ void onDone(CommandRunner runner);
+
+ /**
+ * @param runner
+ * @param e
+ */
+ void onError(CommandRunner runner, Exception e);
+ }
+
+ private static final Logger log = LoggerFactory.getLogger(CommandRunner.class);
+
+ private HttpClient client;
+
+ private final List<Command> commands;
+
+ private final CommandRunnerObserver observer;
+
+ /**
+ * Construct.
+ *
+ * @param commands
+ * @param client
+ * @param observer
+ */
+ public CommandRunner(List<Command> commands, HttpClient client, CommandRunnerObserver observer)
+ {
+ this.commands = commands;
+ this.client = client;
+ this.observer = observer;
+ }
+
+ /**
+ * Gets the HTTP client.
+ *
+ * @return the HTTP client
+ */
+ public HttpClient getClient()
+ {
+ return client;
+ }
+
+ /**
+ * @see java.lang.Runnable#run()
+ */
+ public void run()
+ {
+
+ for (Command command : commands)
+ {
+ try
+ {
+ command.execute(this);
+ }
+ catch (Exception e)
+ {
+ log.error("execution of command " + command + ", thread " + Thread.currentThread() +
+ " failed", e);
+ observer.onError(this, e);
+ return;
+ }
+ }
+ observer.onDone(this);
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java
new file mode 100644
index 0000000..5040546
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/SimpleGetCommand.java
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest.tester;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.wicket.util.io.Streams;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * TODO javadoc
+ */
+public class SimpleGetCommand extends AbstractGetCommand
+{
+ private static final Logger log = LoggerFactory.getLogger(SimpleGetCommand.class);
+
+ private boolean printResponse = false;
+
+ /**
+ * Construct.
+ *
+ * @param urls
+ * URLs to visit
+ * @param iterations
+ * number of executions of the urls
+ */
+ public SimpleGetCommand(List<String> urls, int iterations)
+ {
+ super(urls, iterations);
+ }
+
+ /**
+ * Construct.
+ *
+ * @param url
+ * URL to visit
+ * @param iterations
+ * number of executions of the urls
+ */
+ public SimpleGetCommand(String url, int iterations)
+ {
+ super(Arrays.asList(url), iterations);
+ }
+
+ /**
+ * Gets printResponse.
+ *
+ * @return printResponse
+ */
+ public boolean getPrintResponse()
+ {
+ return printResponse;
+ }
+
+ /**
+ * Sets printResponse.
+ *
+ * @param printResponse
+ * printResponse
+ */
+ public void setPrintResponse(boolean printResponse)
+ {
+ this.printResponse = printResponse;
+ }
+
+ /**
+ * @see org.apache.wicket.threadtest.tester.AbstractGetCommand#doGet(org.apache.commons.httpclient.HttpClient,
+ * String)
+ */
+ @Override
+ protected void doGet(HttpClient client, String url) throws Exception
+ {
+
+ GetMethod method = new GetMethod(url);
+ method.setFollowRedirects(true);
+ try
+ {
+ if (url.contains("bookmarkable"))
+ {
+ log.info(url);
+ }
+ int code = client.executeMethod(method);
+ if (code != 200)
+ {
+ log.error("ERROR! code: " + code);
+ log.error(url);
+ throw new Exception(new String(method.getResponseBody()));
+ }
+ if (getPrintResponse())
+ {
+ log.info("\n" + Streams.readString(method.getResponseBodyAsStream()));
+ }
+ }
+ finally
+ {
+ method.releaseConnection();
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/wicket/blob/dfe9cf01/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Tester.java
----------------------------------------------------------------------
diff --git a/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Tester.java b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Tester.java
new file mode 100644
index 0000000..382aaf8
--- /dev/null
+++ b/testing/wicket-threadtest/src/test/java/org/apache/wicket/threadtest/tester/Tester.java
@@ -0,0 +1,313 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.threadtest.tester;
+
+import static org.junit.Assert.fail;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.params.HttpClientParams;
+import org.apache.commons.httpclient.params.HttpConnectionManagerParams;
+import org.apache.wicket.threadtest.tester.CommandRunner.CommandRunnerObserver;
+import org.apache.wicket.util.time.Duration;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.webapp.WebAppContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * @author eelcohillenius
+ */
+public final class Tester implements CommandRunnerObserver
+{
+ private static final Logger log = LoggerFactory.getLogger(Tester.class);
+
+ private static HttpClientParams params;
+
+ static
+ {
+ params = new HttpClientParams();
+ params.setParameter(HttpClientParams.ALLOW_CIRCULAR_REDIRECTS, true);
+ }
+
+ /**
+ * Main method for just starting the server
+ *
+ * @param args
+ */
+ public static void main(String[] args)
+ {
+ // start server on its own
+ int port = 8090;
+ if (args.length > 0)
+ {
+ port = Integer.valueOf(args[0]);
+ }
+ Server server = startServer(port);
+ try
+ {
+ server.start();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ try
+ {
+ server.stop();
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace();
+ }
+ System.exit(1);
+ }
+ }
+
+ /**
+ * Start Jetty server instance and return the handle.
+ *
+ * @param port
+ * @return server handle
+ */
+ private static Server startServer(int port)
+ {
+ Server server;
+ // start up server
+ server = new Server(port);
+ WebAppContext ctx = new WebAppContext("./src/main/webapp", "/");
+ server.setHandler(ctx);
+ try
+ {
+ server.start();
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
+ return server;
+ }
+
+ private int activeThreads = 0;
+
+ private final List<Command> commands;
+
+ private String host = "localhost";
+
+ /**
+ * if true, each thread will represent a seperate session. If false, the test behaves like one
+ * client issuing multiple concurrent requests.
+ */
+ private final boolean multipleSessions;
+
+ private final int numberOfThreads;
+
+ private int port = 8090;
+
+ private boolean failed;
+
+ /**
+ * Construct.
+ *
+ * @param command
+ * Command to execute
+ * @param numberOfThreads
+ * Number of threads to run the commands. Each thread runs all commands
+ * @param multipleSessions
+ * if true, each thread will represent a seperate session. If false, the test behaves
+ * like one client issuing multiple concurrent requests
+ */
+ public Tester(Command command, int numberOfThreads, boolean multipleSessions)
+ {
+ this(Arrays.asList(command), numberOfThreads, multipleSessions);
+ }
+
+ /**
+ * Construct.
+ *
+ * @param commands
+ * Commands to execute
+ * @param numberOfThreads
+ * Number of threads to run the commands. Each thread runs all commands
+ * @param multipleSessions
+ * if true, each thread will represent a separate session. If false, the test behaves
+ * like one client issuing multiple concurrent requests
+ */
+ public Tester(List<Command> commands, int numberOfThreads, boolean multipleSessions)
+ {
+ this.commands = commands;
+ this.numberOfThreads = numberOfThreads;
+ this.multipleSessions = multipleSessions;
+ }
+
+ /**
+ * Gets host.
+ *
+ * @return host
+ */
+ public String getHost()
+ {
+ return host;
+ }
+
+ /**
+ * Gets port.
+ *
+ * @return port
+ */
+ public int getPort()
+ {
+ return port;
+ }
+
+ public synchronized void onDone(CommandRunner runner)
+ {
+ activeThreads--;
+ notifyAll();
+ }
+
+ public synchronized void onError(CommandRunner runner, Exception e)
+ {
+ failed = true;
+
+ activeThreads--;
+ notifyAll();
+ }
+
+ /**
+ * Runs the test.
+ *
+ * @throws Exception
+ */
+ public void run() throws Exception
+ {
+
+ activeThreads = 0;
+
+ HttpConnectionManagerParams connManagerParams = new HttpConnectionManagerParams();
+ connManagerParams.setDefaultMaxConnectionsPerHost(numberOfThreads * 2);
+ MultiThreadedHttpConnectionManager manager = new MultiThreadedHttpConnectionManager();
+ manager.setParams(connManagerParams);
+
+ Server server = null;
+ GetMethod getMethod = new GetMethod("http://localhost:" + port + "/");
+ try
+ {
+ getMethod.setFollowRedirects(true);
+ HttpClient httpClient = new HttpClient(params, manager);
+ int code = httpClient.executeMethod(getMethod);
+ if (code != 200)
+ {
+ server = startServer(port);
+ }
+ }
+ catch (Exception e)
+ {
+ server = startServer(port);
+ }
+ finally
+ {
+ getMethod.releaseConnection();
+ }
+
+ try
+ {
+
+ ThreadGroup g = new ThreadGroup("runners");
+ Thread[] threads = new Thread[numberOfThreads];
+ HttpClient client = null;
+ for (int i = 0; i < numberOfThreads; i++)
+ {
+
+ if (multipleSessions)
+ {
+ client = new HttpClient(params, manager);
+ client.getHostConfiguration().setHost(host, port);
+ }
+ else
+ {
+ if (client == null)
+ {
+ client = new HttpClient(params, manager);
+ client.getHostConfiguration().setHost(host, port);
+ }
+ }
+ threads[i] = new Thread(g, new CommandRunner(commands, client, this));
+ }
+
+ long start = System.currentTimeMillis();
+
+ for (int i = 0; i < numberOfThreads; i++)
+ {
+ activeThreads++;
+ threads[i].start();
+ }
+
+ while (activeThreads > 0)
+ {
+ synchronized (this)
+ {
+ wait();
+ }
+ }
+
+ long end = System.currentTimeMillis();
+ long time = end - start;
+ log.info("\n******** finished in " + Duration.milliseconds(time) + " (" + time +
+ " milis)");
+
+ }
+ finally
+ {
+ MultiThreadedHttpConnectionManager.shutdownAll();
+ if (server != null)
+ {
+ server.stop();
+ }
+ }
+
+ if (failed) {
+ fail();
+ }
+ }
+
+ /**
+ * Sets host.
+ *
+ * @param host
+ * host
+ */
+ public void setHost(String host)
+ {
+ this.host = host;
+ }
+
+ /**
+ * Sets port.
+ *
+ * @param port
+ * port
+ */
+ public void setPort(int port)
+ {
+ this.port = port;
+ }
+}