Code Search for Developers
 
 
  

MemoryBasedStatisticMapRepositoryTest.java from Tea Stats at Krugle


Show MemoryBasedStatisticMapRepositoryTest.java syntax highlighted

/*
 * This file is distributed under the GPL v2 as part of teastats site statistics package
 * http://teastats.sourceforge.net
 */
package net.time4tea.webstats.statistic.memory;

import junit.framework.TestCase;
import net.time4tea.webstats.statistic.Statistic;
import net.time4tea.webstats.statistic.StatisticMap;
import net.time4tea.webstats.statistic.comparator.ByBytesComparator;
import net.time4tea.webstats.statistic.repo.StatisticMapRepository;
import org.joda.time.DateTime;
import org.joda.time.Instant;

import java.util.Collection;

/**
 * Originally richja May 1, 2006
 */
public class MemoryBasedStatisticMapRepositoryTest extends TestCase {
    private StatisticMapRepository repository;
    private DateTime date;

    public void testWeCanPutSomethingIntoTheRepositoryThenSearchForIt() throws Exception {

        DateTime datetime = new DateTime();
        repository.getStatisticMapForInstant("test", datetime.toInstant());
        Collection<Instant> times = repository.findPeriodsAvailableForNamedMap("test");

        assertNotNull(times);
        assertEquals(1, times.size());
    }

    public void testUpdatesAreRecallable() throws Exception {

        StatisticMap statisticMap = repository.getStatisticMapForInstant("test", date.toInstant());

        assertEquals(0, statisticMap.keys(new ByBytesComparator()).size());

        statisticMap.hit("test", 100);

        StatisticMap hitter2 = repository.getStatisticMapForInstant("test", date.toInstant());

        Collection<String> keys = hitter2.keys(new ByBytesComparator());
        assertEquals(1, keys.size());
        Statistic statistic = hitter2.get(keys.iterator().next());
        assertEquals("test", statistic.getKey());
        assertEquals(100, statistic.getSum());

    }

    protected void setUp() throws Exception {
        super.setUp();
        repository = new MemoryBasedStatisticMapRepository();
        date = new DateTime();
    }
}




See more files for this project here

Tea Stats

Web log analyzer... Written in OO Perl, provides the usual host / page analysis. Can also do site graphing using graphviz, browser, os, worm and search engine identification, and country and session tracking.

Project homepage: http://sourceforge.net/projects/teastats
Programming language(s): Java
License: other

  MemoryBasedStatisticMapRepositoryTest.java