Search in sources :

Example 11 with BeforeEach

use of org.junit.jupiter.api.BeforeEach in project java-design-patterns by iluwatar.

the class AppTest method cleanup.

@BeforeEach
@AfterEach
public void cleanup() {
    File file1 = new File("fish1.out");
    file1.delete();
    File file2 = new File("fish2.out");
    file2.delete();
}
Also used : File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach) AfterEach(org.junit.jupiter.api.AfterEach)

Example 12 with BeforeEach

use of org.junit.jupiter.api.BeforeEach in project java-design-patterns by iluwatar.

the class DispatcherTest method setUp.

/**
 * Dispatcher is a singleton with no way to reset it's internal state back to the beginning.
 * Replace the instance with a fresh one before each test to make sure test cases have no
 * influence on each other.
 */
@BeforeEach
public void setUp() throws Exception {
    final Constructor<Dispatcher> constructor;
    constructor = Dispatcher.class.getDeclaredConstructor();
    constructor.setAccessible(true);
    final Field field = Dispatcher.class.getDeclaredField("instance");
    field.setAccessible(true);
    field.set(Dispatcher.getInstance(), constructor.newInstance());
}
Also used : Field(java.lang.reflect.Field) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 13 with BeforeEach

use of org.junit.jupiter.api.BeforeEach in project java-design-patterns by iluwatar.

the class MongoBankTest method init.

@BeforeEach
public void init() {
    MongoConnectionPropertiesLoader.load();
    MongoClient mongoClient = new MongoClient(System.getProperty("mongo-host"), Integer.parseInt(System.getProperty("mongo-port")));
    mongoClient.dropDatabase(TEST_DB);
    mongoClient.close();
    mongoBank = new MongoBank(TEST_DB, TEST_ACCOUNTS_COLLECTION);
}
Also used : MongoClient(com.mongodb.MongoClient) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

BeforeEach (org.junit.jupiter.api.BeforeEach)13 TestFileManager (io.github.vocabhunter.test.utils.TestFileManager)6 MongoClient (com.mongodb.MongoClient)3 Path (java.nio.file.Path)3 File (java.io.File)2 AfterEach (org.junit.jupiter.api.AfterEach)2 AbstractModule (com.google.inject.AbstractModule)1 Module (com.google.inject.Module)1 GuiTaskHandler (io.github.vocabhunter.analysis.core.GuiTaskHandler)1 FileListManager (io.github.vocabhunter.analysis.settings.FileListManager)1 FileListManagerImpl (io.github.vocabhunter.analysis.settings.FileListManagerImpl)1 Placement (io.github.vocabhunter.gui.common.Placement)1 FileDialogueFactory (io.github.vocabhunter.gui.dialogues.FileDialogueFactory)1 EnvironmentManager (io.github.vocabhunter.gui.services.EnvironmentManager)1 PlacementManager (io.github.vocabhunter.gui.services.PlacementManager)1 WebPageTool (io.github.vocabhunter.gui.services.WebPageTool)1 SettingsManager (io.github.vocabhunter.gui.settings.SettingsManager)1 SettingsManagerImpl (io.github.vocabhunter.gui.settings.SettingsManagerImpl)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1