Search in sources :

Example 1 with AttachmentBuilder

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));
}
Also used : JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) AttachmentBuilder(org.apache.cxf.jaxrs.ext.multipart.AttachmentBuilder) ContentDisposition(org.apache.cxf.jaxrs.ext.multipart.ContentDisposition) MultipartBody(org.apache.cxf.jaxrs.ext.multipart.MultipartBody) Attachment(org.apache.cxf.jaxrs.ext.multipart.Attachment) Test(org.junit.Test) JerseyTest(org.glassfish.jersey.test.JerseyTest)

Aggregations

JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)1 Attachment (org.apache.cxf.jaxrs.ext.multipart.Attachment)1 AttachmentBuilder (org.apache.cxf.jaxrs.ext.multipart.AttachmentBuilder)1 ContentDisposition (org.apache.cxf.jaxrs.ext.multipart.ContentDisposition)1 MultipartBody (org.apache.cxf.jaxrs.ext.multipart.MultipartBody)1 JerseyTest (org.glassfish.jersey.test.JerseyTest)1 Test (org.junit.Test)1