1 /***
2 * JFoxSOAF, Service-Oriented Application Framework
3 *
4 * Copyright (C) www.huihoo.org
5 *
6 * Distributable under GNU LGPL For more information, please visit:
7 * http://www.huihoo.org/jfox/jfoxsoaf
8 */
9
10 package org.huihoo.jfox.soaf.services.cache;
11
12 import junit.framework.TestCase;
13
14 import org.huihoo.jfox.soaf.container.ServiceFactory;
15
16 /***
17 * JUnit test case for the
18 * {@link org.huihoo.jfox.soaf.services.logging.LoggingServiceImpl).
19 *
20 * @author <a href="mailto:founder_chen@yahoo.com">Peter Cheng </a>
21 * @version $Revision: 1.3 $ $Date: 2004/10/20 15:15:27 $
22 * @version Revision: 1.0
23 */
24
25 public class SimpleCacheServiceTest extends TestCase {
26
27 private SimpleCacheService simpleCacheService = (SimpleCacheService) ServiceFactory
28 .getInstance().getService(SimpleCacheService.class);;
29
30 String cache = "simple cache service";
31
32
33
34
35 protected void setUp() throws Exception {
36 super.setUp();
37
38 }
39
40
41
42
43 protected void tearDown() throws Exception {
44 super.tearDown();
45 }
46
47 public void testPut() {
48 try {
49 simpleCacheService.put("SimpleCache", cache);
50 } catch (Exception e) {
51 e.printStackTrace();
52 }
53 }
54
55 public void testGet() {
56 try {
57 assertEquals(simpleCacheService.get("SimpleCache"),
58 "simple cache service");
59 } catch (Exception e) {
60 e.printStackTrace();
61 }
62 }
63
64 public void testRemove() {
65 try {
66 simpleCacheService.remove("SimpleCache");
67 assertEquals(simpleCacheService.get("SimpleCache"), null);
68 } catch (Exception e) {
69 e.printStackTrace();
70 }
71 }
72
73 public void testClear() {
74 try {
75 simpleCacheService.put("SimpleCache", cache);
76 assertEquals(simpleCacheService.size(), 1);
77 simpleCacheService.clear();
78 assertEquals(simpleCacheService.size(), 0);
79 } catch (Exception e) {
80 e.printStackTrace();
81 }
82 }
83
84 }