Search in sources :

Example 1 with AbstractWaitCondition

use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.

the class OpenShiftServiceRequirement method cleanUp.

@Override
public void cleanUp() {
    if (serviceSpec.cleanup()) {
        String projectName = TestUtils.getValueOrDefault(serviceSpec.project(), DatastoreOS3.TEST_PROJECT);
        final IProject project = OpenShift3NativeResourceUtils.getProject(projectName, connection);
        IProjectTemplateProcessing capability = project.getCapability(IProjectTemplateProcessing.class);
        ITemplate processed = capability.process(template);
        for (IResource resource : processed.getObjects()) {
            IResource res = connection.getResource(resource.getKind(), projectName, resource.getName());
            try {
                connection.deleteResource(res);
            } catch (OpenShiftException ex) {
                LOGGER.error("Unable to remove " + res.getKind() + " named " + res.getName());
                LOGGER.error(StackTraceUtils.stackTraceToString(ex));
            }
        }
        cleanResources(connection, ResourceKind.BUILD, project, template);
        cleanResources(connection, ResourceKind.REPLICATION_CONTROLLER, project, template);
        cleanResources(connection, ResourceKind.POD, project, template);
        new WaitWhile(new AbstractWaitCondition() {

            @Override
            public boolean test() {
                for (IResource resource : project.getResources(ResourceKind.POD)) {
                    if (resource.getName().startsWith(template.getName())) {
                        return true;
                    }
                }
                return false;
            }

            @Override
            public String description() {
                return "at least one application pod is running";
            }
        }, TimePeriod.LONG);
        new OpenShiftExplorerView().getOpenShift3Connection(connection).refresh();
    }
}
Also used : IProjectTemplateProcessing(com.openshift.restclient.capability.resources.IProjectTemplateProcessing) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) OpenShiftException(com.openshift.restclient.OpenShiftException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ITemplate(com.openshift.restclient.model.template.ITemplate) AbstractWaitCondition(org.eclipse.reddeer.common.condition.AbstractWaitCondition) OpenShiftExplorerView(org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView) IProject(com.openshift.restclient.model.IProject) IResource(com.openshift.restclient.model.IResource)

Example 2 with AbstractWaitCondition

use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.

the class DebuggingEAPAppTest method checkNewVariableValueIsPropagatedToBrowser.

private void checkNewVariableValueIsPropagatedToBrowser() {
    clickResume();
    new WaitUntil(new AbstractWaitCondition() {

        @Override
        public boolean test() {
            return ((requestResponse != null) && requestResponse.contains("NewWorld"));
        }
    }, TimePeriod.LONG);
}
Also used : WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) AbstractWaitCondition(org.eclipse.reddeer.common.condition.AbstractWaitCondition)

Example 3 with AbstractWaitCondition

use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.

the class DebuggingEAPAppTest method checkVariablesView.

private void checkVariablesView() {
    VariablesView variablesView = new VariablesView();
    variablesView.open();
    // wait for variables to have correct value
    new WaitUntil(new AbstractWaitCondition() {

        @Override
        public boolean test() {
            return variablesView.getValue("name").equals("World");
        }
    });
    new WaitUntil(new AbstractWaitCondition() {

        @Override
        public boolean test() {
            return variablesView.getValue("this").contains("HelloService");
        }
    });
}
Also used : WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) AbstractWaitCondition(org.eclipse.reddeer.common.condition.AbstractWaitCondition) VariablesView(org.eclipse.reddeer.eclipse.debug.ui.views.variables.VariablesView)

Example 4 with AbstractWaitCondition

use of org.eclipse.reddeer.common.condition.AbstractWaitCondition 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);
}
Also used : RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) OpenShiftProject(org.jboss.tools.openshift.reddeer.view.resources.OpenShiftProject) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) AbstractWaitCondition(org.eclipse.reddeer.common.condition.AbstractWaitCondition) OpenShiftExplorerView(org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView) IReplicationController(com.openshift.restclient.model.IReplicationController) OpenShiftResourceExists(org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists) OpenShift3Connection(org.jboss.tools.openshift.reddeer.view.resources.OpenShift3Connection)

Example 5 with AbstractWaitCondition

use of org.eclipse.reddeer.common.condition.AbstractWaitCondition in project jbosstools-openshift by jbosstools.

the class DebuggingEAPAppTest method ensureCorrectFrameIsSelected.

