Package org.apache.james.managesieve.mock

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


     * @throws java.lang.Exception
     */
    @Before
    public void setUp() throws Exception {     
        _mailet = new ManageSieveMailet();
        _repository = new MockSieveRepository();
        _parser = new MockSieveParser();
        _mailet.setSieveParser(_parser);
        _mailet.setSieveRepository(_repository);
        MockMailetConfig config = new MockMailetConfig(new MockMailetContext());
        config.setInitParameter("helpURL", "file:./src/test/resources/help.txt");
View Full Code Here


    /**
     * Test method for {@link org.apache.james.managesieve.core.CoreProcessor#CoreProcessor(org.apache.james.managesieve.api.Session, org.apache.james.managesieve.api.SieveRepository, org.apache.james.managesieve.api.SieveParser)}.
     */
    @Test
    public final void testCoreProcessor() {
        CoreProcessor core = new CoreProcessor(new MockSession(), new MockSieveRepository(), new MockSieveParser());
        assertTrue(core instanceof CoreCommands);
    }
View Full Code Here

     */
    @Test
    public final void testCapability() {
        MockSession session = new MockSession();
        MockSieveParser parser = new MockSieveParser();
        CoreProcessor core = new CoreProcessor(session, new MockSieveRepository(), parser);

        // Unauthenticated
        session.setAuthentication(false);
        parser.setExtensions(Arrays.asList(new String[]{"a","b","c"}));
        Map<Capabilities, String> capabilities = core.capability();
View Full Code Here

     * @throws AuthenticationRequiredException
     */
    @Test
    public final void testCheckScript() throws AuthenticationRequiredException, SyntaxException {
        MockSession session = new MockSession();
        CoreProcessor core = new CoreProcessor(session, new MockSieveRepository(), new MockSieveParser());

        // Unauthorised
        boolean success = false;
        session.setAuthentication(false);
        try {
View Full Code Here

     * @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

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.