KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > oscache > extra > TestScopeEventListenerImpl


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.oscache.extra;
6
7 import com.opensymphony.oscache.base.events.ScopeEvent;
8 import com.opensymphony.oscache.base.events.ScopeEventType;
9
10 import junit.framework.Test;
11 import junit.framework.TestCase;
12 import junit.framework.TestSuite;
13
14 import java.util.Date JavaDoc;
15
16 /**
17  * Test the scope event listener implementation
18  *
19  * $Id: TestScopeEventListenerImpl.java,v 1.1 2005/06/17 05:07:06 dres Exp $
20  * @version $Revision: 1.1 $
21  * @author <a HREF="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
22  */

23 public class TestScopeEventListenerImpl extends TestCase {
24     private static final int PAGE_SCOPE = 1;
25
26     /**
27      * Constructor
28      * <p>
29      * @param str The test name (required by JUnit)
30      */

31     public TestScopeEventListenerImpl(String JavaDoc str) {
32         super(str);
33     }
34
35     /**
36      * This methods returns the name of this test class to JUnit
37      * <p>
38      * @return The name of this class
39      */

40     public static Test suite() {
41         return new TestSuite(TestScopeEventListenerImpl.class);
42     }
43
44     /**
45      * Test the basic implementation of this listener
46      */

47     public void testScopeEventListenerImpl() {
48         // Construct the object we need for the test
49
ScopeEventListenerImpl listener = new ScopeEventListenerImpl();
50
51         // Generates events
52
listener.scopeFlushed(new ScopeEvent(ScopeEventType.ALL_SCOPES_FLUSHED, PAGE_SCOPE, new Date JavaDoc()));
53         listener.scopeFlushed(new ScopeEvent(ScopeEventType.SCOPE_FLUSHED, PAGE_SCOPE, new Date JavaDoc()));
54
55         // Assert the counters
56
assertEquals(listener.getApplicationScopeFlushCount(), 1);
57         assertEquals(listener.getPageScopeFlushCount(), 2);
58         assertEquals(listener.getRequestScopeFlushCount(), 1);
59         assertEquals(listener.getSessionScopeFlushCount(), 1);
60         assertEquals(listener.getTotalScopeFlushCount(), 5);
61     }
62 }
63
Popular Tags