Package org.apache.roller.model

Examples of org.apache.roller.model.UserManager


        testWeblog.setTimeZone("America/Los_Angeles");
        testWeblog.setDateCreated(new java.util.Date());
        testWeblog.setCreator(creator);
       
        // add weblog
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        mgr.addWebsite(testWeblog);
       
        // query for the new weblog and return it
        WebsiteData weblog = mgr.getWebsiteByHandle(handle);
       
        if(weblog == null)
            throw new RollerException("error setting up weblog");
       
        return weblog;
View Full Code Here


     * Convenience method for removing a weblog.
     */
    public static void teardownWeblog(String id) throws Exception {
       
        // lookup the weblog
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WebsiteData weblog = mgr.getWebsite(id);
       
        // remove the weblog
        mgr.removeWebsite(weblog);
    }
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete.
     */
    public void testWeblogCRUD() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WebsiteData weblog = null;
       
        WebsiteData testWeblog = new WebsiteData();
        testWeblog.setName("Test Weblog");
        testWeblog.setDescription("Test Weblog");
        testWeblog.setHandle("testweblog");
        testWeblog.setEmailAddress("testweblog@dev.null");
        testWeblog.setEditorPage("editor-text.jsp");
        testWeblog.setBlacklist("");
        testWeblog.setEmailFromAddress("");
        testWeblog.setEditorTheme("basic");
        testWeblog.setLocale("en_US");
        testWeblog.setTimeZone("America/Los_Angeles");
        testWeblog.setDateCreated(new java.util.Date());
        testWeblog.setCreator(testUser);
       
        // make sure test weblog does not exist
        weblog = mgr.getWebsiteByHandle(testWeblog.getHandle());
        assertNull(weblog);
       
        // add test weblog
        mgr.addWebsite(testWeblog);
        String id = testWeblog.getId();
        TestUtils.endSession(true);
       
        // make sure test weblog exists
        weblog = null;
        weblog = mgr.getWebsite(id);
        assertNotNull(weblog);
        assertEquals(testWeblog, weblog);
       
        // modify weblog and save
        weblog.setName("testtesttest");
        mgr.saveWebsite(weblog);
        TestUtils.endSession(true);
       
        // make sure changes were saved
        weblog = null;
        weblog = mgr.getWebsite(id);
        assertNotNull(weblog);
        assertEquals("testtesttest", weblog.getName());
       
        // remove test weblog
        mgr.removeWebsite(weblog);
        TestUtils.endSession(true);
       
        // make sure weblog no longer exists
        weblog = null;
        weblog = mgr.getWebsite(id);
        assertNull(weblog);
    }
View Full Code Here

    /**
     * Test lookup mechanisms.
     */
    public void testWeblogLookups() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WebsiteData weblog = null;
       
        // add test weblogs
        WebsiteData testWeblog1 = TestUtils.setupWeblog("testWeblog1", testUser);
        WebsiteData testWeblog2 = TestUtils.setupWeblog("testWeblog2", testUser);
        TestUtils.endSession(true);
       
        // lookup by id
        weblog = mgr.getWebsite(testWeblog1.getId());
        assertNotNull(weblog);
        assertEquals(testWeblog1.getHandle(), weblog.getHandle());
       
        // lookup by weblog handle
        weblog = null;
        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
        assertNotNull(weblog);
        assertEquals(testWeblog1.getHandle(), weblog.getHandle());
       
        // make sure disable weblogs are not returned
        weblog.setEnabled(Boolean.FALSE);
        mgr.saveWebsite(weblog);
        weblog = null;
        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
        assertNull(weblog);
       
        // restore enabled state
        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle(), Boolean.FALSE);
        weblog.setEnabled(Boolean.TRUE);
        mgr.saveWebsite(weblog);
        TestUtils.endSession(true);
        weblog = null;
        weblog = mgr.getWebsiteByHandle(testWeblog1.getHandle());
        assertNotNull(weblog);
       
        // get all weblogs for user
        weblog = null;
        List weblogs1 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, null, null, 0, -1);
        assertEquals(2, weblogs1.size());
        weblog = (WebsiteData) weblogs1.get(0);
        assertNotNull(weblog);
       
        // testing paging
        List weblogs11 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, null, null, 0, 1);
        assertEquals(1, weblogs11.size());    
        List weblogs12 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, null, null, 1, 1);
        assertEquals(1, weblogs11.size());    
       
        // make sure disabled weblogs are not returned
        weblog.setEnabled(Boolean.FALSE);
        mgr.saveWebsite(weblog);
        TestUtils.endSession(true);
        List weblogs2 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, null, null, 0, -1);
        assertEquals(1, weblogs2.size());
        weblog = (WebsiteData) weblogs2.get(0);
        assertNotNull(weblog);
       
        // make sure inactive weblogs are not returned
        weblog.setActive(Boolean.FALSE);
        mgr.saveWebsite(weblog);
        TestUtils.endSession(true);
        List weblogs3 = mgr.getWebsites(testUser, Boolean.TRUE, Boolean.TRUE, null, null, 0, -1);
        assertEquals(0, weblogs3.size());
       
        // remove test weblogs
        TestUtils.teardownWeblog(testWeblog1.getId());
        TestUtils.teardownWeblog(testWeblog2.getId());
