001    // Copyright 2007 by Basil Vandegriend.  All rights reserved.
002    
003    package com.basilv.examples.errorhandling;
004    
005    import static org.junit.Assert.*;
006    import org.junit.Test;
007    
008    public class ExceptionInFinallyBlockTest 
009    {  
010      private void haveExceptionInFinallyBlock() {
011        try {
012          if (true) throw new IllegalArgumentException();
013        } finally {
014          if (true) throw new NullPointerException();
015        }
016      }
017      
018      @Test
019      public void testHaveExceptionInFinallyBlock() {
020        try {
021          haveExceptionInFinallyBlock();
022          fail("Expect exception");
023        } catch (NullPointerException e) {
024          // Expected case.
025        }
026      }
027    
028    }