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();
}
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());
}
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);
}
Aggregations