Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SUREFIRE-2210] - Restore ordering of additional class path elements #686

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2569,7 +2569,7 @@ private TestClassPath generateTestClasspath() throws MojoFailureException {

Map<String, Artifact> dependencyConflictIdsProjectArtifacts = classpathArtifacts.stream()
.collect(Collectors.toMap(Artifact::getDependencyConflictId, Function.identity()));
Set<String> additionalClasspathElements = new HashSet<>();
Set<String> additionalClasspathElements = new LinkedHashSet<>();
dmlloyd marked this conversation as resolved.
Show resolved Hide resolved
if (getAdditionalClasspathElements() != null) {
Arrays.stream(getAdditionalClasspathElements()).forEach(additionalClasspathElements::add);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class AdditionalClasspathIT extends SurefireJUnit4IntegrationTestCase {
@Test
public void additionalClasspathElements() {
unpack("/additional-classpath").executeTest().verifyErrorFree(1);
unpack("/additional-classpath").executeTest().verifyErrorFree(2);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package additionalClasspath;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Enumeration;

import junit.framework.TestCase;

public class BasicTest
Expand All @@ -9,7 +16,28 @@ public class BasicTest
public void testExtraResource()
{
assertNotNull( BasicTest.class.getResourceAsStream( "/test.txt" ) );
assertNotNull( getClass().getClassLoader().getResourceAsStream( "test.txt" ) );
assertNotNull( BasicTest.class.getResourceAsStream( "/test2.txt" ) );
assertNotNull( getClass().getClassLoader().getResourceAsStream( "test2.txt" ) );
}

public void testExtraResourceOrder() throws IOException
{
Enumeration<URL> resources = getClass().getClassLoader().getResources("order-test.txt");
assertTrue( resources.hasMoreElements() );
URL url = resources.nextElement();
InputStream is = url.openStream();
assertNotNull( is );
try ( InputStream i = is; InputStreamReader r = new InputStreamReader(is); BufferedReader br = new BufferedReader(r) ) {
assertEquals("1", br.readLine());
}
assertTrue( resources.hasMoreElements() );
url = resources.nextElement();
is = url.openStream();
assertNotNull( is );
try ( InputStream i = is; InputStreamReader r = new InputStreamReader(is); BufferedReader br = new BufferedReader(r) ) {
assertEquals("2", br.readLine());
}
assertFalse( resources.hasMoreElements() );
}
}
Loading