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 8692 2012-10-01 14:16:57Z schulte $ 032 */ 033public abstract class ExceptionEventSourceTest extends TestCase 034{ 035 //--ExceptionEventSourceTest------------------------------------------------ 036 037 /** 038 * Gets the {@code ExceptionEventSource} implementation tests are performed 039 * with. 040 * 041 * @return the {@code ExceptionEventSource} implementation tests are 042 * performed with. 043 */ 044 public abstract ExceptionEventSource getExceptionEventSource(); 045 046 //------------------------------------------------ExceptionEventSourceTest-- 047 //--Tests------------------------------------------------------------------- 048 049 /** 050 * Tests the 051 * {@link ExceptionEventSource#addExceptionListener(ExceptionListener)} and 052 * {@link ExceptionEventSource#removeExceptionListener(ExceptionListener)} 053 * methods to correctly handle {@code null} arguments by throwing a 054 * corresponding {@code NullPointerException}. 055 */ 056 public void testNullArguments() throws Exception 057 { 058 assert this.getExceptionEventSource() != null; 059 060 try 061 { 062 this.getExceptionEventSource().addExceptionListener( null ); 063 throw new AssertionError(); 064 } 065 catch ( NullPointerException e ) 066 { 067 Assert.assertNotNull( e.getMessage() ); 068 System.out.println( e.toString() ); 069 } 070 071 try 072 { 073 this.getExceptionEventSource().removeExceptionListener( null ); 074 throw new AssertionError(); 075 } 076 catch ( NullPointerException e ) 077 { 078 Assert.assertNotNull( e.getMessage() ); 079 System.out.println( e.toString() ); 080 } 081 082 } 083 084 //-------------------------------------------------------------------Tests-- 085}