MimeTypeHelper { @SuppressWarnings("unchecked") public static <T extends Base> String getMimeType(T base) { String type = null; if (base instanceof Document) { Document doc = (Document)base; MimeType mt = doc.getContentType(); type = (mt != null) ? mt.toString() : getMimeType(doc.getRoot()); } else if (base instanceof Element) { Element el = (Element)base; if (el.getDocument() != null) { MimeType mt = el.getDocument().getContentType(); type = (mt != null) ? mt.toString() : null; } if (type == null) { if (el instanceof Feed) type = Constants.FEED_MEDIA_TYPE; else if (el instanceof Entry) type = Constants.ENTRY_MEDIA_TYPE; else if (el instanceof Service) type = Constants.APP_MEDIA_TYPE; else if (el instanceof Categories) type = Constants.CAT_MEDIA_TYPE; } } if (type == null) type = base.getFactory().getMimeType(base); return (type != null) ? type : Constants.XML_MEDIA_TYPE; }  static String getCharset(String mediatype); static boolean isMatch(String a, String b); static boolean isMatch(MimeType a, MimeType b); @SuppressWarnings("unchecked") static boolean isMatch(MimeType a, MimeType b, boolean includeparams); static boolean isApp(String a); static boolean isAtom(String a); static boolean isEntry(String a); static boolean isFeed(String a); static boolean isXml(String a); static boolean isText(String a); static boolean isMimeType(String a); @SuppressWarnings("unchecked") static String getMimeType(T base); static String[] condense(String... types); static Comparator<String> getComparator(); static int compare(MimeType mt1, MimeType mt2); static int compare(String t1, String t2); static boolean isMultipart(String a);  }
@Test public void testGetMimeType() { String mimeType1 = MimeTypeHelper.getMimeType(EasyMock.createMock(Feed.class)); assertEquals("application/atom+xml;type=feed", mimeType1); String mimeType2 = MimeTypeHelper.getMimeType(EasyMock.createMock(Entry.class)); assertEquals("application/atom+xml;type=entry", mimeType2); String mimeType3 = MimeTypeHelper.getMimeType(EasyMock.createMock(Service.class)); assertEquals("application/atomsvc+xml", mimeType3); }