Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian W. Damus2015-04-06 11:52:23 +0000
committerChristian W. Damus2015-04-06 11:52:23 +0000
commit3f5f0be568739bf14152d368c5542f6d2e227abf (patch)
tree9876c5d7a9700ef3636540bda67ebf78cad20b59 /tests/junit/plugins/junit
parentc05685c605cbf3909a74b8dc53fabda9e3f7482c (diff)
downloadorg.eclipse.papyrus-3f5f0be568739bf14152d368c5542f6d2e227abf.tar.gz
org.eclipse.papyrus-3f5f0be568739bf14152d368c5542f6d2e227abf.tar.xz
org.eclipse.papyrus-3f5f0be568739bf14152d368c5542f6d2e227abf.zip
Bug 463631: Regression: Referenced models are not read-only
https://bugs.eclipse.org/bugs/show_bug.cgi?id=463631 Fix new test failure caused by the broken decorator-model read-only policy no longer masking read-only state of sub-unit resources. Incidentally fix NPEs in the stereotype repair snippet in async runnables left over when the model-set (and service registry) is shutting down. Fix warning in the log caused by a test asking for a resource by a URI with fragment.
Diffstat (limited to 'tests/junit/plugins/junit')
-rw-r--r--tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ExecutorRule.java56
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ExecutorRule.java b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ExecutorRule.java
new file mode 100644
index 00000000000..77347df01ce
--- /dev/null
+++ b/tests/junit/plugins/junit/org.eclipse.papyrus.junit.utils/src/org/eclipse/papyrus/junit/utils/rules/ExecutorRule.java
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (c) 2015 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
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Christian W. Damus - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.junit.utils.rules;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.Executor;
+
+import org.eclipse.papyrus.junit.utils.Activator;
+import org.junit.rules.TestRule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+
+import com.google.common.collect.Queues;
+
+/**
+ * A JUnit {@linkplain TestRule rule} that is an {@link Executor} running tasks at clean-up of the
+ * test execution.
+ */
+public class ExecutorRule extends TestWatcher implements Executor {
+ private final BlockingQueue<Runnable> queue = Queues.newLinkedBlockingQueue();
+
+ public ExecutorRule() {
+ super();
+ }
+
+ @Override
+ public void execute(Runnable command) {
+ queue.add(command);
+ }
+
+ protected void runPending() {
+ for (Runnable next = queue.poll(); next != null; next = queue.poll()) {
+ try {
+ next.run();
+ } catch (Exception e) {
+ Activator.log.error("Uncaught exception in test shutdown runnable.", e); //$NON-NLS-1$
+ }
+ }
+ }
+
+ @Override
+ protected void finished(Description description) {
+ runPending();
+ }
+}

Back to the top