Migrate to JUnit5
This commit is contained in:
		@@ -22,9 +22,9 @@
 | 
			
		||||
 */
 | 
			
		||||
package com.iluwatar.execute.around;
 | 
			
		||||
 | 
			
		||||
import org.junit.After;
 | 
			
		||||
import org.junit.Before;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
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;
 | 
			
		||||
@@ -42,8 +42,8 @@ public class AppTest {
 | 
			
		||||
    App.main(args);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @Before
 | 
			
		||||
  @After
 | 
			
		||||
  @BeforeEach
 | 
			
		||||
  @AfterEach
 | 
			
		||||
  public void cleanup() {
 | 
			
		||||
    File file = new File("testfile.txt");
 | 
			
		||||
    file.delete();
 | 
			
		||||
 
 | 
			
		||||
@@ -22,23 +22,26 @@
 | 
			
		||||
 */
 | 
			
		||||
package com.iluwatar.execute.around;
 | 
			
		||||
 | 
			
		||||
import org.junit.Assert;
 | 
			
		||||
import org.junit.Rule;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
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.Assert.assertFalse;
 | 
			
		||||
import static org.junit.Assert.assertTrue;
 | 
			
		||||
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
 | 
			
		||||
 *
 | 
			
		||||
 * @author Jeroen Meulemeester
 | 
			
		||||
 */
 | 
			
		||||
@EnableRuleMigrationSupport
 | 
			
		||||
public class SimpleFileWriterTest {
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
@@ -53,7 +56,7 @@ public class SimpleFileWriterTest {
 | 
			
		||||
  @Test
 | 
			
		||||
  public void testWriterNotNull() throws Exception {
 | 
			
		||||
    final File temporaryFile = this.testFolder.newFile();
 | 
			
		||||
    new SimpleFileWriter(temporaryFile.getPath(), Assert::assertNotNull);
 | 
			
		||||
    new SimpleFileWriter(temporaryFile.getPath(), Assertions::assertNotNull);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /**
 | 
			
		||||
@@ -64,7 +67,7 @@ public class SimpleFileWriterTest {
 | 
			
		||||
    final File nonExistingFile = new File(this.testFolder.getRoot(), "non-existing-file");
 | 
			
		||||
    assertFalse(nonExistingFile.exists());
 | 
			
		||||
 | 
			
		||||
    new SimpleFileWriter(nonExistingFile.getPath(), Assert::assertNotNull);
 | 
			
		||||
    new SimpleFileWriter(nonExistingFile.getPath(), Assertions::assertNotNull);
 | 
			
		||||
    assertTrue(nonExistingFile.exists());
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@@ -85,11 +88,13 @@ public class SimpleFileWriterTest {
 | 
			
		||||
  /**
 | 
			
		||||
   * Verify if an {@link IOException} during the write ripples through
 | 
			
		||||
   */
 | 
			
		||||
  @Test(expected = IOException.class)
 | 
			
		||||
  @Test
 | 
			
		||||
  public void testIoException() throws Exception {
 | 
			
		||||
    final File temporaryFile = this.testFolder.newFile();
 | 
			
		||||
    new SimpleFileWriter(temporaryFile.getPath(), writer -> {
 | 
			
		||||
      throw new IOException("");
 | 
			
		||||
    assertThrows(IOException.class, () -> {
 | 
			
		||||
      final File temporaryFile = this.testFolder.newFile();
 | 
			
		||||
      new SimpleFileWriter(temporaryFile.getPath(), writer -> {
 | 
			
		||||
        throw new IOException("");
 | 
			
		||||
      });
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user