Author: veithen
Date: Sat May 15 10:32:42 2010
New Revision: 944609
URL: http://svn.apache.org/viewvc?rev=944609&view=rev
Log:
Use dynamic port allocation in HTTP tests (instead of hardcoded port 8280).
Added:
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java
(with props)
Modified:
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/HttpTransportDescriptionFactory.java
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/SimpleHTTPServerTest.java
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java
Modified:
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/HttpTransportDescriptionFactory.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/HttpTransportDescriptionFactory.java?rev=944609&r1=944608&r2=944609&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/HttpTransportDescriptionFactory.java
(original)
+++
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/HttpTransportDescriptionFactory.java
Sat May 15 10:32:42 2010
@@ -23,13 +23,16 @@ import org.apache.axis2.description.Para
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.transport.testkit.axis2.TransportDescriptionFactory;
+import org.apache.axis2.transport.testkit.http.HttpTestEnvironment;
+import org.apache.axis2.transport.testkit.tests.Setup;
import
org.apache.axis2.transport.testkit.util.LifecycleFixTransportListenerProxy;
public class HttpTransportDescriptionFactory implements
TransportDescriptionFactory {
- private final int port;
+ private int port;
- public HttpTransportDescriptionFactory(int port) {
- this.port = port;
+ @Setup @SuppressWarnings("unused")
+ private void setUp(HttpTestEnvironment env) {
+ port = env.getServerPort();
}
public TransportInDescription createTransportInDescription() throws
Exception {
Modified:
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/SimpleHTTPServerTest.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/SimpleHTTPServerTest.java?rev=944609&r1=944608&r2=944609&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/SimpleHTTPServerTest.java
(original)
+++
axis/axis2/java/transports/trunk/modules/http/test/org/apache/axis2/transport/http/SimpleHTTPServerTest.java
Sat May 15 10:32:42 2010
@@ -30,7 +30,7 @@ public class SimpleHTTPServerTest extend
public static TestSuite suite() throws Exception {
ManagedTestSuite suite = new
ManagedTestSuite(SimpleHTTPServerTest.class);
- TransportDescriptionFactory tdf = new
HttpTransportDescriptionFactory(8280);
+ TransportDescriptionFactory tdf = new
HttpTransportDescriptionFactory();
new HttpTransportTestSuiteBuilder(suite, tdf).build();
Modified:
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java?rev=944609&r1=944608&r2=944609&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java
(original)
+++
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpChannel.java
Sat May 15 10:32:42 2010
@@ -19,7 +19,6 @@
package org.apache.axis2.transport.testkit.http;
-import java.net.InetSocketAddress;
import java.util.UUID;
import org.apache.axis2.addressing.EndpointReference;
@@ -28,14 +27,15 @@ import org.apache.axis2.transport.testki
import org.apache.axis2.transport.testkit.tests.Setup;
import org.apache.axis2.transport.testkit.tests.TearDown;
import org.apache.axis2.transport.testkit.tests.Transient;
-import org.apache.axis2.transport.testkit.util.tcpmon.Tunnel;
public class HttpChannel implements AsyncChannel, RequestResponseChannel {
+ private int serverPort;
private @Transient String serviceName;
// private @Transient Tunnel tunnel;
@Setup @SuppressWarnings("unused")
- private void setUp() throws Exception {
+ private void setUp(HttpTestEnvironment env) throws Exception {
+ serverPort = env.getServerPort();
serviceName = "TestService-" + UUID.randomUUID();
// tunnel = new Tunnel(new InetSocketAddress("127.0.0.1", 8280));
// tunnel.start();
@@ -51,6 +51,6 @@ public class HttpChannel implements Asyn
}
public EndpointReference getEndpointReference() throws Exception {
- return new EndpointReference("http://localhost:" + /* tunnel.getPort()
*/ 8280 + CONTEXT_PATH + "/" + serviceName);
+ return new EndpointReference("http://localhost:" + /* tunnel.getPort()
*/ serverPort + CONTEXT_PATH + "/" + serviceName);
}
}
\ No newline at end of file
Added:
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java?rev=944609&view=auto
==============================================================================
---
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java
(added)
+++
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java
Sat May 15 10:32:42 2010
@@ -0,0 +1,49 @@
+/*
+ * 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.axis2.transport.testkit.http;
+
+import org.apache.axis2.transport.testkit.tests.Setup;
+import org.apache.axis2.transport.testkit.tests.TearDown;
+import org.apache.axis2.transport.testkit.tests.Transient;
+import org.apache.axis2.transport.testkit.util.PortAllocator;
+
+public class HttpTestEnvironment {
+ public static final HttpTestEnvironment INSTANCE = new
HttpTestEnvironment();
+
+ private @Transient PortAllocator portAllocator;
+ private int serverPort;
+
+ private HttpTestEnvironment() {}
+
+ @Setup @SuppressWarnings("unused")
+ private void setUp(PortAllocator portAllocator) throws Exception {
+ this.portAllocator = portAllocator;
+ serverPort = portAllocator.allocatePort();
+ }
+
+ public int getServerPort() {
+ return serverPort;
+ }
+
+ @TearDown @SuppressWarnings("unused")
+ private void tearDown() throws Exception {
+ portAllocator.releasePort(serverPort);
+ }
+}
Propchange:
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/HttpTestEnvironment.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java
URL:
http://svn.apache.org/viewvc/axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java?rev=944609&r1=944608&r2=944609&view=diff
==============================================================================
---
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java
(original)
+++
axis/axis2/java/transports/trunk/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/http/JettyServer.java
Sat May 15 10:32:42 2010
@@ -36,10 +36,10 @@ public class JettyServer {
private JettyServer() {}
@Setup @SuppressWarnings("unused")
- private void setUp() throws Exception {
+ private void setUp(HttpTestEnvironment env) throws Exception {
server = new Server();
SocketListener listener = new SocketListener();
- listener.setPort(8280);
+ listener.setPort(env.getServerPort());
server.addListener(listener);
context = new HttpContext(server, Channel.CONTEXT_PATH + "/*");
server.start();