View Full Code Here

        mockRequest.setRemoteUser(username);
        mockRequest.setUserPrincipal(new MockPrincipal(username));
        mockRequest.setUserInRole(role, true);
       
        HttpSession session = mockRequest.getSession(true);
        UserManager umgr = RollerFactory.getRoller().getUserManager();
        UserData user = umgr.getUserByUserName(username);
       
        RollerSession rollerSession = new RollerSession();
        rollerSession.setAuthenticatedUser(user);
        session.setAttribute(RollerSession.ROLLER_SESSION, rollerSession);
    }
View Full Code Here

                "anchor21", website2.getDefaultCategory(), website2, user1);
        comment21 = TestUtils.setupComment("Comment21", entry21);
        TestUtils.endSession(true);
    }
    public void testGetMostCommentedWeblogs() throws Exception {       
        UserManager mgr = RollerFactory.getRoller().getUserManager();     
        List list = mgr.getMostCommentedWebsites(null, null, 0, -1)
       
        assertNotNull(list);
        assertEquals(2, list.size());
       
        StatCount s1 = (StatCount)list.get(0);
View Full Code Here

       
        StatCount s2 = (StatCount)list.get(1);
        assertEquals(1L, s2.getCount());  
    }
    public void testGetUserNameLetterMap() throws Exception {       
        UserManager mgr = RollerFactory.getRoller().getUserManager();     
        Map map = mgr.getUserNameLetterMap();   
        assertNotNull(map.get("a"));
        assertNotNull(map.get("b"));
        assertNull(map.get("c"));
    }
View Full Code Here

        assertNotNull(map.get("a"));
        assertNotNull(map.get("b"));
        assertNull(map.get("c"));
    }
    public void testGetWeblogLetterMap() throws Exception {       
        UserManager mgr = RollerFactory.getRoller().getUserManager();     
        Map map = mgr.getWeblogHandleLetterMap();   
        assertNotNull(map.get("a"));
        assertNotNull(map.get("b"));
        assertNull(map.get("c"));
    }
View Full Code Here

               
                // some caches are based on weblog last-modified, so update it
                website.setLastModified(new Date());
               
                try {
                    UserManager umgr = RollerFactory.getRoller().getUserManager();
                    umgr.saveWebsite(website);
                    RollerFactory.getRoller().flush();
                } catch (RollerException ex) {
                    mLogger.error("Error saving website", ex);
                }
               
View Full Code Here

    /**
     * Test basic persistence operations ... Create, Update, Delete
     */
    public void testTemplateCRUD() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate template = null;
       
        // create template
        mgr.savePage(testPage);
        TestUtils.endSession(true);
       
        // check that create was successful
        template = null;
        template = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // update template
        template.setName("testtesttest");
        mgr.savePage(template);
        TestUtils.endSession(true);
       
        // check that update was successful
        template = null;
        template = mgr.getPageByName(testWeblog, "testtesttest");
        assertNotNull(template);
        assertEquals(testPage.getContents(), template.getContents());
       
        // delete template
        mgr.removePage(template);
        TestUtils.endSession(true);
       
        // check that delete was successful
        template = null;
        template = mgr.getPageByName(testWeblog, testPage.getName());
        assertNull(template);
    }
View Full Code Here

TOP

Related Classes of org.apache.roller.model.UserManager

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.