/** Equality tests. */
  public void testEquals() throws Exception {
    MediaType mt1 = new MediaType("application/xml");
    MediaType mt2 = MediaType.APPLICATION_XML;
    assertTrue(mt1.equals(mt2));
    assertEquals(mt1, mt2);

    final Series<Parameter> mediaParams1 = new Form();
    mediaParams1.add(new Parameter("charset", "ISO-8859-1"));
    final MediaType mt1Bis = new MediaType("application/xml", mediaParams1);

    final Series<Parameter> mediaParams2 = new Form();
    mediaParams2.add(new Parameter("charset", "ISO-8859-1"));
    final MediaType mt2Bis = new MediaType("application/xml", mediaParams2);

    final Series<Parameter> mediaParams3 = new Form();
    mediaParams3.add(new Parameter("charset", "ISO-8859-15"));
    final MediaType mt3 = new MediaType("application/xml", mediaParams3);

    assertTrue(mt1Bis.equals(mt2Bis));
    assertEquals(mt1, mt2);
    assertTrue(mt1Bis.equals(mt1, true));
    assertTrue(mt1Bis.equals(mt2, true));
    assertTrue(mt1Bis.equals(mt3, true));

    mt1 = new MediaType("application/*");
    mt2 = MediaType.APPLICATION_ALL;
    assertTrue(mt1.equals(mt2));
    assertEquals(mt1, mt2);
  }
  @Override
  public Representation represent(Variant variant) throws ResourceException {
    final MediaType mediaType = variant.getMediaType();
    if (mediaType.equals(MediaType.TEXT_XML)) {
      return new StringRepresentation("<a>b</a>", mediaType);
    } else if (mediaType.equals(MediaType.TEXT_HTML)) {
      return new StringRepresentation("<html><body>a</body></html>", mediaType);
    }

    return null;
  }
 /**
  * Builds XML or JSON Representation of Project for Create and Update methods.
  *
  * @param item Project
  * @param media APPLICATION_XML or APPLICATION_JSON
  * @return XML or JSON Representation
  */
 public static Representation getRepresentation(TaskModel item, MediaType media) {
   if (media.equals(MediaType.APPLICATION_JSON)) {
     return new JacksonRepresentation<TaskModel>(item);
   } else if (media.equals(MediaType.APPLICATION_XML)) {
     XStream xstream = XStreamFactory.getInstance().getXStream(media, false);
     XstreamRepresentation<TaskModel> rep = new XstreamRepresentation<TaskModel>(media, item);
     configure(xstream);
     rep.setXstream(xstream);
     return rep;
   } else {
     Engine.getLogger(AbstractSitoolsTestCase.class.getName())
         .warning("Only JSON or XML supported in tests");
     return null; // TODO complete test with ObjectRepresentation
   }
 }
  /** Test references that are unequal. */
  public void testUnEquals() throws Exception {
    MediaType mt1 = new MediaType("application/xml");
    MediaType mt2 = new MediaType("application/xml2");
    assertFalse(mt1.equals(mt2));

    final Series<Parameter> mediaParams1 = new Form();
    mediaParams1.add(new Parameter("charset", "ISO-8859-1"));
    final MediaType mt1Bis = new MediaType("application/xml", mediaParams1);

    final Series<Parameter> mediaParams3 = new Form();
    mediaParams3.add(new Parameter("charset", "ISO-8859-15"));
    final MediaType mt3 = new MediaType("application/xml", mediaParams3);

    assertFalse(mt1Bis.equals(mt1));
    assertFalse(mt1Bis.equals(mt3));

    mt1 = new MediaType("application/1");
    mt2 = MediaType.APPLICATION_ALL;
    assertFalse(mt1.equals(mt2));
  }