Compare commits
No commits in common. "7b27ddbc8607c55e7dd867089738c691956a5690" and "2ff4128bc90a07fce7d3837e14c9f15c82899e60" have entirely different histories.
7b27ddbc86
...
2ff4128bc9
10 changed files with 31 additions and 92 deletions
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
|
@ -2,10 +2,6 @@
|
||||||
<component name="EntryPointsManager">
|
<component name="EntryPointsManager">
|
||||||
<pattern value="net.thauvin.erik.httpstatus.HttpStatusBuild" />
|
<pattern value="net.thauvin.erik.httpstatus.HttpStatusBuild" />
|
||||||
<pattern value="net.thauvin.erik.httpstatus.HttpStatusBuild" method="pmd" />
|
<pattern value="net.thauvin.erik.httpstatus.HttpStatusBuild" method="pmd" />
|
||||||
<pattern value="net.thauvin.erik.httpstatus.HttpStatusBuild" method="jacoco" />
|
|
||||||
<pattern value="net.thauvin.erik.httpstatus.taglibs.XmlSupport" method="setDefault" />
|
|
||||||
<pattern value="net.thauvin.erik.httpstatus.taglibs.XmlSupport" method="setEscapeXml" />
|
|
||||||
<pattern value="net.thauvin.erik.httpstatus.taglibs.ReasonTag" method="setCode" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="PDMPlugin">
|
<component name="PDMPlugin">
|
||||||
<option name="customRuleSets">
|
<option name="customRuleSets">
|
||||||
|
|
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
|
@ -2,6 +2,7 @@
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/app.iml" filepath="$PROJECT_DIR$/.idea/app.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/bld.iml" filepath="$PROJECT_DIR$/.idea/bld.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
|
Binary file not shown.
|
@ -34,14 +34,18 @@ package net.thauvin.erik.httpstatus;
|
||||||
|
|
||||||
import rife.bld.BuildCommand;
|
import rife.bld.BuildCommand;
|
||||||
import rife.bld.Project;
|
import rife.bld.Project;
|
||||||
|
import rife.bld.dependencies.Dependency;
|
||||||
import rife.bld.extension.JacocoReportOperation;
|
import rife.bld.extension.JacocoReportOperation;
|
||||||
import rife.bld.extension.PmdOperation;
|
import rife.bld.extension.PmdOperation;
|
||||||
import rife.bld.operations.JUnitOperation;
|
import rife.bld.publish.PublishDeveloper;
|
||||||
import rife.bld.publish.*;
|
import rife.bld.publish.PublishInfo;
|
||||||
import rife.tools.FileUtils;
|
import rife.bld.publish.PublishLicense;
|
||||||
|
import rife.bld.publish.PublishScm;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static rife.bld.dependencies.Repository.*;
|
import static rife.bld.dependencies.Repository.*;
|
||||||
|
@ -71,8 +75,8 @@ public class HttpStatusBuild extends Project {
|
||||||
.include(dependency("jakarta.el", "jakarta.el-api", version(5, 0, 1)));
|
.include(dependency("jakarta.el", "jakarta.el-api", version(5, 0, 1)));
|
||||||
scope(test)
|
scope(test)
|
||||||
.include(dependency("org.assertj", "assertj-joda-time", version(2, 2, 0)))
|
.include(dependency("org.assertj", "assertj-joda-time", version(2, 2, 0)))
|
||||||
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 10, 0)))
|
.include(dependency("org.junit.jupiter", "junit-jupiter", version(5, 9, 3)))
|
||||||
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 10, 0)));
|
.include(dependency("org.junit.platform", "junit-platform-console-standalone", version(1, 9, 3)));
|
||||||
|
|
||||||
javadocOperation().javadocOptions()
|
javadocOperation().javadocOptions()
|
||||||
.docTitle(description + ' ' + version.toString())
|
.docTitle(description + ' ' + version.toString())
|
||||||
|
@ -89,7 +93,6 @@ public class HttpStatusBuild extends Project {
|
||||||
.groupId(pkg)
|
.groupId(pkg)
|
||||||
.artifactId(name.toLowerCase())
|
.artifactId(name.toLowerCase())
|
||||||
.name(name)
|
.name(name)
|
||||||
.version(version)
|
|
||||||
.description(description)
|
.description(description)
|
||||||
.url(url)
|
.url(url)
|
||||||
.developer(new PublishDeveloper().id("ethauvin").name("Erik C. Thauvin").email("erik@thauvin.net")
|
.developer(new PublishDeveloper().id("ethauvin").name("Erik C. Thauvin").email("erik@thauvin.net")
|
||||||
|
@ -107,7 +110,16 @@ public class HttpStatusBuild extends Project {
|
||||||
new HttpStatusBuild().start(args);
|
new HttpStatusBuild().start(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@BuildCommand(summary = "Generates JaCoCo Reports")
|
@Override
|
||||||
|
public void publish() throws Exception {
|
||||||
|
super.publish();
|
||||||
|
var pomPath = Path.of(MAVEN_LOCAL.getArtifactLocation(new Dependency(pkg, name.toLowerCase(), version)),
|
||||||
|
version.toString(),
|
||||||
|
name.toLowerCase() + '-' + version + ".pom");
|
||||||
|
Files.copy(pomPath, Path.of(workDirectory.getAbsolutePath(), "pom.xml"), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
@BuildCommand(summary = "Generates Jacoco Reports")
|
||||||
public void jacoco() throws IOException {
|
public void jacoco() throws IOException {
|
||||||
new JacocoReportOperation()
|
new JacocoReportOperation()
|
||||||
.fromProject(this)
|
.fromProject(this)
|
||||||
|
@ -122,11 +134,4 @@ public class HttpStatusBuild extends Project {
|
||||||
.ruleSets("config/pmd.xml")
|
.ruleSets("config/pmd.xml")
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void publish() throws Exception {
|
|
||||||
super.publish();
|
|
||||||
var xml = new PomBuilder().info(publishOperation().info()).dependencies(dependencies).build();
|
|
||||||
FileUtils.writeString(xml, Path.of(workDirectory.getPath(), "pom.xml").toFile());
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -52,24 +52,15 @@ public class CauseTag extends XmlSupport {
|
||||||
@Override
|
@Override
|
||||||
public void doTag() throws IOException {
|
public void doTag() throws IOException {
|
||||||
final PageContext pageContext = (PageContext) getJspContext();
|
final PageContext pageContext = (PageContext) getJspContext();
|
||||||
final JspWriter out = pageContext.getOut();
|
@SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut();
|
||||||
|
|
||||||
final Throwable cause = pageContext.getErrorData().getThrowable().getCause();
|
final Throwable cause = pageContext.getErrorData().getThrowable().getCause();
|
||||||
|
|
||||||
Utils.outWrite(out, getCause(cause), defaultValue, escapeXml);
|
String message = defaultValue;
|
||||||
|
if (cause != null && cause.getLocalizedMessage() != null) {
|
||||||
|
message = cause.getLocalizedMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
Utils.outWrite(out, message, defaultValue, escapeXml);
|
||||||
* Returns the cause's localized message or default value.
|
|
||||||
*
|
|
||||||
* @param cause The cause.
|
|
||||||
* @return The cause or {@code null}.
|
|
||||||
*/
|
|
||||||
public String getCause(Throwable cause) {
|
|
||||||
if (cause != null && cause.getLocalizedMessage() != null) {
|
|
||||||
return cause.getLocalizedMessage();
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@ public class CodeTag extends SimpleTagSupport {
|
||||||
@Override
|
@Override
|
||||||
public void doTag() throws IOException {
|
public void doTag() throws IOException {
|
||||||
final PageContext pageContext = (PageContext) getJspContext();
|
final PageContext pageContext = (PageContext) getJspContext();
|
||||||
final JspWriter out = pageContext.getOut();
|
@SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut();
|
||||||
|
|
||||||
out.write(String.valueOf(pageContext.getErrorData().getStatusCode()));
|
out.write(String.valueOf(pageContext.getErrorData().getStatusCode()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class MessageTag extends XmlSupport {
|
||||||
@Override
|
@Override
|
||||||
public void doTag() throws IOException {
|
public void doTag() throws IOException {
|
||||||
final PageContext pageContext = (PageContext) getJspContext();
|
final PageContext pageContext = (PageContext) getJspContext();
|
||||||
final JspWriter out = pageContext.getOut();
|
@SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut();
|
||||||
|
|
||||||
final String message = (String) pageContext.getRequest().getAttribute(
|
final String message = (String) pageContext.getRequest().getAttribute(
|
||||||
jakarta.servlet.RequestDispatcher.ERROR_MESSAGE);
|
jakarta.servlet.RequestDispatcher.ERROR_MESSAGE);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class ReasonTag extends XmlSupport {
|
||||||
@Override
|
@Override
|
||||||
public void doTag() {
|
public void doTag() {
|
||||||
final PageContext pageContext = (PageContext) getJspContext();
|
final PageContext pageContext = (PageContext) getJspContext();
|
||||||
final JspWriter out = pageContext.getOut();
|
@SuppressWarnings("PMD.CloseResource") final JspWriter out = pageContext.getOut();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (statusCode > -1) {
|
if (statusCode > -1) {
|
||||||
|
@ -75,6 +75,7 @@ public class ReasonTag extends XmlSupport {
|
||||||
*
|
*
|
||||||
* @param statusCode The status code.
|
* @param statusCode The status code.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setCode(final int statusCode) {
|
public void setCode(final int statusCode) {
|
||||||
this.statusCode = statusCode;
|
this.statusCode = statusCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public abstract class XmlSupport extends SimpleTagSupport {
|
||||||
*
|
*
|
||||||
* @param defaultValue The default value.
|
* @param defaultValue The default value.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setDefault(final String defaultValue) {
|
public void setDefault(final String defaultValue) {
|
||||||
this.defaultValue = defaultValue;
|
this.defaultValue = defaultValue;
|
||||||
}
|
}
|
||||||
|
@ -66,6 +67,7 @@ public abstract class XmlSupport extends SimpleTagSupport {
|
||||||
*
|
*
|
||||||
* @param escapeXml <code>true</code> or <code>false</code>
|
* @param escapeXml <code>true</code> or <code>false</code>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unused")
|
||||||
public void setEscapeXml(final boolean escapeXml) {
|
public void setEscapeXml(final boolean escapeXml) {
|
||||||
this.escapeXml = escapeXml;
|
this.escapeXml = escapeXml;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* CauseTagTest.java
|
|
||||||
*
|
|
||||||
* Copyright 2023 sErik 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:
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*
|
|
||||||
* 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 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;
|
|
||||||
|
|
||||||
import net.thauvin.erik.httpstatus.taglibs.CauseTag;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements the CauseTagTest class.
|
|
||||||
*
|
|
||||||
* @author <a href="https://erik.thauvin.net/">Erik C. Thauvin</a>
|
|
||||||
* @since 1.0
|
|
||||||
*/
|
|
||||||
class CauseTagTest {
|
|
||||||
@Test
|
|
||||||
void causeTest() {
|
|
||||||
var message = "This is the cause";
|
|
||||||
var tag = new CauseTag();
|
|
||||||
|
|
||||||
assertThat(tag.getCause(new Exception(message))).as("has cause").isEqualTo(message);
|
|
||||||
assertThat(tag.getCause(new Exception())).as("no cause").isNull();
|
|
||||||
assertThat(tag.getCause(null)).as("null").isNull();
|
|
||||||
assertThat(tag.getCause(new Exception(""))).as("empty").isEmpty();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue