@Override
 protected void setUp() throws Exception {
   super.setUp();
   data = TracFixture.init010();
   connector =
       (TracRepositoryConnector) TasksUi.getRepositoryConnector(TracCorePlugin.CONNECTOR_KIND);
   attachmentHandler = connector.getTaskAttachmentHandler();
   repository = TracFixture.current().singleRepository(connector);
 }
  public void testUploadAttachment() throws Exception {
    ITask task = TracTestUtil.createTask(repository, data.attachmentTicketId + "");
    File file = File.createTempFile("attachment", null);
    file.deleteOnExit();
    OutputStream out = new FileOutputStream(file);
    try {
      out.write("Mylar".getBytes());
    } finally {
      out.close();
    }
    attachmentHandler.postContent(
        repository, task, new FileTaskAttachmentSource(file), "comment", null, null);

    ITracClient client = connector.getClientManager().getTracClient(repository);
    InputStream in = client.getAttachmentData(data.attachmentTicketId, file.getName(), null);
    try {
      byte[] result = new byte[5];
      in.read(result);
      assertEquals("Mylar", new String(result));
    } finally {
      in.close();
    }
  }