Clover Coverage Report - EasyMock 2.4
Coverage timestamp: mer. juil. 2 2008 02:17:38 CEST
18   49   2   9
0   33   0,11   2
2     1  
1    
 
 
  SerializationTest       Line # 11 18 2 100% 1.0
 
  (1)
 
1    package org.easymock.tests2;
2   
3    import static org.easymock.EasyMock.*;
4    import static org.junit.Assert.*;
5   
6    import java.io.*;
7    import java.util.List;
8   
9    import org.junit.Test;
10   
 
11    public class SerializationTest {
12   
 
13  1 toggle @SuppressWarnings("unchecked")
14    @Test
15    public void test() throws Exception {
16  1 List<String> mock = createMock(List.class);
17   
18  1 mock = serialize(mock);
19   
20  1 expect(mock.get(1)).andReturn("a");
21   
22  1 mock = serialize(mock);
23   
24  1 replay(mock);
25   
26  1 mock = serialize(mock);
27   
28  1 assertEquals("a", mock.get(1));
29   
30  1 mock = serialize(mock);
31   
32  1 verify(mock);
33    }
34   
 
35  4 toggle @SuppressWarnings("unchecked")
36    private <T> T serialize(T o) throws IOException, ClassNotFoundException {
37  4 ByteArrayOutputStream bOut = new ByteArrayOutputStream();
38  4 ObjectOutputStream out = new ObjectOutputStream(bOut);
39  4 out.writeObject(o);
40  4 out.close();
41   
42  4 ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
43  4 ObjectInputStream in = new ObjectInputStream(bIn);
44  4 o = (T) in.readObject();
45  4 in.close();
46   
47  4 return o;
48    }
49    }