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.engine.ILink;
018    import org.apache.tapestry.link.StaticLink;
019    import org.testng.annotations.Test;
020    
021    /**
022     * Tests for {@link org.apache.tapestry.link.StaticLink}.
023     * 
024     * @author Howard Lewis Ship
025     * @since 3.0
026     */
027    @Test
028    public class TestStaticLink extends TapestryTestCase
029    {
030        private static final String URL = "http://host/path";
031    
032        ILink l = new StaticLink(URL);
033    
034        public void testURL()
035        {
036            assertEquals(URL, l.getURL());
037        }
038    
039        public void testAbsoluteURL()
040        {
041            assertEquals(URL, l.getAbsoluteURL());
042        }
043    
044        public void testURLWithAnchor()
045        {
046            assertEquals(URL, l.getURL(null, false));
047            assertEquals(URL + "#anchor", l.getURL("anchor", false));
048            assertEquals(URL + "#feeble", l.getURL("feeble", true));
049        }
050    
051        public void testAbsoluteURLWithParameters()
052        {
053            assertEquals(URL + "#anchor", l.getAbsoluteURL("scheme", "server", 8080, "anchor", false));
054        }
055    
056        public void testGetParameterNames()
057        {
058            assertNull(l.getParameterNames());
059        }
060    
061        public void testGetParameterValues()
062        {
063            try
064            {
065                l.getParameterValues("any");
066    
067                unreachable();
068            }
069            catch (IllegalArgumentException ex)
070            {
071            }
072        }
073    }