Skip to content

Commit

Permalink
Mark wst.server bundles as optional, remove dependency on aeri bundles.
Browse files Browse the repository at this point in the history
Fixes #1922

Signed-off-by: Rastislav Wagner <rawagner@redhat.com>
  • Loading branch information
rawagner committed Jun 1, 2018
1 parent efa75e1 commit 9fe5acc
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 14 deletions.
Expand Up @@ -33,6 +33,8 @@ public class PreferencesUtil {
public static final String CONSOLE_LIMIT_OUTPUT_HIGH_KEY = "Console.highWaterMark";
public static final String CONSOLE_OPEN_ON_ERR_KEY = "DEBUG.consoleOpenOnErr";
public static final String CONSOLE_OPEN_ON_OUT_KEY = "DEBUG.consoleOpenOnOut";
public static final String AERI_PLUGIN = "org.eclipse.epp.logging.aeri.ide";
public static final String AERI_SEND_MODE_KEY = "sendMode";

private static final Logger log = Logger.getLogger(PreferencesUtil.class);

Expand Down Expand Up @@ -153,6 +155,15 @@ public static void setConsoleOpenedOnOutput(boolean openOnOutput) {
log.info("Sets the console open on error to '" + openOnOutput + "'");
Preferences.set(CONSOLE_PLUGIN, CONSOLE_OPEN_ON_OUT_KEY, String.valueOf(openOnOutput));
}

/**
* Sets AERI reporting send mode
* @param mode possible values are NOTIFY, NEVER and BACKGROUND
*/
public static void setAERISendMode(String mode) {
log.info("Setting the aeri reporting to never send.");
Preferences.set(AERI_PLUGIN, AERI_SEND_MODE_KEY, mode);
}

/**
* Validates a given text whether it is one of specified strings.
Expand Down
7 changes: 3 additions & 4 deletions plugins/org.eclipse.reddeer.eclipse/META-INF/MANIFEST.MF
Expand Up @@ -7,7 +7,6 @@ Bundle-Version: 2.2.0.qualifier
Bundle-Activator: org.eclipse.reddeer.eclipse.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.wst.server.ui,
org.eclipse.ui.console,
org.eclipse.reddeer.jface;bundle-version="[2.2.0,2.3.0)",
org.eclipse.reddeer.swt;bundle-version="[2.2.0,2.3.0)",
Expand All @@ -17,7 +16,6 @@ Require-Bundle: org.eclipse.ui,
org.hamcrest.core;bundle-version="1.3.0",
org.eclipse.ui.workbench,
org.eclipse.reddeer.junit;bundle-version="[2.2.0,2.3.0)",
org.eclipse.wst.server.core,
org.eclipse.reddeer.common;bundle-version="[2.2.0,2.3.0)",
org.eclipse.reddeer.direct;bundle-version="[2.2.0,2.3.0)",
org.eclipse.core.resources,
Expand All @@ -27,9 +25,10 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.ui.views.log,
org.eclipse.reddeer.uiforms,
org.eclipse.ui.forms,
org.eclipse.jdt.debug,
org.eclipse.debug.ui,
org.apache.commons.lang
org.apache.commons.lang,
org.eclipse.wst.server.core;resolution:=optional,
org.eclipse.wst.server.ui;resolution:=optional
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Export-Package: org.eclipse.reddeer.eclipse,
Expand Down
Expand Up @@ -11,9 +11,13 @@
*******************************************************************************/
package org.eclipse.reddeer.eclipse.m2e.core.ui.preferences;

import org.eclipse.reddeer.core.matcher.WithTextMatcher;
import org.eclipse.reddeer.core.reference.ReferencedComposite;
import org.eclipse.reddeer.jface.preference.PreferencePage;
import org.eclipse.reddeer.swt.impl.button.CheckBox;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
import org.hamcrest.core.IsEqual;

/**
* Class represents Maven preference page
Expand Down Expand Up @@ -121,7 +125,7 @@ public MavenPreferencePage setDownloadArtifactSources(boolean check) {
* @return true, if is download artifact javadoc checked
*/
public boolean isDownloadArtifactJavadocChecked() {
return new CheckBox(this, MavenPreferencePage.DOWNLOAD_ARTIFACT_JAVADOC).isChecked();
return getDownloadArtifactJavadocButton().isChecked();
}

/**
Expand All @@ -130,10 +134,29 @@ public boolean isDownloadArtifactJavadocChecked() {
* @param check the new download artifact javadoc
*/
public MavenPreferencePage setDownloadArtifactJavadoc(boolean check) {
new CheckBox(this, MavenPreferencePage.DOWNLOAD_ARTIFACT_JAVADOC).toggle(check);
getDownloadArtifactJavadocButton().toggle(check);
return this;
}

/**
* Checkbox text is Download Artifact JavaDoc in Oxygen and Download Artifact Javadoc in Photon
* @return
*/
private CheckBox getDownloadArtifactJavadocButton() {
return new CheckBox(this, new WithTextMatcher(new TypeSafeMatcher<String>() {
@Override
protected boolean matchesSafely(String text) {
return text.toLowerCase().replaceAll("&", "").split("\t")[0].equals(DOWNLOAD_ARTIFACT_JAVADOC.toLowerCase());
}

@Override
public void describeTo(Description desc) {
desc.appendText("Matcher matching text to "+DOWNLOAD_ARTIFACT_JAVADOC);

}
}));
}

/**
* Returns true when Download repository index updates on startup checkbox is checked .
*
Expand Down
Expand Up @@ -26,7 +26,9 @@
import org.eclipse.wst.server.ui.IServerModule;
import org.hamcrest.Matcher;
import org.hamcrest.core.IsEqual;
import org.osgi.framework.Bundle;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.reddeer.common.adaptable.RedDeerAdaptable;
import org.eclipse.reddeer.common.condition.AbstractWaitCondition;
import org.eclipse.reddeer.common.logging.Logger;
Expand Down Expand Up @@ -71,6 +73,11 @@ public abstract class AbstractServer implements Server, RedDeerAdaptable<Server>
protected TreeItem treeItem;

protected ServersView2 view;

private static final boolean isServerBundlePresent = isServerBundlePresent();

private static final String SERVER_CORE_BUNDLE="org.eclipse.wst.server.core";
private static final String SERVER_UI_BUNDLE="org.eclipse.wst.server.ui";

/**
* Creates a new abstract server.
Expand All @@ -79,6 +86,10 @@ public abstract class AbstractServer implements Server, RedDeerAdaptable<Server>
* the tree item
*/
protected AbstractServer(TreeItem treeItem) {
if(!isServerBundlePresent) {
throw new EclipseLayerException("Server bundles '"+SERVER_CORE_BUNDLE+" "+
SERVER_UI_BUNDLE+"' are not present in running eclipse instance");
}
this.treeItem = treeItem;
view = new ServersView2();
}
Expand Down Expand Up @@ -518,4 +529,10 @@ private org.eclipse.wst.server.core.internal.Server getEclipseServer(){
Object o = WidgetHandler.getInstance().getData(treeItem.getSWTWidget());
return (org.eclipse.wst.server.core.internal.Server)o;
}

private static boolean isServerBundlePresent() {
Bundle serverCoreBundle = Platform.getBundle(SERVER_CORE_BUNDLE);
Bundle serverUIBundle = Platform.getBundle(SERVER_UI_BUNDLE);
return serverCoreBundle != null && serverUIBundle != null;
}
}
Expand Up @@ -17,8 +17,7 @@ Require-Bundle: org.eclipse.ui,
org.junit;bundle-version="4.11.0",
org.eclipse.reddeer.common;bundle-version="[2.2.0,2.3.0)",
org.eclipse.reddeer.direct;bundle-version="[2.2.0,2.3.0)",
org.eclipse.reddeer.workbench.core;bundle-version="[2.2.0,2.3.0)",
org.eclipse.epp.logging.aeri.core
org.eclipse.reddeer.workbench.core;bundle-version="[2.2.0,2.3.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ClassPath: .
Import-Package: org.eclipse.reddeer.junit.screenshot
Expand Down
Expand Up @@ -11,9 +11,7 @@
*******************************************************************************/
package org.eclipse.reddeer.junit.extension.before.test.impl;

import org.eclipse.epp.logging.aeri.core.ISystemSettings;
import org.eclipse.epp.logging.aeri.core.SendMode;
import org.eclipse.epp.logging.aeri.core.SystemControl;
import org.eclipse.reddeer.direct.preferences.PreferencesUtil;
import org.eclipse.reddeer.junit.extensionpoint.IBeforeTest;
import org.junit.runners.model.FrameworkMethod;
import org.junit.runners.model.TestClass;
Expand All @@ -33,9 +31,7 @@ public long getPriority() {

@Override
public void runBeforeTestClass(String config, TestClass testClass) {
ISystemSettings settings = SystemControl.getSystemSettings();
settings.setSendMode(SendMode.NEVER);

PreferencesUtil.setAERISendMode("NEVER");
}

@Override
Expand Down

0 comments on commit 9fe5acc

Please sign in to comment.