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 8232a9d
Show file tree
Hide file tree
Showing 4 changed files with 36 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,11 @@
package additionalClasspath;

import java.io.BufferedReader;
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 +18,31 @@ public void testExtraResource()
assertNotNull( BasicTest.class.getResourceAsStream( "/test2.txt" ) );
}

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

0 comments on commit 8232a9d

Please sign in to comment.