diff options
3 files changed, 68 insertions, 2 deletions
diff --git a/m2e-core-tests b/m2e-core-tests -Subproject 711205d080bc809a5fa0aed33abac0827f8e24c +Subproject 4717c7c7a60ada0daabd34efa687c583001d3d2 diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java index d8cbfdeb..93368051 100644 --- a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java +++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/AbstractMavenProjectTestCase.java @@ -34,6 +34,7 @@ import java.util.Hashtable; import java.util.List; import java.util.Set; +import org.junit.After; import org.junit.Before; import org.junit.Rule; import org.junit.rules.TestName; @@ -118,8 +119,6 @@ public abstract class AbstractMavenProjectTestCase { @Before public void setUp() throws Exception { - System.out.println("TEST-SETUP: " + name.getMethodName()); - workspace = ResourcesPlugin.getWorkspace(); mavenConfiguration = MavenPlugin.getMavenConfiguration(); setAutoBuilding(false); @@ -159,6 +158,7 @@ public abstract class AbstractMavenProjectTestCase { FilexWagon.setRequestFilterPattern(null, true); } + @After public void tearDown() throws Exception { waitForJobsToComplete(); WorkspaceHelpers.cleanWorkspace(); diff --git a/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/MavenRunner.java b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/MavenRunner.java new file mode 100644 index 00000000..bd6abf84 --- /dev/null +++ b/org.eclipse.m2e.tests.common/src/org/eclipse/m2e/tests/common/MavenRunner.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2019 Red Hat Inc. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Red Hat Inc. - initial API and implementation + *******************************************************************************/ + +package org.eclipse.m2e.tests.common; + +import org.junit.runners.BlockJUnit4ClassRunner; +import org.junit.runners.model.FrameworkMethod; +import org.junit.runners.model.InitializationError; +import org.junit.runners.model.Statement; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; + +import org.eclipse.m2e.core.MavenPlugin; +import org.eclipse.m2e.core.embedder.IMavenExecutionContext; +import org.eclipse.m2e.core.internal.embedder.AbstractRunnable; + + +/** + * MavenRunner + */ +public class MavenRunner extends BlockJUnit4ClassRunner { + + public MavenRunner(Class<?> klass) throws InitializationError { + super(klass); + } + + protected Statement methodInvoker(FrameworkMethod method, Object test) { + return new Statement() { + + public void evaluate() throws Throwable { + class WrappedThrowable extends RuntimeException { + public WrappedThrowable(Throwable ex) { + super(ex); + } + } + try { + MavenPlugin.getMaven().execute(new AbstractRunnable() { + @SuppressWarnings("synthetic-access") + protected void run(IMavenExecutionContext context, IProgressMonitor monitor) { + try { + MavenRunner.super.methodInvoker(method, test); + } catch(Throwable ex) { + throw new WrappedThrowable(ex); + } + } + }, new NullProgressMonitor()); + } catch(WrappedThrowable e) { + throw e.getCause(); + } + } + + }; + } + +} |