You are viewing a plain text version of this content. The canonical link for it is here.
Posted to awf-commits@incubator.apache.org by jm...@apache.org on 2011/08/02 17:59:28 UTC

svn commit: r1153226 [3/3] - in /incubator/deft/sandbox: ./ src/main/java/org/deftserver/annotation/ src/main/java/org/deftserver/configuration/ src/main/java/org/deftserver/example/ src/main/java/org/deftserver/example/client/ src/main/java/org/deftse...

Modified: incubator/deft/sandbox/src/test/java/org/deftserver/web/HttpServerTest.java
URL: http://svn.apache.org/viewvc/incubator/deft/sandbox/src/test/java/org/deftserver/web/HttpServerTest.java?rev=1153226&r1=1153225&r2=1153226&view=diff
==============================================================================
--- incubator/deft/sandbox/src/test/java/org/deftserver/web/HttpServerTest.java (original)
+++ incubator/deft/sandbox/src/test/java/org/deftserver/web/HttpServerTest.java Tue Aug  2 17:59:22 2011
@@ -19,35 +19,49 @@
  */
 package org.deftserver.web;
 
+import org.deftserver.configuration.Configuration;
 import org.deftserver.web.handler.RequestHandler;
 import org.junit.Test;
 
 import com.google.common.collect.Maps;
 
-
+/**
+ * Test cases for {@link HttpServer}.
+ */
 public class HttpServerTest {
-	
-	private final Application application = new Application(Maps.<String, RequestHandler>newHashMap());
-	
-	@Test(expected=IllegalArgumentException.class)
-	public void testPortInRange_low() {
-		int port = 0;
-		HttpServer server = new HttpServer(application);
-		server.listen(port);
-	}
-	
-
-	@Test(expected=IllegalArgumentException.class)
-	public void testPortInRange_high() {
-		int port = 65536;
-		HttpServer server = new HttpServer(application);
-		server.listen(port);
-	}
-	
-	public void testPortInRange_ok() {
-		int port = 34;
-		HttpServer server = new HttpServer(application);
-		server.listen(port);
-	}
-	
+
+    private final Application application = new Application(Maps.<String, RequestHandler> newHashMap());
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testPortInRange_low() {
+        int port = 0;
+        HttpServer server = createServer();
+        server.listen(port);
+    }
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testPortInRange_high() {
+        int port = 65536;
+        HttpServer server = createServer();
+        server.listen(port);
+    }
+
+    @Test
+    public void testPortInRange_ok() {
+        int port = 34;
+        HttpServer server = createServer();
+        server.listen(port);
+    }
+
+    private HttpServer createServer() {
+
+        HttpServer server = new HttpServer(new Configuration()) {
+            @Override
+            protected Application createApplication(String packageName) {
+                return application;
+            }
+        };
+
+        return server;
+    }
 }