1 package org.apache.commons.jcs.engine.control;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.commons.jcs.engine.behavior.IElementSerializer;
23 import org.apache.commons.jcs.utils.serialization.StandardSerializer;
24
25 import java.io.IOException;
26
27
28 public class MockElementSerializer
29 implements IElementSerializer
30 {
31
32 private String testProperty;
33
34
35 private final StandardSerializer serializer = new StandardSerializer();
36
37
38 public int deSerializeCount = 0;
39
40
41 public int serializeCount = 0;
42
43
44
45
46
47
48
49
50 @Override
51 public <T> T deSerialize( byte[] bytes, ClassLoader loader )
52 throws IOException, ClassNotFoundException
53 {
54 deSerializeCount++;
55 return serializer.deSerialize( bytes, loader );
56 }
57
58
59
60
61
62
63
64 @Override
65 public <T> byte[] serialize( T obj )
66 throws IOException
67 {
68 serializeCount++;
69 return serializer.serialize( obj );
70 }
71
72
73
74
75 public void setTestProperty( String testProperty )
76 {
77 this.testProperty = testProperty;
78 }
79
80
81
82
83 public String getTestProperty()
84 {
85 return testProperty;
86 }
87 }