01: /*
02: * Copyright (c) 2002-2003 by OpenSymphony
03: * All rights reserved.
04: */
05: package com.opensymphony.oscache.base.events;
06:
07: import com.opensymphony.oscache.base.Cache;
08: import com.opensymphony.oscache.general.GeneralCacheAdministrator;
09:
10: import junit.framework.Test;
11: import junit.framework.TestCase;
12: import junit.framework.TestSuite;
13:
14: /**
15: * This is the test class for the CachePatternEvent class. It checks that the
16: * public methods are working properly
17: *
18: * $Id: TestCacheEntryEvent.java 385 2006-10-07 06:57:10Z larst $
19: * @version $Revision: 385 $
20: * @author Lars Torunski
21: */
22: public final class TestCachePatternEvent extends TestCase {
23:
24: /**
25: * Constants required for the test
26: */
27: private final String TEST_PATTERN = "testPattern";
28:
29: /**
30: * Constructor
31: * <p>
32: * @param str The test name (required by JUnit)
33: */
34: public TestCachePatternEvent(String str) {
35: super (str);
36: }
37:
38: /**
39: * This methods returns the name of this test class to JUnit
40: * <p>
41: * @return The test for this class
42: */
43: public static Test suite() {
44: return new TestSuite(TestCachePatternEvent.class);
45: }
46:
47: /**
48: * Test the CacheEntryEvent class
49: */
50: public void testCacheEntryEvent() {
51: // Create all the required objects
52: GeneralCacheAdministrator admin = new GeneralCacheAdministrator();
53: Cache map = new Cache(admin.isMemoryCaching(), admin
54: .isUnlimitedDiskCache(), admin.isOverflowPersistence());
55:
56: // three parameters
57: CachePatternEvent event = new CachePatternEvent(map,
58: TEST_PATTERN, null);
59:
60: // Get back the values and assert them
61: assertEquals(event.getMap(), map);
62: assertEquals(event.getPattern(), TEST_PATTERN);
63: assertNull(event.getOrigin());
64:
65: // two parameters
66: CachePatternEvent event2 = new CachePatternEvent(map,
67: TEST_PATTERN);
68:
69: // Get back the values and assert them
70: assertEquals(event2.getMap(), map);
71: assertEquals(event.getPattern(), TEST_PATTERN);
72: assertNull(event2.getOrigin());
73: }
74: }
|