diff --git a/.idea/modules/httpstatus.iml b/.idea/modules/httpstatus.iml index 9f8f9bf..76d1928 100644 --- a/.idea/modules/httpstatus.iml +++ b/.idea/modules/httpstatus.iml @@ -1,12 +1,25 @@ - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules/httpstatus_main.iml b/.idea/modules/httpstatus_main.iml deleted file mode 100644 index c0ec849..0000000 --- a/.idea/modules/httpstatus_main.iml +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/httpstatus_test.iml b/.idea/modules/httpstatus_test.iml deleted file mode 100644 index 6f972d8..0000000 --- a/.idea/modules/httpstatus_test.iml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/HttpStatus.ipr b/HttpStatus.ipr index 7bfdec5..f5388d7 100644 --- a/HttpStatus.ipr +++ b/HttpStatus.ipr @@ -57,10 +57,6 @@ - - - - @@ -75,7 +71,7 @@ - + @@ -83,12 +79,35 @@ + + + + @@ -157,6 +177,33 @@ + + + + + + + + + + + + Android Lint + + + Java + + + Portability issuesJava + + + + + @@ -170,15 +217,110 @@ - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + @@ -233,7 +375,6 @@ - @@ -242,4 +383,20 @@ + + + + + 1.8.x + + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index b8206b0..e329d55 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id "com.jfrog.bintray" version "1.5" + id "com.jfrog.bintray" version "1.5" } apply plugin: 'java' apply plugin: 'idea' @@ -29,26 +29,26 @@ def pkgIssueTrackerUrl = mavenUrl + '/issues' def pkgLabels = ['jsp', 'tag library', 'http', 'status code', 'java'] def getVersion(isIncrement = false) { - def propsFile = 'version.properties' - def majorKey = 'version.major' - def minorKey = 'version.minor' - def patchKey = 'version.patch' - def metaKey = 'version.buildmeta' - def preKey = 'version.prerelease' - if (isIncrement) { - ant.propertyfile(file: propsFile) { - entry(key: patchKey, - type: 'int', - default: '-1', - operation: '+') - } - } - def p = new Properties() - file(propsFile).withInputStream { stream -> p.load(stream) } - def metadata = p.getProperty(metaKey, '') - def prerelease = p.getProperty(preKey, '') - return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') + - (prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : '')) + def propsFile = 'version.properties' + def majorKey = 'version.major' + def minorKey = 'version.minor' + def patchKey = 'version.patch' + def metaKey = 'version.buildmeta' + def preKey = 'version.prerelease' + if (isIncrement) { + ant.propertyfile(file: propsFile) { + entry(key: patchKey, + type: 'int', + default: '-1', + operation: '+') + } + } + def p = new Properties() + file(propsFile).withInputStream { stream -> p.load(stream) } + def metadata = p.getProperty(metaKey, '') + def prerelease = p.getProperty(preKey, '') + return (p.getProperty(majorKey, '1') + '.' + p.getProperty(minorKey, '0') + '.' + p.getProperty(patchKey, '0') + + (prerelease.length() > 0 ? '-' + prerelease : '') + (metadata.length() > 0 ? '+' + metadata : '')) } version = getVersion(); @@ -57,178 +57,174 @@ mainClassName = 'net.thauvin.erik.httpstatus.Reasons' [compileJava, compileTestJava]*.options*.encoding = 'UTF-8' repositories { - mavenLocal() - jcenter() + mavenLocal() + jcenter() } dependencies { - compile 'javax.servlet:javax.servlet-api:3.1.0' - compile 'javax.servlet.jsp:jsp-api:2.2' + compile 'javax.servlet:javax.servlet-api:3.1.0' + compile 'javax.servlet.jsp:jsp-api:2.2' - testCompile 'org.testng:testng:6.9.12' + testCompile 'org.testng:testng:6.9.12' } bintray { - user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') - key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') - publications = ['MyPublication'] - dryRun = false - pkg { - repo = 'maven' - name = mavenName - licenses = pkgLicenses - desc = mavenDescription - websiteUrl = mavenUrl - issueTrackerUrl = pkgIssueTrackerUrl - vcsUrl = mavenScmCon - labels = pkgLabels - publicDownloadNumbers = true - version { - name = project.version - desc = 'Version ' + project.version - vcsTag = project.version - gpg { - sign = true - } - } - } + user = project.hasProperty('bintrayUser') ? project.property('bintrayUser') : System.getenv('BINTRAY_USER') + key = project.hasProperty('bintrayApiKey') ? project.property('bintrayApiKey') : System.getenv('BINTRAY_API_KEY') + publications = ['MyPublication'] + dryRun = false + pkg { + repo = 'maven' + name = mavenName + licenses = pkgLicenses + desc = mavenDescription + websiteUrl = mavenUrl + issueTrackerUrl = pkgIssueTrackerUrl + vcsUrl = mavenScmCon + labels = pkgLabels + publicDownloadNumbers = true + version { + name = project.version + desc = 'Version ' + project.version + vcsTag = project.version + gpg { + sign = true + } + } + } } def pomConfig = { - licenses { - license { - name mavenLicense - url mavenLicenseUrl - distribution 'repo' - } - } - developers { - developer { - id 'ethauvin' - name 'Erik C. Thauvin' - email 'erik@thauvin.net' - } - } - scm { - connection 'scm:git:' + mavenScmCon - developerConnection 'scm:git:' + mavenScmDevCon - url mavenScmCon - } + licenses { + license { + name mavenLicense + url mavenLicenseUrl + distribution 'repo' + } + } + developers { + developer { + id 'ethauvin' + name 'Erik C. Thauvin' + email 'erik@thauvin.net' + } + } + scm { + connection 'scm:git:' + mavenScmCon + developerConnection 'scm:git:' + mavenScmDevCon + url mavenScmCon + } } publishing { - publications { - MyPublication(MavenPublication) { - from components.java - artifact sourcesJar - artifact javadocJar - groupId mavenGroupId - artifactId rootProject.name - version project.version + publications { + MyPublication(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + groupId mavenGroupId + artifactId rootProject.name + version project.version - pom.withXml { - def root = asNode() - root.appendNode('name', mavenName) - root.appendNode('description', mavenDescription) - root.appendNode('url', mavenUrl) - root.children().last() + pomConfig - } - } - } + pom.withXml { + def root = asNode() + root.appendNode('name', mavenName) + root.appendNode('description', mavenDescription) + root.appendNode('url', mavenUrl) + root.children().last() + pomConfig + } + } + } } task javadocJar(type: Jar, dependsOn: javadoc) { - group = 'Build' - description = 'Builds an archive of the javadoc docs.' - classifier = 'javadoc' - from javadoc.destinationDir + group = 'Build' + description = 'Builds an archive of the javadoc docs.' + classifier = 'javadoc' + from javadoc.destinationDir } task sourcesJar(type: Jar) { - group = 'Build' - description = 'Builds an archive of the source code.' - classifier = 'sources' - from sourceSets.main.allSource + group = 'Build' + description = 'Builds an archive of the source code.' + classifier = 'sources' + from sourceSets.main.allSource } artifacts { - archives javadocJar - archives sourcesJar + archives javadocJar + archives sourcesJar } javadoc { - title = mavenDescription + ' ' + version - options.tags = ['created'] - options.author = true - options.addStringOption('link', 'http://docs.oracle.com/javase/8/docs/api/') - options.addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc : "$System.env.JAVA_HOME/src.zip") - if (JavaVersion.current().isJava8Compatible()) - { - options.addStringOption('Xdoclint:none', '-quiet') - } + title = mavenDescription + ' ' + version + options.tags = ['created'] + options.author = true + options.addStringOption('link', 'http://docs.oracle.com/javase/8/docs/api/') + options.addStringOption('sourcepath', project.hasProperty('jdkSrc') ? jdkSrc : "$System.env.JAVA_HOME/src.zip") + if (JavaVersion.current().isJava8Compatible()) { + options.addStringOption('Xdoclint:none', '-quiet') + } } compileJava { - doFirst { - project.version = getVersion(isRelease) - } - //options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' + doFirst { + project.version = getVersion(isRelease) + } + //options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' } jar { - manifest.attributes('Main-Class': mainClassName) + manifest.attributes('Main-Class': mainClassName) } clean { - delete deployDir + delete deployDir } test { - useTestNG() + useTestNG() } task wrapper(type: Wrapper) { - gradleVersion = gradle.gradleVersion + gradleVersion = gradle.gradleVersion } task copyToDeploy(type: Copy) { - from(configurations.runtime) { - exclude 'javax.servlet-api-*.jar' - exclude 'jsp-api-*.jar' - } - from jar - into deployDir + from(configurations.runtime) { + exclude 'javax.servlet-api-*.jar' + exclude 'jsp-api-*.jar' + } + from jar + into deployDir } task deploy(dependsOn: ['build', 'copyToDeploy']) { - description = 'Copies all needed files to the ${deployDir} directory.' - group = 'Publishing' - outputs.dir deployDir - inputs.files copyToDeploy - mustRunAfter clean + description = 'Copies all needed files to the ${deployDir} directory.' + group = 'Publishing' + outputs.dir deployDir + inputs.files copyToDeploy + mustRunAfter clean } task release(dependsOn: ['wrapper', 'clean', 'deploy']) << { - group = 'Publishing' - description = 'Releases new version.' - isRelease = true + group = 'Publishing' + description = 'Releases new version.' + isRelease = true } task pandoc(type: Exec) { - group = 'Documentation' - def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-c', 'github-pandoc.css', '-o', 'README.html', 'README.md'] - if (Os.isFamily(Os.FAMILY_WINDOWS)) - { - commandLine(['cmd', '/c', 'pandoc'] + pandoc_args) - } - else - { - executable 'pandoc' - args pandoc_args - } - standardOutput = new ByteArrayOutputStream() - ext.output = { - return standardOutput.toString() - } + group = 'Documentation' + def pandoc_args = ['--from', 'markdown_github', '--to', 'html5', '-s', '-c', 'github-pandoc.css', '-o', 'README.html', 'README.md'] + if (Os.isFamily(Os.FAMILY_WINDOWS)) { + commandLine(['cmd', '/c', 'pandoc'] + pandoc_args) + } else { + executable 'pandoc' + args pandoc_args + } + standardOutput = new ByteArrayOutputStream() + ext.output = { + return standardOutput.toString() + } } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java index ee03889..57cdbe5 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/Reasons.java +++ b/src/main/java/net/thauvin/erik/httpstatus/Reasons.java @@ -43,66 +43,55 @@ import java.util.TreeMap; * @created 2015-12-02 * @since 1.0 */ -public class Reasons -{ - /** - * The resource bundle base name. - */ - public static final String BUNDLE_BASENAME = "net.thauvin.erik.httpstatus.reasons"; +public class Reasons { + /** + * The resource bundle base name. + */ + public static final String BUNDLE_BASENAME = "net.thauvin.erik.httpstatus.reasons"; - /** - * The reason phrases map. - */ - private static final Map REASON_PHRASES = new TreeMap(); + /** + * The reason phrases map. + */ + private static final Map REASON_PHRASES = new TreeMap(); - /** - * Returns the reason phrase for the specified status code. - * - * @param statusCode The status code. - * - * @return The reason phrase, or null. - */ - public static String getReasonPhrase(final int statusCode) - { - return getReasonPhrase(Integer.toString(statusCode)); - } + // Initializes the reason phrases map. + static { + final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_BASENAME); + for (final String key : bundle.keySet()) { + REASON_PHRASES.put(key, bundle.getString(key)); + } + } - /** - * Returns the reason phrase for the specified status code. - * - * @param statusCode The status code. - * - * @return The reason phrase, or null. - */ - public static String getReasonPhrase(final String statusCode) - { - return REASON_PHRASES.get(statusCode); - } + /** + * Returns the reason phrase for the specified status code. + * + * @param statusCode The status code. + * @return The reason phrase, or null. + */ + public static String getReasonPhrase(final int statusCode) { + return getReasonPhrase(Integer.toString(statusCode)); + } - /** - * Prints the status codes and reason phrases. - * - * @param args The command line arguments. - */ - public static void main(final String... args) - { - for (final Map.Entry entry : REASON_PHRASES.entrySet()) - { - System.out.println(entry.getKey() + ": " + entry.getValue()); - } + /** + * Returns the reason phrase for the specified status code. + * + * @param statusCode The status code. + * @return The reason phrase, or null. + */ + public static String getReasonPhrase(final String statusCode) { + return REASON_PHRASES.get(statusCode); + } - System.out.println("Total: " + REASON_PHRASES.entrySet().size()); - } + /** + * Prints the status codes and reason phrases. + * + * @param args The command line arguments. + */ + public static void main(final String... args) { + for (final Map.Entry entry : REASON_PHRASES.entrySet()) { + System.out.println(entry.getKey() + ": " + entry.getValue()); + } - /** - * Initializes the reason phrases map. - */ - static - { - final ResourceBundle bundle = ResourceBundle.getBundle(BUNDLE_BASENAME); - for (final String key : bundle.keySet()) - { - REASON_PHRASES.put(key, bundle.getString(key)); - } - } + System.out.println("Total: " + REASON_PHRASES.entrySet().size()); + } } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/httpstatus/Utils.java b/src/main/java/net/thauvin/erik/httpstatus/Utils.java index c0634aa..124a704 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/Utils.java +++ b/src/main/java/net/thauvin/erik/httpstatus/Utils.java @@ -41,95 +41,78 @@ import java.io.Writer; * @created 2015-12-03 * @since 1.0 */ -public final class Utils -{ +public final class Utils { - /** - * Disables the default constructor. - * - * @throws UnsupportedOperationException If the constructor is called. - */ - private Utils() - throws UnsupportedOperationException - { - throw new UnsupportedOperationException("Illegal constructor call."); - } + /** + * Disables the default constructor. + * + * @throws UnsupportedOperationException If the constructor is called. + */ + private Utils() + throws UnsupportedOperationException { + throw new UnsupportedOperationException("Illegal constructor call."); + } - /** - * Writes a string value to the specified writer. The default value is used when the actual value is null. - * - * @param out The writer to output the value to. - * @param value The string value. - * @param defaultValue The default value. - * @param xml The {@link #escapeXml(String) xml} flag. - * - * @throws IOException f an I/O error occurs. - */ - public static void outWrite(final Writer out, final String value, final String defaultValue, final boolean xml) - throws IOException - { - if (xml) - { - if (value != null) - { - out.write(escapeXml(value)); - } - else if (defaultValue != null) - { - out.write(escapeXml(defaultValue)); - } - } - else - { - if (value != null) - { - out.write(value); - } - else if (defaultValue != null) - { - out.write(defaultValue); - } - } - } + /** + * Converts <, >, &, ', " + * to their corresponding entity codes. + * + * @param value The string value to convert. + * @return The converted string value. + */ + public static String escapeXml(final String value) { + final StringBuilder escaped = new StringBuilder(); - /** - * Converts <, >, &, ', " - * to their corresponding entity codes. - * - * @param value The string value to convert. - * - * @return The converted string value. - */ - public static String escapeXml(final String value) - { - final StringBuilder escaped = new StringBuilder(); + for (int i = 0; i < value.length(); i++) { + final char c = value.charAt(i); + switch (c) { + case '<': + escaped.append("<"); + break; + case '>': + escaped.append(">"); + break; + case '&': + escaped.append("&"); + break; + case '\'': + escaped.append("'"); + break; + case '"': + escaped.append("""); + break; + default: + escaped.append(c); + break; + } + } - for (int i = 0; i < value.length(); i++) - { - final char c = value.charAt(i); - switch (c) - { - case '<': - escaped.append("<"); - break; - case '>': - escaped.append(">"); - break; - case '&': - escaped.append("&"); - break; - case '\'': - escaped.append("'"); - break; - case '"': - escaped.append("""); - break; - default: - escaped.append(c); - break; - } - } + return escaped.toString(); + } - return escaped.toString(); - } + /** + * Writes a string value to the specified writer. The default value is used when the actual value is null. + * + * @param out The writer to output the value to. + * @param value The string value. + * @param defaultValue The default value. + * @param xml The {@link #escapeXml(String) xml} flag. + * @throws IOException f an I/O error occurs. + */ + public static void outWrite(final Writer out, final String value, final String defaultValue, final boolean xml) + throws IOException { + if (xml) { + if (value != null) { + out.write(escapeXml(value)); + } else if (defaultValue != null) { + out.write(escapeXml(defaultValue)); + } + } else { + if (value != null) { + out.write(value); + } else if (defaultValue != null) { + out.write(defaultValue); + } + } + } } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java index 9c77803..cc19b00 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CauseTag.java @@ -45,29 +45,24 @@ import java.io.IOException; * @created 2015-12-03 * @since 1.0 */ -public class CauseTag extends XmlSupport -{ - /** - * {@inheritDoc} - */ - @Override - public void doTag() - throws JspException, IOException - { - final PageContext pageContext = (PageContext) getJspContext(); - final JspWriter out = pageContext.getOut(); +public class CauseTag extends XmlSupport { + /** + * {@inheritDoc} + */ + @Override + public void doTag() + throws JspException, IOException { + final PageContext pageContext = (PageContext) getJspContext(); + final JspWriter out = pageContext.getOut(); - String cause; + String cause; - try - { - cause = pageContext.getErrorData().getThrowable().getCause().getLocalizedMessage(); - } - catch (NullPointerException ignore) - { - cause = defaultValue; - } + try { + cause = pageContext.getErrorData().getThrowable().getCause().getLocalizedMessage(); + } catch (NullPointerException ignore) { + cause = defaultValue; + } - Utils.outWrite(out, cause, defaultValue, escapeXml); - } + Utils.outWrite(out, cause, defaultValue, escapeXml); + } } \ No newline at end of file diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java index d073ccf..34b30e8 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/CodeTag.java @@ -44,18 +44,16 @@ import java.io.IOException; * @created 2015-12-03 * @since 1.0 */ -public class CodeTag extends SimpleTagSupport -{ - /** - * {@inheritDoc} - */ - @Override - public void doTag() - throws JspException, IOException - { - final PageContext pageContext = (PageContext) getJspContext(); - final JspWriter out = pageContext.getOut(); +public class CodeTag extends SimpleTagSupport { + /** + * {@inheritDoc} + */ + @Override + public void doTag() + throws JspException, IOException { + final PageContext pageContext = (PageContext) getJspContext(); + final JspWriter out = pageContext.getOut(); - out.write(String.valueOf(pageContext.getErrorData().getStatusCode())); - } + out.write(String.valueOf(pageContext.getErrorData().getStatusCode())); + } } \ No newline at end of file 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 6e3d6fe..bec65eb 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/ReasonTag.java @@ -47,50 +47,41 @@ import java.io.IOException; * @created 2015-12-02 * @since 1.0 */ -public class ReasonTag extends XmlSupport -{ - private int statusCode; +public class ReasonTag extends XmlSupport { + private int statusCode; - /** - * {@inheritDoc} - */ - @Override - public void doTag() - throws JspException, IOException - { - final PageContext pageContext = (PageContext) getJspContext(); - final JspWriter out = pageContext.getOut(); + /** + * {@inheritDoc} + */ + @Override + public void doTag() + throws JspException, IOException { + final PageContext pageContext = (PageContext) getJspContext(); + final JspWriter out = pageContext.getOut(); - try - { - if (statusCode >= 0) - { - Utils.outWrite(out, Reasons.getReasonPhrase(statusCode), defaultValue, escapeXml); - } - else - { - Utils.outWrite(out, - Reasons.getReasonPhrase(pageContext.getErrorData().getStatusCode()), - defaultValue, - escapeXml); - } - } - catch (IOException ignore) - { - // Ignore. - } - } + try { + if (statusCode >= 0) { + Utils.outWrite(out, Reasons.getReasonPhrase(statusCode), defaultValue, escapeXml); + } else { + Utils.outWrite(out, + Reasons.getReasonPhrase(pageContext.getErrorData().getStatusCode()), + defaultValue, + escapeXml); + } + } catch (IOException ignore) { + // Ignore. + } + } - /** - * Sets the status code. - * - * @param statusCode The status code. - */ - @SuppressWarnings("unused") - public void setCode(final int statusCode) - { - this.statusCode = statusCode; - } + /** + * Sets the status code. + * + * @param statusCode The status code. + */ + @SuppressWarnings("unused") + public void setCode(final int statusCode) { + this.statusCode = statusCode; + } } diff --git a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java index 406bcee..5789122 100644 --- a/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java +++ b/src/main/java/net/thauvin/erik/httpstatus/taglibs/XmlSupport.java @@ -40,37 +40,34 @@ import javax.servlet.jsp.tagext.SimpleTagSupport; * @created 2015-12-03 * @since 1.0 */ -public abstract class XmlSupport extends SimpleTagSupport -{ - /** - * Default value string. - */ - protected String defaultValue; +public abstract class XmlSupport extends SimpleTagSupport { + /** + * Default value string. + */ + protected String defaultValue; - /** - * Escape XML flag. - */ - protected boolean escapeXml = true; + /** + * Escape XML flag. + */ + protected boolean escapeXml = true; - /** - * Sets the default value. - * - * @param defaultValue The default value. - */ - @SuppressWarnings("unused") - public void setDefault(final String defaultValue) - { - this.defaultValue = defaultValue; - } + /** + * Sets the default value. + * + * @param defaultValue The default value. + */ + @SuppressWarnings("unused") + public void setDefault(final String defaultValue) { + this.defaultValue = defaultValue; + } - /** - * Sets the {@link net.thauvin.erik.httpstatus.Utils#escapeXml(String) xml} flag. - * - * @param escapeXml true or false - */ - @SuppressWarnings("unused") - public void setEscapeXml(final boolean escapeXml) - { - this.escapeXml = escapeXml; - } + /** + * Sets the {@link net.thauvin.erik.httpstatus.Utils#escapeXml(String) xml} flag. + * + * @param escapeXml true or false + */ + @SuppressWarnings("unused") + public void setEscapeXml(final boolean escapeXml) { + this.escapeXml = escapeXml; + } } \ No newline at end of file diff --git a/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java b/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java index 19e75ec..94b802e 100644 --- a/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java +++ b/src/test/java/net/thauvin/erik/httpstatus/ReasonsTest.java @@ -1,35 +1,33 @@ /* * ReasonsTest.java * - * Copyright (c) 2015, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * modification, are permitted provided that the following conditions are met: * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. + * Neither the name of this project nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package net.thauvin.erik.httpstatus; @@ -47,27 +45,23 @@ import java.util.ResourceBundle; * @since 1.0 */ @SuppressWarnings("unused") -public class ReasonsTest -{ - @DataProvider(name = "reasons") - public Object[][] reasons() - { - final ResourceBundle bundle = ResourceBundle.getBundle(Reasons.BUNDLE_BASENAME); - 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; - } +public class ReasonsTest { + @DataProvider(name = "reasons") + public Object[][] reasons() { + final ResourceBundle bundle = ResourceBundle.getBundle(Reasons.BUNDLE_BASENAME); + 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)); - } + @Test(dataProvider = "reasons") + public void testGetReasonPhrase(String code, String reason) + throws Exception { + Assert.assertEquals(reason, Reasons.getReasonPhrase(code)); + } } \ No newline at end of file diff --git a/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java b/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java index 735e693..4122c5c 100644 --- a/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java +++ b/src/test/java/net/thauvin/erik/httpstatus/UtilsTest.java @@ -1,35 +1,33 @@ /* * UtilsTest.java * - * Copyright (c) 2015, Erik C. Thauvin (erik@thauvin.net) + * Copyright (c) 2015-2016, Erik C. Thauvin (erik@thauvin.net) * All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: + * modification, are permitted provided that the following conditions are met: * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. * - * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. + * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * - * Neither the name of the author nor the names of its contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission. + * Neither the name of this project nor the names of its contributors may be + * used to endorse or promote products derived from this software without + * specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package net.thauvin.erik.httpstatus; @@ -44,15 +42,13 @@ import org.testng.annotations.Test; * @since 1.0 */ @SuppressWarnings("unused") -public class UtilsTest -{ - @Test - public void testEscapeXml() - throws Exception - { - Assert.assertEquals( - "This is a test. We wan't to make sure that everything is <encoded> according the "encoding" parameter & value.", - Utils.escapeXml( - "This is a test. We wan't to make sure that everything is according the \"encoding\" parameter & value.")); - } +public class UtilsTest { + @Test + public void testEscapeXml() + throws Exception { + Assert.assertEquals( + "This is a test. We wan't to make sure that everything is <encoded> according the "encoding" parameter & value.", + Utils.escapeXml( + "This is a test. We wan't to make sure that everything is according the \"encoding\" parameter & value.")); + } } \ No newline at end of file