private TreeItem ensureCorrectFrameIsSelected(LaunchView debugView) {
    List<TreeItem> items;
    TreeItem createHelloMessageDebugItem;
    // get frames of suspended thread. If the desired frame is not present,
    // try reopening Debug view
    items = getSuspendedThreadTreeItem(debugView).getItems();
    if (items.size() < 2) {
        // no stack trace available. Try to close&reopen Debug view (dirty
        // hack)
        debugView.close();
        debugView = new LaunchView();
        debugView.open();
        items = getSuspendedThreadTreeItem(debugView).getItems();
    }
    final List<TreeItem> tIList = items;
    // wait for frame texts to populate.
    new WaitUntil(new AbstractWaitCondition() {

        @Override
        public boolean test() {
            return tIList.stream().peek(ti -> LOGGER.debug(ti.getText())).filter(ti -> ti.getText().contains("createHelloMessage")).findFirst().isPresent();
        }
    }, TimePeriod.LONG);
    createHelloMessageDebugItem = tIList.stream().peek(ti -> LOGGER.debug(ti.getText())).filter(ti -> ti.getText().contains("createHelloMessage")).findFirst().get();
    // select the item and return it
    createHelloMessageDebugItem.select();
    return createHelloMessageDebugItem;
}
Also used : HttpURLConnection(java.net.HttpURLConnection) TimePeriod(org.eclipse.reddeer.common.wait.TimePeriod) DefaultStyledText(org.eclipse.reddeer.swt.impl.styledtext.DefaultStyledText) CleanConnection(org.jboss.tools.openshift.reddeer.requirement.CleanOpenShiftConnectionRequirement.CleanConnection) SuspendedTreeItemIsReady(org.jboss.tools.openshift.ui.bot.test.application.v3.adapter.condition.SuspendedTreeItemIsReady) AbstractWaitCondition(org.eclipse.reddeer.common.condition.AbstractWaitCondition) OpenPerspective(org.eclipse.reddeer.requirements.openperspective.OpenPerspectiveRequirement.OpenPerspective) URL(java.net.URL) WorkbenchShell(org.eclipse.reddeer.workbench.impl.shell.WorkbenchShell) ServerHasPublishState(org.eclipse.reddeer.eclipse.condition.ServerHasPublishState) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) Scanner(java.util.Scanner) CheckBox(org.eclipse.reddeer.swt.impl.button.CheckBox) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) OkButton(org.eclipse.reddeer.swt.impl.button.OkButton) After(org.junit.After) ServerState(org.eclipse.reddeer.eclipse.wst.server.ui.cnf.ServersViewEnums.ServerState) RedDeerSuite(org.eclipse.reddeer.junit.runner.RedDeerSuite) Version(org.jboss.tools.openshift.reddeer.view.resources.ServerAdapter.Version) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) ProjectExplorer(org.eclipse.reddeer.eclipse.ui.navigator.resources.ProjectExplorer) AfterClass(org.junit.AfterClass) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) TestUtils(org.jboss.tools.openshift.reddeer.utils.TestUtils) Predicate(java.util.function.Predicate) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Project(org.eclipse.reddeer.eclipse.core.resources.Project) PushButton(org.eclipse.reddeer.swt.impl.button.PushButton) JavaDebugPreferencePage(org.jboss.tools.openshift.reddeer.preference.page.JavaDebugPreferencePage) WorkbenchPreferenceDialog(org.eclipse.reddeer.workbench.ui.dialogs.WorkbenchPreferenceDialog) OpenShiftUtils(org.jboss.tools.openshift.ui.bot.test.common.OpenShiftUtils) DefaultTree(org.eclipse.reddeer.swt.impl.tree.DefaultTree) LaunchView(org.eclipse.reddeer.eclipse.debug.ui.views.launch.LaunchView) OpenShiftProjectRequirement(org.jboss.tools.openshift.reddeer.requirement.OpenShiftProjectRequirement) List(java.util.List) ServerPublishState(org.eclipse.reddeer.eclipse.wst.server.ui.cnf.ServersViewEnums.ServerPublishState) ConsoleView(org.eclipse.reddeer.eclipse.ui.console.ConsoleView) ShellIsAvailable(org.eclipse.reddeer.swt.condition.ShellIsAvailable) WaitWhile(org.eclipse.reddeer.common.wait.WaitWhile) DefaultToolItem(org.eclipse.reddeer.swt.impl.toolbar.DefaultToolItem) CoreLayerException(org.eclipse.reddeer.core.exception.CoreLayerException) ShellMenuItem(org.eclipse.reddeer.swt.impl.menu.ShellMenuItem) DefaultShell(org.eclipse.reddeer.swt.impl.shell.DefaultShell) ServerHasState(org.eclipse.reddeer.eclipse.condition.ServerHasState) BeforeClass(org.junit.BeforeClass) RunWith(org.junit.runner.RunWith) OpenShiftConnectionRequirement(org.jboss.tools.openshift.reddeer.requirement.OpenShiftConnectionRequirement) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) ServersView2(org.eclipse.reddeer.eclipse.wst.server.ui.cnf.ServersView2) CaptureScreenshotException(org.eclipse.reddeer.junit.screenshot.CaptureScreenshotException) RequiredBasicConnection(org.jboss.tools.openshift.reddeer.requirement.OpenShiftConnectionRequirement.RequiredBasicConnection) OpenShiftExplorerView(org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView) Before(org.junit.Before) PackageExplorerPart(org.eclipse.reddeer.eclipse.jdt.ui.packageview.PackageExplorerPart) ProjectItem(org.eclipse.reddeer.eclipse.core.resources.ProjectItem) RequiredProject(org.jboss.tools.openshift.reddeer.requirement.OpenShiftProjectRequirement.RequiredProject) JobIsRunning(org.eclipse.reddeer.workbench.core.condition.JobIsRunning) Assert.assertTrue(org.junit.Assert.assertTrue) VariablesView(org.eclipse.reddeer.eclipse.debug.ui.views.variables.VariablesView) IOException(java.io.IOException) Test(org.junit.Test) BreakpointsView(org.eclipse.reddeer.eclipse.debug.ui.views.breakpoints.BreakpointsView) InjectRequirement(org.eclipse.reddeer.junit.requirement.inject.InjectRequirement) DebugPerspective(org.eclipse.reddeer.eclipse.ui.perspectives.DebugPerspective) File(java.io.File) Logger(org.eclipse.reddeer.common.logging.Logger) CleanOpenShiftExplorer(org.jboss.tools.openshift.reddeer.requirement.CleanOpenShiftExplorerRequirement.CleanOpenShiftExplorer) RequiredService(org.jboss.tools.openshift.reddeer.requirement.OpenShiftServiceRequirement.RequiredService) TextEditor(org.eclipse.reddeer.workbench.impl.editor.TextEditor) ServerAdapter(org.jboss.tools.openshift.reddeer.view.resources.ServerAdapter) InputStream(java.io.InputStream) TreeItem(org.eclipse.reddeer.swt.api.TreeItem) DefaultTreeItem(org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem) LaunchView(org.eclipse.reddeer.eclipse.debug.ui.views.launch.LaunchView) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) AbstractWaitCondition(org.eclipse.reddeer.common.condition.AbstractWaitCondition)

