01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.oscache.base.events;
06:
07: import junit.framework.Test;
08: import junit.framework.TestCase;
09: import junit.framework.TestSuite;
10:
11: import java.util.Date;
12:
13: /**
14: * This is the test class for the ScopeEvent class. It checks that the
15: * public methods are working properly
16: *
17: * $Id: TestScopeEvent.java 254 2005-06-17 05:07:38Z dres $
18: * @version $Revision: 254 $
19: * @author <a href="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
20: */
21: public final class TestScopeEvent extends TestCase {
22: private final int SCOPE = 3;
23:
24: /**
25: * Constructor
26: * <p>
27: * @param str The test name (required by JUnit)
28: */
29: public TestScopeEvent(String str) {
30: super (str);
31: }
32:
33: /**
34: * This methods returns the name of this test class to JUnit
35: * <p>
36: * @return The name of this class
37: */
38: public static Test suite() {
39: return new TestSuite(TestScopeEvent.class);
40: }
41:
42: /**
43: * Test the ScopeEvent class
44: */
45: public void testScopeEvent() {
46: Date date = new Date();
47:
48: // Create an object and check the parameters
49: ScopeEvent event = new ScopeEvent(
50: ScopeEventType.ALL_SCOPES_FLUSHED, SCOPE, date, null);
51: assertEquals(event.getEventType(),
52: ScopeEventType.ALL_SCOPES_FLUSHED);
53: assertEquals(event.getScope(), SCOPE);
54: assertTrue(event.getDate().equals(date));
55:
56: event = new ScopeEvent(ScopeEventType.SCOPE_FLUSHED, SCOPE,
57: date, null);
58: assertEquals(event.getEventType(), ScopeEventType.SCOPE_FLUSHED);
59: assertEquals(event.getScope(), SCOPE);
60: assertTrue(event.getDate().equals(date));
61: }
62: }
|