/** Testing {@link MediaType#valueOf(String)} and {@link MediaType#register(String, String)} */
  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());
  }
  private Model internalTestSearchRdf(
      final String searchTerm,
      final String[] searchTypes,
      final MediaType requestMediaType,
      final String artifactUri)
      throws Exception {
    final ClientResource searchClientResource =
        new ClientResource(this.getUrl(PoddWebConstants.PATH_SEARCH));

    try {
      searchClientResource.addQueryParameter(PoddWebConstants.KEY_SEARCHTERM, searchTerm);
      if (artifactUri != null) {
        searchClientResource.addQueryParameter(
            PoddWebConstants.KEY_ARTIFACT_IDENTIFIER, artifactUri);
      }

      for (final String searchType : searchTypes) {
        searchClientResource.addQueryParameter(PoddWebConstants.KEY_SEARCH_TYPES, searchType);
      }

      // invoke the search resource
      final Representation results =
          this.doTestAuthenticatedRequest(
              searchClientResource,
              Method.GET,
              null,
              requestMediaType,
              Status.SUCCESS_OK,
              AbstractResourceImplTest.WITH_ADMIN);

      final RDFFormat format =
          Rio.getParserFormatForMIMEType(requestMediaType.getName(), RDFFormat.RDFXML);
      // construct a Model out of the result
      return Rio.parse(new StringReader(this.getText(results)), "", format);
    } finally {
      this.releaseClient(searchClientResource);
    }
  }