@Test( expectedExceptions = {ServerException.class}, expectedExceptionsMessageRegExp = "skopeo failed when trying to retrieve the CDN label of docker image " + IMAGE_REF + " - exit code: 1 - error output: skopeo error output") public void throwWhenSkopeoFailsWithNonZeroCode() throws Exception { doReturn(pluginMeta).when(yamlDownloader).getYamlResponseAndParse(any()); doReturn(pluginSpec).when(pluginMeta).getSpec(); doReturn(containers).when(pluginSpec).getContainers(); doReturn(false).when(containers).isEmpty(); doReturn(1).when(containers).size(); doReturn(container).when(containers).get(0); doReturn(IMAGE_REF).when(container).getImage(); lenient() .when(commandRunner.runCommand(eq("skopeo"), any(), any(), anyLong(), any(), any(), any())) .thenReturn(skopeoHelpProcess, skopeoInspectProcess); doReturn(0).when(skopeoHelpProcess).exitValue(); doReturn(1).when(skopeoInspectProcess).exitValue(); when(commandRunner.newOutputConsumer()).thenReturn(skopeoOutputConsumer); when(commandRunner.newErrorConsumer()).thenReturn(skopeoErrorConsumer); when(skopeoErrorConsumer.getText()).thenReturn("skopeo error output"); service = new CdnSupportService( commandRunner, pluginFQNParser, yamlDownloader, DEFAULT_REGISTRY_URL, EDITOR_REF); service.dockerImage = IMAGE_REF; service.getPaths(); }
@GET @Path("paths") @Produces(APPLICATION_JSON) public String getPaths() throws Exception { if (editorToPrefetch == null) { throw new NotFoundException("No editor is configured for CDN resource pre-fetching"); } if (dockerImage == null) { PluginMeta editorMeta = getEditorMeta(); dockerImage = getDockerImage(editorMeta); } JsonNode json = inspectDockerImage(); return json.path("Labels").path(LABEL_NAME).asText("[]"); }
CdnSupportService extends Service { @GET @Path("paths") @Produces(APPLICATION_JSON) public String getPaths() throws Exception { if (editorToPrefetch == null) { throw new NotFoundException("No editor is configured for CDN resource pre-fetching"); } if (dockerImage == null) { PluginMeta editorMeta = getEditorMeta(); dockerImage = getDockerImage(editorMeta); } JsonNode json = inspectDockerImage(); return json.path("Labels").path(LABEL_NAME).asText("[]"); } }
CdnSupportService extends Service { @GET @Path("paths") @Produces(APPLICATION_JSON) public String getPaths() throws Exception { if (editorToPrefetch == null) { throw new NotFoundException("No editor is configured for CDN resource pre-fetching"); } if (dockerImage == null) { PluginMeta editorMeta = getEditorMeta(); dockerImage = getDockerImage(editorMeta); } JsonNode json = inspectDockerImage(); return json.path("Labels").path(LABEL_NAME).asText("[]"); } @Inject  CdnSupportService(
      PluginFQNParser pluginFQNParser,
      HttpYamlDownloader yamlDownloader,
      @Named("che.workspace.plugin_registry_url") String registryUrl,
      @Nullable @Named("che.fabric8.cdn.prefetch.editor") String editorToPrefetch); @VisibleForTesting  CdnSupportService(
      CommandRunner commandRunner,
      PluginFQNParser pluginFQNParser,
      HttpYamlDownloader yamlDownloader,
      @Named("che.workspace.plugin_registry_url") String registryUrl,
      @Nullable @Named("che.fabric8.cdn.prefetch.editor") String editorToPrefetch); }
CdnSupportService extends Service { @GET @Path("paths") @Produces(APPLICATION_JSON) public String getPaths() throws Exception { if (editorToPrefetch == null) { throw new NotFoundException("No editor is configured for CDN resource pre-fetching"); } if (dockerImage == null) { PluginMeta editorMeta = getEditorMeta(); dockerImage = getDockerImage(editorMeta); } JsonNode json = inspectDockerImage(); return json.path("Labels").path(LABEL_NAME).asText("[]"); } @Inject  CdnSupportService(
      PluginFQNParser pluginFQNParser,
      HttpYamlDownloader yamlDownloader,
      @Named("che.workspace.plugin_registry_url") String registryUrl,
      @Nullable @Named("che.fabric8.cdn.prefetch.editor") String editorToPrefetch); @VisibleForTesting  CdnSupportService(
      CommandRunner commandRunner,
      PluginFQNParser pluginFQNParser,
      HttpYamlDownloader yamlDownloader,
      @Named("che.workspace.plugin_registry_url") String registryUrl,
      @Nullable @Named("che.fabric8.cdn.prefetch.editor") String editorToPrefetch); @GET @Path("paths") @Produces(APPLICATION_JSON) String getPaths(); }
CdnSupportService extends Service { @GET @Path("paths") @Produces(APPLICATION_JSON) public String getPaths() throws Exception { if (editorToPrefetch == null) { throw new NotFoundException("No editor is configured for CDN resource pre-fetching"); } if (dockerImage == null) { PluginMeta editorMeta = getEditorMeta(); dockerImage = getDockerImage(editorMeta); } JsonNode json = inspectDockerImage(); return json.path("Labels").path(LABEL_NAME).asText("[]"); } @Inject  CdnSupportService(
      PluginFQNParser pluginFQNParser,
      HttpYamlDownloader yamlDownloader,
      @Named("che.workspace.plugin_registry_url") String registryUrl,
      @Nullable @Named("che.fabric8.cdn.prefetch.editor") String editorToPrefetch); @VisibleForTesting  CdnSupportService(
      CommandRunner commandRunner,
      PluginFQNParser pluginFQNParser,
      HttpYamlDownloader yamlDownloader,
      @Named("che.workspace.plugin_registry_url") String registryUrl,
      @Nullable @Named("che.fabric8.cdn.prefetch.editor") String editorToPrefetch); @GET @Path("paths") @Produces(APPLICATION_JSON) String getPaths();  }