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.event;
016    
017    import org.apache.tapestry.BaseComponentTestCase;
018    import org.apache.tapestry.describe.DescriptionReceiver;
019    import org.testng.annotations.Test;
020    
021    /**
022     * Tests for {@link org.apache.tapestry.event.ReportStatusEvent}.
023     * 
024     * @author Howard M. Lewis Ship
025     * @since 4.0
026     */
027    @Test
028    public class ReportStatusEventTest extends BaseComponentTestCase
029    {
030        protected DescriptionReceiver newReceiver()
031        {
032            return newMock(DescriptionReceiver.class);
033        }
034    
035        public void testConstructor()
036        {
037            DescriptionReceiver receiver = newReceiver();
038    
039            replay();
040    
041            ReportStatusEvent event = new ReportStatusEvent(this, receiver);
042    
043            assertSame(this, event.getSource());
044    
045            verify();
046        }
047    
048        public void testDelegation()
049        {
050            Object[] values = new Object[]
051            { 1, 2, 3 };
052            Object alternate = new Object();
053    
054            DescriptionReceiver receiver = newReceiver();
055    
056            receiver.array("array", values);
057            receiver.describeAlternate(alternate);
058            receiver.property("boolean-true", true);
059            receiver.property("boolean-false", false);
060            receiver.property("byte", (byte) 37);
061            receiver.property("char", 'z');
062            receiver.property("double", 3.14);
063            receiver.property("float", (float) 9.99);
064            receiver.property("int", -373);
065            receiver.property("long", 373737l);
066            receiver.property("object", this);
067            receiver.property("short", (short) 99);
068            receiver.section("Section");
069            receiver.title("Title");
070    
071            replay();
072    
073            ReportStatusEvent event = new ReportStatusEvent(this, receiver);
074    
075            event.array("array", values);
076            event.describeAlternate(alternate);
077            event.property("boolean-true", true);
078            event.property("boolean-false", false);
079            event.property("byte", (byte) 37);
080            event.property("char", 'z');
081            event.property("double", 3.14);
082            event.property("float", (float) 9.99);
083            event.property("int", -373);
084            event.property("long", 373737l);
085            event.property("object", this);
086            event.property("short", (short) 99);
087            event.section("Section");
088            event.title("Title");
089    
090            verify();
091    
092        }
093    }