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.html;
016    
017    import org.apache.tapestry.BaseComponentTestCase;
018    import org.apache.tapestry.IMarkupWriter;
019    import org.apache.tapestry.IRequestCycle;
020    import org.apache.tapestry.describe.HTMLDescriber;
021    import org.testng.annotations.Test;
022    
023    /**
024     * Tests for {@link org.apache.tapestry.html.Describe}.
025     * 
026     * @author Howard M. Lewis Ship
027     */
028    @Test
029    public class DescribeTest extends BaseComponentTestCase
030    {
031        public void testRewinding()
032        {
033            IMarkupWriter writer = newWriter();
034            IRequestCycle cycle = newCycle(true, false);
035    
036            replay();
037    
038            Describe component = (Describe) newInstance(Describe.class);
039    
040            component.renderComponent(writer, cycle);
041    
042            verify();
043        }
044    
045        public void testRender()
046        {
047            IMarkupWriter writer = newWriter();
048            IRequestCycle cycle = newCycle(false, false);
049            
050            Object object = new Object();
051            
052            HTMLDescriber describer = newMock(HTMLDescriber.class);
053    
054            describer.describeObject(object, writer);
055    
056            replay();
057    
058            Describe component = newInstance(Describe.class, new Object[]
059            { "object", object, "describer", describer });
060    
061            component.renderComponent(writer, cycle);
062    
063            verify();
064        }
065    }