mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 20:57:35 +01:00
Minor - remove StringUtils#getStackTrace
- Remove StringUtils#getStackTrace in favor of Guava's Throwables#getStackTraceAsString
This commit is contained in:
parent
41e400e9dd
commit
5ab3a1f9ef
@ -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.
|
||||
*
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user