Search in sources :

Example 1 with BrowserEditor

use of org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor in project jbosstools-openshift by jbosstools.

the class BrowserIsReadyElseReloadCondition method test.

@Override
public boolean test() {
    BrowserEditor browserEditor = null;
    try {
        browserEditor = new BrowserEditor(new BaseMatcher<String>() {

            @Override
            public boolean matches(Object arg0) {
                return true;
            }

            @Override
            public void describeTo(Description arg0) {
            // TODO Auto-generated method stub
            }
        });
    } catch (CoreLayerException ex) {
        LOGGER.debug("CoreLayerException in waiting for browser in BrowserIsReadyElseReloadCondition");
        LOGGER.debug(StackTraceUtils.stackTraceToString(ex));
        return false;
    }
    String text = browserEditor.getText();
    if (text.contains("Unable to load page") || text.contains("404")) {
        LOGGER.debug("Refreshing browser");
        new ServersView2().open();
        serverAdapter.select();
        new ContextMenuItem("Show In", "Web Browser").select();
        return false;
    } else {
        // Browser is ready
        return true;
    }
}
Also used : Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) ServersView2(org.eclipse.reddeer.eclipse.wst.server.ui.cnf.ServersView2) BrowserEditor(org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor) CoreLayerException(org.eclipse.reddeer.core.exception.CoreLayerException)

Example 2 with BrowserEditor

use of org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor in project jbosstools-openshift by jbosstools.

the class DeploymentTest method testDeploymentOfApplicationCreatedFromTemplate.

@Test
public void testDeploymentOfApplicationCreatedFromTemplate() {
    OpenShiftExplorerView explorer = new OpenShiftExplorerView();
    new WaitUntil(new OpenShiftResourceExists(Resource.BUILD, "eap-app-1", ResourceState.UNSPECIFIED, projectReq.getProjectName(), connectionReq.getConnection()), TimePeriod.DEFAULT, false);
    try {
        new WaitUntil(new OpenShiftResourceExists(Resource.BUILD, "eap-app-1", ResourceState.COMPLETE, projectReq.getProjectName(), connectionReq.getConnection()), TimePeriod.getCustom(600), true);
    } catch (WaitTimeoutExpiredException ex) {
        fail("There should be a successful build of an application, but there is not.");
    }
    try {
        new WaitUntil(new AmountOfResourcesExists(Resource.POD, 2, projectReq.getProjectName(), connectionReq.getConnection()), TimePeriod.getCustom(60), true);
    } catch (WaitTimeoutExpiredException ex) {
        fail("There should be precisely 2 pods. One of the build and one of an running application.");
    }
    explorer.getOpenShift3Connection(connectionReq.getConnection()).getProject(projectReq.getProjectName()).getOpenShiftResources(Resource.ROUTE).get(0).select();
    new ContextMenuItem(OpenShiftLabel.ContextMenu.SHOW_IN_WEB_BROWSER).select();
    try {
        new WaitUntil(new BrowserContainsText("Hello World!"), TimePeriod.VERY_LONG);
        new BrowserEditor("helloworld").close();
    } catch (WaitTimeoutExpiredException ex) {
        fail("Application was not deployed successfully because it is not shown in web browser properly.\n" + ex.getMessage());
    }
}
Also used : AmountOfResourcesExists(org.jboss.tools.openshift.reddeer.condition.AmountOfResourcesExists) ContextMenuItem(org.eclipse.reddeer.swt.impl.menu.ContextMenuItem) WaitTimeoutExpiredException(org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException) BrowserContainsText(org.jboss.tools.openshift.reddeer.condition.BrowserContainsText) BrowserEditor(org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor) WaitUntil(org.eclipse.reddeer.common.wait.WaitUntil) OpenShiftExplorerView(org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView) OpenShiftResourceExists(org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists) AbstractTest(org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest) Test(org.junit.Test)

Example 3 with BrowserEditor

use of org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor in project jbosstools-openshift by jbosstools.

the class DeployDockerImageTest method closeBrowser.

public static void closeBrowser() {
    try {
        BrowserEditor browser = new BrowserEditor(new StringContains("hello"));
        browser.close();
    } catch (RedDeerException ex) {
    // do nothing, browser is not opened
    }
}
Also used : RedDeerException(org.eclipse.reddeer.common.exception.RedDeerException) BrowserEditor(org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor) StringContains(org.hamcrest.core.StringContains)

Aggregations

BrowserEditor (org.eclipse.reddeer.eclipse.ui.browser.BrowserEditor)3 ContextMenuItem (org.eclipse.reddeer.swt.impl.menu.ContextMenuItem)2 RedDeerException (org.eclipse.reddeer.common.exception.RedDeerException)1 WaitTimeoutExpiredException (org.eclipse.reddeer.common.exception.WaitTimeoutExpiredException)1 WaitUntil (org.eclipse.reddeer.common.wait.WaitUntil)1 CoreLayerException (org.eclipse.reddeer.core.exception.CoreLayerException)1 ServersView2 (org.eclipse.reddeer.eclipse.wst.server.ui.cnf.ServersView2)1 BaseMatcher (org.hamcrest.BaseMatcher)1 Description (org.hamcrest.Description)1 StringContains (org.hamcrest.core.StringContains)1 AmountOfResourcesExists (org.jboss.tools.openshift.reddeer.condition.AmountOfResourcesExists)1 BrowserContainsText (org.jboss.tools.openshift.reddeer.condition.BrowserContainsText)1 OpenShiftResourceExists (org.jboss.tools.openshift.reddeer.condition.OpenShiftResourceExists)1 OpenShiftExplorerView (org.jboss.tools.openshift.reddeer.view.OpenShiftExplorerView)1 AbstractTest (org.jboss.tools.openshift.ui.bot.test.application.v3.basic.AbstractTest)1 Test (org.junit.Test)1