1 /* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5 package org.mockitousage.bugs; 6 7 import static org.junit.Assert.fail; 8 import static org.mockito.Mockito.when; 9 10 import org.junit.Test; 11 import org.mockito.Mock; 12 import org.mockitousage.IMethods; 13 import org.mockitoutil.TestBase; 14 15 public class NPEWhenMockingThrowablesTest extends TestBase { 16 17 @Mock IMethods mock; 18 @Mock DummyException mock2; 19 20 class DummyException extends RuntimeException { 21 private static final long serialVersionUID = 1L; 22 } 23 24 // issue 70 25 @Test shouldNotThrowNPE()26 public void shouldNotThrowNPE() { 27 when(mock.simpleMethod()).thenThrow(mock2); 28 try { 29 mock.simpleMethod(); 30 fail(); 31 } catch (DummyException e) { 32 } 33 } 34 } 35