Added test class.

This commit is contained in:
Erik C. Thauvin 2015-12-03 12:29:13 -08:00
parent 0c0e8bf0c5
commit 2a771bc992
5 changed files with 131 additions and 2 deletions

View file

@ -57,7 +57,7 @@ public class Reasons
{
for (final Map.Entry<String, String> entry : REASON_PHRASES.entrySet())
{
System.out.println(entry.getKey() + '=' + entry.getValue());
System.out.println(entry.getKey() + ": " + entry.getValue());
}
}

View file

@ -58,7 +58,7 @@ public class ReasonTag extends SimpleTagSupport
}
}
}
catch (IOException e)
catch (IOException ignore)
{
// Ignore.
}

View file

@ -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 <code>ReasonsTest</code> class.
*
* @author <a href="mailto:erik@thauvin.net">Erik C. Thauvin</a>
* @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));
}
}