Package org.glassfish.jersey.media.multipart

Examples of org.glassfish.jersey.media.multipart.MultiPart


     */
    @Test
    public void testThirteen() {
        final WebTarget target = target().path("multipart/thirteen");

        MultiPart entity = new MultiPart().
                bodyPart("CONTENT", MediaType.TEXT_PLAIN_TYPE);
        String response = target.request("multipart/mixed").put(Entity.entity(entity, "multipart/mixed"), String.class);
        assertEquals("cleanup", response);
    }
View Full Code Here


        }
        String expected = sb.toString();

        final WebTarget target = target().path("multipart/eleven");

        MultiPart entity = new MultiPart().bodyPart(expected, MediaType.TEXT_PLAIN_TYPE);
        MultiPart response = target.request("multipart/mixed").put(Entity.entity(entity, "multipart/mixed"), MultiPart.class);
        String actual = response.getBodyParts().get(0).getEntityAs(String.class);
        assertEquals("Length for multiplier " + multiplier, expected.length(), actual.length());
        assertEquals("Content for multiplier " + multiplier, expected, actual);
        response.cleanup();
    }
View Full Code Here

    @Path("one")
    @GET
    @Produces("multipart/mixed")
    public Response one() {
        MultiPart entity = new MultiPart();
        // Exercise manually adding part(s) to the bodyParts property
        BodyPart part = new BodyPart("This is the only segment", new MediaType("text", "plain"));
        entity.getBodyParts().add(part);
        return Response.ok(entity).type("multipart/mixed").build();
    }
View Full Code Here

    @Path("two")
    @GET
    @Produces("multipart/mixed")
    public Response two() {
        // Exercise builder pattern with default content type
        return Response.ok(new MultiPart().
                             bodyPart("This is the first segment", new MediaType("text", "plain")).
                             bodyPart("<outer><inner>value</inner></outer>", new MediaType("text", "xml"))).build();
    }
View Full Code Here

    @GET
    @Produces("multipart/mixed")
    public Response three() {
        // Exercise builder pattern with explicit content type
        MultiPartBean bean = new MultiPartBean("myname", "myvalue");
        return Response.ok(new MultiPart().
                             type(new MediaType("multipart", "mixed")).
                             bodyPart("This is the first segment", new MediaType("text", "plain")).
                             bodyPart(bean, new MediaType("x-application", "x-format"))).build();
    }
View Full Code Here

            if (n < 0) {
                break;
            }
            sb.append(buffer, 0, n);
        }
        return Response.ok(new MultiPart().bodyPart(sb.toString(), MediaType.TEXT_PLAIN_TYPE)).
                type(new MediaType("multipart", "mixed")).build();
    }
View Full Code Here

    @GET
    @Path("etag")
    @Produces("multipart/mixed")
    public Response etag() {
        MultiPart entity = new MultiPart();
        // Exercise manually adding part(s) to the bodyParts property
        BodyPart part = new BodyPart("This is the only segment", new MediaType("text", "plain"));
        part.getHeaders().add("ETag", "\"value\"");
        entity.getBodyParts().add(part);
        return Response.ok(entity).type("multipart/mixed").build();
    }
View Full Code Here

        final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(baseUri, resourceConfig);

        Client c = ClientBuilder.newClient(new ClientConfig().register(MultiPartFeature.class));
        final Response response = c.target(baseUri).path("/multipart-simple").request().buildGet().invoke();

        MultiPart result = response.readEntity(MultiPart.class);
        System.out.println("RESULT = " + result);

        checkEntity("This is the only segment", (BodyPartEntity) result.getBodyParts().get(0).getEntity());

        server.shutdownNow();
    }
View Full Code Here

    public static class MultiPartResource {

        @GET
        @Produces("multipart/mixed")
        public Response one() {
            MultiPart entity = new MultiPart();
            BodyPart part = new BodyPart("This is the only segment", new MediaType("text", "plain"));
            entity.getBodyParts().add(part);
            return Response.ok(entity).type("multipart/mixed").build();
        }
View Full Code Here

        //                logger.log(Level.FINER, "-------- RAW DATA --------");
        //                logger.log(Level.FINER, data);
        //                logger.log(Level.FINER, "------ END RAW DATA ------");
        //            }
                } else if (MEDIATYPE_MULTIPART.isCompatible(resultMediaType)) {
                    MultiPart mp = response.readEntity(MultiPart.class);
                    Inbound inbound = new RestPayloadImpl.Inbound();
                    setActionReport(RestPayloadImpl.Inbound.fillFromMultipart(mp, inbound, logger));
                    if (logger.isLoggable(Level.FINER)) {
                        logger.log(Level.FINER, "------ PAYLOAD ------");
                        Iterator<Part> parts = inbound.parts();
View Full Code Here

TOP

Related Classes of org.glassfish.jersey.media.multipart.MultiPart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.