mirror of
https://github.com/Alfresco/alfresco-transform-core.git
synced 2025-10-01 14:41:17 +00:00
MNT-24883 base engine changes to maintain source file name
This commit is contained in:
@@ -77,6 +77,7 @@ public class FileManager
|
|||||||
if (request != null && request.getParts() != null)
|
if (request != null && request.getParts() != null)
|
||||||
{
|
{
|
||||||
String submittedFileName = request.getParts().stream()
|
String submittedFileName = request.getParts().stream()
|
||||||
|
.filter(part -> part instanceof MultipartFile && StringUtils.isNotEmpty(part.getSubmittedFileName()))
|
||||||
.map(Part::getSubmittedFileName)
|
.map(Part::getSubmittedFileName)
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
@@ -228,6 +228,7 @@ public class TransformManagerImpl implements TransformManager
|
|||||||
deleteDocUUIDFolder();
|
deleteDocUUIDFolder();
|
||||||
outputStreamLengthRecorder = null;
|
outputStreamLengthRecorder = null;
|
||||||
sourceFile = null;
|
sourceFile = null;
|
||||||
|
sourceFileName = null;
|
||||||
createSourceFileCalled = false;
|
createSourceFileCalled = false;
|
||||||
startedWithSourceFile = null;
|
startedWithSourceFile = null;
|
||||||
}
|
}
|
||||||
|
@@ -26,9 +26,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.alfresco.transform.base.transform;
|
package org.alfresco.transform.base.transform;
|
||||||
|
|
||||||
import org.alfresco.transform.base.CustomTransformer;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
import org.junit.jupiter.api.Test;
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import org.junit.jupiter.api.io.TempDir;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
import java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
@@ -42,20 +42,25 @@ import java.io.IOException;
|
|||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.Part;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import org.junit.jupiter.api.Test;
|
||||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
import org.junit.jupiter.api.io.TempDir;
|
||||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
import org.mockito.Mockito;
|
||||||
|
|
||||||
|
import org.alfresco.transform.base.CustomTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@link StreamHandler}, {@link TransformManagerImpl#createSourceFile()} and
|
* Tests {@link StreamHandler}, {@link TransformManagerImpl#createSourceFile()} and {@link TransformManagerImpl#createTargetFile()} methods.
|
||||||
* {@link TransformManagerImpl#createTargetFile()} methods.
|
|
||||||
*/
|
*/
|
||||||
public class StreamHandlerTest
|
public class StreamHandlerTest
|
||||||
{
|
{
|
||||||
public static final String ORIGINAL = "Original";
|
public static final String ORIGINAL = "Original";
|
||||||
public static final String CHANGE = " plus some change";
|
public static final String CHANGE = " plus some change";
|
||||||
public static final String EXPECTED = ORIGINAL+ CHANGE;
|
public static final String EXPECTED = ORIGINAL + CHANGE;
|
||||||
|
|
||||||
TransformManagerImpl transformManager = new TransformManagerImpl();
|
TransformManagerImpl transformManager = new TransformManagerImpl();
|
||||||
@TempDir
|
@TempDir
|
||||||
@@ -76,6 +81,12 @@ public class StreamHandlerTest
|
|||||||
return new BufferedInputStream(new FileInputStream(sourceFile));
|
return new BufferedInputStream(new FileInputStream(sourceFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private File tempDocFile() throws IOException
|
||||||
|
{
|
||||||
|
return File.createTempFile("temp_", ".docx", tempDir);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private File tempFile() throws IOException
|
private File tempFile() throws IOException
|
||||||
{
|
{
|
||||||
return File.createTempFile("temp_", null, tempDir);
|
return File.createTempFile("temp_", null, tempDir);
|
||||||
@@ -132,12 +143,12 @@ public class StreamHandlerTest
|
|||||||
public void testStartWithInputStream() throws Exception
|
public void testStartWithInputStream() throws Exception
|
||||||
{
|
{
|
||||||
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
write(outputStreamLengthRecorder, read(inputStream)+CHANGE);
|
write(outputStreamLengthRecorder, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
transformManager.getOutputStream().close();
|
transformManager.getOutputStream().close();
|
||||||
@@ -155,14 +166,75 @@ public class StreamHandlerTest
|
|||||||
public void testStartWithInputStreamAndCallCreateSourceFile() throws Exception
|
public void testStartWithInputStreamAndCallCreateSourceFile() throws Exception
|
||||||
{
|
{
|
||||||
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
File sourceFileCreatedByTransform = transformManager.createSourceFile();
|
File sourceFileCreatedByTransform = transformManager.createSourceFile();
|
||||||
assertTrue(sourceFileCreatedByTransform.exists());
|
assertTrue(sourceFileCreatedByTransform.exists());
|
||||||
write(outputStreamLengthRecorder, read(sourceFileCreatedByTransform)+CHANGE);
|
write(outputStreamLengthRecorder, read(sourceFileCreatedByTransform) + CHANGE);
|
||||||
|
|
||||||
|
transformManager.copyTargetFileToOutputStream();
|
||||||
|
transformManager.getOutputStream().close();
|
||||||
|
closeInputStreamWithoutException(inputStream);
|
||||||
|
Long outputLength = transformManager.getOutputLength();
|
||||||
|
transformManager.deleteSourceFile();
|
||||||
|
transformManager.deleteTargetFile();
|
||||||
|
|
||||||
|
assertEquals(EXPECTED, read(outputStream));
|
||||||
|
assertEquals(EXPECTED.length(), outputLength);
|
||||||
|
assertFalse(sourceFileCreatedByTransform.exists());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStartWithInputStreamAndCallCreateSourceFileForDocxFiles() throws Exception
|
||||||
|
{
|
||||||
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
||||||
|
{
|
||||||
|
transformManager.setSourceFileName("test.docx");
|
||||||
|
transformManager.setInputStream(inputStream);
|
||||||
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
|
File sourceFileCreatedByTransform = transformManager.createSourceFile();
|
||||||
|
assertTrue(sourceFileCreatedByTransform.exists());
|
||||||
|
write(outputStreamLengthRecorder, read(sourceFileCreatedByTransform) + CHANGE);
|
||||||
|
|
||||||
|
transformManager.copyTargetFileToOutputStream();
|
||||||
|
transformManager.getOutputStream().close();
|
||||||
|
closeInputStreamWithoutException(inputStream);
|
||||||
|
Long outputLength = transformManager.getOutputLength();
|
||||||
|
transformManager.deleteSourceFile();
|
||||||
|
transformManager.deleteTargetFile();
|
||||||
|
|
||||||
|
assertEquals(EXPECTED, read(outputStream));
|
||||||
|
assertEquals(EXPECTED.length(), outputLength);
|
||||||
|
assertFalse(sourceFileCreatedByTransform.exists());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testStartWithInputStreamAndCallCreateSourceFileForDocxFilesWithHttpRequest() throws Exception
|
||||||
|
{
|
||||||
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
||||||
|
{
|
||||||
|
HttpServletRequest mockRequest = Mockito.mock(HttpServletRequest.class);
|
||||||
|
Part mockPart = Mockito.mock(Part.class);
|
||||||
|
Mockito.when(mockPart.getSubmittedFileName()).thenReturn("dummy.docx");
|
||||||
|
Collection<Part> parts = Arrays.asList(mockPart);
|
||||||
|
Mockito.when(mockRequest.getParts()).thenReturn(parts);
|
||||||
|
|
||||||
|
transformManager.setSourceMimetype("application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||||
|
transformManager.setInputStream(inputStream);
|
||||||
|
transformManager.setRequest(mockRequest);
|
||||||
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
|
File sourceFileCreatedByTransform = transformManager.createSourceFile();
|
||||||
|
assertTrue(sourceFileCreatedByTransform.exists());
|
||||||
|
write(outputStreamLengthRecorder, read(sourceFileCreatedByTransform) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
transformManager.getOutputStream().close();
|
transformManager.getOutputStream().close();
|
||||||
@@ -185,12 +257,12 @@ public class StreamHandlerTest
|
|||||||
transformManager.setSourceFile(sourceFile);
|
transformManager.setSourceFile(sourceFile);
|
||||||
|
|
||||||
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
write(outputStreamLengthRecorder, read(inputStream)+CHANGE);
|
write(outputStreamLengthRecorder, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
closeInputStreamWithoutException(inputStream);
|
closeInputStreamWithoutException(inputStream);
|
||||||
@@ -213,14 +285,14 @@ public class StreamHandlerTest
|
|||||||
transformManager.setSourceFile(sourceFile);
|
transformManager.setSourceFile(sourceFile);
|
||||||
|
|
||||||
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
File sourceFileCreatedByTransform = transformManager.createSourceFile();
|
File sourceFileCreatedByTransform = transformManager.createSourceFile();
|
||||||
assertEquals(sourceFile, sourceFileCreatedByTransform);
|
assertEquals(sourceFile, sourceFileCreatedByTransform);
|
||||||
write(outputStreamLengthRecorder, read(sourceFileCreatedByTransform)+CHANGE);
|
write(outputStreamLengthRecorder, read(sourceFileCreatedByTransform) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
closeInputStreamWithoutException(inputStream);
|
closeInputStreamWithoutException(inputStream);
|
||||||
@@ -247,14 +319,14 @@ public class StreamHandlerTest
|
|||||||
public void testStartWithOutputStreamAndCallCreateTargetFile() throws Exception
|
public void testStartWithOutputStreamAndCallCreateTargetFile() throws Exception
|
||||||
{
|
{
|
||||||
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
ByteArrayOutputStream outputStream = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
transformManager.setOutputStream(outputStream);
|
transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
File targetFileCreatedByTransform = transformManager.createTargetFile();
|
File targetFileCreatedByTransform = transformManager.createTargetFile();
|
||||||
assertTrue(targetFileCreatedByTransform.exists());
|
assertTrue(targetFileCreatedByTransform.exists());
|
||||||
write(targetFileCreatedByTransform, read(inputStream)+CHANGE);
|
write(targetFileCreatedByTransform, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
transformManager.getOutputStream().close();
|
transformManager.getOutputStream().close();
|
||||||
@@ -276,12 +348,12 @@ public class StreamHandlerTest
|
|||||||
transformManager.setTargetFile(targetFile);
|
transformManager.setTargetFile(targetFile);
|
||||||
|
|
||||||
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
write(outputStreamLengthRecorder, read(inputStream)+CHANGE);
|
write(outputStreamLengthRecorder, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
transformManager.getOutputStream().close();
|
transformManager.getOutputStream().close();
|
||||||
@@ -304,14 +376,14 @@ public class StreamHandlerTest
|
|||||||
transformManager.setTargetFile(targetFile);
|
transformManager.setTargetFile(targetFile);
|
||||||
|
|
||||||
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
transformManager.setOutputStream(outputStream);
|
transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
File targetFileCreatedByTransform = transformManager.createTargetFile();
|
File targetFileCreatedByTransform = transformManager.createTargetFile();
|
||||||
assertEquals(targetFile, targetFileCreatedByTransform);
|
assertEquals(targetFile, targetFileCreatedByTransform);
|
||||||
write(targetFileCreatedByTransform, read(inputStream)+CHANGE);
|
write(targetFileCreatedByTransform, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
transformManager.getOutputStream().close();
|
transformManager.getOutputStream().close();
|
||||||
@@ -344,12 +416,12 @@ public class StreamHandlerTest
|
|||||||
transformManager.keepTargetFile();
|
transformManager.keepTargetFile();
|
||||||
|
|
||||||
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
||||||
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
write(outputStreamLengthRecorder, read(inputStream)+CHANGE);
|
write(outputStreamLengthRecorder, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
closeInputStreamWithoutException(inputStream);
|
closeInputStreamWithoutException(inputStream);
|
||||||
@@ -375,12 +447,12 @@ public class StreamHandlerTest
|
|||||||
transformManager.setTargetFile(targetFile);
|
transformManager.setTargetFile(targetFile);
|
||||||
|
|
||||||
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
try (InputStream inputStream = new BufferedInputStream(new FileInputStream(sourceFile));
|
||||||
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
write(outputStreamLengthRecorder, read(inputStream)+CHANGE);
|
write(outputStreamLengthRecorder, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
closeInputStreamWithoutException(inputStream);
|
closeInputStreamWithoutException(inputStream);
|
||||||
@@ -404,12 +476,12 @@ public class StreamHandlerTest
|
|||||||
transformManager.setTargetFile(targetFile);
|
transformManager.setTargetFile(targetFile);
|
||||||
|
|
||||||
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
try (InputStream inputStream = getSourceInputStreamFromBytes();
|
||||||
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(targetFile)))
|
||||||
{
|
{
|
||||||
transformManager.setInputStream(inputStream);
|
transformManager.setInputStream(inputStream);
|
||||||
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
OutputStream outputStreamLengthRecorder = transformManager.setOutputStream(outputStream);
|
||||||
|
|
||||||
write(outputStreamLengthRecorder, read(inputStream)+CHANGE);
|
write(outputStreamLengthRecorder, read(inputStream) + CHANGE);
|
||||||
|
|
||||||
transformManager.copyTargetFileToOutputStream();
|
transformManager.copyTargetFileToOutputStream();
|
||||||
closeInputStreamWithoutException(inputStream);
|
closeInputStreamWithoutException(inputStream);
|
||||||
@@ -437,7 +509,7 @@ public class StreamHandlerTest
|
|||||||
@Override
|
@Override
|
||||||
protected void transform(CustomTransformer customTransformer) throws Exception
|
protected void transform(CustomTransformer customTransformer) throws Exception
|
||||||
{
|
{
|
||||||
write(outputStream, read(inputStream)+CHANGE);
|
write(outputStream, read(inputStream) + CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -448,8 +520,7 @@ public class StreamHandlerTest
|
|||||||
|
|
||||||
try (ByteArrayOutputStream os = new ByteArrayOutputStream())
|
try (ByteArrayOutputStream os = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
new FakeStreamHandler()
|
new FakeStreamHandler() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() throws IOException
|
protected void init() throws IOException
|
||||||
{
|
{
|
||||||
@@ -480,8 +551,7 @@ public class StreamHandlerTest
|
|||||||
File sourceFile = tempFile();
|
File sourceFile = tempFile();
|
||||||
write(sourceFile, ORIGINAL);
|
write(sourceFile, ORIGINAL);
|
||||||
|
|
||||||
new FakeStreamHandler()
|
new FakeStreamHandler() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() throws IOException
|
protected void init() throws IOException
|
||||||
{
|
{
|
||||||
@@ -512,8 +582,7 @@ public class StreamHandlerTest
|
|||||||
File sourceFile = tempFile();
|
File sourceFile = tempFile();
|
||||||
write(sourceFile, ORIGINAL);
|
write(sourceFile, ORIGINAL);
|
||||||
|
|
||||||
new FakeStreamHandler()
|
new FakeStreamHandler() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
protected InputStream getInputStream() throws IOException
|
protected InputStream getInputStream() throws IOException
|
||||||
{
|
{
|
||||||
@@ -533,8 +602,7 @@ public class StreamHandlerTest
|
|||||||
{
|
{
|
||||||
File targetFile = tempFile();
|
File targetFile = tempFile();
|
||||||
|
|
||||||
new FakeStreamHandler()
|
new FakeStreamHandler() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
protected InputStream getInputStream()
|
protected InputStream getInputStream()
|
||||||
{
|
{
|
||||||
@@ -543,7 +611,7 @@ public class StreamHandlerTest
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OutputStream getOutputStream()
|
protected OutputStream getOutputStream()
|
||||||
throws FileNotFoundException
|
throws FileNotFoundException
|
||||||
{
|
{
|
||||||
return getOutputStreamToFile(targetFile);
|
return getOutputStreamToFile(targetFile);
|
||||||
}
|
}
|
||||||
@@ -560,8 +628,7 @@ public class StreamHandlerTest
|
|||||||
{
|
{
|
||||||
try (ByteArrayOutputStream os = new ByteArrayOutputStream())
|
try (ByteArrayOutputStream os = new ByteArrayOutputStream())
|
||||||
{
|
{
|
||||||
new FakeStreamHandler()
|
new FakeStreamHandler() {
|
||||||
{
|
|
||||||
@Override
|
@Override
|
||||||
protected InputStream getInputStream()
|
protected InputStream getInputStream()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user