Java 11 migrate remaining e (#1112)
* Moves eip-aggregator to Java 11 * Moves eip-message-channel to Java 11 * Moves eip-publish-subscribe to Java 11 * Moves eip-splitter to Java 11 * Moves eip-wire-tap to Java 11 * Moves event-aggregator to Java 11 * Moves event-asynchronous to Java 11 * Moves event-driven-architecture to Java 11 * Moves event-queue to Java 11 * Moves event-sourcing to Java 11 * Moves execute-around to Java 11 * Moves extension-objects to Java 11
This commit is contained in:
committed by
Ilkka Seppälä
parent
b09b100614
commit
fb2c026822
@ -36,7 +36,7 @@ public class SimpleFileWriter {
|
||||
* Constructor.
|
||||
*/
|
||||
public SimpleFileWriter(String filename, FileWriterAction action) throws IOException {
|
||||
try (FileWriter writer = new FileWriter(filename)) {
|
||||
try (var writer = new FileWriter(filename)) {
|
||||
action.writeFile(writer);
|
||||
}
|
||||
}
|
||||
|
@ -23,30 +23,26 @@
|
||||
|
||||
package com.iluwatar.execute.around;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
*
|
||||
* Tests execute-around example.
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
public void test() throws IOException {
|
||||
String[] args = {};
|
||||
App.main(args);
|
||||
App.main(new String[]{});
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@AfterEach
|
||||
public void cleanup() {
|
||||
File file = new File("testfile.txt");
|
||||
var file = new File("testfile.txt");
|
||||
file.delete();
|
||||
}
|
||||
}
|
||||
|
@ -23,20 +23,19 @@
|
||||
|
||||
package com.iluwatar.execute.around;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import org.junit.Rule;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.migrationsupport.rules.EnableRuleMigrationSupport;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/**
|
||||
* Date: 12/12/15 - 3:21 PM
|
||||
*
|
||||
@ -50,13 +49,13 @@ public class SimpleFileWriterTest {
|
||||
|
||||
@Test
|
||||
public void testWriterNotNull() throws Exception {
|
||||
final File temporaryFile = this.testFolder.newFile();
|
||||
final var temporaryFile = this.testFolder.newFile();
|
||||
new SimpleFileWriter(temporaryFile.getPath(), Assertions::assertNotNull);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreatesNonExistentFile() throws Exception {
|
||||
final File nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
|
||||
final var nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
|
||||
assertFalse(nonExistingFile.exists());
|
||||
|
||||
new SimpleFileWriter(nonExistingFile.getPath(), Assertions::assertNotNull);
|
||||
@ -65,9 +64,9 @@ public class SimpleFileWriterTest {
|
||||
|
||||
@Test
|
||||
public void testContentsAreWrittenToFile() throws Exception {
|
||||
final String testMessage = "Test message";
|
||||
final var testMessage = "Test message";
|
||||
|
||||
final File temporaryFile = this.testFolder.newFile();
|
||||
final var temporaryFile = this.testFolder.newFile();
|
||||
assertTrue(temporaryFile.exists());
|
||||
|
||||
new SimpleFileWriter(temporaryFile.getPath(), writer -> writer.write(testMessage));
|
||||
@ -76,9 +75,9 @@ public class SimpleFileWriterTest {
|
||||
|
||||
@Test
|
||||
public void testRipplesIoExceptionOccurredWhileWriting() {
|
||||
String message = "Some error";
|
||||
var message = "Some error";
|
||||
assertThrows(IOException.class, () -> {
|
||||
final File temporaryFile = this.testFolder.newFile();
|
||||
final var temporaryFile = this.testFolder.newFile();
|
||||
new SimpleFileWriter(temporaryFile.getPath(), writer -> {
|
||||
throw new IOException(message);
|
||||
});
|
||||
|
Reference in New Issue
Block a user