Package org.apache.tapestry.upload.services

Examples of org.apache.tapestry.upload.services.MultipartDecoderImpl


{

    @Test
    public void createFileUploadGetsConfigurationFromSymbols() throws Exception
    {
        MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, 7777, 6666);

        replay();

        ServletFileUpload servletFileUpload = decoder.createFileUpload();
        assertNotNull(servletFileUpload);
        verify();

        assertEquals(servletFileUpload.getFileSizeMax(), 6666);
        assertEquals(servletFileUpload.getSizeMax(), 7777);
View Full Code Here


    @Test
    public void processFileItemsDoesNothingWhenNullFileItems() throws Exception
    {
        HttpServletRequest request = mockHttpServletRequest();
        MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, -1, -1);

        replay();
        HttpServletRequest decodedRequest = decoder.processFileItems(request, null);
        verify();

        assertSame(request, decodedRequest);
    }
View Full Code Here

    @Test
    public void processFileItemsDoesNothingWhenEmptyFileItems() throws Exception
    {
        HttpServletRequest request = mockHttpServletRequest();
        MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, -1, -1);
        List<FileItem> fileItems = Collections.emptyList();
        replay();

        HttpServletRequest decodedRequest = decoder.processFileItems(request, fileItems);
        verify();

        assertSame(request, decodedRequest);
    }
View Full Code Here

    @Test
    public void processFileItemsCreatesWrappedRequestAndSetsNonFileParameters() throws Exception
    {
        HttpServletRequest request = mockHttpServletRequest();
        MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, -1, -1);
        List<FileItem> fileItems = Arrays.asList(createValueItem("one", "first"), createValueItem(
                "two",
                "second"));
        replay();

        HttpServletRequest decodedRequest = decoder.processFileItems(request, fileItems);

        assertNotSame(decodedRequest, request);

        assertEquals(decodedRequest.getParameter("one"), "first");
        assertEquals(decodedRequest.getParameter("two"), "second");
View Full Code Here

    @Test
    public void processFileItemsSetsFileParametersWithFileName() throws Exception
    {
        HttpServletRequest request = mockHttpServletRequest();
        MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, -1, -1);
        List<FileItem> fileItems = Arrays.asList(
                createFileItem("one", "first.txt"),
                createFileItem("two", "second.txt"));
        replay();

        HttpServletRequest decodedRequest = decoder.processFileItems(request, fileItems);

        assertNotSame(decodedRequest, request);

        assertEquals(decodedRequest.getParameter("one"), "first.txt");
        assertEquals(decodedRequest.getParameter("two"), "second.txt");
View Full Code Here

    @Test
    public void processFileItemsStoresUploadedFile() throws Exception
    {
        HttpServletRequest request = mockHttpServletRequest();
        MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, -1, -1);
        List<FileItem> fileItems = Arrays.asList(
                createFileItem("one", "first.txt"),
                createFileItem("two", "second.txt"));
        replay();

        decoder.processFileItems(request, fileItems);

        verify();
        assertNotNull(decoder.getFileUpload("one"));
        assertEquals(decoder.getFileUpload("one").getFileName(), "first.txt");
        assertNotNull(decoder.getFileUpload("two"));
        assertEquals(decoder.getFileUpload("two").getFileName(), "second.txt");
    }
View Full Code Here

    @Test
    public void threadDidCleanupDeletesAllFileItems() throws Exception
    {
        HttpServletRequest request = mockHttpServletRequest();
        MultipartDecoderImpl decoder = new MultipartDecoderImpl("/tmp", 888, -1, -1);
        StubFileItem firstItem = new StubFileItem("one");
        firstItem.setFormField(false);
        StubFileItem secondItem = new StubFileItem("two");
        secondItem.setFormField(false);

        List<FileItem> fileItems = new ArrayList<FileItem>();
        fileItems.add(firstItem);
        fileItems.add(secondItem);
        replay();

        decoder.processFileItems(request, fileItems);

        assertFalse(firstItem.isDeleted());
        assertFalse(secondItem.isDeleted());
        decoder.threadDidCleanup();
        assertTrue(firstItem.isDeleted());
        assertTrue(secondItem.isDeleted());

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.upload.services.MultipartDecoderImpl

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.