Package org.apache.roller.model

Examples of org.apache.roller.model.UserManager


     * Convenience method for removing a user.
     */
    public static void teardownUser(String id) throws Exception {
       
        // lookup the user
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        UserData user = mgr.getUser(id);
       
        // remove the user
        mgr.removeUser(user);
    }
View Full Code Here


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

    /**
     * Test lookup mechanisms ... id, name, link, weblog
     */
    public void testPermissionsLookups() throws Exception {
       
        UserManager mgr = RollerFactory.getRoller().getUserManager();
        WeblogTemplate page = null;
       
        // create page
        mgr.savePage(testPage);
        String id = testPage.getId();
        TestUtils.endSession(true);
       
        // lookup by id
        page = mgr.getPage(id);
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by name
        page = null;
        page = mgr.getPageByName(testWeblog, testPage.getName());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup by link
        page = null;
        page = mgr.getPageByLink(testWeblog, testPage.getLink());
        assertNotNull(page);
        assertEquals(testPage.getContents(), page.getContents());
       
        // lookup all pages for weblog
        List pages = mgr.getPages(testWeblog);
        assertNotNull(pages);
        assertEquals(1, pages.size());
       
        // delete page
        mgr.removePage(page);
        TestUtils.endSession(true);
    }
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);
        assertEquals(2, weblogs1.size());
        weblog = (WebsiteData) weblogs1.get(0);
        assertNotNull(weblog);
       
        // 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);
        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);
        assertEquals(0, weblogs3.size());
       
        // remove test weblogs
        TestUtils.teardownWeblog(testWeblog1.getId());
        TestUtils.teardownWeblog(testWeblog2.getId());
View Full Code Here

        mUser = createUser(
                testUsername,
                "password",
                "TestUser",
                "testuser@example.com");
        UserManager umgr = getRoller().getUserManager();
        mWebsite = (WebsiteData)umgr.getWebsites(mUser, null, null).get(0);
       
        PropertiesManager propmgr = getRoller().getPropertiesManager();
        Map props = propmgr.getProperties();
        RollerPropertyData prop =
                (RollerPropertyData)props.get("site.absoluteurl");
View Full Code Here

    protected UserData createUser(
            String username,
            String password,
            String fullName,
            String email) throws RollerException {
        UserManager umgr = getRoller().getUserManager();
        WeblogManager wmgr = getRoller().getWeblogManager();
       
        // Create and add new new user
        UserData ud = new UserData(null,
                username,      // userName
                password,      // password
                fullName,      // fullName
                email,         // emailAddress
                "en_US_WIN",
                "America/Los_Angeles",
                new java.util.Date(), // dateCreated
                Boolean.TRUE);
        umgr.addUser(ud);
       
        WebsiteData website = new WebsiteData(
                    username,              // handle
                    ud,                // creator
                    username,              // name
View Full Code Here

    }
   
    //-----------------------------------------------------------------------
    /** If you use this, call tearDownTestWeblogs() */
    public void setUpTestWeblogs() throws Exception {
        UserManager umgr = getRoller().getUserManager();
        WeblogManager wmgr = getRoller().getWeblogManager();
       
        // Loop to create weblogs
        for (int i=0; i<mBlogCount; i++) {
           
            UserData ud = createUser(
                    "testuser"+i,         // userName
                    "password",           // password
                    "Test User #"+i,      // fullName
                    "test"+i+"@test.com"  // emailAddress
                    );
            ud.setEnabled(new Boolean(i%2 == 0)); // half of users are disabled
            WebsiteData website = (WebsiteData)umgr.getWebsites(ud, null, null).get(0);
            mWebsitesCreated.add(website);
            mUsersCreated.add(ud);
           
            mLogger.debug("Created user "+ud.getUserName());
           
            // ensure that the first weblog entry created is the newest
            mCalendar = Calendar.getInstance();
            mCalendar.setTime(new Date());
           
            // create categories
            website  = umgr.getWebsite(website.getId());
            WeblogCategoryData rootCat = wmgr.getRootWeblogCategory(website);
            createCategoryPostsAndComments(0, wmgr, ud, website, rootCat);
           
        }
       
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.