diff options
Diffstat (limited to 'jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java')
-rw-r--r-- | jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java | 59 |
1 files changed, 5 insertions, 54 deletions
diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java index 15c7e0fe0d..9401682da5 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/MimeTypesTest.java @@ -18,10 +18,8 @@ package org.eclipse.jetty.http; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - +import org.eclipse.jetty.io.Buffer; +import org.junit.Assert; import org.junit.Test; public class MimeTypesTest @@ -58,60 +56,13 @@ public class MimeTypesTest assertMimeTypeByExtension("text/plain","test.txt"); assertMimeTypeByExtension("text/plain","TEST.TXT"); } - - @Test - public void testGetMimeByExtension_NoExtension() - { - MimeTypes mimetypes = new MimeTypes(); - String contentType = mimetypes.getMimeByExtension("README"); - assertNull(contentType); - } private void assertMimeTypeByExtension(String expectedMimeType, String filename) { MimeTypes mimetypes = new MimeTypes(); - String contentType = mimetypes.getMimeByExtension(filename); + Buffer contentType = mimetypes.getMimeByExtension(filename); String prefix = "MimeTypes.getMimeByExtension(" + filename + ")"; - assertNotNull(prefix,contentType); - assertEquals(prefix,expectedMimeType,contentType); - } - - @Test - public void testCharsetFromContentType() - { - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar;charset=abc;some=else")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar;charset=abc")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar ; charset = abc")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar ; charset = abc ; some=else")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar;other=param;charset=abc;some=else")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar;other=param;charset=abc")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar other = param ; charset = abc")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar other = param ; charset = abc ; some=else")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar other = param ; charset = abc")); - assertEquals("abc",MimeTypes.getCharsetFromContentType("foo/bar other = param ; charset = \"abc\" ; some=else")); - assertEquals(null,MimeTypes.getCharsetFromContentType("foo/bar")); - assertEquals("UTF-8",MimeTypes.getCharsetFromContentType("foo/bar;charset=uTf8")); - assertEquals("UTF-8",MimeTypes.getCharsetFromContentType("foo/bar;other=\"charset=abc\";charset=uTf8")); - assertEquals("UTF-8",MimeTypes.getCharsetFromContentType("text/html;charset=utf-8")); - - } - - @Test - public void testContentTypeWithoutCharset() - { - assertEquals("foo/bar;some=else",MimeTypes.getContentTypeWithoutCharset("foo/bar;charset=abc;some=else")); - assertEquals("foo/bar",MimeTypes.getContentTypeWithoutCharset("foo/bar;charset=abc")); - assertEquals("foo/bar",MimeTypes.getContentTypeWithoutCharset("foo/bar ; charset = abc")); - assertEquals("foo/bar;some=else",MimeTypes.getContentTypeWithoutCharset("foo/bar ; charset = abc ; some=else")); - assertEquals("foo/bar;other=param;some=else",MimeTypes.getContentTypeWithoutCharset("foo/bar;other=param;charset=abc;some=else")); - assertEquals("foo/bar;other=param",MimeTypes.getContentTypeWithoutCharset("foo/bar;other=param;charset=abc")); - assertEquals("foo/bar ; other = param",MimeTypes.getContentTypeWithoutCharset("foo/bar ; other = param ; charset = abc")); - assertEquals("foo/bar ; other = param;some=else",MimeTypes.getContentTypeWithoutCharset("foo/bar ; other = param ; charset = abc ; some=else")); - assertEquals("foo/bar ; other = param",MimeTypes.getContentTypeWithoutCharset("foo/bar ; other = param ; charset = abc")); - assertEquals("foo/bar ; other = param;some=else",MimeTypes.getContentTypeWithoutCharset("foo/bar ; other = param ; charset = \"abc\" ; some=else")); - assertEquals("foo/bar",MimeTypes.getContentTypeWithoutCharset("foo/bar")); - assertEquals("foo/bar",MimeTypes.getContentTypeWithoutCharset("foo/bar;charset=uTf8")); - assertEquals("foo/bar;other=\"charset=abc\"",MimeTypes.getContentTypeWithoutCharset("foo/bar;other=\"charset=abc\";charset=uTf8")); - assertEquals("text/html",MimeTypes.getContentTypeWithoutCharset("text/html;charset=utf-8")); + Assert.assertNotNull(prefix,contentType); + Assert.assertEquals(prefix,expectedMimeType,contentType.toString()); } } |