Repository: GoogleContainerTools/jib
File: jib-cli/src/integration-test/java/com/google/cloud/tools/jib/cli/JarCommandTest.java (Java)

Code before:
                "--target",
                "docker://packaged-spring-boot",
                jarPath.toString(),
                "--mode=packaged");
    assertThat(exitCode).isEqualTo(0);

    String output =
        new Command("docker", "run", "--rm", "--detach", "-p8080:8080", "packaged-spring-boot")
            .run();
    containerName = output.trim();

    assertThat(getContent(new URL("http://localhost:8080"))).isEqualTo("Hello world");
  }

  @Test
  public void testJar_baseImageSpecified()
      throws IOException, URISyntaxException, InterruptedException {
    Path jarPath = Paths.get(Resources.getResource("jarTest/standard/noDependencyJar.jar").toURI());
    Integer exitCode =
        new CommandLine(new JibCli())
            .execute(
                "jar",
                "--target",
                "docker://cli-gcr-base",
                "--from",
                "gcr.io/google-appengine/openjdk:8",
                jarPath.toString());
    assertThat(exitCode).isEqualTo(0);
    String output = new Command("docker", "run", "--rm", "cli-gcr-base").run();
    assertThat(output).isEqualTo("Hello World");
  }

  @Nullable
  private static String getContent(URL url) throws InterruptedException {
    for (int i = 0; i < 40; i++) {
      Thread.sleep(500);
      try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
          try (InputStream in = connection.getInputStream()) {
            return Blobs.writeToString(Blobs.from(in));
          }
        }
      } catch (IOException ignored) {
        // ignored
      }
    }
    return null;
  }
}


Review comment (suggestion):
nit: how about this?

```suggestion
                "jar",
                "--target=docker://cli-gcr-base",
                "--from=gcr.io/google-appengine/openjdk:8",
```

Code after:
                "--target",
                "docker://packaged-spring-boot",
                jarPath.toString(),
                "--mode=packaged");
    assertThat(exitCode).isEqualTo(0);

    String output =
        new Command("docker", "run", "--rm", "--detach", "-p8080:8080", "packaged-spring-boot")
            .run();
    containerName = output.trim();

    assertThat(getContent(new URL("http://localhost:8080"))).isEqualTo("Hello world");
  }

  @Test
  public void testJar_baseImageSpecified()
      throws IOException, URISyntaxException, InterruptedException {
    Path jarPath = Paths.get(Resources.getResource("jarTest/standard/noDependencyJar.jar").toURI());
    Integer exitCode =
        new CommandLine(new JibCli())
            .execute(
                "jar",
                "--target=docker://cli-gcr-base",
                "--from=gcr.io/google-appengine/openjdk:8",
                jarPath.toString());
    assertThat(exitCode).isEqualTo(0);
    String output = new Command("docker", "run", "--rm", "cli-gcr-base").run();
    assertThat(output).isEqualTo("Hello World");
  }

  @Nullable
  private static String getContent(URL url) throws InterruptedException {
    for (int i = 0; i < 40; i++) {
      Thread.sleep(500);
      try {
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
          try (InputStream in = connection.getInputStream()) {
            return Blobs.writeToString(Blobs.from(in));
          }
        }
      } catch (IOException ignored) {
        // ignored
      }
    }
    return null;
  }
}