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 authored and kwin committed Nov 14, 2023
1 parent 9b7ecf1 commit 47c5816
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
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
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() );
}
}

0 comments on commit 47c5816

Please sign in to comment.