EMMA Coverage Report (generated Fri Jul 28 01:51:09 CEST 2006)
[all classes][org.jtiger.assertion]

COVERAGE SUMMARY FOR SOURCE FILE [SerializationTesterFactory.java]

nameclass, %method, %block, %line, %
SerializationTesterFactory.java100% (2/2)100% (7/7)90%  (85/94)81%  (26/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SerializationTesterFactory100% (1/1)100% (2/2)100% (14/14)100% (5/5)
SerializationTesterFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newSerializationTester (Serializable): SerializationTester 100% (1/1)100% (11/11)100% (3/3)
     
class SerializationTesterFactory$SerializationTesterImpl100% (1/1)100% (5/5)89%  (71/80)78%  (21/27)
SerializationTesterFactory$SerializationTesterImpl (Serializable): void 100% (1/1)100% (6/6)100% (3/3)
serializeDeserialize (Serializable): Object 100% (1/1)100% (26/26)100% (6/6)
serializes (): boolean 100% (1/1)77%  (10/13)67%  (4/6)
serializesEqual (): boolean 100% (1/1)81%  (13/16)67%  (4/6)
serializesSame (): boolean 100% (1/1)84%  (16/19)67%  (4/6)

1/*
2 * JTiger Unit Testing Framework for J2SE 1.5
3 * Copyright (C) 2005 Tony Morris
4 *
5 * This software is licenced under the
6 * Common Public Licence version 1.0
7 * http://www.opensource.org/licenses/cpl1.0.php
8 *
9 * You received a copy of this licence with this software.
10 */
11package org.jtiger.assertion;
12 
13import java.io.ByteArrayInputStream;
14import java.io.ByteArrayOutputStream;
15import java.io.IOException;
16import java.io.ObjectInputStream;
17import java.io.ObjectOutputStream;
18import java.io.Serializable;
19 
20final class SerializationTesterFactory
21{
22    private SerializationTesterFactory()
23    {
24 
25    }
26 
27    static SerializationTester newSerializationTester(final Serializable s) throws NullPointerException
28    {
29        if(s == null)
30        {
31            throw new NullPointerException();
32        }
33 
34        return new SerializationTesterImpl(s);
35    }
36 
37    private static final class SerializationTesterImpl implements SerializationTester
38    {
39        private final Serializable s;
40 
41        SerializationTesterImpl(final Serializable s)
42        {
43            this.s = s;
44        }
45 
46        public boolean serializes()
47        {
48            try
49            {
50                serializeDeserialize(s);
51 
52                return true;
53            }
54            catch(IOException ioe)
55            {
56                return false;
57            }
58            catch(ClassNotFoundException cnfe)
59            {
60                return false;
61            }
62        }
63 
64        public boolean serializesSame()
65        {
66            try
67            {
68                final Object o = serializeDeserialize(s);
69 
70                return o == s;
71            }
72            catch(IOException ioe)
73            {
74                return false;
75            }
76            catch(ClassNotFoundException cnfe)
77            {
78                return false;
79            }
80        }
81 
82        public boolean serializesEqual()
83        {
84            try
85            {
86                final Object o = serializeDeserialize(s);
87 
88                return o.equals(s);
89            }
90            catch(IOException ioe)
91            {
92                return false;
93            }
94            catch(ClassNotFoundException cnfe)
95            {
96                return false;
97            }
98        }
99 
100        private Object serializeDeserialize(final Serializable serializable) throws IOException, ClassNotFoundException
101        {
102            final ByteArrayOutputStream baout = new ByteArrayOutputStream();
103 
104            final ObjectOutputStream out = new ObjectOutputStream(baout);
105 
106            out.writeObject(serializable);
107 
108            final ByteArrayInputStream bain = new ByteArrayInputStream(baout.toByteArray());
109 
110            final ObjectInputStream in = new ObjectInputStream(bain);
111 
112            return in.readObject();
113        }
114    }
115}

[all classes][org.jtiger.assertion]
EMMA 2.0.5312 (C) Vladimir Roubtsov