Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/de/cuioss/tools/io/FileLoaderUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.StringWriter;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -99,7 +98,7 @@ public static Path copyFileToTemp(final FileLoader source, final boolean markDel
final Path target = PathTraversalSecurity.createSecureTempFile(namePart, null != suffix ? "." + suffix : null);

try (final var inputStream = source.inputStream()) {
Files.copy(new BufferedInputStream(inputStream), target, StandardCopyOption.REPLACE_EXISTING);
Files.copy(inputStream, target, StandardCopyOption.REPLACE_EXISTING);
}
if (markDeleteOnExit) {
target.toFile().deleteOnExit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ void shouldCopySourceMapForImmutableMap() {
@DisplayName("Should handle stream to immutable map conversion")
void shouldHandleStreamToImmutableMap() {
final Map<String, String> result = immutableMap(
immutableMap("1", "1-1", "2", "").entrySet().stream().filter(entry -> !"".equals(entry.getValue())));
immutableMap("1", "1-1", "2", "").entrySet().stream().filter(entry -> !entry.getValue().isEmpty()));
assertEquals(1, result.size());
assertTrue(result.containsKey("1"));
}
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/de/cuioss/tools/io/FileSystemLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
package de.cuioss.tools.io;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.junit.jupiter.api.Assertions.*;
Expand Down Expand Up @@ -134,10 +136,9 @@ void shouldFailToLoadNotExistingFile() {
}

@Test
void shouldHandleOutputStreamForWritableFile() throws Exception {
// Create a temporary file for testing
File tempFile = File.createTempFile("test", ".txt");
tempFile.deleteOnExit();
void shouldHandleOutputStreamForWritableFile(@TempDir Path tempDir) throws Exception {
// Create a temporary file inside the JUnit-managed temp directory (auto-cleaned)
File tempFile = Files.createFile(tempDir.resolve("test.txt")).toFile();

var loader = new FileSystemLoader(tempFile.getAbsolutePath());
assertTrue(loader.isWritable());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public Class<byte[]> getType() {
}

private static void generateTestData(final OutputStream out, final long size) throws IOException {
for (var i = 0; i < size; i++) {
for (long i = 0; i < size; i++) {
// nice varied byte pattern compatible with Readers and Writers
out.write((byte) (i % 127 + 1));
}
Expand Down