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.asset;
016    
017    import org.apache.hivemind.Location;
018    import org.apache.tapestry.BaseComponentTestCase;
019    import org.testng.annotations.Test;
020    
021    /**
022     * Tests for {@link org.apache.tapestry.asset.DefaultAssetFactory}.
023     * 
024     * @author Howard M. Lewis Ship
025     * @since 4.0
026     */
027    @Test
028    public class TestDefaultAssetFactory extends BaseComponentTestCase
029    {
030        public void testCreateAssetFull()
031        {
032            Location l = newLocation();
033            replay();
034    
035            AssetFactory factory = new DefaultAssetFactory();
036    
037            ExternalAsset asset = (ExternalAsset) factory.createAsset(null, null, "/foo/bar/baz", null, l);
038    
039            assertEquals("ExternalAsset[/foo/bar/baz]", asset.toString());
040            assertSame(l, asset.getLocation());
041            
042            verify();
043        }
044    
045        public void testCreateAssetFromResource()
046        {
047            Location l = newLocation();
048    
049            replay();
050    
051            AssetFactory factory = new DefaultAssetFactory();
052    
053            ExternalAsset asset = (ExternalAsset) factory.createAsset(null, null, "/foo/bar/baz", null, l);
054    
055            assertEquals("ExternalAsset[/foo/bar/baz]", asset.toString());
056            assertSame(l, asset.getLocation());
057            
058            verify();
059    
060        }
061    }