From 5ab3a1f9ef730c8673a7da4d0216591c77c04216 Mon Sep 17 00:00:00 2001 From: ljacqu Date: Sat, 26 Dec 2015 18:01:09 +0100 Subject: [PATCH] Minor - remove StringUtils#getStackTrace - Remove StringUtils#getStackTrace in favor of Guava's Throwables#getStackTraceAsString --- .../fr/xephi/authme/util/StringUtils.java | 21 ------------------- .../fr/xephi/authme/util/StringUtilsTest.java | 15 +------------ 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/src/main/java/fr/xephi/authme/util/StringUtils.java b/src/main/java/fr/xephi/authme/util/StringUtils.java index 1751461d8..9ae0ec0fd 100644 --- a/src/main/java/fr/xephi/authme/util/StringUtils.java +++ b/src/main/java/fr/xephi/authme/util/StringUtils.java @@ -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. * diff --git a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java index 9776f1ee9..238c8bcef 100644 --- a/src/test/java/fr/xephi/authme/util/StringUtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/StringUtilsTest.java @@ -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