Package org.apache.james.managesieve.api

Examples of org.apache.james.managesieve.api.SieveRepository


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

        // Authorised - non-existent script
        success = false;
        session.setAuthentication(true);
        session.setUser("test");
        try {
            core.deleteScript("script");
        } catch (ScriptNotFoundException ex) {
            success = true;
        }
        assertTrue("Expected ScriptNotFoundException", success);
       
        // Authorised - existent script
        session.setAuthentication(true);
        session.setUser("test");
        repository.putScript("test", "script", "content");
        core.deleteScript("script");
        success = false;
        try {
            repository.getScript("test", "script");
        } catch (ScriptNotFoundException ex) {
            success = true;
        }
        assertTrue("Expected ScriptNotFoundException", success);
       
        // Authorised - active script
        success = false;
        session.setAuthentication(true);
        session.setUser("test");
        repository.putScript("test", "script", "content");
        repository.setActive("test", "script");
        try {
            core.deleteScript("script");
        } catch (IsActiveException ex) {
            success = true;
        }
View Full Code Here


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

        // Authorised - non-existent script
        success = false;
        session.setAuthentication(true);
        session.setUser("test");
        try {
            core.getScript("script");
        } catch (ScriptNotFoundException ex) {
            success = true;
        }
        assertTrue("Expected ScriptNotFoundException", success);
       
        // Authorised - existent script
        session.setAuthentication(true);
        session.setUser("test");
        repository.putScript("test", "script", "content");
        core.getScript("script");
    }
View Full Code Here

     * @throws AuthenticationRequiredException
     */
    @Test
    public final void testHaveSpace() throws QuotaExceededException, AuthenticationRequiredException {
        MockSession session = new MockSession();
        SieveRepository repository = new MockSieveRepository();
        CoreProcessor core = new CoreProcessor(session, repository, new MockSieveParser());
       
        // Unauthorised
        boolean success = false;
        session.setAuthentication(false);
View Full Code Here

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

        // Authorised - non-existent script
        success = false;
        session.setAuthentication(true);
        session.setUser("test");
        List<ScriptSummary> summaries = core.listScripts();
        assertTrue(summaries.isEmpty());
       
        // Authorised - existent script
        session.setAuthentication(true);
        session.setUser("test");
        repository.putScript("test", "script", "content");
        summaries = core.listScripts();
        assertEquals(1, summaries.size());
    }
View Full Code Here

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

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

     * @throws UserNotFoundException
     */
    @Test
    public final void testRenameScript() throws ScriptNotFoundException, IsActiveException, DuplicateException, AuthenticationRequiredException, SyntaxException, QuotaExceededException, UserNotFoundException, StorageException {
        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.renameScript("oldName", "newName");
        } catch (AuthenticationRequiredException ex) {
            success = true;
        }
        assertTrue("Expected AuthenticationRequiredException", success);

        // Authorised
        success = false;
        session.setAuthentication(true);
        session.setUser("test");
        repository.putScript("test", "oldName", "content");
        core.renameScript("oldName", "newName");
        assertEquals("content", repository.getScript("test", "oldName"));
    }
View Full Code Here

     * @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.api.SieveRepository

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.