use of org.eclipse.reddeer.common.exception.RedDeerException in project jbosstools-openshift by jbosstools.
the class OpenShiftServiceRequirement method waitForUI.
/**
* Waits for the service and replication controller to appear in the UI,
* possibly refreshes the project. This shouldnt be required but turns out
* that the UI takes extensive amount of time to notice the new resources.
* We therefore make sure they are present in UI before considering this
* requirement as fullfilled and possibly refresh the project (in ui) to
* force it to appear. This shouldnt be necessary, I consider this as workaround.
*
* @param projectName
* @param serviceName
*/
private void waitForUI(final String serviceName, final String projectName) {
// wait for service to appear in UI
new WaitUntil(new AbstractWaitCondition() {
@Override
public boolean test() {
OpenShiftExplorerView explorer = new OpenShiftExplorerView();
explorer.open();
OpenShift3Connection os3Connection = explorer.getOpenShift3Connection(connection);
assertThat(os3Connection, not(nullValue()));
OpenShiftProject os3Project = os3Connection.getProject(projectName);
assertThat(os3Project, not(nullValue()));
boolean serviceExists = false;
try {
serviceExists = os3Project.getService(serviceName) != null;
} catch (RedDeerException e) {
// catched intentionnally
System.err.println(e);
}
/*
* WORKAROUND: UI takes extensive amount of time to notice resource changes
* -> refresh tree to force it to see changes
*/
if (!serviceExists) {
os3Project.refresh();
}
return serviceExists;
}
}, TimePeriod.VERY_LONG);
// wait for replication controller to appear in UI
List<IReplicationController> rcs = connection.getResources(ResourceKind.REPLICATION_CONTROLLER, service.getNamespaceName());
IReplicationController serviceRc = ResourceUtils.getReplicationControllerFor(service, rcs);
assertThat(serviceRc, not(nullValue()));
new WaitUntil(new OpenShiftResourceExists(Resource.DEPLOYMENT, containsString(serviceRc.getName()), ResourceState.UNSPECIFIED, projectName, connection), TimePeriod.VERY_LONG);
}
use of org.eclipse.reddeer.common.exception.RedDeerException in project jbosstools-openshift by jbosstools.
the class TestUtils method getProjectAbsolutePath.
/**
* Provide resource absolute path in project directory
* @param path - resource relative path
* @return resource absolute path
*/
public static String getProjectAbsolutePath(String... path) {
// Construct path
StringBuilder builder = new StringBuilder();
for (String fragment : path) {
builder.append("/" + fragment);
}
String filePath = System.getProperty("user.dir");
File file = new File(filePath + builder.toString());
if (!file.exists()) {
throw new RedDeerException("Resource file does not exists within project path " + filePath + builder.toString());
}
return file.getAbsolutePath();
}
use of org.eclipse.reddeer.common.exception.RedDeerException in project jbosstools-openshift by jbosstools.
the class OpenShiftServiceRequirement method fulfill.
@Override
public void fulfill() {
this.connection = ConnectionUtils.getConnectionOrDefault(serviceSpec.connectionURL());
assertNotNull(NLS.bind("No connection for {0} exists", serviceSpec.connectionURL()), connection);
final String projectName = TestUtils.getValueOrDefault(serviceSpec.project(), DatastoreOS3.TEST_PROJECT);
assertTrue(NLS.bind("No project {0} exists on server {1}", projectName, connection.getHost()), OpenShift3NativeResourceUtils.hasProject(projectName, connection));
final String serviceName = serviceSpec.service();
final String templateName = serviceSpec.template();
IResourceFactory factory = new ClientBuilder(connection.getHost()).build().getResourceFactory();
try {
// try if template comes from a URL
URL url = new URL(templateName);
template = factory.create(url.openStream());
} catch (MalformedURLException ex) {
// template is not a URL, try a path to local file instead
if (new File(templateName).exists()) {
try {
template = factory.create(new FileInputStream(templateName));
} catch (FileNotFoundException e) {
throw new RedDeerException("Unable to read local template", e);
}
} else {
// it is not an external template
template = connection.getResource(ResourceKind.TEMPLATE, OpenShiftResources.OPENSHIFT_PROJECT, templateName);
}
} catch (IOException ex) {
throw new RedDeerException("Unable to read template from URL", ex);
}
assertNotNull(template);
this.service = getOrCreateService(projectName, serviceName, template);
if (serviceSpec.waitForBuild()) {
waitForResources(serviceName, projectName, service);
waitForUI(serviceName, projectName);
}
}
use of org.eclipse.reddeer.common.exception.RedDeerException in project jbosstools-openshift by jbosstools.
the class CDKServerEditorAbstractTest method addCDKServer.
public void addCDKServer() {
NewCDKServerWizard dialog = CDKTestUtils.openNewServerWizardDialog();
try {
setupServerWizardPage(dialog);
new WaitUntil(new ControlIsEnabled(new FinishButton()), TimePeriod.MEDIUM, false);
dialog.finish(TimePeriod.MEDIUM);
} catch (RedDeerException coreExc) {
new CancelButton().click();
throw new CDKServerException("Exception occured in CDK server wizard, wizard was canceled", coreExc);
}
}
use of org.eclipse.reddeer.common.exception.RedDeerException in project jbosstools-openshift by jbosstools.
the class CDKAbstractTest method getProjectAbsolutePath.
/**
* Provide resource absolute path in project directory
* @param path - resource relative path
* @return resource absolute path
*/
public static String getProjectAbsolutePath(String... path) {
// Construct path
StringBuilder builder = new StringBuilder();
for (String fragment : path) {
builder.append("/" + fragment);
}
String filePath = "";
filePath = System.getProperty("user.dir");
File file = new File(filePath + builder.toString());
if (!file.exists()) {
throw new RedDeerException("Resource file does not exists within project path " + filePath + builder.toString());
}
return file.getAbsolutePath();
}
Aggregations