@Test
  public void checkAgentStatusShouldIncludeMd5Checksum_forAgent_forLauncher_whenChecksumsAreCached()
      throws Exception {
    when(pluginsZip.md5()).thenReturn("plugins-zip-md5");

    controller.checkAgentStatus(response);

    try (InputStream stream =
        new TFSJarDetector.DevelopmentServerTFSJarDetector(systemEnvironment)
            .getJarURL()
            .openStream()) {
      assertEquals(
          md5DigestOfStream(stream),
          response.getHeader(SystemEnvironment.AGENT_TFS_SDK_MD5_HEADER));
    }

    try (InputStream stream = JarDetector.create(systemEnvironment, "agent-launcher.jar")) {
      assertEquals(
          md5DigestOfStream(stream),
          response.getHeader(SystemEnvironment.AGENT_LAUNCHER_CONTENT_MD5_HEADER));
    }

    try (InputStream stream = JarDetector.create(systemEnvironment, "agent.jar")) {
      assertEquals(
          md5DigestOfStream(stream),
          response.getHeader(SystemEnvironment.AGENT_CONTENT_MD5_HEADER));
    }

    assertEquals(
        "plugins-zip-md5", response.getHeader(SystemEnvironment.AGENT_PLUGINS_ZIP_MD5_HEADER));
    assertEquals("8443", response.getHeader("Cruise-Server-Ssl-Port"));
  }
  @Test
  public void contentShouldIncludeMd5Checksum_forAgentLauncher() throws Exception {
    controller.downloadAgentLauncher(response);
    assertEquals("8443", response.getHeader("Cruise-Server-Ssl-Port"));
    assertEquals("application/octet-stream", response.getContentType());

    try (InputStream stream = JarDetector.create(systemEnvironment, "agent-launcher.jar")) {
      assertEquals(md5DigestOfStream(stream), response.getHeader("Content-MD5"));
    }
    try (InputStream is = JarDetector.create(systemEnvironment, "agent-launcher.jar")) {
      assertTrue(Arrays.equals(IOUtils.toByteArray(is), response.getContentAsByteArray()));
    }
  }
  @Test
  public void headShouldIncludeMd5ChecksumAndServerUrl_forAgentLauncher() throws Exception {
    controller.checkAgentLauncherVersion(response);
    assertEquals("8443", response.getHeader("Cruise-Server-Ssl-Port"));

    try (InputStream stream = JarDetector.create(systemEnvironment, "agent-launcher.jar")) {
      assertEquals(md5DigestOfStream(stream), response.getHeader("Content-MD5"));
    }
  }