mirror of
https://github.com/internetarchive/heritrix3.git
synced 2026-09-25 23:25:44 +00:00
* ContentExtractorTestBase.java
createRecorder(String,String) - new method for creating test Recorder and specifying charset
createRecorder(String) - deprecate (use default charset as before)
This commit is contained in:
@@ -21,7 +21,9 @@ package org.archive.modules.extractor;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.archive.modules.CrawlURI;
|
||||
import org.archive.modules.ProcessorTestBase;
|
||||
@@ -123,13 +125,16 @@ public abstract class ContentExtractorTestBase extends ProcessorTestBase {
|
||||
assertTrue(uri.getAnnotations().isEmpty());
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Recorder createRecorder(String content) throws IOException {
|
||||
return createRecorder(content, Charset.defaultCharset().name());
|
||||
}
|
||||
|
||||
|
||||
public static Recorder createRecorder(String content)
|
||||
throws Exception {
|
||||
public static Recorder createRecorder(String content, String charset)
|
||||
throws IOException {
|
||||
File temp = File.createTempFile("test", ".tmp");
|
||||
Recorder recorder = new Recorder(temp, 1024, 1024);
|
||||
byte[] b = content.getBytes(); // FIXME: Allow other encodings?
|
||||
byte[] b = content.getBytes(charset);
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(b);
|
||||
InputStream is = recorder.inputWrap(bais);
|
||||
for (int x = is.read(); x >= 0; x = is.read());
|
||||
|
||||
Reference in New Issue
Block a user