EMMA Coverage Report (generated Tue Feb 12 22:23:49 ICT 2008)
[all classes][net.sourceforge.hiveutils.test]

COVERAGE SUMMARY FOR SOURCE FILE [SaveConstraint.java]

nameclass, %method, %block, %line, %
SaveConstraint.java100% (1/1)60%  (3/5)58%  (22/38)62%  (8/13)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class SaveConstraint100% (1/1)60%  (3/5)58%  (22/38)62%  (8/13)
SaveConstraint (): void 0%   (0/1)0%   (0/4)0%   (0/2)
describeTo (StringBuffer): StringBuffer 0%   (0/1)0%   (0/12)0%   (0/3)
SaveConstraint (Constraint): void 100% (1/1)100% (6/6)100% (3/3)
eval (Object): boolean 100% (1/1)100% (13/13)100% (4/4)
getArgument (): Object 100% (1/1)100% (3/3)100% (1/1)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveutils.test;
16 
17import org.jmock.core.Constraint;
18 
19/**
20 * jMock <code>Constraint</code> that just retains the value passed to it, and
21 * optionnally evaluates another <code>Constraint</code> on that value.
22 *
23 * @author Jean-Francois Poilpret
24 */
25public class SaveConstraint implements Constraint
26{
27        /**
28         * Constructor creating a constraint to save the evaluated argument without
29         * any additional check on that value.
30         */
31        public SaveConstraint()
32        {
33                this(null);
34        }
35 
36        /**
37         * Constructor creating a constraint to save the evaluated argument and
38         * evaluating any additional check on that value.
39         * @param inner the <code>Constraint</code> to be evaluated on the value
40         */
41        public SaveConstraint(Constraint inner)
42        {
43                _inner = inner;
44        }
45 
46        /**
47         * Return the last value saved in this constraint.
48         * @return the last value saved in this constraint, or <code>null</code> if
49         * no value was saved
50         */        
51        public Object        getArgument()
52        {
53                return _arg;
54        }
55        
56        public boolean        eval(Object o)
57        {
58                // Save value
59                _arg = o;
60                if (_inner != null)
61                {
62                        return _inner.eval(o);
63                }
64                else
65                {
66                        return true;
67                }
68        }
69        
70        public StringBuffer        describeTo(StringBuffer buffer)
71        {
72                if (_inner != null)
73                {
74                        return _inner.describeTo(buffer);
75                }
76                else
77                {
78                        return buffer.append("save");
79                }
80        }
81        
82        protected final Constraint        _inner;
83        protected Object                        _arg;
84}

[all classes][net.sourceforge.hiveutils.test]
EMMA 2.0.5312 (C) Vladimir Roubtsov