use of org.jboss.tools.openshift.reddeer.exception.OpenShiftToolsException in project jbosstools-openshift by jbosstools.
the class OpenShiftCommandLineToolsRequirement method downloadAndExtractOpenShiftClient.
private File downloadAndExtractOpenShiftClient(String url) {
LOGGER.info("Creating directory binaries");
File outputDirectory = new File(CLIENT_TOOLS_DESTINATION);
FileHelper.createDirectory(outputDirectory);
String fileName = downloadArchive(url);
String extractedDirectory = extractArchive(fileName, outputDirectory);
if (StringUtils.isEmpty(extractedDirectory) || !(new File(extractedDirectory).exists())) {
throw new OpenShiftToolsException("Cannot extract archive " + fileName + ". " + "Archive does not extract into a single root folder");
}
return new File(extractedDirectory, OCBinaryFile.get().getName());
}
use of org.jboss.tools.openshift.reddeer.exception.OpenShiftToolsException in project jbosstools-openshift by jbosstools.
the class ConnectionUtils method getConnection.
/**
* Returns a connection for the given connection server and username
* @param connectionUrlString
* @return
*
* @see ConnectionURL
*/
public static Connection getConnection(String username, String server) {
try {
String url = UrlUtils.getUrlFor(username, server);
ConnectionURL connectionUrl = ConnectionURL.forURL(url);
return ConnectionsRegistrySingleton.getInstance().getByUrl(connectionUrl, Connection.class);
} catch (UnsupportedEncodingException | MalformedURLException e) {
throw new OpenShiftToolsException(NLS.bind("Could not lookup connection to server {0}: {1}", server, e));
}
}
use of org.jboss.tools.openshift.reddeer.exception.OpenShiftToolsException in project jbosstools-openshift by jbosstools.
the class FileHelper method unzipFile.
public static void unzipFile(File zipArchive, File outputDirectory) {
ZipFile zipfile = null;
try {
zipfile = new ZipFile(zipArchive);
} catch (IOException ex) {
throw new OpenShiftToolsException("Exception occured while processing zip file.\n" + ex.getMessage());
}
String extractedDirectory = StringUtils.chomp(zipArchive.getName(), ".zip");
Enumeration<? extends ZipEntry> entries = zipfile.entries();
while (entries.hasMoreElements()) {
ZipEntry entry = (ZipEntry) entries.nextElement();
unzipEntry(zipfile, entry, new File(outputDirectory, extractedDirectory));
}
}
use of org.jboss.tools.openshift.reddeer.exception.OpenShiftToolsException in project jbosstools-openshift by jbosstools.
the class OpenShift3ConnectionWizard method discover.
/**
* Overwriting of URL requires user confirmation, Message Dialog is shown. If
* url is not filled in, no dialog pops up and url is generated automatically.
* If it is not possible to get proper registry url (ie. adapter is stopped),
* then Error dialog is thrown.
*/
public void discover() {
Button discover = getDiscoveryButton();
discover.click();
try {
new WaitUntil(new ShellIsAvailable(OpenShiftLabel.Shell.REGISTRY_URL_NOT_FOUND), TimePeriod.DEFAULT);
// Error dialog appeared, exception will be thrown
log.error("Unable to discover a registry URL");
throw new OpenShiftToolsException(OpenShiftLabel.Shell.REGISTRY_URL_NOT_FOUND);
} catch (WaitTimeoutExpiredException exc) {
// Error dialog was not thrown
}
try {
confirmMessageDialog();
} catch (WaitTimeoutExpiredException exc) {
// Confirmation dialog did not appear, only spotted reason so far is that
// it would be replacing the same URL.
log.info("Discover action did not invoke any dialog");
}
}
use of org.jboss.tools.openshift.reddeer.exception.OpenShiftToolsException in project jbosstools-openshift by jbosstools.
the class CDKImageRegistryUrlDiscoveryFailureTest method testRegistryUrlNotFoundDialog.
/**
* Covers JBIDE-25049
*/
@Test
public void testRegistryUrlNotFoundDialog() {
String shellTitle = OpenShiftLabel.Shell.REGISTRY_URL_NOT_FOUND;
wizard.getImageRegistryUrl().setText("");
wizard.finish();
stopServerAdapter();
wizard = connection.editConnection();
switchOffPasswordSaving();
try {
wizard.discover();
fail("Expected OpenshiftToolsException was not thrown, possibly no dialog is shown.");
} catch (OpenShiftToolsException osExc) {
// os exception was thrown with specific message
assertTrue("Registry URL not found dialog did not appear.", osExc.getMessage().contains(shellTitle));
// error dialog is still there
new WaitUntil(new ShellIsAvailable(shellTitle), TimePeriod.SHORT);
new DefaultShell(shellTitle);
new OkButton().click();
}
wizard.cancel();
}
Aggregations