Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian W. Damus2016-01-05 09:25:45 -0500
committerChristian W. Damus2016-01-05 09:27:20 -0500
commit54ca0b035b00e790ca1a113bb2eeb94be1076e5f (patch)
treeeab84f784be4a9b5a188939a7d14309a815b84ab /tests
parent4eb11422ef206033ab108cc132d1278f9f18d650 (diff)
downloadorg.eclipse.papyrus-54ca0b035b00e790ca1a113bb2eeb94be1076e5f.tar.gz
org.eclipse.papyrus-54ca0b035b00e790ca1a113bb2eeb94be1076e5f.tar.xz
org.eclipse.papyrus-54ca0b035b00e790ca1a113bb2eeb94be1076e5f.zip
Bug 485212: [Tests] Failures in validation marker deletion advice tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=485212 The Papyrus validation service API used by the tests changed in an incompatible way, now no longer delegating by default to the UML validator. So, the test case is updated to use that validator explicitly in order to actually generate the problem markers that the test cases operate on.
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/org.eclipse.papyrus.infra.services.edit.tests.launch2
-rw-r--r--tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/advice/MarkerDeletionAdviceTest.java36
2 files changed, 21 insertions, 17 deletions
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/org.eclipse.papyrus.infra.services.edit.tests.launch b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/org.eclipse.papyrus.infra.services.edit.tests.launch
index cd48266d315..0c27a90dc2b 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/org.eclipse.papyrus.infra.services.edit.tests.launch
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/org.eclipse.papyrus.infra.services.edit.tests.launch
@@ -24,7 +24,7 @@
<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="org.eclipse.papyrus.infra.services.edit.tests.suites.AllTests"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.papyrus.infra.services.edit.tests"/>
diff --git a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/advice/MarkerDeletionAdviceTest.java b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/advice/MarkerDeletionAdviceTest.java
index 115c79c6dc2..06dd26bbf7d 100644
--- a/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/advice/MarkerDeletionAdviceTest.java
+++ b/tests/junit/plugins/infra/services/org.eclipse.papyrus.infra.services.edit.tests/src/org/eclipse/papyrus/infra/services/edit/tests/edit/advice/MarkerDeletionAdviceTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 CEA and others.
+ * Copyright (c) 2014, 2016 CEA, Christian W. Damus, and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Christian W. Damus (CEA) - Initial API and implementation
+ * Christian W. Damus - bug 485212
*
*/
package org.eclipse.papyrus.infra.services.edit.tests.edit.advice;
@@ -35,6 +36,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.emf.common.util.BasicDiagnostic;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
@@ -46,6 +48,7 @@ import org.eclipse.papyrus.commands.wrappers.GMFtoEMFCommandWrapper;
import org.eclipse.papyrus.infra.services.edit.internal.advice.MarkerDeletionAdvice;
import org.eclipse.papyrus.infra.services.edit.service.ElementEditServiceUtils;
import org.eclipse.papyrus.infra.services.edit.service.IElementEditService;
+import org.eclipse.papyrus.infra.services.validation.EValidatorAdapter;
import org.eclipse.papyrus.infra.services.validation.EcoreDiagnostician;
import org.eclipse.papyrus.infra.services.validation.IPapyrusDiagnostician;
import org.eclipse.papyrus.infra.services.validation.ValidationTool;
@@ -58,6 +61,7 @@ import org.eclipse.uml2.uml.Association;
import org.eclipse.uml2.uml.LoopNode;
import org.eclipse.uml2.uml.NamedElement;
import org.eclipse.uml2.uml.Property;
+import org.eclipse.uml2.uml.UMLPackage;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
@@ -173,8 +177,8 @@ public class MarkerDeletionAdviceTest extends AbstractPapyrusTest {
editor.open();
// Validate the model
- IPapyrusDiagnostician diagnostician = new EcoreDiagnostician();
- diagnostician.initialize(((AdapterFactoryEditingDomain)editor.getEditingDomain()).getAdapterFactory(), new NullProgressMonitor());
+ IPapyrusDiagnostician diagnostician = new EcoreDiagnostician(new EValidatorAdapter((EValidator) EValidator.Registry.INSTANCE.get(UMLPackage.eINSTANCE)));
+ diagnostician.initialize(((AdapterFactoryEditingDomain) editor.getEditingDomain()).getAdapterFactory(), new NullProgressMonitor());
BasicDiagnostic diagnostic = diagnostician.createDefaultDiagnostic(editor.getModel());
diagnostician.validate(editor.getModel(), diagnostic, diagnostician.createDefaultContext());
@@ -190,9 +194,9 @@ public class MarkerDeletionAdviceTest extends AbstractPapyrusTest {
<T extends NamedElement> T findElement(Class<T> type, String name) {
T result = null;
- for(Iterator<?> iter = editor.getModelResource().getAllContents(); iter.hasNext();) {
+ for (Iterator<?> iter = editor.getModelResource().getAllContents(); iter.hasNext();) {
Object next = iter.next();
- if(type.isInstance(next) && ((name == null) || name.equals(((NamedElement)next).getName()))) {
+ if (type.isInstance(next) && ((name == null) || name.equals(((NamedElement) next).getName()))) {
result = type.cast(next);
break;
}
@@ -225,8 +229,8 @@ public class MarkerDeletionAdviceTest extends AbstractPapyrusTest {
private void letMarkerCacheClearOut() {
Display display = Display.getCurrent();
- if(display != null) {
- while(display.readAndDispatch()) {
+ if (display != null) {
+ while (display.readAndDispatch()) {
// Pass
}
}
@@ -241,7 +245,7 @@ public class MarkerDeletionAdviceTest extends AbstractPapyrusTest {
public void describeTo(Description description) {
description.appendText("marker of ");
- switch(markerSeverity) {
+ switch (markerSeverity) {
case IMarker.SEVERITY_INFO:
description.appendText("INFO");
break;
@@ -260,10 +264,10 @@ public class MarkerDeletionAdviceTest extends AbstractPapyrusTest {
public boolean matches(Object item) {
boolean result = item instanceof IMarkerDelta;
- if(result) {
- IMarkerDelta markerDelta = (IMarkerDelta)item;
+ if (result) {
+ IMarkerDelta markerDelta = (IMarkerDelta) item;
result = (markerDelta.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR) == markerSeverity) //
- && messagePattern.matcher(markerDelta.getAttribute(IMarker.MESSAGE, "")).find();
+ && messagePattern.matcher(markerDelta.getAttribute(IMarker.MESSAGE, "")).find();
}
return result;
@@ -314,9 +318,9 @@ public class MarkerDeletionAdviceTest extends AbstractPapyrusTest {
event.getDelta().accept(new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) throws CoreException {
- if(file.equals(delta.getResource()) && ((delta.getFlags() & IResourceDelta.MARKERS) != 0)) {
- for(IMarkerDelta markerDelta : delta.getMarkerDeltas()) {
- switch(markerDelta.getKind()) {
+ if (file.equals(delta.getResource()) && ((delta.getFlags() & IResourceDelta.MARKERS) != 0)) {
+ for (IMarkerDelta markerDelta : delta.getMarkerDeltas()) {
+ switch (markerDelta.getKind()) {
case IResourceDelta.ADDED:
markersAdded = markersAdded || anyAssertionMatches(markerDelta);
break;
@@ -354,9 +358,9 @@ public class MarkerDeletionAdviceTest extends AbstractPapyrusTest {
private boolean anyAssertionMatches(IMarkerDelta markerDelta) {
boolean result = false;
- for(Matcher<? super IMarkerDelta> next : markerAssertions) {
+ for (Matcher<? super IMarkerDelta> next : markerAssertions) {
result = next.matches(markerDelta);
- if(result) {
+ if (result) {
break;
}
}

Back to the top