blob: 22607e8fc26b8a48b606f350c46dbaf854a5ba87 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.http;
import com.yahoo.container.jdisc.HttpResponse;
import java.io.IOException;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*;
/**
* Base class for handler tests
*
* @author musum
* @since 5.1.14
*/
public class HandlerTest {
public static void assertHttpStatusCodeErrorCodeAndMessage(HttpResponse response, int statusCode, HttpErrorResponse.errorCodes errorCode, String message) throws IOException {
assertNotNull(response);
String renderedString = SessionHandlerTest.getRenderedString(response);
if (renderedString == null) {
renderedString = "assert failed";
}
assertThat(renderedString, response.getStatus(), is(statusCode));
if (errorCode != null) {
assertThat(renderedString, containsString(errorCode.name()));
}
assertThat(renderedString, containsString(message));
}
public static void assertHttpStatusCodeAndMessage(HttpResponse response, int statusCode, String message) throws IOException {
assertHttpStatusCodeErrorCodeAndMessage(response, statusCode, null, message);
}
}
|