1/* 2 * Copyright (c) 2007 Mockito contributors 3 * This program is made available under the terms of the MIT License. 4 */ 5package org.mockitousage.internal.debugging; 6 7import static org.assertj.core.api.Assertions.assertThat; 8 9import org.junit.Test; 10import org.mockito.internal.debugging.LocationImpl; 11import org.mockito.internal.exceptions.stacktrace.StackTraceFilter; 12import org.mockitoutil.TestBase; 13 14import static junit.framework.TestCase.assertEquals; 15 16@SuppressWarnings("serial") 17public class LocationImplTest extends TestBase { 18 19 @Test 20 public void shouldLocationNotContainGetStackTraceMethod() { 21 assertThat(new LocationImpl().toString()).contains("shouldLocationNotContainGetStackTraceMethod"); 22 } 23 24 @Test 25 public void shouldBeSafeInCaseForSomeReasonFilteredStackTraceIsEmpty() { 26 //given 27 StackTraceFilter filterReturningEmptyArray = new StackTraceFilter() { 28 @Override 29 public StackTraceElement[] filter(StackTraceElement[] target, boolean keepTop) { 30 return new StackTraceElement[0]; 31 } 32 }; 33 34 //when 35 String loc = new LocationImpl(filterReturningEmptyArray).toString(); 36 37 //then 38 assertEquals("-> at <<unknown line>>", loc); 39 } 40} 41