KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > test > internal > performance > eval > AssertChecker


1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.test.internal.performance.eval;
12
13 import java.util.Arrays JavaDoc;
14 import java.util.HashSet JavaDoc;
15 import java.util.Set JavaDoc;
16
17 import org.eclipse.test.internal.performance.data.Assert;
18 import org.eclipse.test.internal.performance.data.Dim;
19
20 /**
21  * @since 3.1
22  */

23 public abstract class AssertChecker {
24     private Set JavaDoc fDimensions;
25     
26     public AssertChecker(Dim dimension) {
27         this(new Dim[] {dimension});
28     }
29     
30     public AssertChecker(Dim[] dimensions) {
31         fDimensions= new HashSet JavaDoc();
32         fDimensions.addAll(Arrays.asList(dimensions));
33     }
34     
35     public Dim[] getDimensions() {
36         return (Dim[]) fDimensions.toArray(new Dim[fDimensions.size()]);
37     }
38
39     protected Dim getDimension() {
40         Assert.isTrue(fDimensions.size() == 1);
41         return getDimensions()[0];
42     }
43
44     /**
45      * Evaluates the predicate.
46      *
47      * @param reference statistics of dimensions of the reference metering session
48      * @param measured statistics of dimensions of the metering session to be tested
49      * @param message a message presented to the user upon failure
50      * @return <code>true</code> if the predicate passes, <code>false</code> if it fails
51      */

52     public abstract boolean test(StatisticsSession reference, StatisticsSession measured, StringBuffer JavaDoc message);
53 }
54
Popular Tags