Skip to content

Commit

Permalink
[SUREFIRE-2226] Upgrade to Maven Verifier 2.0.0-M1
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o authored and slawekjaranowski committed Sep 20, 2024
1 parent 5aa3515 commit 4584ebb
Show file tree
Hide file tree
Showing 30 changed files with 56 additions and 53 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
<!-- Do not upgrade, needs code changes -->
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
<version>1.8.0</version>
<version>2.0.0-M1</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
Expand Down
7 changes: 7 additions & 0 deletions surefire-its/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
<artifactId>maven-verifier</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId>
Expand Down Expand Up @@ -192,6 +198,7 @@
<configuration>
<skipTests>${skipTests}</skipTests>
<runOrder>alphabetical</runOrder>
<forkCount>1C</forkCount>
<threadCount>1</threadCount>
<forkCount>1C</forkCount>
<rerunFailingTestsCount>1</rerunFailingTestsCount>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.ArrayList;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.List;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Ignore;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.List;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.AbstractJava9PlusIT;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Arrays;
import java.util.Calendar;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;
Expand All @@ -32,7 +32,11 @@ public class Surefire1602IT extends SurefireJUnit4IntegrationTestCase {
@Test
public void nonCanonicalPath() throws VerificationException {
SurefireLauncher launcher = unpack("/surefire-1602");
launcher.setLogFileName("log-install.txt");
launcher.executeInstall();
launcher.reset();

launcher.setLogFileName("log-test.txt");
launcher.addGoal("--file").addGoal("./integration-tests/pom.xml").executeTest();
launcher.getSubProjectValidator("integration-tests").assertTestSuiteResults(1, 0, 0, 0);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.io.IOException;
import java.util.Properties;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.fixture;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;

import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
import org.apache.maven.shared.utils.io.FileUtils;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;

import static java.util.Collections.singletonMap;
import static java.util.Collections.unmodifiableList;
Expand All @@ -52,7 +51,7 @@ public final class MavenLauncher {

private final Map<String, String> envVars = new HashMap<>();

private final Map<String, String> props = new LinkedHashMap<>();
private final Properties props = new Properties();

private File unpackedAt;

Expand Down Expand Up @@ -138,6 +137,8 @@ private static StackTraceElement[] getStackTraceElements() {
public void reset() {
resetGoals();
resetCliOptions();
verifier = null;
validator = null;
}

private void resetCliOptions() {
Expand Down Expand Up @@ -221,7 +222,7 @@ private void writeGoal(String newGoal) {
String goal = it.next();
if (goal.equals(sysPropKey) || goal.startsWith(sysPropStarter)) {
System.out.printf(
"[WARNING] System property already exists '%s'. Overriding to '%s'.\n", goal, newGoal);
"[WARNING] System property already exists '%s'. Overriding to '%s'.%n", goal, newGoal);
it.set(newGoal);
return;
}
Expand All @@ -242,7 +243,7 @@ private OutputValidator conditionalExec(String goal) {
}
}
if (expectFailure) {
throw new RuntimeException("Expecting build failure, got none!");
throw new RuntimeException("Expecting build failure, have got none!");
}
return verify;
}
Expand All @@ -259,21 +260,14 @@ public OutputValidator execute(String goal) {

public OutputValidator executeCurrentGoals() {
try {
List<String> goalsAndProps = new ArrayList<>(goals);

for (Entry<String, String> e : props.entrySet()) {
String key = e.getKey();
String val = e.getValue();
goalsAndProps.add(val == null ? "-D" + key : "-D" + key + "=" + val);
}

getVerifier().setCliOptions(cliOptions);
getVerifier().executeGoals(goalsAndProps, envVars);
getVerifier().addCliArguments(cliOptions.toArray(new String[0]));
getVerifier().addCliArguments(goals.toArray(new String[] {}));
getVerifier().setSystemProperties(props);
getVerifier().setEnvironmentVariables(envVars);
getVerifier().execute();
return getValidator();
} catch (VerificationException e) {
throw new SurefireVerifierException(e.getLocalizedMessage(), e);
} finally {
getVerifier().resetStreams();
}
}

Expand Down Expand Up @@ -399,12 +393,10 @@ String getTestMethodName() {

private static Verifier createVerifier(String basedir, String settingsFile, String[] defaultCliOptions)
throws VerificationException {
Verifier verifier = defaultCliOptions == null

return defaultCliOptions == null
? new Verifier(basedir, settingsFile, false)
: new Verifier(basedir, settingsFile, false, defaultCliOptions);

verifier.getVerifierProperties().setProperty("use.mavenRepoLocal", "true");
return verifier;
}

private static File settingsXmlPath() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.maven.it.VerificationException;
import org.apache.maven.it.Verifier;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.shared.verifier.Verifier;
import org.hamcrest.Matcher;

import static java.nio.charset.StandardCharsets.UTF_8;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.ArrayList;
import java.util.List;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;

/**
* Encapsulate all needed features to start a surefire run
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.util.Set;
import java.util.TreeSet;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.Iterator;
import java.util.List;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
import org.junit.Before;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.hamcrest.Matchers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.junit.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.io.FilenameFilter;
import java.util.Collection;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import java.util.Set;
import java.util.TreeSet;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
package org.apache.maven.surefire.its.jiras;

import org.apache.maven.it.VerificationException;
import org.apache.maven.shared.verifier.VerificationException;
import org.apache.maven.surefire.its.fixture.OutputValidator;
import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
import org.apache.maven.surefire.its.fixture.SurefireLauncher;
Expand Down

0 comments on commit 4584ebb

Please sign in to comment.