001: /*
002: * Copyright 2007 Google Inc.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package com.google.gwt.junit.client;
017:
018: import com.google.gwt.junit.client.impl.ExceptionWrapper;
019: import com.google.gwt.user.client.rpc.IsSerializable;
020:
021: import java.util.Map;
022: import java.util.HashMap;
023:
024: /**
025: * The result of a single trial-run of a single benchmark method. Each Trial
026: * contains the results of running a benchmark method with one set of
027: * values for its parameters. TestResults for a method will contain Trials
028: * for all permutations of the parameter values. For test methods without
029: * parameters, there is only 1 trial result.
030: *
031: * @skip
032: */
033: public class Trial implements IsSerializable {
034:
035: ExceptionWrapper exceptionWrapper;
036:
037: double runTimeMillis;
038:
039: // Deserialized from exceptionWrapper on the server-side
040: transient Throwable exception;
041:
042: /**
043: * @gwt.typeArgs <java.lang.String,java.lang.String>
044: */
045: Map<String, String> variables;
046:
047: /**
048: * Creates a new Trial.
049: *
050: * @param runTimeMillis The amount of time spent executing the test
051: * @param exceptionWrapper The wrapped getException thrown by the the last
052: * test, or <code>null</code> if the last test
053: * completed successfully.
054: */
055: public Trial(Map<String, String> variables, double runTimeMillis,
056: ExceptionWrapper exceptionWrapper) {
057: this .variables = variables;
058: this .runTimeMillis = runTimeMillis;
059: this .exceptionWrapper = exceptionWrapper;
060: }
061:
062: public Trial() {
063: this .variables = new HashMap<String, String>();
064: }
065:
066: public Throwable getException() {
067: return exception;
068: }
069:
070: public ExceptionWrapper getExceptionWrapper() {
071: return exceptionWrapper;
072: }
073:
074: public double getRunTimeMillis() {
075: return runTimeMillis;
076: }
077:
078: /**
079: * Returns the names and values of the variables used in the test. If there
080: * were no variables, the map is empty.
081: */
082: public Map<String, String> getVariables() {
083: return variables;
084: }
085:
086: public void setException(Throwable exception) {
087: this .exception = exception;
088: }
089:
090: public void setExceptionWrapper(ExceptionWrapper exceptionWrapper) {
091: this .exceptionWrapper = exceptionWrapper;
092: }
093:
094: public void setRunTimeMillis(double runTimeMillis) {
095: this .runTimeMillis = runTimeMillis;
096: }
097:
098: @Override
099: public String toString() {
100: return "variables: " + variables + ", exceptionWrapper: "
101: + exceptionWrapper + ", runTimeMillis: "
102: + runTimeMillis;
103: }
104: }
|