mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
Add a pseudo-integration test for getResources()
This adds an extra class path element to the VM running the unit tests, writes files with identical file names into both directories and then verifies that SystemClassLoader#getResources can find them. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
parent
167688eabd
commit
a2feec0bab
11
makefile
11
makefile
@ -1474,13 +1474,20 @@ ifeq ($(continuations),true)
|
||||
$(build)/compile-x86-asm.o: $(src)/continuations-x86.$(asm-format)
|
||||
endif
|
||||
|
||||
$(build)/run-tests.sh: $(test-classes) makefile
|
||||
$(build)/run-tests.sh: $(test-classes) makefile $(build)/extra-dir/multi-classpath-test.txt $(build)/test/multi-classpath-test.txt
|
||||
echo 'cd $$(dirname $$0)' > $(@)
|
||||
echo "sh ./test.sh 2>/dev/null \\" >> $(@)
|
||||
echo "$(shell echo $(library-path) | sed 's|$(build)|\.|g') ./$(name)-unittest${exe-suffix} ./$(notdir $(test-executable)) $(mode) \"-Djava.library.path=. -cp test\" \\" >> $(@)
|
||||
echo "$(shell echo $(library-path) | sed 's|$(build)|\.|g') ./$(name)-unittest${exe-suffix} ./$(notdir $(test-executable)) $(mode) \"-Djava.library.path=. -cp test:extra-dir\" \\" >> $(@)
|
||||
echo "$(call class-names,$(test-build),$(filter-out $(test-support-classes), $(test-classes))) \\" >> $(@)
|
||||
echo "$(continuation-tests) $(tail-tests)" >> $(@)
|
||||
|
||||
$(build)/extra-dir/multi-classpath-test.txt:
|
||||
mkdir -p $(build)/extra-dir
|
||||
echo "$@" > $@
|
||||
|
||||
$(build)/test/multi-classpath-test.txt:
|
||||
echo "$@" > $@
|
||||
|
||||
$(build)/test.sh: $(test)/test.sh
|
||||
cp $(<) $(@)
|
||||
|
||||
|
@ -1,3 +1,7 @@
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.Enumeration;
|
||||
|
||||
public class Misc {
|
||||
private static class μClass {
|
||||
public int μField;
|
||||
@ -262,6 +266,27 @@ public class Misc {
|
||||
|
||||
expect((Protected.class.getModifiers() & java.lang.reflect.Modifier.PUBLIC)
|
||||
== 0);
|
||||
|
||||
try {
|
||||
int count = 0;
|
||||
boolean test = false, extraDir = false;
|
||||
ClassLoader loader = Misc.class.getClassLoader();
|
||||
Enumeration<URL> resources = loader.getResources("multi-classpath-test.txt");
|
||||
while (resources.hasMoreElements()) {
|
||||
++count;
|
||||
String url = resources.nextElement().toString();
|
||||
if (url.contains("extra-dir")) {
|
||||
extraDir = true;
|
||||
} else if (url.contains("test")) {
|
||||
test = true;
|
||||
}
|
||||
}
|
||||
expect(count == 2);
|
||||
expect(test);
|
||||
expect(extraDir);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected class Protected { }
|
||||
|
Loading…
Reference in New Issue
Block a user