Testing some perceived odd behavior with MimeTypes object.

This commit is contained in:
Joakim Erdfelt 2011-08-12 14:04:33 -07:00
parent c75b76b9a1
commit 06e7813539
1 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,50 @@
package org.eclipse.jetty.http;
import org.eclipse.jetty.io.Buffer;
import org.junit.Assert;
import org.junit.Test;
public class MimeTypesTest
{
@Test
public void testGetMimeByExtension_Gzip()
{
assertMimeTypeByExtension("application/gzip","test.gz");
}
@Test
public void testGetMimeByExtension_Png()
{
assertMimeTypeByExtension("image/png","test.png");
assertMimeTypeByExtension("image/png","TEST.PNG");
assertMimeTypeByExtension("image/png","Test.Png");
}
@Test
public void testGetMimeByExtension_Png_MultiDot()
{
assertMimeTypeByExtension("image/png","org.eclipse.jetty.Logo.png");
}
@Test
public void testGetMimeByExtension_Png_DeepPath()
{
assertMimeTypeByExtension("image/png","/org/eclipse/jetty/Logo.png");
}
@Test
public void testGetMimeByExtension_Text()
{
assertMimeTypeByExtension("text/plain","test.txt");
assertMimeTypeByExtension("text/plain","TEST.TXT");
}
private void assertMimeTypeByExtension(String expectedMimeType, String filename)
{
MimeTypes mimetypes = new MimeTypes();
Buffer contentType = mimetypes.getMimeByExtension(filename);
String prefix = "MimeTypes.getMimeByExtension(" + filename + ")";
Assert.assertNotNull(prefix,contentType);
Assert.assertEquals(prefix,expectedMimeType,contentType.toString());
}
}