001    // SECTION-START[License Header]
002    // <editor-fold defaultstate="collapsed" desc=" Generated License ">
003    /*
004     *   Java Object Management and Configuration
005     *   Copyright (C) Christian Schulte, 2005-206
006     *   All rights reserved.
007     *
008     *   Redistribution and use in source and binary forms, with or without
009     *   modification, are permitted provided that the following conditions
010     *   are met:
011     *
012     *     o Redistributions of source code must retain the above copyright
013     *       notice, this list of conditions and the following disclaimer.
014     *
015     *     o Redistributions in binary form must reproduce the above copyright
016     *       notice, this list of conditions and the following disclaimer in
017     *       the documentation and/or other materials provided with the
018     *       distribution.
019     *
020     *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
021     *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
022     *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
023     *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
024     *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
025     *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
026     *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
027     *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
028     *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
029     *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
030     *
031     *   $JOMC: ListenerTest.java 4459 2012-03-27 23:55:31Z schulte2005 $
032     *
033     */
034    // </editor-fold>
035    // SECTION-END
036    package org.jomc.ri.test;
037    
038    import java.util.logging.Level;
039    import org.jomc.ri.DefaultListener;
040    import org.jomc.spi.Listener;
041    import org.junit.Test;
042    import static org.junit.Assert.assertNotNull;
043    import static org.junit.Assert.fail;
044    
045    // SECTION-START[Documentation]
046    // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
047    /**
048     * {@code Listener} test cases.
049     *
050     * <dl>
051     *   <dt><b>Identifier:</b></dt><dd>JOMC :: RI :: Tests :: Listener Test</dd>
052     *   <dt><b>Name:</b></dt><dd>JOMC :: RI :: Tests :: Listener Test</dd>
053     *   <dt><b>Abstract:</b></dt><dd>No</dd>
054     *   <dt><b>Final:</b></dt><dd>No</dd>
055     *   <dt><b>Stateless:</b></dt><dd>No</dd>
056     * </dl>
057     *
058     * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0
059     * @version 1.2.2
060     */
061    // </editor-fold>
062    // SECTION-END
063    // SECTION-START[Annotations]
064    // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
065    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
066    // </editor-fold>
067    // SECTION-END
068    public class ListenerTest
069    {
070        // SECTION-START[ListenerTest]
071    
072        /** The {@code Listener} instance tests are performed with. */
073        private Listener listener;
074    
075        /**
076         * Gets the {@code Listener} instance tests are performed with.
077         *
078         * @return The {@code Listener} instance tests are performed with.
079         *
080         * @see #newListener()
081         */
082        public Listener getListener()
083        {
084            if ( this.listener == null )
085            {
086                this.listener = this.newListener();
087            }
088    
089            return this.listener;
090        }
091    
092        /**
093         * Creates a new {@code Listener} instance to test.
094         *
095         * @return A new {@code Listener} instance to test.
096         *
097         * @see #getListener()
098         */
099        protected Listener newListener()
100        {
101            return new DefaultListener();
102        }
103    
104        @Test
105        public final void testLog() throws Exception
106        {
107            try
108            {
109                this.getListener().onLog( null, null, null );
110                fail( "Expected NullPointerException not thrown." );
111            }
112            catch ( final NullPointerException e )
113            {
114                assertNotNull( e.getMessage() );
115                System.out.println( e );
116            }
117    
118            this.getListener().onLog( Level.INFO, "TEST", new Exception() );
119        }
120    
121        // SECTION-END
122        // SECTION-START[Constructors]
123        // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
124        /** Creates a new {@code ListenerTest} instance. */
125        @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.2.2", comments = "See http://jomc.sourceforge.net/jomc/1.2/jomc-tools-1.2.2" )
126        public ListenerTest()
127        {
128            // SECTION-START[Default Constructor]
129            super();
130            // SECTION-END
131        }
132        // </editor-fold>
133        // SECTION-END
134        // SECTION-START[Dependencies]
135        // SECTION-END
136        // SECTION-START[Properties]
137        // SECTION-END
138        // SECTION-START[Messages]
139        // SECTION-END
140    }