Created
September 4, 2011 02:19
-
-
Save coderunner/1192128 to your computer and use it in GitHub Desktop.
Revisions
-
coderunner revised this gist
Sep 5, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ public class TestRequestHandler { private static final String STORE_BODY = "stored body"; private static final String CASE_HEADER = "case"; private static final String UPPERCASE = "uppercase"; private static final String REQUEST_PATH = "path"; private ExampleRequestHandler requestHandler; @@ -33,7 +33,7 @@ public void shouldReturnedAnUpperCaseVersionOfStoredText() monitoring.incrementRequestCounter(); expect(request.getPath()).andReturn(REQUEST_PATH); expect(request.getHeaders()).andReturn(headers); expect(headers.get(CASE_HEADER)).andReturn(UPPERCASE); expect(context.getStore()).andReturn(store); expect(store.get(REQUEST_PATH)).andReturn(STORE_BODY); -
coderunner revised this gist
Sep 4, 2011 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,7 +34,6 @@ public void shouldReturnedAnUpperCaseVersionOfStoredText() expect(request.getPath()).andReturn(REQUEST_PATH); expect(request.getHeaders()).andReturn(headers); expect(headers.get(CASE_HEADER)).andReturn(CASE_HEADER_VALUE); expect(context.getStore()).andReturn(store); expect(store.get(REQUEST_PATH)).andReturn(STORE_BODY); -
coderunner revised this gist
Sep 4, 2011 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,8 +32,9 @@ public void shouldReturnedAnUpperCaseVersionOfStoredText() expect(context.getMonitoring()).andReturn(monitoring); monitoring.incrementRequestCounter(); expect(request.getPath()).andReturn(REQUEST_PATH); expect(request.getHeaders()).andReturn(headers); expect(headers.get(CASE_HEADER)).andReturn(CASE_HEADER_VALUE); expect(context.getStore()).andReturn(store); expect(store.get(REQUEST_PATH)).andReturn(STORE_BODY); -
coderunner revised this gist
Sep 4, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,9 +34,9 @@ public void shouldReturnedAnUpperCaseVersionOfStoredText() expect(request.getPath()).andReturn(REQUEST_PATH); expect(headers.get(CASE_HEADER)).andReturn(CASE_HEADER_VALUE); expect(request.getHeaders()).andReturn(headers); expect(context.getStore()).andReturn(store); expect(store.get(REQUEST_PATH)).andReturn(STORE_BODY); //enter replay mode replay(request, context, monitoring, store, headers); -
coderunner revised this gist
Sep 4, 2011 . 1 changed file with 11 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -26,6 +26,8 @@ public void setup() @Test public void shouldReturnedAnUpperCaseVersionOfStoredText() { //record mode //record behavior and expected calls reset(request, context, monitoring, store, headers); expect(context.getMonitoring()).andReturn(monitoring); monitoring.incrementRequestCounter(); @@ -34,11 +36,18 @@ public void shouldReturnedAnUpperCaseVersionOfStoredText() expect(request.getHeaders()).andReturn(headers); expect(store.get(REQUEST_PATH)).andReturn(STORE_BODY); expect(context.getStore()).andReturn(store); //enter replay mode replay(request, context, monitoring, store, headers); //test call HttpResponse response = requestHandler.handle(request, context); //assertions assertEquals(STORE_BODY.toUpperCase(), response.getBody()); assertEquals(200, response.getCode()); //verify mocks verify(request, context, monitoring, store, headers); } } -
coderunner renamed this gist
Sep 4, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
coderunner created this gist
Sep 4, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ public class TestRequestHandler { private static final String STORE_BODY = "stored body"; private static final String CASE_HEADER = "case"; private static final String CASE_HEADER_VALUE = "uppercase"; private static final String REQUEST_PATH = "path"; private ExampleRequestHandler requestHandler; private HttpRequest request; private Context context; private Monitoring monitoring; private Store store; private Map<String, String> headers; @Before public void setup() { requestHandler = new ExampleRequestHandler(); request = createMock(HttpRequest.class); context = createMock(Context.class); monitoring = createMock(Monitoring.class); store = createMock(Store.class); headers = createMock(Map.class); } @Test public void shouldReturnedAnUpperCaseVersionOfStoredText() { reset(request, context, monitoring, store, headers); expect(context.getMonitoring()).andReturn(monitoring); monitoring.incrementRequestCounter(); expect(request.getPath()).andReturn(REQUEST_PATH); expect(headers.get(CASE_HEADER)).andReturn(CASE_HEADER_VALUE); expect(request.getHeaders()).andReturn(headers); expect(store.get(REQUEST_PATH)).andReturn(STORE_BODY); expect(context.getStore()).andReturn(store); replay(request, context, monitoring, store, headers); HttpResponse response = requestHandler.handle(request, context); assertEquals(STORE_BODY.toUpperCase(), response.getBody()); verify(request, context, monitoring, store, headers); } }