Skip to content
Permalink
Browse files

[#1314] Made FunctionalTest.assertContentType(String contentType, Res…

…ponse response) check that responseContentType is not null
  • Loading branch information...
andreassimon authored and mbknor committed Dec 14, 2011
1 parent 679d532 commit 27ad902303d6c7ca466e2076fd702eb134699d71
@@ -408,8 +408,10 @@ public static void assertCharset(String charset, Response response) {
* @param response server response
*/
public static void assertContentType(String contentType, Response response) {
assertTrue("Response contentType unmatched : '" + contentType + "' !~ '" + response.contentType + "'",
response.contentType.startsWith(contentType));
String responseContentType = response.contentType;
assertNotNull("Response contentType missing", responseContentType);
assertTrue("Response contentType unmatched : '" + contentType + "' !~ '" + responseContentType + "'",
responseContentType.startsWith(contentType));
}

/**
@@ -0,0 +1,19 @@
package play.test;

import static org.junit.Assert.*;
import static play.test.FunctionalTest.*;

import org.junit.Test;

import play.mvc.Http.Response;

public class ContentTypeAssertionTest {

@Test(expected=AssertionError.class)
public void givenContentTypeIsMissing_shouldThrowAssertionError() {
Response responseWithoutContentType = new Response();

assertContentType("text/html", responseWithoutContentType);
}

}

0 comments on commit 27ad902

Please sign in to comment.
You can’t perform that action at this time.