@Test public void testIt() throws Exception { final String responseBody = executeVerifyWithGet(); assertNotNull( "Received message body must not be null.", responseBody ); assertContains( "Response must match expected content.", "It works !!", responseBody ); assertTrue( "Tomcat folder should exist in target folder of project at " + webappHome, new File( webappHome, "target/tomcat" ).exists() ); logger.info( "Error Free Log check" ); verifier.verifyErrorFreeLog(); }
private JSONObject extractJsonFromResponse(String response) throws JSONException { String defaultCruftMsg = "throw 1; < don't be evil' >"; assertStartsWith(defaultCruftMsg, response); response = response.substring(defaultCruftMsg.length()); return new JSONObject(response).getJSONObject(REQUEST_URL.toString()); }
@Test public void testIt() throws Exception { final String responseBody = executeVerifyWithGet(); assertNotNull( "Received message body must not be null.", responseBody ); assertContains( "Response must match expected content.", "It works !!", responseBody ); assertTrue( "Tomcat folder should exist in target folder of project at " + webappHome, new File( webappHome, "target/tomcat" ).exists() ); logger.info( "Error Free Log check" ); verifier.verifyErrorFreeLog(); }
private JSONObject extractJsonFromResponse(String response) throws JSONException { String defaultCruftMsg = "throw 1; < don't be evil' >"; assertStartsWith(defaultCruftMsg, response); response = response.substring(defaultCruftMsg.length()); return new JSONObject(response).getJSONObject(REQUEST_URL.toString()); }
@Test public void testIt() throws Exception { final String responseBody = executeVerifyWithGet(); assertNotNull( "Received message body must not be null.", responseBody ); assertContains( "Response must match expected content.", "Success!", responseBody ); logger.info( "Error Free Log check" ); verifier.verifyErrorFreeLog(); }
private JSONObject extractJsonFromResponse() throws JSONException { String body = recorder.getResponseAsString(); assertStartsWith(MakeRequestHandler.UNPARSEABLE_CRUFT, body); body = body.substring(MakeRequestHandler.UNPARSEABLE_CRUFT.length()); return new JSONObject(body).getJSONObject(REQUEST_URL.toString()); }
@Test public void testIt() throws Exception { final String responseBody = executeVerifyWithGet(); assertNotNull( "Received message body must not be null.", responseBody ); assertContains( "Response must match expected content.", "It works !!", responseBody ); assertTrue( "Tomcat folder should exist in target folder of project at " + webappHome, new File( webappHome, "target/tomcat" ).exists() ); logger.info( "Error Free Log check" ); verifier.verifyErrorFreeLog(); verifyConnectorsStarted(); }
private void assertResponseOk(int expectedStatus, String expectedBody) throws JSONException { if (recorder.getHttpStatusCode() == HttpServletResponse.SC_OK) { String body = recorder.getResponseAsString(); assertStartsWith(MakeRequestHandler.UNPARSEABLE_CRUFT, body); body = body.substring(MakeRequestHandler.UNPARSEABLE_CRUFT.length()); JSONObject object = new JSONObject(body); object = object.getJSONObject(REQUEST_URL.toString()); assertEquals(expectedStatus, object.getInt("rc")); assertEquals(expectedBody, object.getString("body")); } else { fail("Invalid response for request."); } }
@Test public void testIt() throws Exception { final String responseBody = executeVerifyWithGet(); assertNotNull( "Received message body from " + getWebappUrl() + " must not be null.", responseBody ); assertContains( "Response from " + getWebappUrl() + " must match expected content.", URL_QUERY, responseBody ); final File tomcatFolder = new File( webappHome, "target/tc" ); final File emptyLocation = new File( tomcatFolder, "conf/empty.txt" ); assertTrue( "Tomcat folder \"" + tomcatFolder.getAbsolutePath() + "\" should exist in target folder of project at " + webappHome, tomcatFolder.exists() ); assertTrue( "File \"" + emptyLocation.getAbsolutePath() + "\" should have been copied from tcconf to tomcat/conf", emptyLocation.exists() ); logger.info( "Error Free Log check" ); verifier.verifyErrorFreeLog(); verifyConnectorsStarted(); }
private void assertResponseOk(int expectedStatus, String expectedBody) throws JSONException { if (recorder.getHttpStatusCode() == HttpServletResponse.SC_OK) { String body = recorder.getResponseAsString(); String defaultCruftMsg = "throw 1; < don't be evil' >"; assertStartsWith(defaultCruftMsg, body); body = body.substring(defaultCruftMsg.length()); JSONObject object = new JSONObject(body); object = object.getJSONObject(REQUEST_URL.toString()); assertEquals(expectedStatus, object.getInt("rc")); assertEquals(expectedBody, object.getString("body")); } else { fail("Invalid response for request."); } }
@Test public void testDoPostException() throws Exception { setupRequest(BASIC_SYNTAX_URL); expect(request.getInputStream()).andReturn(postContentStream); expect(request.getMethod()).andReturn(POST_METHOD); expect(proxyHandler.fetch(proxyUri, POST_CONTENT)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doPost(request, recorder); verify(); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }
private void assertResponseOk(int expectedStatus, String expectedBody) throws JSONException { if (recorder.getHttpStatusCode() == HttpServletResponse.SC_OK) { String body = recorder.getResponseAsString(); String defaultCruftMsg = "throw 1; < don't be evil' >"; assertStartsWith(defaultCruftMsg, body); body = body.substring(defaultCruftMsg.length()); JSONObject object = new JSONObject(body); object = object.getJSONObject(REQUEST_URL.toString()); assertEquals(expectedStatus, object.getInt("rc")); assertEquals(expectedBody, object.getString("body")); } else { fail("Invalid response for request."); } }
@Test public void testDoPostException() throws Exception { setupRequest(BASIC_SYNTAX_URL); expect(request.getInputStream()).andReturn(postContentStream); expect(request.getMethod()).andReturn(POST_METHOD); expect(proxyHandler.fetch(proxyUri, POST_CONTENT)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doPost(request, recorder); verify(); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }
@Test public void testDoGetException() throws Exception { setupGet(); expect(pipeline.execute(internalRequest)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doGet(request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }
@Test public void testDoPostException() throws Exception { setupPost(); expect(pipeline.execute(internalRequest)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doPost(request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); } }
@Test public void testDoGetException() throws Exception { setupGet(); expect(pipeline.execute(internalRequest)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doGet(request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }
@Test public void testDoPostException() throws Exception { setupPost(); expect(pipeline.execute(internalRequest)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doPost(request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); } }
@Test public void testDoGetException() throws Exception { setupGet(); expect(pipeline.execute(internalRequest)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doGet(request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }
@Test public void testDoPostException() throws Exception { setupPost(); expect(pipeline.execute(internalRequest)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doPost(request, recorder); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); } }
@Test public void testDoGetException() throws Exception { setupRequest(BASIC_SYNTAX_URL); expect(proxyHandler.fetch(proxyUri)).andThrow( new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT, ERROR_MESSAGE)); replay(); servlet.doGet(request, recorder); verify(); assertEquals(HttpServletResponse.SC_BAD_REQUEST, recorder.getHttpStatusCode()); assertContains(ERROR_MESSAGE, recorder.getResponseAsString()); }