001    // Copyright 2004, 2005 The Apache Software Foundation
002    //
003    // Licensed under the Apache License, Version 2.0 (the "License");
004    // you may not use this file except in compliance with the License.
005    // You may obtain a copy of the License at
006    //
007    //     http://www.apache.org/licenses/LICENSE-2.0
008    //
009    // Unless required by applicable law or agreed to in writing, software
010    // distributed under the License is distributed on an "AS IS" BASIS,
011    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012    // See the License for the specific language governing permissions and
013    // limitations under the License.
014    package org.apache.tapestry.multipart;
015    
016    import org.apache.commons.fileupload.FileItem;
017    import org.apache.tapestry.TestBase;
018    import static org.easymock.EasyMock.expect;
019    import org.testng.annotations.Test;
020    
021    /**
022     *  Tests functionality of {@link UploadPart}.
023     */
024    @Test
025    public class TestUploadPart extends TestBase {
026    
027        public void test_Windows_File_Name()
028        {
029            FileItem item = newMock(FileItem.class);
030            
031            expect(item.getName()).andReturn("C:\\\\documents\\things\\image.png");
032            
033            replay();
034            
035            UploadPart part = new UploadPart(item);
036            assertEquals(part.getFileName(), "image.png");
037            
038            verify();
039        }
040        
041        public void test_Windows_File_Path()
042        {
043            FileItem item = newMock(FileItem.class);
044            
045            expect(item.getName()).andReturn("C:\\\\documents\\things\\image.png");
046            
047            replay();
048            
049            UploadPart part = new UploadPart(item);
050            assertEquals(part.getFilePath(), "C:\\\\documents\\things\\image.png");
051            
052            verify();
053        }
054    }