Merge remote-tracking branch 'origin/jetty-9.4.x' into jetty-10.0.x
Signed-off-by: gregw <gregw@webtide.com>
This commit is contained in:
commit
c793b54781
|
@ -26,6 +26,7 @@ import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.nio.channels.ReadableByteChannel;
|
import java.nio.channels.ReadableByteChannel;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -416,14 +417,17 @@ public class ResourceCollection extends Resource
|
||||||
public String[] list()
|
public String[] list()
|
||||||
{
|
{
|
||||||
assertResourcesSet();
|
assertResourcesSet();
|
||||||
|
|
||||||
HashSet<String> set = new HashSet<>();
|
HashSet<String> set = new HashSet<>();
|
||||||
for (Resource r : _resources)
|
for (Resource r : _resources)
|
||||||
{
|
{
|
||||||
Collections.addAll(set, r.list());
|
String[] list = r.list();
|
||||||
|
if (list != null)
|
||||||
|
Collections.addAll(set, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (String[])set.stream().sorted().toArray();
|
String[] result = set.toArray(new String[0]);
|
||||||
|
Arrays.sort(result);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.eclipse.jetty.toolchain.test.FS;
|
import org.eclipse.jetty.toolchain.test.FS;
|
||||||
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
|
||||||
|
@ -33,7 +34,10 @@ import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
import org.junit.jupiter.api.extension.ExtendWith;
|
||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
|
import static org.hamcrest.Matchers.contains;
|
||||||
|
import static org.hamcrest.Matchers.emptyArray;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
import static org.hamcrest.Matchers.nullValue;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
@ -175,6 +179,19 @@ public class ResourceCollectionTest
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testList() throws Exception
|
||||||
|
{
|
||||||
|
ResourceCollection rc1 = new ResourceCollection(
|
||||||
|
Resource.newResource("src/test/resources/org/eclipse/jetty/util/resource/one/"),
|
||||||
|
Resource.newResource("src/test/resources/org/eclipse/jetty/util/resource/two/"),
|
||||||
|
Resource.newResource("src/test/resources/org/eclipse/jetty/util/resource/three/"));
|
||||||
|
|
||||||
|
assertThat(Arrays.asList(rc1.list()), contains("1.txt", "2.txt", "3.txt", "dir/"));
|
||||||
|
assertThat(Arrays.asList(rc1.addPath("dir").list()), contains("1.txt", "2.txt", "3.txt"));
|
||||||
|
assertThat(rc1.addPath("unknown").list(), emptyArray());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testMultipleSources1() throws Exception
|
public void testMultipleSources1() throws Exception
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue