summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/host-jetty/src/test/java
diff options
context:
space:
mode:
authorrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-03-14 00:50:38 +0000
committerrfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68>2010-03-14 00:50:38 +0000
commitb4f48f407a8fefba16395eceb34de6bd48e74d12 (patch)
tree7e1bcf4456ef1dfd3b4d337ed7ea262f1259ffef /sca-java-2.x/trunk/modules/host-jetty/src/test/java
parent014971ccb5b2041147cf9d84d498cce64ea0493e (diff)
Improve the IP address binding to be based on the host from the uri
Having servlet host to return deployed uri git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@922701 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/host-jetty/src/test/java')
-rw-r--r--sca-java-2.x/trunk/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java b/sca-java-2.x/trunk/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java
index 2ab9e46b10..a3199cf4d1 100644
--- a/sca-java-2.x/trunk/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java
+++ b/sca-java-2.x/trunk/modules/host-jetty/src/test/java/org/apache/tuscany/sca/http/jetty/JettyServerTestCase.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ConnectException;
+import java.net.InetAddress;
import java.net.Socket;
import java.net.URL;
@@ -41,6 +42,7 @@ import junit.framework.TestCase;
import org.apache.tuscany.sca.host.http.DefaultResourceServlet;
import org.apache.tuscany.sca.work.NotificationListener;
import org.apache.tuscany.sca.work.WorkScheduler;
+import org.junit.Assert;
/**
* @version $Rev$ $Date$
@@ -98,6 +100,30 @@ public class JettyServerTestCase extends TestCase {
service.stop();
assertTrue(servlet.invoked);
}
+
+ /**
+ * Verifies requests are properly routed according to the Servlet mapping
+ */
+ public void testDeployedURI() throws Exception {
+ JettyServer service = new JettyServer(workScheduler);
+ service.setDefaultPort(8085);
+ service.start();
+ TestServlet servlet = new TestServlet();
+ String host = InetAddress.getLocalHost().getHostAddress();
+ String hostName = InetAddress.getLocalHost().getHostName();
+ String url1 = service.addServletMapping("/MyService", servlet);
+ Assert.assertEquals("http://" + host + ":8085/MyService", url1);
+ String url2 = service.addServletMapping("http://localhost:8086/MyService", servlet);
+ Assert.assertEquals("http://localhost:8086/MyService", url2);
+ String url3 = service.addServletMapping("http://" + host + ":8087/MyService", servlet);
+ Assert.assertEquals("http://" + host + ":8087/MyService", url3);
+ String url4 = service.addServletMapping("http://0.0.0.0:8088/MyService", servlet);
+ Assert.assertEquals("http://" + host + ":8088/MyService", url4);
+ String url5 = service.addServletMapping("http://" + hostName + ":8089/MyService", servlet);
+ Assert.assertEquals("http://" + hostName + ":8089/MyService", url5);
+
+ service.stop();
+ }
public void testRegisterServletMappingSSL() throws Exception {
System.setProperty("javax.net.ssl.keyStore", "target/test-classes/tuscany.keyStore");