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    
015    package org.apache.tapestry.junit;
016    
017    import org.apache.tapestry.multipart.ValuePart;
018    import org.testng.annotations.Test;
019    
020    /**
021     * A few tests to fill in the code coverage of {@link org.apache.tapestry.multipart.ValuePart}and
022     * {@link org.apache.tapestry.multipart.UploadPart}.
023     * 
024     * @author Howard Lewis Ship
025     * @since 3.0
026     */
027    @Test
028    public class TestMultipart extends TapestryTestCase
029    {
030    
031        public void testSingle()
032        {
033            ValuePart p = new ValuePart("first");
034    
035            assertEquals(1, p.getCount());
036            assertEquals("first", p.getValue());
037    
038            checkList("values", new String[]
039            { "first" }, p.getValues());
040        }
041    
042        public void testTwo()
043        {
044            ValuePart p = new ValuePart("alpha");
045    
046            p.add("beta");
047    
048            assertEquals(2, p.getCount());
049            assertEquals("alpha", p.getValue());
050            checkList("values", new String[]
051            { "alpha", "beta" }, p.getValues());
052        }
053    
054        public void testThree()
055        {
056            ValuePart p = new ValuePart("moe");
057            p.add("larry");
058            p.add("curly");
059    
060            checkList("values", new String[]
061            { "moe", "larry", "curly" }, p.getValues());
062        }
063    }