From 9f735889adcc4485b96b880bc26370aab4e62630 Mon Sep 17 00:00:00 2001 From: "Olivier B. OURA" Date: Fri, 12 Mar 2021 07:02:04 +0000 Subject: [PATCH 01/16] Improve test coverage #1088 --- pom.xml | 2 +- src/main/java/org/takes/rs/xe/XeWhen.java | 6 -- .../org/takes/facets/fork/FkRegexTest.java | 11 +++ src/test/java/org/takes/rs/xe/XeWhenTest.java | 17 +++++ src/test/java/org/takes/tk/TkHtmlTest.java | 69 +++++++++++++++++++ src/test/java/org/takes/tk/TkTextTest.java | 69 +++++++++++++++++++ 6 files changed, 167 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index f67a2d1fb..6300a2099 100644 --- a/pom.xml +++ b/pom.xml @@ -486,7 +486,7 @@ SOFTWARE. report + true + -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US ${argLine} org.takes.misc.PerformanceTests - - ${project.build.directory}/test-classes/org/takes/http/keystore - + ${project.build.directory}/test-classes/org/takes/http/keystore abc123 - - ${project.build.directory}/test-classes/org/takes/http/keystore - - abc123 - + ${project.build.directory}/test-classes/org/takes/http/keystore + abc123 @@ -354,7 +354,7 @@ SOFTWARE. org.apache.maven.plugins maven-compiler-plugin - 3.8.0 + 3.8.1 ${jdk.version} ${jdk.version} @@ -373,8 +373,7 @@ SOFTWARE. verify - src/verifier/verifications.xml - + src/verifier/verifications.xml @@ -404,10 +403,11 @@ SOFTWARE. com.qulice qulice-maven-plugin - ${qulice.version} + 0.19.4 checkstyle:/src/site/resources/.* + duplicatefinder:.* @@ -459,8 +459,7 @@ SOFTWARE. 0.8.6 file - ${project.build.directory}/coverage - + ${project.build.directory}/coverage @@ -522,5 +521,31 @@ SOFTWARE. + + + java-xml-bind + + [1.11,) + + + + javax.xml.bind + jaxb-api + 2.3.0 + + + com.sun.xml.bind + jaxb-core + 2.3.0 + runtime + + + com.sun.xml.bind + jaxb-impl + 2.3.0 + runtime + + + diff --git a/src/it/file-manager/pom.xml b/src/it/file-manager/pom.xml index ee9d1cefa..f32e408f9 100644 --- a/src/it/file-manager/pom.xml +++ b/src/it/file-manager/pom.xml @@ -27,14 +27,14 @@ SOFTWARE. com.jcabi parent - 0.40.1 + 0.49.1 org.takes.test file-manager 1.0-SNAPSHOT 9.1.0.8 - 1.7 + 1.8 @@ -70,6 +70,7 @@ SOFTWARE. com.jcabi jcabi-log + 0.20.1 test @@ -209,7 +210,7 @@ SOFTWARE. com.qulice qulice-maven-plugin - @qulice.version@ + 0.19.4 diff --git a/src/it/file-manager/src/test/java/org/takes/it/fm/AppTest.java b/src/it/file-manager/src/test/java/org/takes/it/fm/AppTest.java index 47db7a744..936e62739 100644 --- a/src/it/file-manager/src/test/java/org/takes/it/fm/AppTest.java +++ b/src/it/file-manager/src/test/java/org/takes/it/fm/AppTest.java @@ -31,7 +31,7 @@ import java.io.IOException; import java.net.HttpURLConnection; import java.net.URI; -import org.apache.commons.io.FileUtils; +import java.nio.file.Files; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -57,7 +57,7 @@ public final class AppTest { @Test public void justWorks() throws Exception { final File dir = this.temp.newFolder(); - FileUtils.write(new File(dir, "hello.txt"), "hello, world!"); + Files.write(new File(dir, "hello.txt").toPath(), "hello, world!".getBytes()); new FtRemote(new App(dir)).exec( new FtRemote.Script() { @Override diff --git a/src/main/java/org/takes/rs/Body.java b/src/main/java/org/takes/rs/Body.java index 312ba5053..1bc4324f4 100644 --- a/src/main/java/org/takes/rs/Body.java +++ b/src/main/java/org/takes/rs/Body.java @@ -170,10 +170,12 @@ private void estimate() throws IOException { /** * Decorator that will store the content of the underlying Body into a * temporary File. + * *

