EMMA Coverage Report (generated Wed Oct 03 04:37:30 CEST 2012)
[all classes][org.jdtaus.core.text.spi.it]

COVERAGE SUMMARY FOR SOURCE FILE [ApplicationLoggerTest.java]

nameclass, %method, %block, %line, %
ApplicationLoggerTest.java0%   (0/3)0%   (0/13)0%   (0/131)0%   (0/29)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ApplicationLoggerTest0%   (0/1)0%   (0/7)0%   (0/102)0%   (0/23)
<static initializer> 0%   (0/1)0%   (0/15)0%   (0/1)
ApplicationLoggerTest (): void 0%   (0/1)0%   (0/3)0%   (0/2)
getApplicationLogger (): ApplicationLogger 0%   (0/1)0%   (0/3)0%   (0/1)
getMessageEventSource (): MessageEventSource 0%   (0/1)0%   (0/3)0%   (0/1)
setApplicationLogger (ApplicationLogger): void 0%   (0/1)0%   (0/7)0%   (0/3)
testIllegalArguments (): void 0%   (0/1)0%   (0/26)0%   (0/7)
testLog (): void 0%   (0/1)0%   (0/45)0%   (0/9)
     
class ApplicationLoggerTest$10%   (0/1)0%   (0/3)0%   (0/19)0%   (0/3)
ApplicationLoggerTest$1 (ApplicationLoggerTest): void 0%   (0/1)0%   (0/6)0%   (0/1)
getFormatArguments (Locale): Object [] 0%   (0/1)0%   (0/3)0%   (0/1)
getText (Locale): String 0%   (0/1)0%   (0/10)0%   (0/1)
     
class ApplicationLoggerTest$TestMessageListener0%   (0/1)0%   (0/3)0%   (0/10)0%   (0/4)
ApplicationLoggerTest$TestMessageListener (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getLastEvent (): MessageEvent 0%   (0/1)0%   (0/3)0%   (0/1)
onMessage (MessageEvent): void 0%   (0/1)0%   (0/4)0%   (0/2)

1/*
2 *  jDTAUS Core Test Suite
3 *  Copyright (C) 2005 Christian Schulte
4 *  <cs@schulte.it>
5 *
6 *  This library is free software; you can redistribute it and/or
7 *  modify it under the terms of the GNU Lesser General Public
8 *  License as published by the Free Software Foundation; either
9 *  version 2.1 of the License, or any later version.
10 *
11 *  This library is distributed in the hope that it will be useful,
12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 *  Lesser General Public License for more details.
15 *
16 *  You should have received a copy of the GNU Lesser General Public
17 *  License along with this library; if not, write to the Free Software
18 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19 *
20 */
21package org.jdtaus.core.text.spi.it;
22 
23import java.util.Locale;
24import junit.framework.Assert;
25import org.jdtaus.core.text.Message;
26import org.jdtaus.core.text.MessageEvent;
27import org.jdtaus.core.text.MessageEventSource;
28import org.jdtaus.core.text.MessageListener;
29import org.jdtaus.core.text.it.MessageEventSourceTest;
30import org.jdtaus.core.text.spi.ApplicationLogger;
31 
32/**
33 * Testcase for {@code ApplicationLogger} implementations.
34 *
35 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
36 * @version $JDTAUS: ApplicationLoggerTest.java 8641 2012-09-27 06:45:17Z schulte $
37 */
38public class ApplicationLoggerTest extends MessageEventSourceTest
39{
40    //--MessageEventSourceTest--------------------------------------------------
41 
42    /**
43     * {@inheritDoc}
44     * @see #getApplicationLogger()
45     */
46    public final MessageEventSource getMessageEventSource()
47    {
48        return this.logger;
49    }
50 
51    //--------------------------------------------------MessageEventSourceTest--
52    //--ApplicationLoggerTest---------------------------------------------------
53 
54    /** Implementation to test. */
55    private ApplicationLogger logger;
56 
57    /**
58     * Gets the {@code ApplicationLogger} implementation tests are performed
59     * with.
60     *
61     * @return the {@code ApplicationLogger} implementation tests are performed
62     * with.
63     */
64    public ApplicationLogger getApplicationLogger()
65    {
66        return this.logger;
67    }
68 
69    /**
70     * Sets the {@code ApplicationLogger} implementation tests are performed
71     * with.
72     *
73     * @param value the {@code ApplicationLogger} implementation to perform
74     * tests with.
75     */
76    public final void setApplicationLogger( final ApplicationLogger value )
77    {
78        this.logger = value;
79        this.setMessageEventSource( value );
80    }
81 
82    /** {@code MessageListener} implementation tests are performed with. */
83    public static final class TestMessageListener implements MessageListener
84    {
85 
86        /** The last event provided to this listener. */
87        private MessageEvent lastEvent;
88 
89        /**
90         * Gets the last event provided to this listener.
91         *
92         * @return the last event provided to this listener.
93         */
94        public MessageEvent getLastEvent()
95        {
96            return this.lastEvent;
97        }
98 
99        public void onMessage( final MessageEvent messageEvent )
100        {
101            this.lastEvent = messageEvent;
102        }
103 
104    }
105 
106    //---------------------------------------------------ApplicationLoggerTest--
107    //--Tests-------------------------------------------------------------------
108 
109    /**
110     * Tests the {@link ApplicationLogger#log(MessageEvent)} method to handle
111     * illegal arguments correctly by throwing a corresponding
112     * {@code NullPointerException}.
113     */
114    public void testIllegalArguments() throws Exception
115    {
116        assert this.getApplicationLogger() != null;
117 
118        try
119        {
120            this.getApplicationLogger().log( null );
121            throw new AssertionError();
122        }
123        catch ( NullPointerException e )
124        {
125            Assert.assertNotNull( e.getMessage() );
126            System.out.println( e.toString() );
127        }
128 
129    }
130 
131    /**
132     * Tests the {@link ApplicationLogger#log(MessageEvent)} method to fire
133     * corresponding events.
134     */
135    public void testLog() throws Exception
136    {
137        assert this.getApplicationLogger() != null;
138 
139        final TestMessageListener listener = new TestMessageListener();
140        final Message message = new Message()
141        {
142 
143            public Object[] getFormatArguments( final Locale locale )
144            {
145                return new Object[ 0 ];
146            }
147 
148            public String getText( final Locale locale )
149            {
150                return ApplicationLoggerTest.class.getName();
151            }
152 
153        };
154 
155        this.getMessageEventSource().addMessageListener( listener );
156 
157        MessageEvent evt = new MessageEvent( this, message,
158                                             MessageEvent.INFORMATION );
159 
160        this.getApplicationLogger().log( evt );
161        Assert.assertNotNull( listener.getLastEvent() );
162        Assert.assertTrue( listener.getLastEvent() == evt );
163    }
164 
165    //-------------------------------------------------------------------Tests--
166}

[all classes][org.jdtaus.core.text.spi.it]
EMMA 2.1.5320 (stable) (C) Vladimir Roubtsov