• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.internal.debugging;
6 
7 import static org.assertj.core.api.Assertions.assertThat;
8 
9 import org.junit.Test;
10 import org.mockito.internal.debugging.LocationImpl;
11 import org.mockito.internal.exceptions.stacktrace.StackTraceFilter;
12 import org.mockitoutil.TestBase;
13 
14 import static org.junit.Assert.assertEquals;
15 
16 @SuppressWarnings("serial")
17 public class LocationImplTest extends TestBase {
18 
19     @Test
shouldLocationNotContainGetStackTraceMethod()20     public void shouldLocationNotContainGetStackTraceMethod() {
21         assertThat(new LocationImpl().toString()).contains("shouldLocationNotContainGetStackTraceMethod");
22     }
23 
24     @Test
shouldBeSafeInCaseForSomeReasonFilteredStackTraceIsEmpty()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