01: // Modified or written by Object Mentor, Inc. for inclusion with FitNesse.
02: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
03: // Released under the terms of the GNU General Public License version 2 or later.
04: // Copyright (c) 2002 Cunningham & Cunningham, Inc.
05: // Released under the terms of the GNU General Public License version 2 or later.
06:
07: package fit;
08:
09: import java.util.Date;
10: import java.text.*;
11:
12: public class TimedActionFixture extends ActionFixture {
13: private static SimpleDateFormat makeDateFormat() {
14: //SimpleDateFormat is not thread safe, so we need to create each instance independently.
15: return new SimpleDateFormat("hh:mm:ss");
16: }
17:
18: public void doTable(Parse table) {
19: super .doTable(table);
20: table.parts.parts.last().more = td("time");
21: table.parts.parts.last().more = td("split");
22: }
23:
24: public void doCells(Parse cells) {
25: Date start = time();
26: super .doCells(cells);
27: long split = time().getTime() - start.getTime();
28: cells.last().more = td(makeDateFormat().format(start));
29: cells.last().more = td(split < 1000 ? " " : Double
30: .toString((split) / 1000.0));
31: }
32:
33: // Utility //////////////////////////////////
34:
35: public Date time() {
36: return new Date();
37: }
38:
39: public Parse td(String body) {
40: return new Parse("td", gray(body), null, null);
41: }
42:
43: }
|