KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > oscache > base > TestAbstractCacheAdministrator


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

5 package com.opensymphony.oscache.base;
6
7 import junit.framework.TestCase;
8
9 /**
10  * Test class for the AbstractCacheAdministrator class. It tests some of the
11  * public methods of the admin. Some others cannot be tested since they are
12  * linked to the property file used for the tests, and since this file
13  * will change, the value of some parameters cannot be asserted
14  *
15  * $Id: TestAbstractCacheAdministrator.java,v 1.1 2005/06/17 05:06:47 dres Exp $
16  * @version $Revision: 1.1 $
17  * @author <a HREF="mailto:abergevin@pyxis-tech.com">Alain Bergevin</a>
18  */

19 public abstract class TestAbstractCacheAdministrator extends TestCase {
20     // Constants used in the tests
21
private final String JavaDoc CACHE_PATH_PROP = "cache.path";
22     private final String JavaDoc CONTENT = "Content for the abstract cache admin test";
23     private final String JavaDoc ENTRY_KEY = "Test Abstract Admin Key";
24     private final String JavaDoc INVALID_PROP_NAME = "INVALID_PROP_NAME";
25     private final String JavaDoc TEST_LOG = "test log";
26
27     /**
28      * Constructor for the this test class.
29      * <p>
30      * @param str Test name (required by JUnit)
31      */

32     protected TestAbstractCacheAdministrator(String JavaDoc str) {
33         super(str);
34     }
35
36     /**
37      * Cannot be tested since CacheContents is an interface
38      */

39     public void testCacheContents() {
40     }
41
42     /**
43      * We cannot test this method because the value depends on the property
44      */

45     public void testGetCachePath() {
46     }
47
48     /**
49      * Validate that the properties retrieved by the admin are the same as the one
50      * specified in the property file. Do not test cache path or memory cache
51      * since it changes with the tests
52      */

53     public void testGetProperty() {
54         // Check if all the default properties are OK
55
assertNull(getAdmin().getProperty(INVALID_PROP_NAME));
56         assertNull(getAdmin().getProperty(""));
57
58         try {
59             assertNull(getAdmin().getProperty(null));
60             fail("NullPointerException expected (property Key null).");
61         } catch (Exception JavaDoc e) {
62         }
63     }
64
65     /**
66      * We cannot test this method because the value depends on the property
67      */

68     public void testIsFileCaching() {
69     }
70
71     /**
72      * We cannot test this method because the value depends on the property
73      */

74     public void testIsMemoryCaching() {
75     }
76
77     /**
78      * Perform a call to the log method. Unfornately, there is no way to check
79      * if the logging is done correctly, we only invoke it
80      */

81     public void testLog() {
82         // Invoke the log
83
// The other log method is not tested since it calls the same as we do
84
//TODO
85

86         /*getAdmin().log(TEST_LOG, System.out);
87         getAdmin().log("", System.out);
88         getAdmin().log(null, System.out);
89         getAdmin().log(TEST_LOG, null);
90           */

91     }
92
93     // Abstract method that returns an instance of an admin
94
protected abstract AbstractCacheAdministrator getAdmin();
95 }
96
Popular Tags