1 // SECTION-START[License Header] 2 // <editor-fold defaultstate="collapsed" desc=" Generated License "> 3 /* 4 * Java Object Management and Configuration 5 * Copyright (C) Christian Schulte, 2005-206 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 12 * o Redistributions of source code must retain the above copyright 13 * notice, this list of conditions and the following disclaimer. 14 * 15 * o Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in 17 * the documentation and/or other materials provided with the 18 * distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 21 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 22 * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL 23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 * 31 * $JOMC: ListenerTest.java 4588 2012-06-03 06:01:30Z schulte2005 $ 32 * 33 */ 34 // </editor-fold> 35 // SECTION-END 36 package org.jomc.ri.test; 37 38 import java.util.logging.Level; 39 import org.jomc.ri.DefaultListener; 40 import org.jomc.spi.Listener; 41 import org.junit.Test; 42 import static org.junit.Assert.assertNotNull; 43 import static org.junit.Assert.fail; 44 45 // SECTION-START[Documentation] 46 // <editor-fold defaultstate="collapsed" desc=" Generated Documentation "> 47 /** 48 * {@code Listener} test cases. 49 * 50 * <dl> 51 * <dt><b>Identifier:</b></dt><dd>JOMC :: RI :: Tests :: Listener Test</dd> 52 * <dt><b>Name:</b></dt><dd>JOMC :: RI :: Tests :: Listener Test</dd> 53 * <dt><b>Abstract:</b></dt><dd>No</dd> 54 * <dt><b>Final:</b></dt><dd>No</dd> 55 * <dt><b>Stateless:</b></dt><dd>No</dd> 56 * </dl> 57 * 58 * @author <a href="mailto:schulte2005@users.sourceforge.net">Christian Schulte</a> 1.0 59 * @version 1.3 60 */ 61 // </editor-fold> 62 // SECTION-END 63 // SECTION-START[Annotations] 64 // <editor-fold defaultstate="collapsed" desc=" Generated Annotations "> 65 @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" ) 66 // </editor-fold> 67 // SECTION-END 68 public class ListenerTest 69 { 70 // SECTION-START[ListenerTest] 71 72 /** The {@code Listener} instance tests are performed with. */ 73 private Listener listener; 74 75 /** 76 * Gets the {@code Listener} instance tests are performed with. 77 * 78 * @return The {@code Listener} instance tests are performed with. 79 * 80 * @see #newListener() 81 */ 82 public Listener getListener() 83 { 84 if ( this.listener == null ) 85 { 86 this.listener = this.newListener(); 87 } 88 89 return this.listener; 90 } 91 92 /** 93 * Creates a new {@code Listener} instance to test. 94 * 95 * @return A new {@code Listener} instance to test. 96 * 97 * @see #getListener() 98 */ 99 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.3", comments = "See http://jomc.sourceforge.net/jomc/1.3/jomc-tools-1.3" ) 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 }