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

COVERAGE SUMMARY FOR SOURCE FILE [TestResultFactory.java]

nameclass, %method, %block, %line, %
TestResultFactory.java100% (2/2)100% (19/19)96%  (488/508)100% (88,8/89)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TestResultFactory100% (1/1)100% (2/2)100% (18/18)100% (5/5)
TestResultFactory (): void 100% (1/1)100% (3/3)100% (2/2)
newTestResult (TestResultType, String, Throwable, Long, Method): TestResult 100% (1/1)100% (15/15)100% (3/3)
     
class TestResultFactory$TestResultImpl100% (1/1)100% (17/17)96%  (470/490)100% (83,8/84)
TestResultFactory$TestResultImpl (TestResultType, String, Throwable, Long, Me... 100% (1/1)100% (31/31)100% (2/2)
TestResultFactory$TestResultImpl (TestResultType, String, Throwable, Long, Re... 100% (1/1)100% (39/39)100% (14/14)
equals (Object): boolean 100% (1/1)86%  (127/147)98%  (5,8/6)
getCategories (): ReadOnlyArray 100% (1/1)100% (3/3)100% (1/1)
getElapsedTime (): Long 100% (1/1)100% (3/3)100% (1/1)
getException (): Throwable 100% (1/1)100% (3/3)100% (1/1)
getFixtureClass (): Class 100% (1/1)100% (3/3)100% (1/1)
getFixtureDescription (): String 100% (1/1)100% (3/3)100% (1/1)
getFixtureName (): String 100% (1/1)100% (3/3)100% (1/1)
getMessage (): String 100% (1/1)100% (3/3)100% (1/1)
getTestDescription (): String 100% (1/1)100% (3/3)100% (1/1)
getTestMethodName (): String 100% (1/1)100% (3/3)100% (1/1)
getTestMethodParameterTypes (): ReadOnlyArray 100% (1/1)100% (3/3)100% (1/1)
getTestName (): String 100% (1/1)100% (3/3)100% (1/1)
getTestResultType (): TestResultType 100% (1/1)100% (3/3)100% (1/1)
hashCode (): int 100% (1/1)100% (127/127)100% (25/25)
toString (): String 100% (1/1)100% (110/110)100% (25/25)

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.framework;
12 
13import static org.jtiger.framework.SequenceFactory.newSequence;
14import java.lang.reflect.Method;
15import static org.jtiger.framework.FixtureDescriptionFactory.newFixtureDescription;
16import static org.jtiger.framework.FixtureNameFactory.newFixtureName;
17import static org.jtiger.framework.TestDescriptionFactory.newTestDescription;
18import static org.jtiger.framework.TestMethodCategoriesFactory.newTestMethodCategories;
19import static org.jtiger.framework.TestNameFactory.newTestName;
20 
21final class TestResultFactory
22{
23    private TestResultFactory()
24    {
25 
26    }
27 
28    static TestResult newTestResult(final TestResultType testResultType, final String message,
29                                    final Throwable exception, final Long elapsedTime, final Method m) throws NullPointerException
30    {
31        if(m == null)
32        {
33            throw new NullPointerException();
34        }
35 
36        return new TestResultImpl(testResultType, message, exception, elapsedTime, m);
37    }
38 
39    private static final class TestResultImpl implements TestResult
40    {
41        private static final long serialVersionUID = 2L;
42 
43        private final TestResultType testResultType;
44        private final String message;
45        private final Throwable exception;
46        private final Long elapsedTime;
47        private final ReadOnlyArray<String> categories;
48        private final String testName;
49        private final String testDescription;
50        private final String testMethodName;
51        private final ReadOnlyArray<Class<?>> testMethodParameterTypes;
52        private final String fixtureName;
53        private final String fixtureDescription;
54        private final Class<?> fixtureClass;
55 
56        TestResultImpl(final TestResultType testResultType, final String message, final Throwable exception,
57                       final Long elapsedTime, final Method m)
58        {
59            this(testResultType,
60                    message,
61                    exception,
62                    elapsedTime,
63                    newTestMethodCategories().getTestMethodCategories(m),
64                    newTestName().getTestName(m),
65                    newTestDescription().getTestDescription(m),
66                    m.getName(),
67                    newSequence(m.getParameterTypes()),
68                    newFixtureName().getFixtureName(m.getDeclaringClass()),
69                    newFixtureDescription().getFixtureDescription(m.getDeclaringClass()),
70                    m.getDeclaringClass());
71        }
72 
73        private TestResultImpl(
74                final TestResultType testResultType,
75                final String message,
76                final Throwable exception,
77                final Long elapsedTime,
78                final ReadOnlyArray<String> categories,
79                final String testName,
80                final String testDescription,
81                final String testMethodName,
82                final ReadOnlyArray<Class<?>> testMethodParameterTypes,
83                final String fixtureName,
84                final String fixtureDescription,
85                final Class<?> fixtureClass)
86        {
87            this.testResultType = testResultType;
88            this.message = message;
89            this.exception = exception;
90            this.elapsedTime = elapsedTime;
91            this.categories = categories;
92            this.testName = testName;
93            this.testDescription = testDescription;
94            this.testMethodName = testMethodName;
95            this.testMethodParameterTypes = testMethodParameterTypes;
96            this.fixtureName = fixtureName;
97            this.fixtureDescription = fixtureDescription;
98            this.fixtureClass = fixtureClass;
99        }
100 
101        public TestResultType getTestResultType()
102        {
103            return testResultType;
104        }
105 
106        public String getMessage()
107        {
108            return message;
109        }
110 
111        public Throwable getException()
112        {
113            return exception;
114        }
115 
116        public Long getElapsedTime()
117        {
118            return elapsedTime;
119        }
120 
121        public ReadOnlyArray<String> getCategories()
122        {
123            return categories;
124        }
125 
126        public String getTestName()
127        {
128            return testName;
129        }
130 
131        public String getTestDescription()
132        {
133            return testDescription;
134        }
135 
136        public String getTestMethodName()
137        {
138            return testMethodName;
139        }
140 
141        public ReadOnlyArray<Class<?>> getTestMethodParameterTypes()
142        {
143            return testMethodParameterTypes;
144        }
145 
146        public String getFixtureName()
147        {
148            return fixtureName;
149        }
150 
151        public String getFixtureDescription()
152        {
153            return fixtureDescription;
154        }
155 
156        public Class<?> getFixtureClass()
157        {
158            return fixtureClass;
159        }
160 
161        @Override
162        public String toString()
163        {
164            final StringBuilder sb = new StringBuilder();
165 
166            sb.append('[');
167            sb.append(testResultType);
168            sb.append("][");
169            sb.append(message);
170            sb.append("][");
171            sb.append(exception);
172            sb.append("][");
173            sb.append(elapsedTime);
174            sb.append("][");
175            sb.append(categories);
176            sb.append("][");
177            sb.append(testName);
178            sb.append("][");
179            sb.append(testDescription);
180            sb.append("][");
181            sb.append(testMethodName);
182            sb.append("][");
183            sb.append(fixtureName);
184            sb.append("][");
185            sb.append(fixtureDescription);
186            sb.append("][");
187            sb.append(fixtureClass);
188            sb.append(']');
189 
190            return sb.toString();
191        }
192 
193        @Override
194        public boolean equals(final Object o)
195        {
196            if(this == o)
197            {
198                return true;
199            }
200 
201            if(o == null || o.getClass() != TestResultImpl.class)
202            {
203                return false;
204            }
205 
206            final TestResultImpl r = (TestResultImpl)o;
207 
208            return (testResultType == r.testResultType) &&
209                    (message == null ? r.message == null : message.equals(r.message)) &&
210                    (exception == null ? r.exception == null : exception.equals(r.exception)) &&
211                    (elapsedTime == null ? r.elapsedTime == null : elapsedTime.equals(r.elapsedTime)) &&
212                    (categories == null ? r.categories == null : categories.equals(r.categories)) &&
213                    (testName == null ? r.testName == null : testName.equals(r.testName)) &&
214                    (testDescription == null ? r.testDescription == null : testDescription.equals(r.testDescription)) &&
215                    (testMethodName == null ? r.testMethodName == null : testMethodName.equals(r.testMethodName)) &&
216                    (fixtureName == null ? r.fixtureName == null : fixtureName.equals(r.fixtureName)) &&
217                    (fixtureDescription == null ? r.fixtureDescription == null : fixtureDescription.equals(r.fixtureDescription)) &&
218                    (fixtureClass == r.fixtureClass);
219        }
220 
221        @Override
222        public int hashCode()
223        {
224            final int oddPrime = 461;
225            int result = 73;
226 
227            if(testResultType != null)
228            {
229                result = result * oddPrime + testResultType.hashCode();
230            }
231 
232            if(message != null)
233            {
234                result = result * oddPrime + message.hashCode();
235            }
236 
237            if(exception != null)
238            {
239                result = result * oddPrime + exception.hashCode();
240            }
241 
242            if(elapsedTime != null)
243            {
244                result = result * oddPrime + elapsedTime.hashCode();
245            }
246 
247            if(categories != null)
248            {
249                result = result * oddPrime + categories.hashCode();
250            }
251 
252            if(testName != null)
253            {
254                result = result * oddPrime + testName.hashCode();
255            }
256 
257            if(testDescription != null)
258            {
259                result = result * oddPrime + testDescription.hashCode();
260            }
261 
262            if(testMethodName != null)
263            {
264                result = result * oddPrime + testMethodName.hashCode();
265            }
266 
267            if(fixtureName != null)
268            {
269                result = result * oddPrime + fixtureName.hashCode();
270            }
271 
272            if(fixtureDescription != null)
273            {
274                result = result * oddPrime + fixtureDescription.hashCode();
275            }
276 
277            if(fixtureClass != null)
278            {
279                result = result * oddPrime + fixtureClass.hashCode();
280            }
281 
282            return result;
283        }
284    }
285}

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