use of org.apache.cxf.jaxrs.ext.multipart.AttachmentBuilder in project jersey by jersey.
the class Jersey2776ITCase method testThatMultipartServerSupportsBoundaryQuotesEvenWithInterferingRuntimeDelegate.
@Test
public void testThatMultipartServerSupportsBoundaryQuotesEvenWithInterferingRuntimeDelegate() {
final JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress(getBaseUri().toString());
bean.setServiceClass(ApacheCxfMultipartClient.class);
final ApacheCxfMultipartClient cxfClient = bean.create(ApacheCxfMultipartClient.class);
final String originalContent = "abc";
final byte[] content = originalContent.getBytes(StandardCharsets.US_ASCII);
final Attachment fileAttachment = new AttachmentBuilder().object(content).contentDisposition(new ContentDisposition("form-data; filename=\"abc-file\"; name=\"file_path\"")).build();
final String fileContentReturnedFromServer = cxfClient.uploadDocument(new MultipartBody(fileAttachment));
assertThat(fileContentReturnedFromServer, equalTo(originalContent));
}
Aggregations