The content of the Body will be stored into a temporary * file to be able to read it as many times as we want so use it only * for large content, for small content use {@link Body.ByteArray} * instead. + * * @since 0.32 */ final class TempFile implements Body { @@ -192,6 +194,7 @@ final class TempFile implements Body { * Constructs a {@code TempFile} with the specified {@link Body}. * @param body The content of the body to store into a temporary file. */ + @SuppressWarnings("PMD.ConstructorOnlyInitializesOrCallOtherConstructors") TempFile(final Body body) { this.body = body; this.file = new File( @@ -202,6 +205,7 @@ final class TempFile implements Body { UUID.randomUUID().toString() ) ); + this.file.deleteOnExit(); } @Override @@ -214,18 +218,6 @@ public int length() throws IOException { return (int) this.file().length(); } - // Needed to remove the file once the Stream object is no more used. - // @checkstyle NoFinalizerCheck (2 lines) - // @checkstyle ProtectedMethodInFinalClassCheck (3 lines) - @Override - protected void finalize() throws Throwable { - try { - Files.delete(Paths.get(this.file.getAbsolutePath())); - } finally { - super.finalize(); - } - } - /** * Gives the {@code File} that contains the content of the underlying * {@code Body}. diff --git a/src/test/java/org/takes/rq/RqFakeTest.java b/src/test/java/org/takes/rq/RqFakeTest.java index 93a29e8a7..741145b00 100644 --- a/src/test/java/org/takes/rq/RqFakeTest.java +++ b/src/test/java/org/takes/rq/RqFakeTest.java @@ -38,7 +38,7 @@ * @since 0.24 */ @SuppressWarnings({"PMD.AvoidUsingHardCodedIP", "PMD.AvoidDuplicateLiterals"}) -final class RqFakeTest { +public final class RqFakeTest { /** * Can conform to the Object.equals() contract. From 0ac6580cef39f4445de4a2cbebb0a762c0b31600 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Sun, 14 Nov 2021 08:34:58 +0300 Subject: [PATCH 14/16] #1110 puzzle time --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4dae735a7..3dcadcd03 100644 --- a/pom.xml +++ b/pom.xml @@ -314,7 +314,7 @@ SOFTWARE. 3.0.0-M5 From 3bea758a6ff848f2c3599c909b788d537fb6beb4 Mon Sep 17 00:00:00 2001 From: "Olivier B. OURA" Date: Sun, 14 Nov 2021 23:49:15 +0000 Subject: [PATCH 15/16] Declares exception to be caught #1088 --- src/test/java/org/takes/rs/xe/XeWhenTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/takes/rs/xe/XeWhenTest.java b/src/test/java/org/takes/rs/xe/XeWhenTest.java index 5bd903195..b253937e9 100644 --- a/src/test/java/org/takes/rs/xe/XeWhenTest.java +++ b/src/test/java/org/takes/rs/xe/XeWhenTest.java @@ -97,10 +97,10 @@ void buildsXmlResponseFromPositiveCondition() throws IOException { /** * XeWhen can build XML response with negative condition. * - * @throws IOException If some problem inside + * @throws Exception If some problem inside */ @Test - void buildsXmlResponseFromNegativeCondition() throws IOException { + void buildsXmlResponseFromNegativeCondition() throws Exception { MatcherAssert.assertThat( IOUtils.toString( new RsXembly( From ae3c15cf3b52adeb099682085b83eb86ed10df1c Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Mon, 15 Nov 2021 08:45:50 +0300 Subject: [PATCH 16/16] #1094 new parent --- pom.xml | 9 +-------- src/main/java/org/takes/rq/multipart/RqMtFake.java | 1 - src/site/site.xml | 8 ++++---- src/test/java/org/takes/http/BkBasicTest.java | 5 ++--- src/test/java/org/takes/http/FtBasicTest.java | 4 ++-- src/test/java/org/takes/rq/multipart/RqMtFakeTest.java | 5 ++--- src/test/java/org/takes/rs/RsXsltTest.java | 5 +++-- src/test/java/org/takes/tk/TkSlf4jRemoteTest.java | 4 ++-- 8 files changed, 16 insertions(+), 25 deletions(-) diff --git a/pom.xml b/pom.xml index 3dcadcd03..ab5b21ab5 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ SOFTWARE. com.jcabi parent - 0.49.1 + 0.56.0 org.takes takes @@ -221,11 +221,6 @@ SOFTWARE. 9.7.0-7 test - - org.hibernate - hibernate-validator - test - javax.el javax.el-api @@ -311,7 +306,6 @@ SOFTWARE. maven-surefire-plugin - 3.0.0-M5