assertEquals("text/plain", bd.getMimeType());
assertEquals("iso-8859-1", bd.getCharset());
}
public void testGetMimeType() {
BodyDescriptor bd = null;
bd = new BodyDescriptor();
bd.addField("Content-Type ", "text/PLAIN");
assertEquals("text/plain", bd.getMimeType());
bd = new BodyDescriptor();
bd.addField("Content-Type ", "text/PLAIN;");
assertEquals("text/plain", bd.getMimeType());
bd = new BodyDescriptor();
bd.addField("content-type", " TeXt / html ");
assertEquals("text/html", bd.getMimeType());
bd = new BodyDescriptor();
bd.addField("CONTENT-TYPE", " x-app/yada ; param = yada");
assertEquals("x-app/yada", bd.getMimeType());
bd = new BodyDescriptor();
bd.addField("CONTENT-TYPE", " yada");
assertEquals("text/plain", bd.getMimeType());
/*
* Make sure that only the first Content-Type header added is used.
*/
bd = new BodyDescriptor();
bd.addField("Content-Type ", "text/plain");
assertEquals("text/plain", bd.getMimeType());
bd.addField("Content-Type ", "text/html");
assertEquals("text/plain", bd.getMimeType());
/*
* Implicit mime types.
*/
BodyDescriptor child = null;
BodyDescriptor parent = null;
parent = new BodyDescriptor();
parent.addField("Content-Type", "mutlipart/alternative; boundary=foo");
child = new BodyDescriptor(parent);
assertEquals("text/plain", child.getMimeType());
child.addField("Content-Type", " child/type");
assertEquals("child/type", child.getMimeType());
parent = new BodyDescriptor();
parent.addField("Content-Type", "multipart/digest; boundary=foo");
child = new BodyDescriptor(parent);
assertEquals("message/rfc822", child.getMimeType());
child.addField("Content-Type", " child/type");
assertEquals("child/type", child.getMimeType());
}