struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r681695 - in /struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example: GetOrdersTest.java ListOrdersTest.java ParameterUtils.java PostOrderTest.java
Date Fri, 01 Aug 2008 13:56:29 GMT
Author: mrdon
Date: Fri Aug  1 06:56:28 2008
New Revision: 681695

URL: http://svn.apache.org/viewvc?rev=681695&view=rev
Log:
Making the base url of the integration tests configurable

Added:
    struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ParameterUtils.java
Modified:
    struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/GetOrdersTest.java
    struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ListOrdersTest.java
    struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/PostOrderTest.java

Modified: struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/GetOrdersTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/GetOrdersTest.java?rev=681695&r1=681694&r2=681695&view=diff
==============================================================================
--- struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/GetOrdersTest.java
(original)
+++ struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/GetOrdersTest.java
Fri Aug  1 06:56:28 2008
@@ -5,7 +5,7 @@
 public class GetOrdersTest extends WebTestCase {
 
     public void setUp() throws Exception {
-        getTestContext().setBaseUrl("http://localhost:8080/struts2-rest-showcase");
+        getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
     }
 
 

Modified: struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ListOrdersTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ListOrdersTest.java?rev=681695&r1=681694&r2=681695&view=diff
==============================================================================
--- struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ListOrdersTest.java
(original)
+++ struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ListOrdersTest.java
Fri Aug  1 06:56:28 2008
@@ -5,7 +5,7 @@
 public class ListOrdersTest extends WebTestCase {
 
     public void setUp() throws Exception {
-        getTestContext().setBaseUrl("http://localhost:8080/struts2-rest-showcase");
+        getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
     }
 
 

Added: struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ParameterUtils.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ParameterUtils.java?rev=681695&view=auto
==============================================================================
--- struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ParameterUtils.java
(added)
+++ struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/ParameterUtils.java
Fri Aug  1 06:56:28 2008
@@ -0,0 +1,12 @@
+package it.org.apache.struts2.rest.example;
+
+public class ParameterUtils {
+
+    public static String getBaseUrl() {
+        String port = System.getProperty("http.port");
+        if (port == null) {
+            port = "8080";
+        }
+        return "http://localhost:"+port+"/struts2-rest-showcase";
+    }
+}

Modified: struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/PostOrderTest.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/PostOrderTest.java?rev=681695&r1=681694&r2=681695&view=diff
==============================================================================
--- struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/PostOrderTest.java
(original)
+++ struts/struts2/trunk/apps/rest-showcase/src/test/java/it/org/apache/struts2/rest/example/PostOrderTest.java
Fri Aug  1 06:56:28 2008
@@ -12,7 +12,7 @@
 public class PostOrderTest extends WebTestCase {
 
     public void setUp() throws Exception {
-        getTestContext().setBaseUrl("http://localhost:8080/struts2-rest-showcase");
+        getTestContext().setBaseUrl(ParameterUtils.getBaseUrl());
     }
 
 
@@ -57,14 +57,14 @@
         HttpClient client = new HttpClient();
         PostMethod method = null;
         try {
-            method = new PostMethod("http://localhost:8080/struts2-rest-showcase/orders.xml");
+            method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.xml");
             method.setRequestEntity(new StringRequestEntity("<org.apache.struts2.rest.example.Order>\n"
+
                     "<clientName>Test3</clientName>\n" +
                     "<amount>3342</amount>\n" +
                     "</org.apache.struts2.rest.example.Order>"));
             client.executeMethod(method);
             assertEquals(201, method.getStatusCode());
-            assertTrue(method.getResponseHeader("Location").getValue().startsWith("http://localhost:8080/struts2-rest-showcase/orders/"));
+            assertTrue(method.getResponseHeader("Location").getValue().startsWith(ParameterUtils.getBaseUrl()+"/orders/"));
         } finally {
             method.releaseConnection();
         }
@@ -74,7 +74,7 @@
         HttpClient client = new HttpClient();
         PostMethod method = null;
         try {
-            method = new PostMethod("http://localhost:8080/struts2-rest-showcase/orders.xml");
+            method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.xml");
             method.setRequestEntity(new StringRequestEntity("<org.apache.struts2.rest.example.Order>\n"
+
                     "<amount>3342</amount>\n" +
                     "</org.apache.struts2.rest.example.Order>"));
@@ -92,11 +92,11 @@
         HttpClient client = new HttpClient();
         PostMethod method = null;
         try {
-            method = new PostMethod("http://localhost:8080/struts2-rest-showcase/orders.json");
+            method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.json");
             method.setRequestEntity(new StringRequestEntity("{\"amount\":33,\"clientName\":\"Test4\"}"));
             client.executeMethod(method);
             assertEquals(201, method.getStatusCode());
-            assertTrue(method.getResponseHeader("Location").getValue().startsWith("http://localhost:8080/struts2-rest-showcase/orders/"));
+            assertTrue(method.getResponseHeader("Location").getValue().startsWith(ParameterUtils.getBaseUrl()+"/orders/"));
         } finally {
             method.releaseConnection();
         }
@@ -106,7 +106,7 @@
         HttpClient client = new HttpClient();
         PostMethod method = null;
         try {
-            method = new PostMethod("http://localhost:8080/struts2-rest-showcase/orders.json");
+            method = new PostMethod(ParameterUtils.getBaseUrl()+"/orders.json");
             method.setRequestEntity(new StringRequestEntity("{\"amount\":33}"));
             client.executeMethod(method);
             String response = method.getResponseBodyAsString();



Mime
View raw message