*/
@Test
public final void testGetActive() throws ScriptNotFoundException,
AuthenticationRequiredException, UserNotFoundException, StorageException,
QuotaExceededException {
MockSession session = new MockSession();
SieveRepository repository = new MockSieveRepository();
CoreProcessor core = new CoreProcessor(session, repository, new MockSieveParser());
// Unauthorised
boolean success = false;
session.setAuthentication(false);
try {
core.getActive();
} catch (AuthenticationRequiredException ex) {
success = true;
}
assertTrue("Expected AuthenticationRequiredException", success);
// Authorised - non-existent script
success = false;
session.setAuthentication(true);
session.setUser("test");
try {
core.getActive();
} catch (ScriptNotFoundException ex) {
success = true;
}
assertTrue("Expected ScriptNotFoundException", success);
// Authorised - existent script, inactive
session.setAuthentication(true);
session.setUser("test");
repository.putScript("test", "script", "content");
try {
core.getActive();
} catch (ScriptNotFoundException ex) {
success = true;
}
assertTrue("Expected ScriptNotFoundException", success);
// Authorised - existent script, active
session.setAuthentication(true);
session.setUser("test");
repository.setActive("test", "script");
core.getActive();
}