001    // Copyright 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.util;
016    
017    import org.apache.hivemind.Resource;
018    import org.apache.tapestry.BaseComponentTestCase;
019    import org.testng.annotations.Test;
020    
021    /**
022     * Tests for {@link org.apache.tapestry.util.DescribedLocation}.
023     * 
024     * @author Howard Lewis Ship
025     * @since 4.0
026     */
027    @Test
028    public class TestDescribedLocation extends BaseComponentTestCase
029    {
030        public void testLineRowAreZero()
031        {
032            Resource r = newMock(Resource.class);
033    
034            replay();
035    
036            DescribedLocation l = new DescribedLocation(r, "location description");
037    
038            assertEquals(0, l.getLineNumber());
039            assertEquals(0, l.getColumnNumber());
040    
041            assertSame(r, l.getResource());
042    
043            assertEquals("location description", l.toString());
044    
045            verify();
046        }
047    
048        public void testEquals()
049        {
050            Resource r = newMock(Resource.class);
051            Resource r2 = newMock(Resource.class);
052    
053            replay();
054    
055            DescribedLocation l = new DescribedLocation(r, "location description");
056            DescribedLocation l2 = new DescribedLocation(r2, "location description");
057            DescribedLocation l3 = new DescribedLocation(r, "wrong description");
058            DescribedLocation l4 = new DescribedLocation(r, "location description");
059    
060            assertEquals(false, l.equals(null));
061            assertEquals(false, l.equals("XYZ"));
062            assertEquals(false, l.equals(l2));
063            assertEquals(false, l.equals(l3));
064            assertEquals(true, l.equals(l4));
065    
066            verify();
067        }
068    }