diff --git a/HttpStatus.iml b/HttpStatus.iml index f9bb861..f05d6c7 100644 --- a/HttpStatus.iml +++ b/HttpStatus.iml @@ -41,5 +41,89 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8880542..56c327b 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,8 @@ repositories { dependencies { compile 'servletapi:servlet-api:+' compile 'javax.servlet.jsp:jsp-api:+' + + testCompile 'org.testng:testng:+' } compileJava { @@ -51,6 +53,10 @@ clean { delete deployDir } +test { + useTestNG() +} + task wrapper(type: Wrapper) { gradleVersion = gradle.gradleVersion } diff --git a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java index 490df7c..3b8d714 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java +++ b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java @@ -57,7 +57,7 @@ public class Reasons { for (final Map.Entry entry : REASON_PHRASES.entrySet()) { - System.out.println(entry.getKey() + '=' + entry.getValue()); + System.out.println(entry.getKey() + ": " + entry.getValue()); } } diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java index a9d2508..2c4059c 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java @@ -58,7 +58,7 @@ public class ReasonTag extends SimpleTagSupport } } } - catch (IOException e) + catch (IOException ignore) { // Ignore. } diff --git a/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java b/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java new file mode 100644 index 0000000..284130c --- /dev/null +++ b/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java @@ -0,0 +1,39 @@ +package net.thauvin.erik.httpstatus; + +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.util.ResourceBundle; + +/** + * The ReasonsTest class. + * + * @author Erik C. Thauvin + * @created 2015-12-03 + * @since 1.0 + */ +public class ReasonsTest +{ + @DataProvider(name = "reasons") + public Object[][] reasons() + { + final ResourceBundle bundle = ResourceBundle.getBundle("net.thauvin.erik.httpstatus.reasons"); + final Object[][] reasons = new String[bundle.keySet().size()][2]; + int i = 0; + for (final String key : bundle.keySet()) + { + reasons[i][0] = key; + reasons[i][1] = bundle.getString(key); + i++; + } + return reasons; + } + + @Test(dataProvider = "reasons") + public void testGetReasonPhrase(String code, String reason) + throws Exception + { + Assert.assertEquals(reason, Reasons.getReasonPhrase(code)); + } +} \ No newline at end of file