From 6442ef5a874af40d2ca84127aab3c8ce748e7b13 Mon Sep 17 00:00:00 2001 From: Ville Oikarinen Date: Sun, 17 Nov 2024 16:11:30 +0200 Subject: [PATCH] fixed trivial warnings --- .../org/fluentjava/iwant/wsdef/IwantModules.java | 15 ++++++--------- .../iwantwsrootfinder/IwantWsRootFinderTest.java | 8 +++++--- .../fluentjava/iwant/plannermocks/TaskMock.java | 6 +++--- .../iwant/plugin/findbugs/FindbugsReport.java | 4 +++- .../iwant/plugin/findbugs/FindbugsReportTest.java | 4 +++- .../iwant/plugin/jacoco/JacocoCoverage.java | 4 +++- .../fluentjava/iwant/plugin/pmd/PmdReport.java | 4 +++- .../fluentjava/iwant/plugin/pmd/PmdTestBase.java | 4 +++- .../org/fluentjava/iwant/testarea/TestArea.java | 8 ++++---- .../iwant/tests/PlannerMicrobenchmarkTest.java | 3 ++- 10 files changed, 35 insertions(+), 25 deletions(-) diff --git a/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java b/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java index 42fe6cf4..5798f300 100644 --- a/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java +++ b/as-iwant-developer/i-have/wsdef/src/main/java/org/fluentjava/iwant/wsdef/IwantModules.java @@ -108,10 +108,6 @@ private IwantSrcModuleSpex module(String fullName) { .name("jaxen").version("2.0.0").jar()) .end(); - private static final JavaModule junit() { - return JavaBinModule.providing(TestedIwantDependencies.junit()).end(); - } - private static final Set junitJupiterModules() { // TODO rm redundancy between this and WorkspaceDefinitionContextImpl Set deps = new LinkedHashSet<>(); @@ -219,7 +215,7 @@ private JavaSrcModule iwantIwantWsrootFinder() { private JavaSrcModule iwantTestarea() { return lazy(() -> privateModule("testarea").noTestJava() - .mainDeps(iwantEntry(), junit()).end()); + .mainDeps(iwantEntry()).mainDeps(junitJupiterModules()).end()); } private JavaSrcModule iwantEntrymocks() { @@ -319,7 +315,8 @@ private JavaSrcModule iwantPlannerApi() { private JavaSrcModule iwantPlannerMocks() { return lazy(() -> essentialModule("planner-mocks").noTestJava() - .mainDeps(iwantPlannerApi(), junit()).end()); + .mainDeps(iwantPlannerApi()).mainDeps(junitJupiterModules()) + .end()); } private JavaSrcModule iwantPlanner() { @@ -500,9 +497,9 @@ private JavaSrcModule iwantTutorialWsdefs() { iwantEclipseSettings(), iwantPluginAnt(), iwantPluginFindbugs(), iwantPluginGithub(), iwantPluginJacoco(), iwantPluginPmd(), - iwantPluginTestng(), iwantPluginWar(), junit(), - scalaLibrary, testng) - .end()); + iwantPluginTestng(), iwantPluginWar(), scalaLibrary, + testng) + .mainDeps(junitJupiterModules()).end()); } private final Target extendedIwantEnumsJava = new ExtendedIwantEnums( diff --git a/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java b/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java index 7485063d..8bce95aa 100644 --- a/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java +++ b/essential/iwant-iwant-wsroot-finder/src/test/java/org/fluentjava/iwant/iwantwsrootfinder/IwantWsRootFinderTest.java @@ -4,6 +4,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; import org.junit.jupiter.api.Test; @@ -16,8 +17,8 @@ public void knownFileIsFoundUnderWsRoot() throws IOException { "as-iwant-developer/i-have/conf/ws-info"); assertTrue(wsInfo.exists()); - assertTrue( - FileUtils.readFileToString(wsInfo).contains("WSNAME=iwant\n")); + assertTrue(FileUtils.readFileToString(wsInfo, StandardCharsets.UTF_8) + .contains("WSNAME=iwant\n")); } @Test @@ -27,7 +28,8 @@ public void knownFileIsFoundUnderMockEssential() throws IOException { + "org/fluentjava/iwant/api/wsdef/MockedApiWsdef.java"); assertTrue(mockedApiWsdef.exists()); - assertTrue(FileUtils.readFileToString(mockedApiWsdef) + assertTrue(FileUtils + .readFileToString(mockedApiWsdef, StandardCharsets.UTF_8) .contains("public class MockedApiWsdef")); } diff --git a/essential/iwant-planner-mocks/src/main/java/org/fluentjava/iwant/plannermocks/TaskMock.java b/essential/iwant-planner-mocks/src/main/java/org/fluentjava/iwant/plannermocks/TaskMock.java index 6d37cdb2..7821efe5 100644 --- a/essential/iwant-planner-mocks/src/main/java/org/fluentjava/iwant/plannermocks/TaskMock.java +++ b/essential/iwant-planner-mocks/src/main/java/org/fluentjava/iwant/plannermocks/TaskMock.java @@ -1,5 +1,7 @@ package org.fluentjava.iwant.plannermocks; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -11,8 +13,6 @@ import org.fluentjava.iwant.plannerapi.Task; import org.fluentjava.iwant.plannerapi.TaskDirtiness; -import junit.framework.Assert; - public class TaskMock implements Task { private final String name; @@ -100,7 +100,7 @@ public void shallEventuallyStartRefresh( throw new IllegalStateException(e); } } - Assert.assertEquals(Arrays.toString(expectedAllocatedResource), + assertEquals(Arrays.toString(expectedAllocatedResource), allocatedResources.values().toString()); } log(this, "did eventually start refresh with ", diff --git a/optional/iwant-plugin-findbugs/src/main/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReport.java b/optional/iwant-plugin-findbugs/src/main/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReport.java index 62902140..0df05368 100644 --- a/optional/iwant-plugin-findbugs/src/main/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReport.java +++ b/optional/iwant-plugin-findbugs/src/main/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReport.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -170,7 +171,8 @@ public void path(TargetEvaluationContext ctx) throws Exception { Iwant.mkdirs(dest); File buildXml = new File(dest, "build.xml"); - FileUtils.writeStringToFile(buildXml, antScript(ctx)); + FileUtils.writeStringToFile(buildXml, antScript(ctx), + StandardCharsets.UTF_8); List cachedAnts = new ArrayList<>(); cachedAnts.add(ctx.cached(antJar)); diff --git a/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java b/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java index 3eee252f..352abc79 100644 --- a/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java +++ b/optional/iwant-plugin-findbugs/src/test/java/org/fluentjava/iwant/plugin/findbugs/FindbugsReportTest.java @@ -7,6 +7,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; import org.fluentjava.iwant.api.javamodules.JavaBinModule; @@ -72,7 +73,8 @@ protected String reportContent(Target report, String extension) if (!reportFile.exists()) { return null; } - String reportFileContent = FileUtils.readFileToString(reportFile); + String reportFileContent = FileUtils.readFileToString(reportFile, + StandardCharsets.UTF_8); return reportFileContent; } diff --git a/optional/iwant-plugin-jacoco/src/main/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverage.java b/optional/iwant-plugin-jacoco/src/main/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverage.java index b08e642c..11f51ef3 100644 --- a/optional/iwant-plugin-jacoco/src/main/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverage.java +++ b/optional/iwant-plugin-jacoco/src/main/java/org/fluentjava/iwant/plugin/jacoco/JacocoCoverage.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -229,7 +230,8 @@ private List mainArgsToUse(TargetEvaluationContext ctx) private static List mainArgsFromFile(File argumentsFile) throws IOException { List lines = new ArrayList<>(); - for (Object line : FileUtils.readLines(argumentsFile)) { + for (Object line : FileUtils.readLines(argumentsFile, + StandardCharsets.UTF_8)) { lines.add((String) line); } return lines; diff --git a/optional/iwant-plugin-pmd/src/main/java/org/fluentjava/iwant/plugin/pmd/PmdReport.java b/optional/iwant-plugin-pmd/src/main/java/org/fluentjava/iwant/plugin/pmd/PmdReport.java index 1af8a15e..33b01544 100644 --- a/optional/iwant-plugin-pmd/src/main/java/org/fluentjava/iwant/plugin/pmd/PmdReport.java +++ b/optional/iwant-plugin-pmd/src/main/java/org/fluentjava/iwant/plugin/pmd/PmdReport.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -132,7 +133,8 @@ private File rulesetFile(TargetEvaluationContext ctx, File dest) private File generatedRuleset(File dest) throws IOException { File generated = new File(dest, "ruleset.xml"); - FileUtils.writeStringToFile(generated, rulesetXml()); + FileUtils.writeStringToFile(generated, rulesetXml(), + StandardCharsets.UTF_8); return generated; } diff --git a/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdTestBase.java b/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdTestBase.java index 7b2a273a..e90db701 100644 --- a/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdTestBase.java +++ b/optional/iwant-plugin-pmd/src/test/java/org/fluentjava/iwant/plugin/pmd/PmdTestBase.java @@ -2,6 +2,7 @@ import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import org.apache.commons.io.FileUtils; import org.fluentjava.iwant.api.model.Target; @@ -25,7 +26,8 @@ protected String reportContent(Target report, String extension) if (!reportFile.exists()) { return null; } - String reportFileContent = FileUtils.readFileToString(reportFile); + String reportFileContent = FileUtils.readFileToString(reportFile, + StandardCharsets.UTF_8); return reportFileContent; } diff --git a/private/iwant-testarea/src/main/java/org/fluentjava/iwant/testarea/TestArea.java b/private/iwant-testarea/src/main/java/org/fluentjava/iwant/testarea/TestArea.java index 1088d8fc..a7f7cbec 100644 --- a/private/iwant-testarea/src/main/java/org/fluentjava/iwant/testarea/TestArea.java +++ b/private/iwant-testarea/src/main/java/org/fluentjava/iwant/testarea/TestArea.java @@ -1,5 +1,7 @@ package org.fluentjava.iwant.testarea; +import static org.junit.jupiter.api.Assertions.assertEquals; + import java.io.File; import java.io.FileReader; import java.io.FileWriter; @@ -8,8 +10,6 @@ import org.fluentjava.iwant.entry.Iwant; -import junit.framework.Assert; - public final class TestArea { private final File testArea; @@ -144,8 +144,8 @@ private static File tryToWriteTextFile(File file, String content) public void shallContainFragmentIn(String path, String fragment) { String actual = contentOf(path); if (!actual.contains(fragment)) { - Assert.assertEquals( - "File " + path + "\nshould contain:\n" + fragment, actual); + assertEquals("File " + path + "\nshould contain:\n" + fragment, + actual); } } diff --git a/private/iwant-tests/src/test/java/org/fluentjava/iwant/tests/PlannerMicrobenchmarkTest.java b/private/iwant-tests/src/test/java/org/fluentjava/iwant/tests/PlannerMicrobenchmarkTest.java index a5cb500d..b61df3c7 100644 --- a/private/iwant-tests/src/test/java/org/fluentjava/iwant/tests/PlannerMicrobenchmarkTest.java +++ b/private/iwant-tests/src/test/java/org/fluentjava/iwant/tests/PlannerMicrobenchmarkTest.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import java.io.File; +import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -150,7 +151,7 @@ public void path(TargetEvaluationContext ctx) throws Exception { for (T dep : deps) { File cachedDep = ctx.cached(dep); FileUtils.writeStringToFile(new File(dest, dep.name()), - cachedDep.getAbsolutePath()); + cachedDep.getAbsolutePath(), StandardCharsets.UTF_8); } targetRefreshCount.incrementAndGet(); }