Minor - remove StringUtils#getStackTrace

- Remove StringUtils#getStackTrace in favor of Guava's Throwables#getStackTraceAsString
This commit is contained in:
ljacqu 2015-12-26 18:01:09 +01:00
parent 41e400e9dd
commit 5ab3a1f9ef
2 changed files with 1 additions and 35 deletions

View File

@ -4,8 +4,6 @@ import net.ricecode.similarity.LevenshteinDistanceStrategy;
import net.ricecode.similarity.StringSimilarityService;
import net.ricecode.similarity.StringSimilarityServiceImpl;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
/**
@ -108,25 +106,6 @@ public final class StringUtils {
return join(delimiter, Arrays.asList(elements));
}
/**
* Get a full stack trace of an exception as a string.
*
* @param exception The exception.
*
* @return Stack trace as a string.
*/
public static String getStackTrace(Exception exception) {
// Create a string and print writer to print the stack trace into
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
// Print the stack trace into the print writer
exception.printStackTrace(printWriter);
// Return the result as a string
return stringWriter.toString();
}
/**
* Format the information from a Throwable as string, retaining the type and its message.
*

View File

@ -6,9 +6,8 @@ import java.net.MalformedURLException;
import java.util.Arrays;
import java.util.List;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.stringContainsInOrder;
import static org.hamcrest.Matchers.greaterThan;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
@ -121,18 +120,6 @@ public class StringUtilsTest {
assertThat(result, equalTo("[MalformedURLException]: Unrecognized URL format"));
}
@Test
public void shouldPrintStackTrace() {
// given
MalformedURLException ex = new MalformedURLException("Unrecognized URL format");
// when
String result = StringUtils.getStackTrace(ex);
// then
assertThat(result, stringContainsInOrder(getClass().getName()));
}
@Test
public void shouldGetDifferenceWithNullString() {
// given/when/then