use of com.linkedin.multipart.MultiPartMIMEInputStream in project rest.li by linkedin.
the class TestMIMEIntegrationReaderWriter method testEachSingleBodyDataSourceMultipleTimes.
@Test(dataProvider = "eachSingleBodyDataSource", enabled = false)
public void testEachSingleBodyDataSourceMultipleTimes(final int chunkSize, final MIMEDataPart bodyPart) throws Exception {
final List<MultiPartMIMEDataSourceWriter> dataSources = new ArrayList<>();
for (int i = 0; i < 4; i++) {
final MultiPartMIMEInputStream inputStreamDataSource = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(bodyPart.getPartData().copyBytes()), scheduledExecutorService, bodyPart.getPartHeaders()).withWriteChunkSize(chunkSize).build();
dataSources.add(inputStreamDataSource);
}
final MultiPartMIMEWriter writer = new MultiPartMIMEWriter.Builder("some preamble", "").appendDataSources(dataSources).build();
executeRequestAndAssert(writer, Collections.unmodifiableList(Arrays.asList(bodyPart, bodyPart, bodyPart, bodyPart)));
}
use of com.linkedin.multipart.MultiPartMIMEInputStream in project rest.li by linkedin.
the class TestMIMEIntegrationReaderWriter method testMultipleBodies.
@Test(dataProvider = "chunkSizes")
public void testMultipleBodies(final int chunkSize) throws Exception {
final MultiPartMIMEInputStream normalBodyInputStream = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(_normalBody.getPartData().copyBytes()), scheduledExecutorService, _normalBody.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final MultiPartMIMEInputStream headerLessBodyInputStream = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(_headerLessBody.getPartData().copyBytes()), scheduledExecutorService, _headerLessBody.getPartHeaders()).withWriteChunkSize(chunkSize).build();
// Copying over empty ByteString, but let's keep things consistent.
final MultiPartMIMEInputStream bodyLessBodyInputStream = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(_bodyLessBody.getPartData().copyBytes()), scheduledExecutorService, _bodyLessBody.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final MultiPartMIMEInputStream purelyEmptyBodyInputStream = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(_purelyEmptyBody.getPartData().copyBytes()), scheduledExecutorService, _purelyEmptyBody.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final MultiPartMIMEWriter writer = new MultiPartMIMEWriter.Builder("some preamble", "").appendDataSource(normalBodyInputStream).appendDataSource(headerLessBodyInputStream).appendDataSource(bodyLessBodyInputStream).appendDataSource(purelyEmptyBodyInputStream).build();
executeRequestAndAssert(writer, Collections.unmodifiableList(Arrays.asList(_normalBody, _headerLessBody, _bodyLessBody, _purelyEmptyBody)));
}
use of com.linkedin.multipart.MultiPartMIMEInputStream in project rest.li by linkedin.
the class TestMIMEIntegrationReaderWriter method testEachSingleBodyDataSource.
@Test(dataProvider = "eachSingleBodyDataSource", enabled = false)
public void testEachSingleBodyDataSource(final int chunkSize, final MIMEDataPart bodyPart) throws Exception {
final MultiPartMIMEInputStream inputStreamDataSource = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(bodyPart.getPartData().copyBytes()), scheduledExecutorService, bodyPart.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final MultiPartMIMEWriter writer = new MultiPartMIMEWriter.Builder("some preamble", "").appendDataSource(inputStreamDataSource).build();
executeRequestAndAssert(writer, Collections.unmodifiableList(Collections.singletonList(bodyPart)));
}
use of com.linkedin.multipart.MultiPartMIMEInputStream in project rest.li by linkedin.
the class MIMETestUtils method generateInputStreamDataSources.
// The chaining tests will use these:
public static List<MultiPartMIMEDataSourceWriter> generateInputStreamDataSources(final int chunkSize, final ExecutorService executorService) {
final MultiPartMIMEInputStream bodyADataSource = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(BODY_A.getPartData().copyBytes()), executorService, BODY_A.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final MultiPartMIMEInputStream bodyBDataSource = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(BODY_B.getPartData().copyBytes()), executorService, BODY_B.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final MultiPartMIMEInputStream bodyCDataSource = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(BODY_C.getPartData().copyBytes()), executorService, BODY_C.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final MultiPartMIMEInputStream bodyDDataSource = new MultiPartMIMEInputStream.Builder(new ByteArrayInputStream(BODY_D.getPartData().copyBytes()), executorService, BODY_D.getPartHeaders()).withWriteChunkSize(chunkSize).build();
final List<MultiPartMIMEDataSourceWriter> dataSources = new ArrayList<>();
dataSources.add(bodyADataSource);
dataSources.add(bodyBDataSource);
dataSources.add(bodyCDataSource);
dataSources.add(bodyDDataSource);
return dataSources;
}
Aggregations