use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.
the class ServersCheckerTest method awaitShouldReturnOnFirstUnavailability.
@Test(timeOut = 5000)
public void awaitShouldReturnOnFirstUnavailability() throws Exception {
CompletableFuture<String> future1 = spy(new CompletableFuture<>());
CompletableFuture<String> future2 = spy(new CompletableFuture<>());
CompletableFuture<String> future3 = spy(new CompletableFuture<>());
when(connectionChecker.getReportCompFuture()).thenReturn(future1).thenReturn(future2).thenReturn(future3);
checker.startAsync(readinessHandler);
future2.completeExceptionally(new InfrastructureException("error"));
try {
checker.await();
fail();
} catch (InfrastructureException ignored) {
verify(future1, never()).complete(anyString());
verify(future2, never()).complete(anyString());
verify(future3, never()).complete(anyString());
verify(future1, never()).completeExceptionally(any(Throwable.class));
verify(future2).completeExceptionally(any(Throwable.class));
verify(future3, never()).completeExceptionally(any(Throwable.class));
}
}
use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.
the class ServersCheckerTest method throwsExceptionIfAnyServerIsNotAvailable.
@Test(expectedExceptions = InfrastructureException.class, expectedExceptionsMessageRegExp = "oops!")
public void throwsExceptionIfAnyServerIsNotAvailable() throws InfrastructureException {
doThrow(new InfrastructureException("oops!")).when(connectionChecker).checkOnce(any());
checker.checkOnce(ref -> {
});
}
use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.
the class RecipeRetriever method prepareURL.
private URL prepareURL(String location) throws InfrastructureException {
URI uri;
try {
uri = new URI(location);
} catch (URISyntaxException e) {
LOG.debug(e.getLocalizedMessage(), e);
throw new InfrastructureException("Location of recipe downloading is not supported because it is not a valid URI");
}
// if URI to this server add token to access protected API
boolean addToken = isTokenNeeded(uri);
UriBuilder uriBuilder = makeURIAbsolute(uri);
if (addToken) {
addToken(uriBuilder);
}
try {
return uriBuilder.build().toURL();
} catch (MalformedURLException e) {
LOG.debug(e.getLocalizedMessage(), e);
throw new InfrastructureException("Constructing URL for downloading recipe failed");
}
}
use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.
the class PluginFQNParser method parsePluginFQNs.
private Collection<PluginFQN> parsePluginFQNs(String attribute) throws InfrastructureException {
String[] plugins = splitAttribute(attribute);
if (plugins.length == 0) {
return emptyList();
}
List<PluginFQN> collectedFQNs = new ArrayList<>();
for (String plugin : plugins) {
PluginFQN pFQN = parsePluginFQN(plugin);
String pluginKey = firstNonNull(pFQN.getReference(), pFQN.getId());
if (collectedFQNs.stream().anyMatch(p -> pluginKey.equals(p.getId()) || pluginKey.equals(p.getReference()))) {
throw new InfrastructureException(format("Invalid Che tooling plugins configuration: plugin %s is duplicated", // even if different registries
pluginKey));
}
collectedFQNs.add(pFQN);
}
return collectedFQNs;
}
use of org.eclipse.che.api.workspace.server.spi.InfrastructureException in project devspaces-images by redhat-developer.
the class PluginFQNParser method parsePluginFQN.
public ExtendedPluginFQN parsePluginFQN(String plugin) throws InfrastructureException {
String url;
String id;
String publisher;
String name;
String version;
URI registryURI = null;
Matcher matcher = PLUGIN_PATTERN.matcher(plugin);
if (matcher.matches()) {
url = matcher.group("url");
id = matcher.group("id");
publisher = matcher.group("publisher");
name = matcher.group("name");
version = matcher.group("version");
} else {
throw new InfrastructureException(format(INCORRECT_PLUGIN_FORMAT_TEMPLATE, plugin));
}
if (!isNullOrEmpty(url)) {
if (isNullOrEmpty(id)) {
// reference only
return new ExtendedPluginFQN(url);
} else {
// registry + id
try {
registryURI = new URI(url);
} catch (URISyntaxException e) {
throw new InfrastructureException(format("Plugin registry URL '%s' is invalid. Problematic plugin entry: '%s'", url, plugin));
}
}
}
return new ExtendedPluginFQN(registryURI, id, publisher, name, version);
}
Aggregations