Skip to content

Commit

Permalink
fixed trivial warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
wipu committed Nov 17, 2024
1 parent 9327e30 commit 6442ef5
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<JavaModule> junitJupiterModules() {
// TODO rm redundancy between this and WorkspaceDefinitionContextImpl
Set<JavaModule> deps = new LinkedHashSet<>();
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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"));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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 ",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<File> cachedAnts = new ArrayList<>();
cachedAnts.add(ctx.cached(antJar));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -229,7 +230,8 @@ private List<String> mainArgsToUse(TargetEvaluationContext ctx)
private static List<String> mainArgsFromFile(File argumentsFile)
throws IOException {
List<String> lines = new ArrayList<>();
for (Object line : FileUtils.readLines(argumentsFile)) {
for (Object line : FileUtils.readLines(argumentsFile,
StandardCharsets.UTF_8)) {
lines.add((String) line);
}
return lines;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -8,8 +10,6 @@

import org.fluentjava.iwant.entry.Iwant;

import junit.framework.Assert;

public final class TestArea {

private final File testArea;
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 6442ef5

Please sign in to comment.