Close opened resources
- Add BufferedReader instantiation into try-with-resources statement - Close scanner that was opened - Create utility class to format a caught exception
This commit is contained in:
@@ -2,6 +2,7 @@ package fr.xephi.authme.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -84,4 +85,16 @@ public class StringUtilsTest {
|
||||
// then
|
||||
assertThat(result, equalTo("hello"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldFormatException() {
|
||||
// given
|
||||
MalformedURLException ex = new MalformedURLException("Unrecognized URL format");
|
||||
|
||||
// when
|
||||
String result = StringUtils.formatException(ex);
|
||||
|
||||
// then
|
||||
assertThat(result, equalTo("[MalformedURLException]: Unrecognized URL format"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user