public class TestContentType extends TapestryTestCase
{
public void testParsing1() throws Exception
{
ContentType contentType = new ContentType("text/html;charset=utf-8");
assertEquals("The base type of the ContentType is invalid", "text", contentType
.getBaseType());
assertEquals("The html type of the ContentType is invalid", "html", contentType
.getSubType());
assertEquals("The mime type of the ContentType is invalid", "text/html", contentType
.getMimeType());
String[] parameterNames = contentType.getParameterNames();
assertEquals(
"The number of parameter names of the ContentType is invalid",
1,
parameterNames.length);
assertEquals(
"The parameter names of the ContentType are invalid",
"charset",
parameterNames[0]);
String charset = contentType.getParameter("charset");
assertEquals("The charset parameter of the ContentType is invalid", "utf-8", charset);
String nonexistant = contentType.getParameter("nonexistant");
assertTrue(
"ContentType does not return null for a non-existant parameter",
nonexistant == null);
}