use of com.serotonin.m2m2.SimulationTimerProvider in project ma-core-public by MangoAutomation.
the class MangoTestBase method after.
@After
public void after() {
// Tear down to simulate some form of shutdown
for (Module module : ModuleRegistry.getModules()) {
module.postRuntimeManagerTerminate(false);
}
// Need to restart background processing and clear it out
Common.backgroundProcessing.terminate();
Common.backgroundProcessing.joinTermination();
for (Module module : ModuleRegistry.getModules()) {
module.postTerminate(false);
}
// Setup for next test in class
Common.eventManager.purgeAllEvents();
Common.backgroundProcessing = lifecycle.getBackgroundProcessing();
Common.backgroundProcessing.initialize(false);
SimulationTimerProvider provider = (SimulationTimerProvider) Providers.get(TimerProvider.class);
provider.reset();
// Clean the noSQL database
if (properties.getBoolean("tests.after.deleteAllPointData", true)) {
try {
Common.getBean(PointValueDao.class).deleteAllPointData();
} catch (UnsupportedOperationException e) {
LOG.warn("PointValueDao does not support deleteAllPointData() method. Your tests may be effected if you reuse this Mango lifecycle");
}
}
// Clear all caches in services
Common.getRuntimeContext().getBeansOfType(CachingService.class).values().forEach(s -> s.clearCaches(true));
DatabaseProxy databaseProxy = Common.getBean(DatabaseProxy.class);
// Try to release active connections if possible
if (databaseProxy instanceof BasePooledProxy) {
((BasePooledProxy) databaseProxy).softEvictConnections();
}
// Clean database
databaseProxy.clean();
}
use of com.serotonin.m2m2.SimulationTimerProvider in project ma-core-public by infiniteautomation.
the class MigrationPointValueDaoTest method getLifecycle.
@Override
protected MockMangoLifecycle getLifecycle() {
MockMangoLifecycle lifecycle = super.getLifecycle();
lifecycle.setTimer(new SimulationTimerProvider(new SimulationTimer(ZoneOffset.UTC)));
return lifecycle;
}
use of com.serotonin.m2m2.SimulationTimerProvider in project ma-core-public by infiniteautomation.
the class MangoTestBase method after.
@After
public void after() {
// Tear down to simulate some form of shutdown
for (Module module : ModuleRegistry.getModules()) {
module.postRuntimeManagerTerminate(false);
}
// Need to restart background processing and clear it out
Common.backgroundProcessing.terminate();
Common.backgroundProcessing.joinTermination();
for (Module module : ModuleRegistry.getModules()) {
module.postTerminate(false);
}
// Setup for next test in class
Common.eventManager.purgeAllEvents();
Common.backgroundProcessing = lifecycle.getBackgroundProcessing();
Common.backgroundProcessing.initialize(false);
SimulationTimerProvider provider = (SimulationTimerProvider) Providers.get(TimerProvider.class);
provider.reset();
// Clean the noSQL database
if (properties.getBoolean("tests.after.deleteAllPointData", true)) {
try {
Common.getBean(PointValueDao.class).deleteAllPointData();
} catch (UnsupportedOperationException e) {
LOG.warn("PointValueDao does not support deleteAllPointData() method. Your tests may be effected if you reuse this Mango lifecycle");
}
}
// Clear all caches in services
Common.getRuntimeContext().getBeansOfType(CachingService.class).values().forEach(s -> s.clearCaches(true));
DatabaseProxy databaseProxy = Common.getBean(DatabaseProxy.class);
// Try to release active connections if possible
if (databaseProxy instanceof BasePooledProxy) {
((BasePooledProxy) databaseProxy).softEvictConnections();
}
// Clean database
databaseProxy.clean();
}
use of com.serotonin.m2m2.SimulationTimerProvider in project ma-core-public by infiniteautomation.
the class MangoTestBase method before.
@Before
public void before() {
createTestDB();
// So it only happens once per class for now (problems with restarting lifecycle during a running JVM)
if (lifecycle == null) {
lifecycle = getLifecycle();
try {
lifecycle.initialize();
} catch (Exception e) {
throw new RuntimeException("Lifecycle failed to initialize", e);
}
} else {
// Re-initialize database
Common.getBean(DatabaseProxy.class).initialize();
// Lifecycle hook for things that need to run to install into a new database
for (Module module : ModuleRegistry.getModules()) {
module.postDatabase();
}
// Fix cached users for new database
Common.getBean(UsersService.class).clearCaches(false);
}
SimulationTimerProvider provider = (SimulationTimerProvider) Providers.get(TimerProvider.class);
this.timer = provider.getSimulationTimer();
}
use of com.serotonin.m2m2.SimulationTimerProvider in project ma-core-public by MangoAutomation.
the class MangoTestBase method before.
@Before
public void before() {
createTestDB();
// So it only happens once per class for now (problems with restarting lifecycle during a running JVM)
if (lifecycle == null) {
lifecycle = getLifecycle();
try {
lifecycle.initialize();
} catch (InterruptedException | ExecutionException e) {
fail(e.getMessage());
}
} else {
// Re-initialize database
Common.getBean(DatabaseProxy.class).initialize();
// Lifecycle hook for things that need to run to install into a new database
for (Module module : ModuleRegistry.getModules()) {
module.postDatabase();
}
// Fix cached users for new database
Common.getBean(UsersService.class).clearCaches(false);
}
SimulationTimerProvider provider = (SimulationTimerProvider) Providers.get(TimerProvider.class);
this.timer = provider.getSimulationTimer();
}
Aggregations