Package org.apache.roller.weblogger.pojos

Examples of org.apache.roller.weblogger.pojos.WeblogHitCount


   
    public void testIncrementHitCount() throws Exception {
       
        WeblogEntryManager mgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
       
        WeblogHitCount testCount = new WeblogHitCount();
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        testCount.setWeblog(testWeblog);
        testCount.setDailyHits(10);
       
        // create
        mgr.saveHitCount(testCount);
        String id = testCount.getId();
        TestUtils.endSession(true);
       
        // make sure it was created
        WeblogHitCount hitCount = null;
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(10, hitCount.getDailyHits());
       
        // increment
        mgr.incrementHitCount(testWeblog, 25);
        TestUtils.endSession(true);
       
        // make sure it was incremented properly
        hitCount = null;
        testWeblog = TestUtils.getManagedWebsite(testWeblog);
        hitCount = mgr.getHitCountByWeblog(testWeblog);
        assertNotNull(hitCount);
        assertEquals(35, hitCount.getDailyHits());
       
        // delete
        mgr.removeHitCount(hitCount);
        TestUtils.endSession(true);
       
View Full Code Here


        testUser = TestUtils.getManagedUser(testUser);
        Weblog blog1 = TestUtils.setupWeblog("hitCntTest1", testUser);
        Weblog blog2 = TestUtils.setupWeblog("hitCntTest2", testUser);
        Weblog blog3 = TestUtils.setupWeblog("hitCntTest3", testUser);
       
        WeblogHitCount cnt1 = TestUtils.setupHitCount(blog1, 10);
        WeblogHitCount cnt2 = TestUtils.setupHitCount(blog2, 20);
        WeblogHitCount cnt3 = TestUtils.setupHitCount(blog3, 30);
       
        TestUtils.endSession(true);
       
        try {
            // make sure data was properly initialized
            WeblogHitCount testCount = null;
            testCount = mgr.getHitCount(cnt1.getId());
            assertEquals(10, testCount.getDailyHits());
            testCount = mgr.getHitCount(cnt2.getId());
            assertEquals(20, testCount.getDailyHits());
            testCount = mgr.getHitCount(cnt3.getId());
            assertEquals(30, testCount.getDailyHits());

            // reset count for one weblog
            blog1 = TestUtils.getManagedWebsite(blog1);
            mgr.resetHitCount(blog1);
            TestUtils.endSession(true);

            // make sure it reset only one weblog
            testCount = mgr.getHitCount(cnt1.getId());
            assertEquals(0, testCount.getDailyHits());
            testCount = mgr.getHitCount(cnt2.getId());
            assertEquals(20, testCount.getDailyHits());
            testCount = mgr.getHitCount(cnt3.getId());
            assertEquals(30, testCount.getDailyHits());

            // reset all counts
            mgr.resetAllHitCounts();
            TestUtils.endSession(true);

            // make sure it reset all counts
            testCount = mgr.getHitCount(cnt1.getId());
            assertEquals(0, testCount.getDailyHits());
            testCount = mgr.getHitCount(cnt2.getId());
            assertEquals(0, testCount.getDailyHits());
            testCount = mgr.getHitCount(cnt3.getId());
            assertEquals(0, testCount.getDailyHits());
       
        } finally {
            // cleanup
            TestUtils.teardownHitCount(cnt1.getId());
            TestUtils.teardownHitCount(cnt2.getId());
View Full Code Here

        testUser = TestUtils.getManagedUser(testUser);
        Weblog blog1 = TestUtils.setupWeblog("hitCntHotTest1", testUser);
        Weblog blog2 = TestUtils.setupWeblog("hitCntHotTest2", testUser);
        Weblog blog3 = TestUtils.setupWeblog("hitCntHotTest3", testUser);
       
        WeblogHitCount cnt1 = TestUtils.setupHitCount(blog1, 10);
        WeblogHitCount cnt2 = TestUtils.setupHitCount(blog2, 20);
        WeblogHitCount cnt3 = TestUtils.setupHitCount(blog3, 30);
       
        TestUtils.endSession(true);
       
        // make sure data was properly initialized
        WeblogHitCount testCount = null;
        testCount = mgr.getHitCount(cnt1.getId());
        assertEquals(10, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt2.getId());
        assertEquals(20, testCount.getDailyHits());
        testCount = mgr.getHitCount(cnt3.getId());
        assertEquals(30, testCount.getDailyHits());
       
        // get hot weblogs
        List hotBlogs = mgr.getHotWeblogs(1, 0, 5);
        assertNotNull(hotBlogs);
        assertEquals(3, hotBlogs.size());
       
        // also check ordering and values
        WeblogHitCount hitCount = null;
        Iterator it = hotBlogs.iterator();
        for(int i=3; it.hasNext(); i--) {
            hitCount = (WeblogHitCount) it.next();
           
            assertEquals(i*10, hitCount.getDailyHits());
        }
       
        // cleanup
        TestUtils.teardownHitCount(cnt1.getId());
        TestUtils.teardownHitCount(cnt2.getId());
View Full Code Here

    //------------------------------------------------------------------------
   
    /** Encapsulates RefererManager */
    public int getDayHits() {
        try {
            WeblogHitCount hitCount = mWeblogEntryMgr.getHitCountByWeblog(mWebsite);
           
            return (hitCount != null) ? hitCount.getDailyHits() : 0;
           
        } catch (WebloggerException e) {
            mLogger.error("PageModel getDayHits()", e);
        }
        return 0;
View Full Code Here

            WeblogManager mgr = WebloggerFactory.getWeblogger().getWeblogManager();
            List hotBlogs = mgr.getHotWeblogs(sinceDays, 0, length);
           
            Iterator hitCounts = hotBlogs.iterator();
            while (hitCounts.hasNext()) {
                WeblogHitCount hitCount = (WeblogHitCount) hitCounts.next();
                StatCount statCount = new StatCount(
                    hitCount.getWeblog().getId(),
                    hitCount.getWeblog().getHandle(),
                    hitCount.getWeblog().getName(),
                    "statCount.weblogDayHits",
                    hitCount.getDailyHits());
                statCount.setWeblogHandle(hitCount.getWeblog().getHandle());
                results.add(statCount);             
            }
           
        } catch (Exception e) {
            log.error("ERROR: fetching hot weblog list", e);
View Full Code Here

TOP

Related Classes of org.apache.roller.weblogger.pojos.WeblogHitCount

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.