#67 [CLI,DAEMON] Return proper return codes / status codes

This commit is contained in:
Andreas Penski 2020-09-02 12:34:20 +00:00
parent fa7faf9961
commit f2223552ad
21 changed files with 424 additions and 248 deletions

View file

@ -1,6 +1,7 @@
package de.kosit.validationtool.daemon;
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpStatus.SC_NOT_ACCEPTABLE;
import static org.apache.http.HttpStatus.SC_OK;
import java.io.IOException;
@ -41,7 +42,7 @@ public class CheckHandlerIT extends BaseIT {
@Test
public void testUnknown() throws IOException {
try ( final InputStream io = Simple.UNKNOWN.toURL().openStream() ) {
given().contentType(APPLICATION_XML).body(toContent(io)).when().post("/").then().statusCode(SC_OK);
given().contentType(APPLICATION_XML).body(toContent(io)).when().post("/").then().statusCode(SC_NOT_ACCEPTABLE);
}
}

View file

@ -38,7 +38,7 @@ public class ConfigHandlerTest {
final Configuration config = TestConfigurationFactory.createSimpleConfiguration().build();
final ConfigHandler handler = new ConfigHandler(config, new ConversionService());
handler.handle(exchange);
verify(exchange, times(1)).sendResponseHeaders(ConfigHandler.OK, 0);
verify(exchange, times(1)).sendResponseHeaders(HttpStatus.SC_OK, 0);
verify(stream, atLeast(1)).write(any());
}
@ -55,6 +55,6 @@ public class ConfigHandlerTest {
handler.handle(exchange);
verify(headers, times(1)).add(any(), any());
verify(stream, atLeast(1)).write(any());
assertThat(valueCapture.getValue()).isEqualTo(500);
assertThat(valueCapture.getValue()).isEqualTo(HttpStatus.SC_INTERNAL_SERVER_ERROR);
}
}