use of org.apache.isis.core.runtime.authentication.standard.SimpleSession in project estatio by estatio.
the class FakeScheduler method runBackgroundCommands.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
public void runBackgroundCommands(@ParameterLayout(named = "Wait for (ms)") final Integer waitFor) throws InterruptedException {
List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
if (commands.isEmpty()) {
throw new IllegalStateException("There are no commands not yet started");
}
transactionService.nextTransaction();
BackgroundCommandExecutionFromBackgroundCommandServiceJdo backgroundExec = new BackgroundCommandExecutionFromBackgroundCommandServiceJdo();
final SimpleSession session = new SimpleSession("scheduler_user", new String[] { "admin_role" });
final Thread thread = new Thread(() -> backgroundExec.execute(session, null));
thread.start();
thread.join(waitFor);
commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
if (!commands.isEmpty()) {
throw new IllegalStateException("There are still " + commands.size() + " not yet started");
}
}
use of org.apache.isis.core.runtime.authentication.standard.SimpleSession in project estatio by estatio.
the class RunBackgroundCommandsService method runBackgroundCommands.
@Programmatic
public void runBackgroundCommands() throws InterruptedException {
List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
assertThat(commands).hasSize(1);
transactionService.nextTransaction();
BackgroundCommandExecutionFromBackgroundCommandServiceJdo backgroundExec = new BackgroundCommandExecutionFromBackgroundCommandServiceJdo();
final SimpleSession session = new SimpleSession("scheduler_user", new String[] { "admin_role" });
final Thread thread = new Thread(() -> backgroundExec.execute(session, null));
thread.start();
thread.join(5000L);
commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
assertThat(commands).isEmpty();
}
use of org.apache.isis.core.runtime.authentication.standard.SimpleSession in project estatio by estatio.
the class FakeScheduler method runBackgroundCommands.
@Action(semantics = SemanticsOf.NON_IDEMPOTENT)
public void runBackgroundCommands(@ParameterLayout(named = "Wait for (ms)") final Integer waitFor) throws InterruptedException {
List<CommandJdo> commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
if (commands.isEmpty()) {
throw new IllegalStateException("There are no commands not yet started");
}
transactionService.nextTransaction();
BackgroundCommandExecutionFromBackgroundCommandServiceJdo backgroundExec = new BackgroundCommandExecutionFromBackgroundCommandServiceJdo();
final SimpleSession session = new SimpleSession("scheduler_user", new String[] { "admin_role" });
final Thread thread = new Thread(() -> backgroundExec.execute(session, null));
thread.start();
thread.join(waitFor);
commands = backgroundCommandRepository.findBackgroundCommandsNotYetStarted();
if (!commands.isEmpty()) {
throw new IllegalStateException("There are still " + commands.size() + " not yet started");
}
}
Aggregations