Skip to content

Commit

Permalink
Minor regression fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
essiembre committed Aug 14, 2023
1 parent adf048b commit 61f058e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/norconex/commons/lang/map/Properties.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.set.ListOrderedSet;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.input.ReaderInputStream;
import org.apache.commons.io.output.WriterOutputStream;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -716,7 +715,8 @@ private synchronized void loadFromJavaUtilProperties(

if (input instanceof Reader reader) {
if (isXML) {
p.loadFromXML(new ReaderInputStream(reader, UTF_8));
p.loadFromXML(IOUtils.toInputStream(
IOUtils.toString(reader), UTF_8));
} else {
p.load(reader);
}
Expand Down
38 changes: 19 additions & 19 deletions src/test/java/com/norconex/commons/lang/exec/SystemCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ class SystemCommandTest {

@Test
void testInFileOutFile() throws IOException, SystemCommandException {
File inFile = inputAsFile();
File outFile = newTempFile();
var inFile = inputAsFile();
var outFile = newTempFile();

SystemCommand cmd = ExternalApp.newSystemCommand(
var cmd = ExternalApp.newSystemCommand(
ExternalApp.TYPE_INFILE_OUTFILE, inFile, outFile);
ExternalAppListener l = addEnvAndListener(cmd);
var l = addEnvAndListener(cmd);
cmd.execute();

Assertions.assertEquals(
Expand All @@ -63,11 +63,11 @@ void testInFileOutFile() throws IOException, SystemCommandException {

@Test
void testInFileStdout() throws IOException, SystemCommandException {
File inFile = inputAsFile();
var inFile = inputAsFile();

SystemCommand cmd = ExternalApp.newSystemCommand(
var cmd = ExternalApp.newSystemCommand(
ExternalApp.TYPE_INFILE_STDOUT, inFile);
ExternalAppListener l = addEnvAndListener(cmd);
var l = addEnvAndListener(cmd);
cmd.execute();
Assertions.assertEquals(expectedOutputAsString(), l.getStdoutContent());
Assertions.assertTrue(
Expand All @@ -76,12 +76,12 @@ void testInFileStdout() throws IOException, SystemCommandException {

@Test
void testStdinOutFile() throws IOException, SystemCommandException {
InputStream input = inputAsStream();
File outFile = newTempFile();
var input = inputAsStream();
var outFile = newTempFile();

SystemCommand cmd = ExternalApp.newSystemCommand(
var cmd = ExternalApp.newSystemCommand(
ExternalApp.TYPE_STDIN_OUTFILE, outFile);
ExternalAppListener l = addEnvAndListener(cmd);
var l = addEnvAndListener(cmd);
cmd.execute(input);
input.close();
Assertions.assertEquals(expectedOutputAsString(), fileAsString(outFile));
Expand All @@ -91,10 +91,10 @@ void testStdinOutFile() throws IOException, SystemCommandException {

@Test
void testStdinStdout() throws IOException, SystemCommandException {
InputStream input = inputAsStream();
SystemCommand cmd = ExternalApp.newSystemCommand(
var input = inputAsStream();
var cmd = ExternalApp.newSystemCommand(
ExternalApp.TYPE_STDIN_STDOUT);
ExternalAppListener l = addEnvAndListener(cmd);
var l = addEnvAndListener(cmd);
cmd.execute(input);
input.close();
Assertions.assertEquals(expectedOutputAsString(), l.getStdoutContent());
Expand All @@ -104,9 +104,9 @@ void testStdinStdout() throws IOException, SystemCommandException {

@Test
void testDefaultsNullErrors() {
SystemCommand cmd = new SystemCommand("blah");
var cmd = new SystemCommand("blah");

ExternalAppListener l = addEnvAndListener(cmd);
var l = addEnvAndListener(cmd);
assertThat(cmd.getOutputListeners()).hasSize(1);
assertThat(cmd.getErrorListeners()).hasSize(1);
cmd.removeOutputListener(l);
Expand Down Expand Up @@ -134,7 +134,7 @@ void testDefaultsNullErrors() {
}

private File inputAsFile() throws IOException {
File inFile = newTempFile();
var inFile = newTempFile();
FileUtils.copyInputStreamToFile(
getClass().getResourceAsStream(IN_FILE_PATH), inFile);
return inFile;
Expand All @@ -150,7 +150,7 @@ private String expectedOutputAsString() throws IOException {
EXPECTED_OUT_FILE_PATH), StandardCharsets.UTF_8);
}
private File newTempFile() throws IOException {
File file = Files.createTempFile(
var file = Files.createTempFile(
tempFolder, "SystemCommandTest", null).toFile();
if (!file.exists()) {
// Just making sure it exists
Expand All @@ -167,7 +167,7 @@ private ExternalAppListener addEnvAndListener(SystemCommand cmd) {
envs.put(ExternalApp.ENV_STDERR_AFTER, ExternalApp.ENV_STDERR_AFTER);
cmd.setEnvironmentVariables(envs);

ExternalAppListener l = new ExternalAppListener();
var l = new ExternalAppListener();
cmd.addErrorListener(l);
cmd.addOutputListener(l);
return l;
Expand Down

0 comments on commit 61f058e

Please sign in to comment.