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