001/* 002 * jDTAUS Core Test Suite 003 * Copyright (C) 2005 Christian Schulte 004 * <cs@schulte.it> 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License, or any later version. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 019 * 020 */ 021package org.jdtaus.core.lang.it; 022 023import junit.framework.Assert; 024import junit.framework.TestCase; 025import org.jdtaus.core.lang.ExceptionEventSource; 026 027/** 028 * Testcase for {@code ExceptionEventSource} implementations. 029 * 030 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 031 * @version $JDTAUS: ExceptionEventSourceTest.java 8743 2012-10-07 03:06:20Z schulte $ 032 */ 033public abstract class ExceptionEventSourceTest extends TestCase 034{ 035 //--ExceptionEventSourceTest------------------------------------------------ 036 037 /** Creates a new {@code ExceptionEventSourceTest} instance. */ 038 public ExceptionEventSourceTest() 039 { 040 super(); 041 } 042 043 /** 044 * Gets the {@code ExceptionEventSource} implementation tests are performed 045 * with. 046 * 047 * @return the {@code ExceptionEventSource} implementation tests are 048 * performed with. 049 */ 050 public abstract ExceptionEventSource getExceptionEventSource(); 051 052 //------------------------------------------------ExceptionEventSourceTest-- 053 //--Tests------------------------------------------------------------------- 054 055 /** 056 * Tests the 057 * {@link ExceptionEventSource#addExceptionListener(ExceptionListener)} and 058 * {@link ExceptionEventSource#removeExceptionListener(ExceptionListener)} 059 * methods to correctly handle {@code null} arguments by throwing a 060 * corresponding {@code NullPointerException}. 061 */ 062 public void testNullArguments() throws Exception 063 { 064 assert this.getExceptionEventSource() != null; 065 066 try 067 { 068 this.getExceptionEventSource().addExceptionListener( null ); 069 throw new AssertionError(); 070 } 071 catch ( final NullPointerException e ) 072 { 073 Assert.assertNotNull( e.getMessage() ); 074 System.out.println( e.toString() ); 075 } 076 077 try 078 { 079 this.getExceptionEventSource().removeExceptionListener( null ); 080 throw new AssertionError(); 081 } 082 catch ( final NullPointerException e ) 083 { 084 Assert.assertNotNull( e.getMessage() ); 085 System.out.println( e.toString() ); 086 } 087 088 } 089 090 //-------------------------------------------------------------------Tests-- 091}