@Test public void testStopShouldCallStopJettyServer() throws Exception { // GIVEN doNothing().when(underTest).stopServer(); // WHEN underTest.stop(); // THEN verify(underTest).stopServer(); }
@Test public void testStopShouldLogErrorWhenWebAppCanNotBeStopped() throws Exception { // GIVEN willThrow(new Exception(EXCPEPTION_MESSAGE)).given(underTest).stopServer(); // WHEN underTest.stop(); // THEN verify(logger).error("Proxy can not be stopped: " + EXCPEPTION_MESSAGE); }
@Test(expectedExceptions = ProxyCannotBeStartedException.class) public void testStartShouldThrowExceptionWhenTheProxyCannotBeStarted() throws Exception { // GIVEN int requestTimeout = 30000; propertiesDTO = new PropertyDTO(0, requestTimeout); given(configurationAccess.getProperties()).willReturn(propertiesDTO); doThrow(Exception.class).when(server).start(requestTimeout); // WHEN underTest.start(); // THEN exception thrown }
@Test public void testStartShouldStartTheProxySuccessfully() throws Exception { // GIVEN int requestTimeout = 30000; int proxyPort = 9092; propertiesDTO = new PropertyDTO(proxyPort, requestTimeout); given(configurationAccess.getProperties()).willReturn(propertiesDTO); // WHEN underTest.start(); // THEN verify(server).setPort(proxyPort); verify(server).start(requestTimeout); verify(server).addRequestInterceptor(loggingRequestInterceptor); verify(server).addResponseInterceptor(loggingResponseInterceptor); }