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

COVERAGE SUMMARY FOR SOURCE FILE [ObjectFactoryContract.java]

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

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ObjectFactoryContract100% (1/1)100% (7/7)100% (75/75)100% (26/26)
ObjectFactoryContract (): void 100% (1/1)100% (3/3)100% (2/2)
assertObjectFactoryFillsContract (ObjectFactory, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertObjectFactoryXConsistentlyEqual (ObjectFactory, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertObjectFactoryXConsistentlyNewInstance (ObjectFactory, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertObjectFactoryXYConsistentlyUnequal (ObjectFactory, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertObjectFactoryYConsistentlyEqual (ObjectFactory, Object []): void 100% (1/1)100% (12/12)100% (4/4)
assertObjectFactoryYConsistentlyNewInstance (ObjectFactory, 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 static org.jtiger.assertion.ObjectFactoryContractTesterFactory.newObjectFactoryContractTester;
14 
15/**
16 * Provides the ability to make assertions on the contract defined by {@link ObjectFactory}.
17 * The contract has five (5) aspects, which are specified by {@link ObjectFactory}.
18 *
19 * @see ObjectFactory
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 ObjectFactoryContract
26{
27    private ObjectFactoryContract()
28    {
29 
30    }
31 
32    /**
33     * Asserts that the given <code>ObjectFactory</code> meets one aspect of the entire contract.
34     * The {@link ObjectFactory#newInstanceX()} method must consistently return new instances.
35     *
36     * @param factory The object factory to assert has met the aspect of the contract.
37     * @param message The assertion message.
38     * @throws AssertionException If the {@link ObjectFactory#newInstanceX()} method does not consistently return new
39     * instances.
40     */
41    public static void assertObjectFactoryXConsistentlyNewInstance(final ObjectFactory<?> factory, final Object... message) throws AssertionException
42    {
43        final ObjectFactoryContractTester tester = newObjectFactoryContractTester(factory);
44 
45        if(!tester.isXConsistentlyNewInstance())
46        {
47            throw new AssertionException(message);
48        }
49    }
50 
51    /**
52     * Asserts that the given <code>ObjectFactory</code> meets one aspect of the entire contract.
53     * The {@link ObjectFactory#newInstanceY()} method must consistently return new instances.
54     *
55     * @param factory The object factory to assert has met the aspect of the contract.
56     * @param message The assertion message.
57     * @throws AssertionException If the {@link ObjectFactory#newInstanceY()} method does not consistently return new
58     * instances.
59     */
60    public static void assertObjectFactoryYConsistentlyNewInstance(final ObjectFactory<?> factory, final Object... message) throws AssertionException
61    {
62        final ObjectFactoryContractTester tester = newObjectFactoryContractTester(factory);
63 
64        if(!tester.isYConsistentlyNewInstance())
65        {
66            throw new AssertionException(message);
67        }
68    }
69 
70    /**
71     * Asserts that the given <code>ObjectFactory</code> meets one aspect of the entire contract.
72     * The {@link ObjectFactory#newInstanceX()} method must consistently return equal instances.
73     *
74     * @param factory The object factory to assert has met the aspect of the contract.
75     * @param message The assertion message.
76     * @throws AssertionException If the {@link ObjectFactory#newInstanceX()} method does not consistently return equal
77     * instances.
78     */
79    public static void assertObjectFactoryXConsistentlyEqual(final ObjectFactory<?> factory, final Object... message) throws AssertionException
80    {
81        final ObjectFactoryContractTester tester = newObjectFactoryContractTester(factory);
82 
83        if(!tester.isXConsistentlyEqual())
84        {
85            throw new AssertionException(message);
86        }
87    }
88 
89    /**
90     * Asserts that the given <code>ObjectFactory</code> meets one aspect of the entire contract.
91     * The {@link ObjectFactory#newInstanceY()} method must consistently return equal instances.
92     *
93     * @param factory The object factory to assert has met the aspect of the contract.
94     * @param message The assertion message.
95     * @throws AssertionException If the {@link ObjectFactory#newInstanceY()} method does not consistently return equal
96     * instances.
97     */
98    public static void assertObjectFactoryYConsistentlyEqual(final ObjectFactory<?> factory, final Object... message) throws AssertionException
99    {
100        final ObjectFactoryContractTester tester = newObjectFactoryContractTester(factory);
101 
102        if(!tester.isYConsistentlyEqual())
103        {
104            throw new AssertionException(message);
105        }
106    }
107 
108    /**
109     * Asserts that the given <code>ObjectFactory</code> meets one aspect of the entire contract.
110     * The {@link ObjectFactory#newInstanceX()} method must consistently return instances that are unequal to instances
111     * returned by the {@link ObjectFactory#newInstanceY()} method.
112     *
113     * @param factory The object factory to assert has met the aspect of the contract.
114     * @param message The assertion message.
115     * @throws AssertionException If the {@link ObjectFactory#newInstanceY()} method does not consistently return
116     * instances that are unequal to instances returned by the {@link ObjectFactory#newInstanceY()} method.
117     */
118    public static void assertObjectFactoryXYConsistentlyUnequal(final ObjectFactory<?> factory, final Object... message) throws AssertionException
119    {
120        final ObjectFactoryContractTester tester = newObjectFactoryContractTester(factory);
121 
122        if(!tester.isXYConsistentlyUnequal())
123        {
124            throw new AssertionException(message);
125        }
126    }
127 
128    /**
129     * Asserts that the given <code>ObjectFactory</code> meets the entire contract.
130     *
131     * @see ObjectFactory
132     * @param factory The object factory to assert has met the contract.
133     * @param message The assertion message.
134     * @throws AssertionException If the object factory does not meet the entire contract.
135     */
136    public static void assertObjectFactoryFillsContract(final ObjectFactory<?> factory, final Object... message) throws AssertionException
137    {
138        final ObjectFactoryContractTester tester = newObjectFactoryContractTester(factory);
139 
140        if(!tester.fillsContract())
141        {
142            throw new AssertionException(message);
143        }
144    }
145}

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