*/
public void testValueOf() {
assertSame(MediaType.APPLICATION_XML, MediaType
.valueOf("application/xml"));
assertSame(MediaType.ALL, MediaType.valueOf("*/*"));
final MediaType newType = MediaType
.valueOf("application/x-restlet-test");
assertEquals("application", newType.getMainType());
assertEquals("x-restlet-test", newType.getSubType());
assertEquals("application/x-restlet-test", newType.getName());
// Should not have got registered by call to valueOf() alone
assertNotSame(newType, MediaType.valueOf("application/x-restlet-test"));
final MediaType registeredType = MediaType.register(
"application/x-restlet-test", "Restlet testcase");
assertNotSame(newType, registeredType); // didn't touch old value
assertEquals("application/x-restlet-test", registeredType.getName());
assertEquals("Restlet testcase", registeredType.getDescription());
// Later valueOf calls always returns the registered type
assertSame(registeredType, MediaType
.valueOf("application/x-restlet-test"));
assertSame(registeredType, MediaType
.valueOf("application/x-restlet-test"));
// Test toString() equivalence
MediaType mediaType = MediaType
.valueOf("application/atom+xml; name=value");
assertEquals("application/atom+xml; name=value", mediaType.toString());
assertEquals(MediaType.APPLICATION_ATOM, mediaType.getParent());
}