blob: ccae305c6d3f3c2560b9adddc1120304eb788541 (
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
36
37
38
39
40
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.application.container.handler;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
/**
* @author Einar M R Rosenvinge
*/
public class ResponseTestCase {
@Test
public void requireThatCharsetParsingWorks() {
assertThat(Response.charset("text/foobar").toString().toLowerCase(), equalTo("utf-8"));
assertThat(Response.charset("adsf").toString().toLowerCase(), equalTo("utf-8"));
assertThat(Response.charset("").toString().toLowerCase(), equalTo("utf-8"));
assertThat(Response.charset(null).toString().toLowerCase(), equalTo("utf-8"));
assertThat(Response.charset("something; charset=US-ASCII").toString().toLowerCase(), equalTo("us-ascii"));
assertThat(Response.charset("something; charset=iso-8859-1").toString().toLowerCase(), equalTo("iso-8859-1"));
assertThat(Response.charset("something; charset=").toString().toLowerCase(), equalTo("utf-8"));
assertThat(Response.charset("something; charset=bananarama").toString().toLowerCase(), equalTo("utf-8"));
}
@Test
public void testDefaultResponseBody() {
Response res1 = new Response();
Response res2 = new Response(new byte[0]);
assertThat(res1.getBody(), notNullValue());
assertThat(res1.getBody().length, is(0));
assertThat(res2.getBody(), notNullValue());
assertThat(res2.getBody().length, is(0));
}
}
|