Aggregations

AbstractWaitCondition (org.eclipse.reddeer.common.condition.AbstractWaitCondition)7 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)6 WaitWhile (org.eclipse.reddeer.common.wait.WaitWhile)3 CoreLayerException (org.eclipse.reddeer.core.exception.CoreLayerException)3 VariablesView (org.eclipse.reddeer.eclipse.debug.ui.views.variables.VariablesView)3 OkButton (org.eclipse.reddeer.swt.impl.button.OkButton)3 DefaultShell (org.eclipse.reddeer.swt.impl.shell.DefaultShell)3 OpenShiftExplorerView (org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView)3 IOException (java.io.IOException)2 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)2 LaunchView (org.eclipse.reddeer.eclipse.debug.ui.views.launch.LaunchView)2 CaptureScreenshotException (org.eclipse.reddeer.junit.screenshot.CaptureScreenshotException)2 TreeItem (org.eclipse.reddeer.swt.api.TreeItem)2 CheckBox (org.eclipse.reddeer.swt.impl.button.CheckBox)2 ContextMenuItem (org.eclipse.reddeer.swt.impl.menu.ContextMenuItem)2 DefaultStyledText (org.eclipse.reddeer.swt.impl.styledtext.DefaultStyledText)2 DefaultTreeItem (org.eclipse.reddeer.swt.impl.tree.DefaultTreeItem)2 JobIsRunning (org.eclipse.reddeer.workbench.core.condition.JobIsRunning)2 AbstractTest (org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest)2 Test (org.junit.Test)2