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

COVERAGE SUMMARY FOR SOURCE FILE [Serialization.java]

nameclass, %method, %block, %line, %
Serialization.java100% (1/1)100% (7/7)100% (75/75)100% (26/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class Serialization100% (1/1)100% (7/7)100% (75/75)100% (26/26)
Serialization (): void 100% (1/1)100% (3/3)100% (2/2)
assertNotSerializes (Serializable, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertSerializes (Serializable, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertSerializesEqual (Serializable, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertSerializesSame (Serializable, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertSerializesUnequal (Serializable, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertSerializesUnsame (Serializable, Object []): void 100% (1/1)100% (12/12)100% (4/4)

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.Serializable;
14import static org.jtiger.assertion.SerializationTesterFactory.newSerializationTester;
15 
16/**
17 * Provides the ability to make assertions regarding the serializability of objects.
18 *
19 * @see Serializable
20 * @author %javadoc.author.tag%
21 * @version %version%<br/>
22 *          <i>Build Number %build.number%</i><br/>
23 *          <i>Build Time %build.time% CET (GMT + 1)</i>
24 */
25public final class Serialization
26{
27    private Serialization()
28    {
29 
30    }
31 
32    /**
33     * Asserts that the given <code>Serializable</code> instance successfully (without exceptions) serializes and
34     * deserializes.
35     *
36     * @param s The <code>Serializable</code> instance to make the assertion on.
37     * @param message The assertion message.
38     * @throws AssertionException If the given <code>Serializable</code> instance does not successfully
39     * (without exceptions) serialize and deserialize.
40     */
41    public static void assertSerializes(final Serializable s, final Object... message) throws AssertionException
42    {
43        final SerializationTester tester = newSerializationTester(s);
44 
45        if(!tester.serializes())
46        {
47            throw new AssertionException(message);
48        }
49    }
50 
51    /**
52     * Asserts that the given <code>Serializable</code> instance does not successfully (without exceptions) serialize
53     * and deserialize.
54     *
55     * @param s The <code>Serializable</code> instance to make the assertion on.
56     * @param message The assertion message.
57     * @throws AssertionException If the given <code>Serializable</code> instance successfully (without exceptions)
58     * serializes and deserializes.
59     */
60    public static void assertNotSerializes(final Serializable s, final Object... message) throws AssertionException
61    {
62        final SerializationTester tester = newSerializationTester(s);
63 
64        if(tester.serializes())
65        {
66            throw new AssertionException(message);
67        }
68    }
69 
70    /**
71     * Asserts that the given <code>Serializable</code> instance serializes and deserializes to produce the same
72     * instance. This can only be achieved by overriding the <code>readResolve</code> method.
73     *
74     * @param s The <code>Serializable</code> instance to make the assertion on.
75     * @param message The assertion message.
76     * @throws AssertionException If the given <code>Serializable</code> instance does not serialize and deserialize to
77     * produce the same instance.
78     */
79    public static void assertSerializesSame(final Serializable s, final Object... message) throws AssertionException
80    {
81        final SerializationTester tester = newSerializationTester(s);
82 
83        if(!tester.serializesSame())
84        {
85            throw new AssertionException(message);
86        }
87    }
88 
89    /**
90     * Asserts that the given <code>Serializable</code> instance serializes and deserializes to produce a new
91     * instance.
92     *
93     * @param s The <code>Serializable</code> instance to make the assertion on.
94     * @param message The assertion message.
95     * @throws AssertionException If the given <code>Serializable</code> instance does not serialize and deserialize to
96     * produce a new instance.
97     */
98    public static void assertSerializesUnsame(final Serializable s, final Object... message) throws AssertionException
99    {
100        final SerializationTester tester = newSerializationTester(s);
101 
102        if(tester.serializesSame())
103        {
104            throw new AssertionException(message);
105        }
106    }
107 
108    /**
109     * Asserts that the given <code>Serializable</code> instance serializes and deserializes to produce an instance that
110     * is equal according to its equals method implementation.
111     *
112     * @see Object#equals(Object)
113     * @param s The <code>Serializable</code> instance to make the assertion on.
114     * @param message The assertion message.
115     * @throws AssertionException If the given <code>Serializable</code> instance does not serialize and deserialize to
116     * produce an instance that is equal according to its equals method implementation.
117     */
118    public static void assertSerializesEqual(final Serializable s, final Object... message) throws AssertionException
119    {
120        final SerializationTester tester = newSerializationTester(s);
121 
122        if(!tester.serializesEqual())
123        {
124            throw new AssertionException(message);
125        }
126    }
127 
128    /**
129     * Asserts that the given <code>Serializable</code> instance serializes and deserializes to produce an instance that
130     * is unequal according to its equals method implementation.
131     *
132     * @see Object#equals(Object)
133     * @param s The <code>Serializable</code> instance to make the assertion on.
134     * @param message The assertion message.
135     * @throws AssertionException If the given <code>Serializable</code> instance does not serialize and deserialize to
136     * produce an instance that is unequal according to its equals method implementation.
137     */
138    public static void assertSerializesUnequal(final Serializable s, final Object... message) throws AssertionException
139    {
140        final SerializationTester tester = newSerializationTester(s);
141 
142        if(tester.serializesEqual())
143        {
144            throw new AssertionException(message);
145        }
146    }
147}

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