Title: [930] trunk/components/base/src/test/java/org/servicemix/components/http: Change http+soap test cases so that they shut down the web server
- Revision
- 930
- Author
- gnt
- Date
- 2005-11-25 03:27:03 -0500 (Fri, 25 Nov 2005)
Log Message
Change http+soap test cases so that they shut down the web server
Modified Paths
Diff
Modified: trunk/components/base/src/test/java/org/servicemix/components/http/HttpSoapAttachmentsTest.java (929 => 930)
--- trunk/components/base/src/test/java/org/servicemix/components/http/HttpSoapAttachmentsTest.java 2005-11-24 22:37:55 UTC (rev 929)
+++ trunk/components/base/src/test/java/org/servicemix/components/http/HttpSoapAttachmentsTest.java 2005-11-25 08:27:03 UTC (rev 930)
@@ -41,13 +41,26 @@
public class HttpSoapAttachmentsTest extends TestCase {
- public void testWithAttachments() throws Exception {
- JBIContainer container = new JBIContainer();
+ private static final int PORT = 7012;
+
+ protected JBIContainer container;
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
container.setMonitorInstallationDirectory(false);
container.setUseMBeanServer(false);
container.setCreateMBeanServer(false);
container.init();
container.start();
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ public void testWithAttachments() throws Exception {
ActivationSpec as = new ActivationSpec();
as.setId("echo");
as.setComponent(new EchoComponent());
@@ -55,7 +68,7 @@
container.activateComponent(as);
as = new ActivationSpec();
as.setId("xfireBinding");
- as.setComponent(new HttpSoapConnector(null, 8081, true));
+ as.setComponent(new HttpSoapConnector(null, PORT, true));
as.setDestinationService(new QName("echo"));
container.activateComponent(as);
@@ -68,7 +81,7 @@
sendAtts.write(bos);
InputStream is = new ByteArrayInputStream(bos.toByteArray());
PostMethodWebRequest req = new PostMethodWebRequest(
- "http://localhost:8081", is, sendAtts.getContentType());
+ "http://localhost:" + PORT, is, sendAtts.getContentType());
WebResponse response = new WebConversation().getResponse(req);
System.out.println(response.getText());
}
Modified: trunk/components/base/src/test/java/org/servicemix/components/http/HttpSoapTest.java (929 => 930)
--- trunk/components/base/src/test/java/org/servicemix/components/http/HttpSoapTest.java 2005-11-24 22:37:55 UTC (rev 929)
+++ trunk/components/base/src/test/java/org/servicemix/components/http/HttpSoapTest.java 2005-11-25 08:27:03 UTC (rev 930)
@@ -38,14 +38,27 @@
import com.meterware.httpunit.WebResponse;
public class HttpSoapTest extends TestCase {
+
+ private static final int PORT = 7012;
- public void testInOut() throws Exception {
- JBIContainer container = new JBIContainer();
+ protected JBIContainer container;
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
container.setMonitorInstallationDirectory(false);
container.setUseMBeanServer(false);
container.setCreateMBeanServer(false);
container.init();
container.start();
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ public void testInOut() throws Exception {
ActivationSpec as = new ActivationSpec();
as.setId("echo");
as.setComponent(new EchoComponent());
@@ -53,11 +66,11 @@
container.activateComponent(as);
as = new ActivationSpec();
as.setId("xfireBinding");
- as.setComponent(new HttpSoapConnector(null, 8081, true));
+ as.setComponent(new HttpSoapConnector(null, PORT, true));
as.setDestinationService(new QName("echo"));
container.activateComponent(as);
- URLConnection connection = new URL("http://localhost:8081").openConnection();
+ URLConnection connection = new URL("http://localhost:" + PORT).openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
OutputStream os = connection.getOutputStream();
@@ -72,12 +85,6 @@
}
public void testInOnly() throws Exception {
- JBIContainer container = new JBIContainer();
- container.setMonitorInstallationDirectory(false);
- container.setUseMBeanServer(false);
- container.setCreateMBeanServer(false);
- container.init();
- container.start();
ActivationSpec as = new ActivationSpec();
as.setId("trace");
as.setComponent(new TraceComponent());
@@ -85,12 +92,12 @@
container.activateComponent(as);
as = new ActivationSpec();
as.setId("xfireBinding");
- as.setComponent(new HttpSoapConnector(null, 8081, false));
+ as.setComponent(new HttpSoapConnector(null, PORT, false));
as.setDestinationService(new QName("trace"));
container.activateComponent(as);
PostMethodWebRequest req = new PostMethodWebRequest(
- "http://localhost:8081/?name=Guillaume", getClass().getResourceAsStream("soap-request.xml"), null);
+ "http://localhost:" + PORT + "/?name=Guillaume", getClass().getResourceAsStream("soap-request.xml"), null);
WebResponse response = new WebConversation().getResponse(req);
System.out.println(response.getText());
}