1 package org.apache.commons.jcs3.auxiliary;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.apache.commons.jcs3.engine.logging.CacheEvent;
26 import org.apache.commons.jcs3.engine.logging.behavior.ICacheEvent;
27 import org.apache.commons.jcs3.engine.logging.behavior.ICacheEventLogger;
28
29 /**
30 * For testing auxiliary event logging. Improve later so we can test the details. This is very
31 * crude.
32 */
33 public class MockCacheEventLogger
34 implements ICacheEventLogger
35 {
36 /** times called */
37 public int applicationEventCalls;
38
39 /** times called */
40 public int startICacheEventCalls;
41
42 /** times called */
43 public int endICacheEventCalls;
44
45 /** times called */
46 public int errorEventCalls;
47
48 /** list of messages */
49 public List<String> errorMessages = new ArrayList<>();
50
51 /**
52 * @param source
53 * @param eventName
54 * @param optionalDetails
55 */
56 @Override
57 public void logApplicationEvent( final String source, final String eventName, final String optionalDetails )
58 {
59 applicationEventCalls++;
60 }
61
62 /**
63 * @param event
64 */
65 @Override
66 public <T> void logICacheEvent( final ICacheEvent<T> event )
67 {
68 endICacheEventCalls++;
69 }
70
71 /**
72 * @param source
73 * @param eventName
74 * @param errorMessage
75 */
76 @Override
77 public void logError( final String source, final String eventName, final String errorMessage )
78 {
79 errorEventCalls++;
80 errorMessages.add( errorMessage );
81 }
82
83 /**
84 * @param source
85 * @param region
86 * @param eventName
87 * @param optionalDetails
88 * @param key
89 * @return ICacheEvent
90 */
91 @Override
92 public <T> ICacheEvent<T> createICacheEvent( final String source, final String region,
93 final String eventName, final String optionalDetails, final T key )
94 {
95 startICacheEventCalls++;
96 return new CacheEvent<>();
97 }
98 }