Skip to content

Commit

Permalink
[SUREFIRE-2210] - Restore ordering of additional class path elements
Browse files Browse the repository at this point in the history
  • Loading branch information
dmlloyd committed Nov 13, 2023
1 parent 9b7ecf1 commit e902384
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
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<>();
if (getAdditionalClasspathElements() != null) {
Arrays.stream(getAdditionalClasspathElements()).forEach(additionalClasspathElements::add);
}
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 @@ -12,4 +19,23 @@ public void testExtraResource()
assertNotNull( BasicTest.class.getResourceAsStream( "/test2.txt" ) );
}

public void testExtraResourceOrder() throws IOException
{
Enumeration<URL> resources = BasicTest.class.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() );
}
}

0 comments on commit e902384

Please sign in to comment.