Package org.glassfish.jersey.media.multipart

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


        String expectedFilename = "bar.txt";

        cut.setName(name);
        cut.setFilename(expectedFilename);

        ContentDisposition actual = cut.buildContentDisposition();

        assertEquals(expectedType, actual.getType());
        assertEquals(expectedFilename, actual.getFileName());
    }
View Full Code Here


        String expectedType = "form-data";
        String expectedFilename = "foo";

        cut.setName(name);

        ContentDisposition actual = cut.buildContentDisposition();

        assertEquals(expectedType, actual.getType());
        assertEquals(expectedFilename, actual.getFileName());
    }
View Full Code Here

    }

    @Test
    public void testToString() {
        final Date date = new Date();
        final ContentDisposition contentDisposition = ContentDisposition.type(contentDispositionType).fileName("test.file")
                .creationDate(date).modificationDate(date).readDate(date).size(1222).build();
        final String dateString = HttpDateFormat.getPreferredDateFormat().format(date);
        final String header = contentDispositionType + "; filename=\"test.file\"; creation-date=\""
                + dateString + "\"; modification-date=\"" + dateString + "\"; read-date=\"" + dateString + "\"; size=1222";
        assertEquals(header, contentDisposition.toString());
    }
View Full Code Here

        contentDispositionType = "inline";
    }

    @Test
    public void testCreate() {
        ContentDisposition contentDisposition = ContentDisposition.type(null).build();

        assertNotNull(contentDisposition);
        assertEquals(null, contentDisposition.getType());

        contentDisposition = ContentDisposition.type(contentDispositionType).build();

        assertNotNull(contentDisposition);
        assertEquals(contentDispositionType, contentDisposition.getType());

        final Date date = new Date();
        contentDisposition = ContentDisposition.type(contentDispositionType).fileName("test.file")
                .creationDate(date).modificationDate(date).readDate(date).size(1222).build();

        assertContentDisposition(contentDisposition, date);
        String header = contentDispositionType;

        try {
            contentDisposition = new ContentDisposition(contentDisposition.toString());
            assertNotNull(contentDisposition);
            contentDisposition = new ContentDisposition(header);
            assertNotNull(contentDisposition);
            assertEquals(contentDispositionType, contentDisposition.getType());
            final String dateString = HttpDateFormat.getPreferredDateFormat().format(date);
            header = contentDispositionType + ";filename=\"test.file\";creation-date=\""
                    + dateString + "\";modification-date=\"" + dateString + "\";read-date=\""
                    + dateString + "\";size=1222";

            contentDisposition = new ContentDisposition(header);
            assertContentDisposition(contentDisposition, date);
            contentDisposition = new ContentDisposition(HttpHeaderReader.newInstance(header), true);
            assertContentDisposition(contentDisposition, date);
        }
        catch (final ParseException ex) {
            fail(ex.getMessage());
        }
        try {
            new ContentDisposition((HttpHeaderReader) null, true);
            fail("NullPointerException was expected to be thrown.");
        }
        catch (final ParseException exception) {
            fail(exception.getMessage());
        }
View Full Code Here

                }
                if (client2Server) {
                    bp = new FormDataBodyPart(part.getName(), part, mt);
                } else {
                    bp = new BodyPart(part, mt);
                    ContentDisposition cd = ContentDisposition.type("file").fileName(part.getName()).build();
                    if (logger.isLoggable(Level.FINEST)) {
                        logger.log(Level.FINEST, "addToMultipart[{0}]: Content Disposition: {1}", new Object[]{index, cd});
                    }
                    bp.setContentDisposition(cd);
                }
View Full Code Here

            List<BodyPart> bodyParts = mp.getBodyParts();
            int index = 0;
            for (BodyPart bodyPart : bodyParts) {
                index++;
                String name = "noname";
                ContentDisposition cd = bodyPart.getContentDisposition();
                if (cd != null) {
                    if (cd.getFileName() != null) {
                        name = cd.getFileName();
                    }
                }
                if (logger.isLoggable(Level.FINER)) {
                    logger.log(Level.FINER, "--------- BODY PART [{0}] ---------", index);
                    MultivaluedMap<String, String> headers = bodyPart.getHeaders();
View Full Code Here

TOP

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

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.