Package org.apache.james.managesieve.mock

Examples of org.apache.james.managesieve.mock.MockSieveRepository


     * @throws UserNotFoundException
     */
    @Test
    public final void testSetActive() 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.setActive("script");
        } catch (AuthenticationRequiredException ex) {
            success = true;
        }
        assertTrue("Expected AuthenticationRequiredException", success);

        // Authorised
        success = false;
        session.setAuthentication(true);
        session.setUser("test");
        repository.putScript("test", "script", "content");
        core.setActive("script");
        assertEquals("content", repository.getActive("test"));
    }
View Full Code Here


    @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();
    }
View Full Code Here

TOP

Related Classes of org.apache.james.managesieve.mock.MockSieveRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.