KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > batik > test > ParametrizedTest


1 /*
2
3    Copyright 2003 The Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17  */

18 package org.apache.batik.test;
19
20
21 /**
22  * This test validates that test properties are inherited from the class that
23  * defines the "class" attribute down to each test instance that uses the
24  * same class.
25  *
26  * @author <a HREF="mailto:vincent.hardy@sun.com">Vincent Hardy</a>
27  * @version $Id: ParametrizedTest.java,v 1.4 2004/08/18 07:16:57 vhardy Exp $
28  */

29 public class ParametrizedTest extends AbstractTest {
30     protected String JavaDoc A = "initial_A_value";
31     protected String JavaDoc B = "initial_B_value";
32     protected String JavaDoc expectedA = "unset";
33     protected String JavaDoc expectedB = "unset";
34
35     public void setA(String JavaDoc A) {
36         this.A = A;
37     }
38
39     public void setB(String JavaDoc B) {
40         this.B = B;
41     }
42
43     public void setExpectedA(String JavaDoc expectedA) {
44         this.expectedA = expectedA;
45     }
46
47     public void setExpectedB(String JavaDoc expectedB) {
48         this.expectedB = expectedB;
49     }
50
51     public String JavaDoc getA() {
52         return A;
53     }
54
55     public String JavaDoc getB() {
56         return B;
57     }
58
59     public String JavaDoc getExpectedA() {
60         return expectedA;
61     }
62
63     public String JavaDoc getExpectedB() {
64         return expectedB;
65     }
66
67     public TestReport runImpl() throws Exception JavaDoc {
68         if (!A.equals(expectedA) || !B.equals(expectedB)) {
69             TestReport r = reportError("Unexpected A or B value");
70             r.addDescriptionEntry("expected.A", expectedA);
71             r.addDescriptionEntry("actual.A", A);
72             r.addDescriptionEntry("expected.B", expectedB);
73             r.addDescriptionEntry("actual.B", B);
74             return r;
75         }
76
77         return reportSuccess();
78     }
79 }
80
Popular Tags