package org.jogger;

import org.apache.http.HttpResponse;
import org.apache.http.client.fluent.Request;
import org.testng.Assert;
import org.testng.annotations.Test;

public class JoggerServerTest {

	@Test
	public void shouldStartServer() throws Exception {
		JoggerServer joggerServer = new JoggerServer(new Jogger());
		joggerServer.listen(27773);

		HttpResponse response = Request.Get("http://localhost:27773/").execute().returnResponse();
		Assert.assertEquals(response.getStatusLine().getStatusCode(), 404);
		
		joggerServer.stop();
	}
	
}

@@ -97,16 +97,49 @@
 equest;%0A
+import org.jogger.http.Response;%0A
 import o
@@ -378,16 +378,25 @@
 7773);%0A%0A
+%09%09try %7B%0A%09
 %09%09HttpRe
@@ -482,16 +482,17 @@
 se();%0A%09%09
+%09
 Assert.a
@@ -553,17 +553,29 @@
 404);%0A%09%09
-%0A
+%7D finally %7B%0A%09
 %09%09jogger
@@ -589,15 +589,1125 @@
 stop();%0A
+%09%09%7D%0A%09%7D%0A%09%0A%09@Test%0A%09public void shouldExecuteRoute() throws Exception %7B%0A%09%09Jogger app = new Jogger();%0A%09%09app.get(%22/%22, new RouteHandler() %7B%0A%09%09%09@Override%0A%09%09%09public void handle(org.jogger.http.Request request, Response response) %7B%0A%09%09%09%09%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09JoggerServer joggerServer = new JoggerServer(app);%0A%09%09joggerServer.listen(27773);%0A%0A%09%09try %7B%0A%09%09%09HttpResponse response = Request.Get(%22http://localhost:27773/%22).execute().returnResponse();%0A%09%09%09Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);%0A%09%09%7D finally %7B%0A%09%09%09joggerServer.stop();%0A%09%09%7D%0A%09%7D%0A%09%0A%09@Test%0A%09public void shouldHandleException() throws Exception %7B%0A%09%09Jogger app = new Jogger();%0A%09%09app.get(%22/%22, new RouteHandler() %7B%0A%09%09%09@Override%0A%09%09%09public void handle(org.jogger.http.Request request, Response response) %7B%0A%09%09%09%09throw new RuntimeException();%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09JoggerServer joggerServer = new JoggerServer(app);%0A%09%09joggerServer.listen(27773);%0A%0A%09%09try %7B%0A%09%09%09HttpResponse response = Request.Get(%22http://localhost:27773/%22).execute().returnResponse();%0A%09%09%09Assert.assertEquals(response.getStatusLine().getStatusCode(), 500);%0A%09%09%7D finally %7B%0A%09%09%09joggerServer.stop();%0A%09%09%7D%0A
 %09%7D%0A%09%0A%7D%0A

Create tests for JoggerServer