diff options
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse')
16 files changed, 343 insertions, 86 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareStatement.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareStatement.java index 14fc87724..fed080673 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareStatement.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareStatement.java @@ -37,77 +37,122 @@ import org.junit.runners.model.Statement; @SuppressWarnings("restriction") public abstract class AbstractCompareStatement extends Statement { - private final static String EXTENSION_POINT_CLASS_SELECTOR = "impl"; //$NON-NLS-1$ + /** The class selector for the extension point. */ + private static final String EXTENSION_POINT_CLASS_SELECTOR = "impl"; //$NON-NLS-1$ - private final static String EXTENSION_POINT_ID_SELECTOR = "id"; //$NON-NLS-1$ + /** The id selector for the extension point. */ + private static final String EXTENSION_POINT_ID_SELECTOR = "id"; //$NON-NLS-1$ - private final static String PREFERENCES_SEPARATOR = ";"; //$NON-NLS-1$ + /** The separator used to build a string of preferences. */ + private static final String PREFERENCES_SEPARATOR = ";"; //$NON-NLS-1$ - private final static String DIFF_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + "." //$NON-NLS-1$ + /** Separator used to construct the following IDs. */ + private static final String ID_SEPARATOR = "."; //$NON-NLS-1$ + + /** The id of the diff extension point. */ + private static final String DIFF_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + ID_SEPARATOR + EMFCompareRCPPlugin.DIFF_ENGINE_PPID; - private final static String EQ_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + "." //$NON-NLS-1$ + /** The id of the equivalence extension point. */ + private static final String EQ_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + ID_SEPARATOR + EMFCompareRCPPlugin.EQUI_ENGINE_PPID; - private final static String REQ_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + "." //$NON-NLS-1$ + /** The id of the requirement extension point. */ + private static final String REQ_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + ID_SEPARATOR + EMFCompareRCPPlugin.REQ_ENGINE_PPID; - private final static String CONFLICT_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + "." //$NON-NLS-1$ + /** The id of the conflict extension point. */ + private static final String CONFLICT_EXTENSION_POINT_ID = EMFCompareRCPPlugin.PLUGIN_ID + ID_SEPARATOR + EMFCompareRCPPlugin.CONFLICT_DETECTOR_PPID; + /** The test class. */ + protected final Object testObject; + + /** The test method that will be run. */ + protected final FrameworkMethod test; + + /** The EMFCompare preferences. */ private final IEclipsePreferences emfComparePreferences = EMFCompareRCPPlugin.getDefault() .getEMFComparePreferences(); + /** The EMFCompare UI preferences. */ private final IPreferenceStore uiPreferenceStore = EMFCompareIDEUIPlugin.getDefault() .getPreferenceStore(); - protected final Object testObject; - - protected final FrameworkMethod test; - + /** The resolution strategy used for this test. */ private final ResolutionStrategyID resolutionStrategy; + /** The match engines disabled used for this test. */ private final Class<?>[] disabledMatchEngines; + /** The diff engine used for this test. */ private final Class<?> diffEngine; + /** The eq engine used for this test. */ private final Class<?> eqEngine; + /** The req engine used for this test. */ private final Class<?> reqEngine; + /** The conflict detector used for this test. */ private final Class<?> conflictDetector; + /** The post-processors disabled for this test. */ private final Class<?>[] disabledPostProcessors; - private String defaultResolutionStrategy; + /** The default resolution strategy. */ + private String defaultResolutionStrategy = "WORKSPACE"; //$NON-NLS-1$ + /** The default disabled match engines. */ private List<String> defaultDisabledMatchEngines = new ArrayList<String>(); - private String defaultDiffEngine = "org.eclipse.emf.compare.rcp.default.conflictDetector"; //$NON-NLS-1$ + /** The default diff engine. */ + private String defaultDiffEngine = "org.eclipse.emf.compare.rcp.default.diffEngine"; //$NON-NLS-1$ - private String defaultEqEngine = "org.eclipse.emf.compare.rcp.default.conflictDetector"; //$NON-NLS-1$ + /** The default eq engine. */ + private String defaultEqEngine = "org.eclipse.emf.compare.rcp.default.equiEngine"; //$NON-NLS-1$ - private String defaultReqEngine = "org.eclipse.emf.compare.rcp.default.conflictDetector"; //$NON-NLS-1$ + /** The default req engine. */ + private String defaultReqEngine = "org.eclipse.emf.compare.rcp.default.reqEngine"; //$NON-NLS-1$ - private String defaultConflictDetector = "org.eclipse.emf.compare.rcp.default.conflictDetector"; //$NON-NLS-1$ + /** The default conflict detector. */ + private String defaultConflictDetector = "org.eclipse.emf.compare.rcp.fast.conflictDetector"; //$NON-NLS-1$ + /** The default disabled post-processors. */ private List<String> defaultDisabledPostProcessors = new ArrayList<String>(); + /** + * Constructor for the classic (no Git) comparison statement. + * + * @param testObject + * The test class + * @param test + * The test method + * @param resolutionStrategy + * The resolution strategy used for this test + * @param selectedEngines + * EMFComapre configurations for this test + */ public AbstractCompareStatement(Object testObject, FrameworkMethod test, - ResolutionStrategyID resolutionStrategy, Class<?>[] disabledMatchEngineFactory, - Class<?> diffEngine, Class<?> eqEngine, Class<?> reqEngine, Class<?> conflictDetector, - Class<?>[] disabledPostProcessors) { + ResolutionStrategyID resolutionStrategy, EMFCompareTestConfiguration selectedEngines) { this.testObject = testObject; this.test = test; this.resolutionStrategy = resolutionStrategy; - this.disabledMatchEngines = disabledMatchEngineFactory; - this.diffEngine = diffEngine; - this.eqEngine = eqEngine; - this.reqEngine = reqEngine; - this.conflictDetector = conflictDetector; - this.disabledPostProcessors = disabledPostProcessors; + this.disabledMatchEngines = selectedEngines.getDisabledMatchEngines(); + this.diffEngine = selectedEngines.getDiffEngine(); + this.eqEngine = selectedEngines.getEqEngine(); + this.reqEngine = selectedEngines.getReqEngine(); + this.conflictDetector = selectedEngines.getConflictDetector(); + this.disabledPostProcessors = selectedEngines.getDisabledPostProcessors(); } + /** + * Normalize the given path (remove first "/" and "./" if necessary). + * + * @param value + * The given path + * @return the normalized path + */ protected String normalizePath(String value) { if (value.startsWith("/")) { //$NON-NLS-1$ return value.substring(1, value.length()); @@ -118,6 +163,9 @@ public abstract class AbstractCompareStatement extends Statement { } } + /** + * Restore preferences as they were before the test. + */ protected void restoreEMFComparePreferences() { uiPreferenceStore.setValue(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE, defaultResolutionStrategy); @@ -131,6 +179,9 @@ public abstract class AbstractCompareStatement extends Statement { join(defaultDisabledPostProcessors, PREFERENCES_SEPARATOR)); } + /** + * Set the preferences required to run the test. + */ protected void setEMFComparePreferences() { setResolutionStrategyPreference(); setMatchPreference(); @@ -141,6 +192,9 @@ public abstract class AbstractCompareStatement extends Statement { setPostProcessorPreference(); } + /** + * Set the resolution strategy preference. + */ private void setResolutionStrategyPreference() { defaultResolutionStrategy = uiPreferenceStore .getString(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE); @@ -148,6 +202,9 @@ public abstract class AbstractCompareStatement extends Statement { resolutionStrategy.name()); } + /** + * Set the match engine preference. + */ private void setMatchPreference() { String disabMatchEngine = emfComparePreferences.get( EMFComparePreferences.MATCH_ENGINE_DISABLE_ENGINES, @@ -165,6 +222,9 @@ public abstract class AbstractCompareStatement extends Statement { join(matchEngineNames, PREFERENCES_SEPARATOR)); } + /** + * Set the diff engine preference. + */ private void setDiffPreference() { IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(DIFF_EXTENSION_POINT_ID); @@ -184,6 +244,9 @@ public abstract class AbstractCompareStatement extends Statement { emfComparePreferences.put(EMFComparePreferences.DIFF_ENGINES, diffEngineId); } + /** + * Set the equivalence engine preference. + */ private void setEqPreference() { IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(EQ_EXTENSION_POINT_ID); @@ -203,6 +266,9 @@ public abstract class AbstractCompareStatement extends Statement { emfComparePreferences.put(EMFComparePreferences.EQUI_ENGINES, eqEngineId); } + /** + * Set the requirement engine preference. + */ private void setReqPreference() { IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(REQ_EXTENSION_POINT_ID); @@ -222,6 +288,9 @@ public abstract class AbstractCompareStatement extends Statement { emfComparePreferences.put(EMFComparePreferences.REQ_ENGINES, reqEngineId); } + /** + * Set the conflict detector preference. + */ private void setConflictPreference() { IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry(); IExtensionPoint extensionPoint = extensionRegistry.getExtensionPoint(CONFLICT_EXTENSION_POINT_ID); @@ -242,6 +311,9 @@ public abstract class AbstractCompareStatement extends Statement { emfComparePreferences.put(EMFComparePreferences.CONFLICTS_DETECTOR, conflictDetectorId); } + /** + * Set the post-processors preference. + */ private void setPostProcessorPreference() { String disabPostProcessors = emfComparePreferences.get(EMFComparePreferences.DISABLED_POST_PROCESSOR, join(defaultDisabledPostProcessors, PREFERENCES_SEPARATOR)); @@ -258,6 +330,15 @@ public abstract class AbstractCompareStatement extends Statement { join(postProcessorNames, PREFERENCES_SEPARATOR)); } + /** + * Join a collection of string with the given separator. + * + * @param parts + * The collection of Strings + * @param separator + * The separator + * @return the joined string + */ private String join(Collection<String> parts, String separator) { StringBuilder sb = new StringBuilder(); int i = 0; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestCaseJUnitBlock.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestCaseJUnitBlock.java index 404b2e704..f5e581adf 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestCaseJUnitBlock.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestCaseJUnitBlock.java @@ -21,47 +21,48 @@ import org.junit.runners.model.InitializationError; */ public abstract class AbstractCompareTestCaseJUnitBlock extends BlockJUnit4ClassRunner { - protected final ResolutionStrategyID resolutionStrategy; - - protected final Class<?>[] disabledMatchEngines; - - protected final Class<?> diffEngine; + /** Separator used to construct the name of the test. */ + private static final String NAME_SEPARATOR = " - "; //$NON-NLS-1$ - protected final Class<?> eqEngine; - - protected final Class<?> reqEngine; - - protected final Class<?> conflictDetector; + /** The resolution strategy to use for the test. */ + protected final ResolutionStrategyID resolutionStrategy; - protected final Class<?>[] disabledPostProcessors; + /** Wrapper for the configurations of EMFCompare for the test. */ + protected final EMFCompareTestConfiguration configuration; + /** + * Constructor for the classic (no Git) comparison statement. + * + * @param klass + * The test class + * @param resolutionStrategy + * The resolution strategy used for this test + * @param configuration + * EMFCompare configurations for this test + * @throws InitializationError + * If something went wrong during test initialization + */ public AbstractCompareTestCaseJUnitBlock(Class<?> klass, ResolutionStrategyID resolutionStrategy, - Class<?>[] disabledMatchEngines, Class<?> diffEngine, Class<?> eqEngine, Class<?> reqEngine, - Class<?> conflictDetector, Class<?>[] disabledPostProcessors) throws InitializationError { + EMFCompareTestConfiguration configuration) throws InitializationError { super(klass); this.resolutionStrategy = resolutionStrategy; - this.disabledMatchEngines = disabledMatchEngines; - this.diffEngine = diffEngine; - this.eqEngine = eqEngine; - this.reqEngine = reqEngine; - this.conflictDetector = conflictDetector; - this.disabledPostProcessors = disabledPostProcessors; + this.configuration = configuration; } @Override protected String testName(FrameworkMethod method) { final StringBuilder name = new StringBuilder(); name.append(super.testName(method)); - name.append(" - "); //$NON-NLS-1$ + name.append(NAME_SEPARATOR); name.append(resolutionStrategy.name().toLowerCase()); - name.append(" - "); //$NON-NLS-1$ - name.append(diffEngine.getSimpleName()); - name.append(" - "); //$NON-NLS-1$ - name.append(eqEngine.getSimpleName()); - name.append(" - "); //$NON-NLS-1$ - name.append(reqEngine.getSimpleName()); - name.append(" - "); //$NON-NLS-1$ - name.append(conflictDetector.getSimpleName()); + name.append(NAME_SEPARATOR); + name.append(configuration.getDiffEngine().getSimpleName()); + name.append(NAME_SEPARATOR); + name.append(configuration.getEqEngine().getSimpleName()); + name.append(NAME_SEPARATOR); + name.append(configuration.getReqEngine().getSimpleName()); + name.append(NAME_SEPARATOR); + name.append(configuration.getConflictDetector().getSimpleName()); return name.toString(); } diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestRunner.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestRunner.java index bc3e9828e..7cd9190fe 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestRunner.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/AbstractCompareTestRunner.java @@ -44,7 +44,7 @@ public abstract class AbstractCompareTestRunner extends ParentRunner<Runner> { /** Default list of resolution strategies used if the @ResolutionStrategies annotation is not used. */ private final ResolutionStrategyID[] defaultResolutionStrategies = new ResolutionStrategyID[] { - ResolutionStrategyID.WORKSPACE }; + ResolutionStrategyID.WORKSPACE, }; /** Default list of match engines disabled if the @MatchEngines annotation is not used. */ private final Class<?>[] defaultDisabledMatchEngines = new Class<?>[] {}; @@ -65,6 +65,14 @@ public abstract class AbstractCompareTestRunner extends ParentRunner<Runner> { /** Default list of resolution strategies disabled if the @PostProcessors annotation is not used. */ private final Class<?>[] defaultDisabledPostProcessors = new Class<?>[] {}; + /** + * The constructor. + * + * @param testClass + * The given test class + * @throws InitializationError + * If the test cannot be created + */ public AbstractCompareTestRunner(Class<?> testClass) throws InitializationError { super(testClass); @@ -133,15 +141,19 @@ public abstract class AbstractCompareTestRunner extends ParentRunner<Runner> { disabledPostProcessors = pProcessors.value(); } + // CHECKSTYLE:OFF those embedded fors are necessary to create all the test possibilities for (ResolutionStrategyID resolutionStrategy : resolutionStrategies) { for (Class<?> diffEngine : diffEngines) { for (Class<?> eqEngine : eqEngines) { for (Class<?> reqEngine : reqEngines) { for (Class<?> conflictDetector : conflictDetectors) { + // CHECKSTYLE:ON try { - createRunner(getTestClass().getJavaClass(), resolutionStrategy, + EMFCompareTestConfiguration configuration = new EMFCompareTestConfiguration( disabledMatchEngines, diffEngine, eqEngine, reqEngine, conflictDetector, disabledPostProcessors); + createRunner(getTestClass().getJavaClass(), resolutionStrategy, + configuration); } catch (InitializationError e) { e.printStackTrace(); Assert.fail(e.getMessage()); @@ -160,24 +172,13 @@ public abstract class AbstractCompareTestRunner extends ParentRunner<Runner> { * The class to test * @param resolutionStrategy * The resolution strategy used for this runner - * @param disabledMatchEngines - * The match engines disabled for this runner - * @param diffEngine - * The diff engine used for this runner - * @param eqEngine - * The eq engine used for this runner - * @param reqEngine - * The req engine used for this runner - * @param conflictDetector - * The conflict detector used for this runner - * @param disabledPostProcessors - * The post processors disabled for this runner + * @param configuration + * EMFCompare configurations for the test * @throws InitializationError * If the creation of the runner goes wrong */ public abstract void createRunner(Class<?> testClass, ResolutionStrategyID resolutionStrategy, - Class<?>[] disabledMatchEngines, Class<?> diffEngine, Class<?> eqEngine, Class<?> reqEngine, - Class<?> conflictDetector, Class<?>[] disabledPostProcessors) throws InitializationError; + EMFCompareTestConfiguration configuration) throws InitializationError; /** * {@inheritDoc} diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/EMFCompareTestConfiguration.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/EMFCompareTestConfiguration.java new file mode 100644 index 000000000..739beca62 --- /dev/null +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/EMFCompareTestConfiguration.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2016 Obeo. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Obeo - initial API and implementation + *******************************************************************************/ +package org.eclipse.emf.compare.ide.ui.tests.framework; + +/** + * This class is a wrapper for EMFCompare configurations. + * + * @author <a href="mailto:mathieu.cartaud@obeo.fr">Mathieu Cartaud</a> + */ +public class EMFCompareTestConfiguration { + + /** The match engines disabled used for this test. */ + private final Class<?>[] disabledMatchEngines; + + /** The diff engine used for this test. */ + private final Class<?> diffEngine; + + /** The eq engine used for this test. */ + private final Class<?> eqEngine; + + /** The req engine used for this test. */ + private final Class<?> reqEngine; + + /** The conflict detector used for this test. */ + private final Class<?> conflictDetector; + + /** The post-processors disabled for this test. */ + private final Class<?>[] disabledPostProcessors; + + /** + * The constructor. + * + * @param disabledMatchEngineFactory + * The match engines disabled for the test + * @param diffEngine + * The diff engine used for the test + * @param eqEngine + * The eq engine used for the test + * @param reqEngine + * The req engine used for the test + * @param conflictDetector + * The conflict detector used for the test + * @param disabledPostProcessors + * The post processors disabled for the test + */ + public EMFCompareTestConfiguration(Class<?>[] disabledMatchEngineFactory, Class<?> diffEngine, Class<?> eqEngine, + Class<?> reqEngine, Class<?> conflictDetector, Class<?>[] disabledPostProcessors) { + this.disabledMatchEngines = disabledMatchEngineFactory; + this.diffEngine = diffEngine; + this.eqEngine = eqEngine; + this.reqEngine = reqEngine; + this.conflictDetector = conflictDetector; + this.disabledPostProcessors = disabledPostProcessors; + } + + public Class<?>[] getDisabledMatchEngines() { + return disabledMatchEngines; + } + + public Class<?> getDiffEngine() { + return diffEngine; + } + + public Class<?> getEqEngine() { + return eqEngine; + } + + public Class<?> getReqEngine() { + return reqEngine; + } + + public Class<?> getConflictDetector() { + return conflictDetector; + } + + public Class<?>[] getDisabledPostProcessors() { + return disabledPostProcessors; + } + +} diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/RuntimeTestRunner.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/RuntimeTestRunner.java index c4f1f56ff..983c0fd58 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/RuntimeTestRunner.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/RuntimeTestRunner.java @@ -20,16 +20,22 @@ import org.junit.runners.model.InitializationError; */ public class RuntimeTestRunner extends AbstractCompareTestRunner { + /** + * The constructor. + * + * @param testClass + * The given test class + * @throws InitializationError + * If the test cannot be created + */ public RuntimeTestRunner(Class<?> testClass) throws InitializationError { super(testClass); } @Override public void createRunner(Class<?> testClass, ResolutionStrategyID resolutionStrategy, - Class<?>[] disabledMatchEngines, Class<?> diffEngine, Class<?> eqEngine, Class<?> reqEngine, - Class<?> conflictDetector, Class<?>[] disabledPostProcessors) throws InitializationError { - runners.add(new CompareTestCaseJUnitBlock(testClass, resolutionStrategy, disabledMatchEngines, - diffEngine, eqEngine, reqEngine, conflictDetector, disabledPostProcessors)); + EMFCompareTestConfiguration configuration) throws InitializationError { + runners.add(new CompareTestCaseJUnitBlock(testClass, resolutionStrategy, configuration)); } } diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/Compare.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/Compare.java index 67462a0dc..e120c9b7f 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/Compare.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/Compare.java @@ -28,14 +28,24 @@ import java.lang.annotation.Target; @Target(ElementType.METHOD) public @interface Compare { - /** Path to the file used for the left side. */ + /** + * Path to the file used for the left side. + * + * @return the value + */ String left(); - /** Path to the file used for the right side. */ + /** + * Path to the file used for the right side. + * + * @return the value + */ String right(); /** * Path to the file used for the ancestor side. If set, the comparison will be 3-way, 2-way otherwise. + * + * @return the value or an empty String if not used */ String ancestor() default ""; } diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ConflictDetectors.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ConflictDetectors.java index 3843f1d59..d0199eea6 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ConflictDetectors.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ConflictDetectors.java @@ -32,6 +32,8 @@ public @interface ConflictDetectors { * The list of conflict detectors to test. If the annotation is used empty, the default array will be * returned. If the annotation is not used the conflict detectors defined in a default array in the class * EMFCompareGitTestRunner will be used. + * + * @return the value or the default array if user specify nothing */ Class<?>[] value() default {DefaultConflictDetector.class, MatchBasedConflictDetector.class }; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DiffEngines.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DiffEngines.java index 3b0970ce9..fe7c5bafc 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DiffEngines.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DiffEngines.java @@ -31,6 +31,8 @@ public @interface DiffEngines { * The list of diff engines to test. If the annotation is used empty, the default array will be returned. * If the annotation is not used the diff engines defined in a default array in the class * EMFCompareGitTestRunner will be used. + * + * @return the value or the default array if user specify nothing */ Class<?>[] value() default {DefaultDiffEngine.class }; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledMatchEngines.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledMatchEngines.java index 1b582e367..23db8538f 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledMatchEngines.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledMatchEngines.java @@ -28,6 +28,8 @@ public @interface DisabledMatchEngines { * The list of match engines disabled for the test. If the annotation is used empty, the default array * will be returned. If the annotation is not used the match engines defined in a default array in the * class EMFCompareGitTestRunner will be disabled. Other match engines will be used for the comparison. + * + * @return the value or the default array if user specify nothing */ Class<?>[] value() default {}; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledPostProcessors.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledPostProcessors.java index bfa66b3ba..3cf819c0c 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledPostProcessors.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/DisabledPostProcessors.java @@ -29,6 +29,8 @@ public @interface DisabledPostProcessors { * The list of post processors disabled for the test. If the annotation is used empty, the default array * will be returned. If the annotation is not used the post processors defined in a default array in the * class EMFCompareGitTestRunner will be used. + * + * @return the value or the default array if user specify nothing */ Class<?>[] value() default {}; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/EqEngines.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/EqEngines.java index 7e6adadd9..425ad85ad 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/EqEngines.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/EqEngines.java @@ -31,6 +31,8 @@ public @interface EqEngines { * The list of equivalence engines to test. If the annotation is used empty, the default array will be * returned. If the annotation is not used the eq engines defined in a default array in the class * EMFCompareGitTestRunner will be used. + * + * @return the value or the default array if user specify nothing */ Class<?>[] value() default {DefaultEquiEngine.class }; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ReqEngines.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ReqEngines.java index f42253a87..f7676523e 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ReqEngines.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ReqEngines.java @@ -31,6 +31,8 @@ public @interface ReqEngines { * The list of requirement engines to test. If the annotation is used empty, the default array will be * returned. If the annotation is not used the req engines defined in a default array in the class * EMFCompareGitTestRunner will be used. + * + * @return the value or the default array if user specify nothing */ Class<?>[] value() default {DefaultReqEngine.class }; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ResolutionStrategies.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ResolutionStrategies.java index 19128fcde..0a4a08ac7 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ResolutionStrategies.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/annotations/ResolutionStrategies.java @@ -31,6 +31,8 @@ public @interface ResolutionStrategies { * The list of resolution strategies to test. If the annotation is used empty, the default array will be * returned (only workspace resolution strategy). If the annotation is not used the resolution strategies * defined in a default array in the class EMFCompareGitTestRunner will be used. + * + * @return the value or the default array if user specify nothing */ ResolutionStrategyID[] value() default {ResolutionStrategyID.WORKSPACE }; diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareStatement.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareStatement.java index d2f7776b7..c8d16039e 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareStatement.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareStatement.java @@ -12,17 +12,33 @@ package org.eclipse.emf.compare.ide.ui.tests.framework.internal; import org.eclipse.emf.compare.Comparison; import org.eclipse.emf.compare.ide.ui.tests.framework.AbstractCompareStatement; +import org.eclipse.emf.compare.ide.ui.tests.framework.EMFCompareTestConfiguration; import org.eclipse.emf.compare.ide.ui.tests.framework.ResolutionStrategyID; import org.eclipse.emf.compare.ide.ui.tests.framework.annotations.Compare; import org.junit.runners.model.FrameworkMethod; +/** + * JUnit statement for simple comparison tests. + * + * @author <a href="mailto:mathieu.cartaud@obeo.fr">Mathieu Cartaud</a> + */ public class CompareStatement extends AbstractCompareStatement { + /** + * Constructor for the classic (no Git) comparison statement. + * + * @param testObject + * The test class + * @param test + * The test method + * @param resolutionStrategy + * The resolution strategy used for this test + * @param configuration + * EMFComapre configurations for this test + */ public CompareStatement(Object testObject, FrameworkMethod test, ResolutionStrategyID resolutionStrategy, - Class<?>[] disabledMatchEngineFactory, Class<?> diffEngine, Class<?> eqEngine, Class<?> reqEngine, - Class<?> conflictDetector, Class<?>[] disabledPostProcessors) { - super(testObject, test, resolutionStrategy, disabledMatchEngineFactory, diffEngine, eqEngine, - reqEngine, conflictDetector, disabledPostProcessors); + EMFCompareTestConfiguration configuration) { + super(testObject, test, resolutionStrategy, configuration); } @Override diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestCaseJUnitBlock.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestCaseJUnitBlock.java index dc8236520..de79bf6ad 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestCaseJUnitBlock.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestCaseJUnitBlock.java @@ -15,23 +15,37 @@ import com.google.common.collect.Lists; import java.util.List; import org.eclipse.emf.compare.ide.ui.tests.framework.AbstractCompareTestCaseJUnitBlock; +import org.eclipse.emf.compare.ide.ui.tests.framework.EMFCompareTestConfiguration; import org.eclipse.emf.compare.ide.ui.tests.framework.ResolutionStrategyID; import org.eclipse.emf.compare.ide.ui.tests.framework.annotations.Compare; import org.junit.Assert; +import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.InitializationError; import org.junit.runners.model.Statement; /** + * EMFCompare specific {@link BlockJUnit4ClassRunner} used for simple comparisons. + * * @author <a href="mailto:mathieu.cartaud@obeo.fr">Mathieu Cartaud</a> */ public class CompareTestCaseJUnitBlock extends AbstractCompareTestCaseJUnitBlock { + /** + * Constructor for the classic (no Git) comparison JUnit block. + * + * @param klass + * The test class + * @param resolutionStrategy + * The resolution strategy used for this test + * @param configuration + * EMFComapre configurations for this test + * @throws InitializationError + * If something went wrong during test initialization + */ public CompareTestCaseJUnitBlock(Class<?> klass, ResolutionStrategyID resolutionStrategy, - Class<?>[] disabledMatchEngines, Class<?> diffEngine, Class<?> eqEngine, Class<?> reqEngine, - Class<?> conflictDetector, Class<?>[] disabledPostProcessors) throws InitializationError { - super(klass, resolutionStrategy, disabledMatchEngines, diffEngine, eqEngine, reqEngine, - conflictDetector, disabledPostProcessors); + EMFCompareTestConfiguration configuration) throws InitializationError { + super(klass, resolutionStrategy, configuration); } @Override @@ -46,14 +60,15 @@ public class CompareTestCaseJUnitBlock extends AbstractCompareTestCaseJUnitBlock Object testObject = null; try { testObject = createTest(); + // CHECKSTYLE:OFF JUnit method createTest() throw an Exception } catch (Exception e) { + // CHECKSTYLE:ON Assert.fail(e.getMessage()); } Statement result = null; if (method.getAnnotation(Compare.class) != null) { - result = new CompareStatement(testObject, method, resolutionStrategy, disabledMatchEngines, - diffEngine, eqEngine, reqEngine, conflictDetector, disabledPostProcessors); + result = new CompareStatement(testObject, method, resolutionStrategy, configuration); } return result; } diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestSupport.java b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestSupport.java index 417937534..a4cd35536 100644 --- a/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestSupport.java +++ b/plugins/org.eclipse.emf.compare.ide.ui.tests.framework/src/org/eclipse/emf/compare/ide/ui/tests/framework/internal/CompareTestSupport.java @@ -36,12 +36,29 @@ import org.eclipse.emf.ecore.util.EcoreUtil; @SuppressWarnings("restriction") public class CompareTestSupport { + /** The left side resourceSet. */ private ResourceSet leftRS; + /** The right side resourceSet. */ private ResourceSet rightRS; - private ResourceSet ancestorRS = null; + /** The ancestor side resourceSet. */ + private ResourceSet ancestorRS; + /** + * Load the resource for the given paths. The paths must be relative to the given class. + * + * @param clazz + * The test class + * @param left + * The left resource relative path + * @param right + * The right resource relative path + * @param ancestor + * The ancestor resource relative path + * @throws IOException + * If a file cannot be read + */ protected void loadResources(Class<?> clazz, String left, String right, String ancestor) throws IOException { leftRS = new ResourceSetImpl(); @@ -106,6 +123,11 @@ public class CompareTestSupport { return resource; } + /** + * Launch EMFCompare comparison with the known parameters. + * + * @return the comparison + */ public Comparison compare() { DefaultComparisonScope scope = new DefaultComparisonScope(leftRS, rightRS, ancestorRS); final Builder comparisonBuilder = EMFCompare.builder(); @@ -113,6 +135,9 @@ public class CompareTestSupport { return comparisonBuilder.build().compare(scope); } + /** + * Place for specific tear down treatments to do after the test. + */ protected void tearDown() { // TODO is there something to do? } |