LUCENE-5945: Cleanup & javadocs

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1624791 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2014-09-13 23:34:59 +00:00
parent 737acac742
commit af287593c8
2 changed files with 9 additions and 7 deletions

View File

@ -1663,9 +1663,9 @@ public abstract class LuceneTestCase extends Assert {
}
/**
* Gets a resource from the classpath as {@link Path}. This method should only
* Gets a resource from the test's classpath as {@link Path}. This method should only
* be used, if a real file is needed. To get a stream, code should prefer
* {@link Class#getResourceAsStream} using {@code this.getClass()}.
* {@link #getDataInputStream(String)}.
*/
protected Path getDataPath(String name) throws IOException {
try {
@ -1675,12 +1675,15 @@ public abstract class LuceneTestCase extends Assert {
}
}
/**
* Gets a resource from the test's classpath as {@link InputStream}.
*/
protected InputStream getDataInputStream(String name) throws IOException {
try {
return this.getClass().getResourceAsStream(name);
} catch (Exception e) {
InputStream in = this.getClass().getResourceAsStream(name);
if (in == null) {
throw new IOException("Cannot find resource: " + name);
}
return in;
}
public void assertReaderEquals(String info, IndexReader leftReader, IndexReader rightReader) throws IOException {

View File

@ -28,7 +28,6 @@ import java.nio.CharBuffer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -108,6 +107,7 @@ public final class TestUtil {
try (ZipInputStream zipInput = new ZipInputStream(in)) {
ZipEntry entry;
byte[] buffer = new byte[8192];
while ((entry = zipInput.getNextEntry()) != null) {
Path targetFile = destDir.resolve(entry.getName());
@ -116,7 +116,6 @@ public final class TestUtil {
Files.createDirectories(targetFile.getParent());
if (!entry.isDirectory()) {
OutputStream out = Files.newOutputStream(targetFile);
byte[] buffer = new byte[8192];
int len;
while((len = zipInput.read(buffer)) >= 0) {
out.write(buffer, 0, len);