Skip to content

Commit 0a25c7a

Browse files
committed
Fixing test failure
1 parent 5df7b77 commit 0a25c7a

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

src/test/java/org/audit4j/core/Audit4jTestBase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ protected void watchStop() {
5454
Log.info(watch.getLastTaskName() + "=" + watch.getLastTaskTime() + ":" + watch.getLastTaskTimeMillis() + "ms");
5555
}
5656

57-
57+
protected void halt(){
58+
for (int i = 0; i < 100000; i++) {
59+
System.out.print("");
60+
}
61+
}
5862

5963
/**
6064
* Before.

src/test/java/org/audit4j/core/util/StopWatchTest.java

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import static org.junit.Assert.assertEquals;
44
import static org.junit.Assert.assertNotNull;
55

6+
import org.audit4j.core.Audit4jTestBase;
67
import org.junit.After;
78
import org.junit.Before;
89
import org.junit.Test;
@@ -15,7 +16,7 @@
1516
* @author JanithB
1617
* @version $Revision: 1.0 $
1718
*/
18-
public class StopWatchTest {
19+
public class StopWatchTest extends Audit4jTestBase{
1920
/**
2021
* Run the StopWatch() constructor test.
2122
*
@@ -105,6 +106,7 @@ public void testGetLastTaskName_1() throws Exception {
105106
StopWatch fixture = new StopWatch("");
106107
fixture.setKeepTaskList(true);
107108
fixture.start("");
109+
halt();
108110
fixture.stop();
109111

110112
String result = fixture.getLastTaskName();
@@ -125,6 +127,7 @@ public void testGetLastTaskName_2() throws Exception {
125127
StopWatch fixture = new StopWatch("");
126128
fixture.setKeepTaskList(true);
127129
fixture.start("");
130+
halt();
128131
fixture.stop();
129132

130133
String result = fixture.getLastTaskName();
@@ -145,6 +148,7 @@ public void testGetLastTaskTime_1() throws Exception {
145148
StopWatch fixture = new StopWatch("");
146149
fixture.setKeepTaskList(true);
147150
fixture.start("");
151+
halt();
148152
fixture.stop();
149153

150154
long result = fixture.getLastTaskTime();
@@ -165,6 +169,7 @@ public void testGetLastTaskTime_2() throws Exception {
165169
StopWatch fixture = new StopWatch("");
166170
fixture.setKeepTaskList(true);
167171
fixture.start("");
172+
halt();
168173
fixture.stop();
169174

170175
long result = fixture.getLastTaskTime();
@@ -185,6 +190,7 @@ public void testGetLastTaskTimeMillis_1() throws Exception {
185190
StopWatch fixture = new StopWatch("");
186191
fixture.setKeepTaskList(true);
187192
fixture.start("");
193+
halt();
188194
fixture.stop();
189195

190196
long result = fixture.getLastTaskTimeMillis();
@@ -205,6 +211,7 @@ public void testGetLastTaskTimeMillis_2() throws Exception {
205211
StopWatch fixture = new StopWatch("");
206212
fixture.setKeepTaskList(true);
207213
fixture.start("");
214+
halt();
208215
fixture.stop();
209216

210217
long result = fixture.getLastTaskTimeMillis();
@@ -225,6 +232,7 @@ public void testGetTaskCount_1() throws Exception {
225232
StopWatch fixture = new StopWatch("");
226233
fixture.setKeepTaskList(true);
227234
fixture.start("");
235+
halt();
228236
fixture.stop();
229237

230238
int result = fixture.getTaskCount();
@@ -245,6 +253,7 @@ public void testGetTaskInfo_1() throws Exception {
245253
StopWatch fixture = new StopWatch();
246254
fixture.setKeepTaskList(true);
247255
fixture.start("test");
256+
halt();
248257
fixture.stop();
249258

250259
StopWatch.TaskInfo[] result = fixture.getTaskInfo();
@@ -271,6 +280,7 @@ public void testGetTaskInfo_2() throws Exception {
271280
StopWatch fixture = new StopWatch("");
272281
fixture.setKeepTaskList(false);
273282
fixture.start("");
283+
halt();
274284
fixture.stop();
275285

276286
StopWatch.TaskInfo[] result = fixture.getTaskInfo();
@@ -291,6 +301,7 @@ public void testGetTotalTime_1() throws Exception {
291301
StopWatch fixture = new StopWatch("");
292302
fixture.setKeepTaskList(true);
293303
fixture.start("");
304+
halt();
294305
fixture.stop();
295306

296307
long result = fixture.getTotalTime();
@@ -311,6 +322,7 @@ public void testGetTotalTimeMillis_1() throws Exception {
311322
StopWatch fixture = new StopWatch("");
312323
fixture.setKeepTaskList(true);
313324
fixture.start("");
325+
halt();
314326
fixture.stop();
315327

316328
long result = fixture.getTotalTimeMillis();
@@ -331,6 +343,7 @@ public void testGetTotalTimeSeconds_1() throws Exception {
331343
StopWatch fixture = new StopWatch("");
332344
fixture.setKeepTaskList(true);
333345
fixture.start("");
346+
halt();
334347
fixture.stop();
335348

336349
double result = fixture.getTotalTimeSeconds();
@@ -351,6 +364,7 @@ public void testIsRunning_1() throws Exception {
351364
StopWatch fixture = new StopWatch("");
352365
fixture.setKeepTaskList(true);
353366
fixture.start("");
367+
halt();
354368
fixture.stop();
355369

356370
boolean result = fixture.isRunning();
@@ -371,6 +385,7 @@ public void testIsRunning_2() throws Exception {
371385
StopWatch fixture = new StopWatch("");
372386
fixture.setKeepTaskList(true);
373387
fixture.start("");
388+
halt();
374389
fixture.stop();
375390

376391
boolean result = fixture.isRunning();
@@ -391,6 +406,7 @@ public void testPrettyPrint_1() throws Exception {
391406
StopWatch fixture = new StopWatch("");
392407
fixture.setKeepTaskList(true);
393408
fixture.start("");
409+
halt();
394410
fixture.stop();
395411

396412
String result = fixture.prettyPrint();
@@ -411,6 +427,7 @@ public void testPrettyPrint_2() throws Exception {
411427
StopWatch fixture = new StopWatch("");
412428
fixture.setKeepTaskList(true);
413429
fixture.start("");
430+
halt();
414431
fixture.stop();
415432

416433
String result = fixture.prettyPrint();
@@ -431,10 +448,12 @@ public void testPrettyPrint_3() throws Exception {
431448
StopWatch fixture = new StopWatch("");
432449
fixture.setKeepTaskList(false);
433450
fixture.start("");
451+
halt();
434452
fixture.stop();
435453

436454
String result = fixture.prettyPrint();
437-
455+
System.out.println(result);
456+
438457
// add additional test code here
439458
assertEquals("StopWatch '': running time (millis) = 0\nNo task info kept", result);
440459
}
@@ -451,6 +470,7 @@ public void testReset_1() throws Exception {
451470
StopWatch fixture = new StopWatch("");
452471
fixture.setKeepTaskList(true);
453472
fixture.start("");
473+
halt();
454474
fixture.stop();
455475

456476
fixture.reset();
@@ -470,6 +490,7 @@ public void testSetKeepTaskList_1() throws Exception {
470490
StopWatch fixture = new StopWatch("");
471491
fixture.setKeepTaskList(true);
472492
fixture.start("");
493+
halt();
473494
fixture.stop();
474495
boolean keepTaskList = true;
475496

@@ -490,6 +511,7 @@ public void testShortSummary_1() throws Exception {
490511
StopWatch fixture = new StopWatch("");
491512
fixture.setKeepTaskList(true);
492513
fixture.start("");
514+
halt();
493515
fixture.stop();
494516

495517
String result = fixture.shortSummary();
@@ -510,6 +532,7 @@ public void testStart_1() throws Exception {
510532
StopWatch fixture = new StopWatch("");
511533
fixture.setKeepTaskList(true);
512534
fixture.start("");
535+
halt();
513536
fixture.stop();
514537

515538
fixture.start();
@@ -529,6 +552,7 @@ public void testStart_2() throws Exception {
529552
StopWatch fixture = new StopWatch("");
530553
fixture.setKeepTaskList(true);
531554
fixture.start("");
555+
halt();
532556
fixture.stop();
533557

534558
fixture.start();
@@ -548,6 +572,7 @@ public void testStart_3() throws Exception {
548572
StopWatch fixture = new StopWatch("");
549573
fixture.setKeepTaskList(true);
550574
fixture.start("");
575+
halt();
551576
fixture.stop();
552577
String taskName = "";
553578

@@ -568,6 +593,7 @@ public void testStart_4() throws Exception {
568593
StopWatch fixture = new StopWatch("");
569594
fixture.setKeepTaskList(true);
570595
fixture.start("");
596+
halt();
571597
fixture.stop();
572598
String taskName = "";
573599

@@ -588,6 +614,7 @@ public void testStop_1() throws Exception {
588614
StopWatch fixture = new StopWatch("");
589615
fixture.setKeepTaskList(true);
590616
fixture.start("");
617+
halt();
591618
fixture.stop();
592619

593620
fixture.stop();
@@ -607,6 +634,7 @@ public void testStop_2() throws Exception {
607634
StopWatch fixture = new StopWatch("");
608635
fixture.setKeepTaskList(true);
609636
fixture.start("");
637+
halt();
610638
fixture.stop();
611639

612640
fixture.stop();
@@ -626,6 +654,7 @@ public void testStop_3() throws Exception {
626654
StopWatch fixture = new StopWatch("");
627655
fixture.setKeepTaskList(false);
628656
fixture.start("");
657+
halt();
629658
fixture.stop();
630659

631660
fixture.stop();
@@ -645,6 +674,7 @@ public void testToString_1() throws Exception {
645674
StopWatch fixture = new StopWatch("");
646675
fixture.setKeepTaskList(false);
647676
fixture.start("");
677+
halt();
648678
fixture.stop();
649679

650680
String result = fixture.toString();
@@ -665,6 +695,7 @@ public void testToString_2() throws Exception {
665695
StopWatch fixture = new StopWatch("");
666696
fixture.setKeepTaskList(true);
667697
fixture.start("");
698+
halt();
668699
fixture.stop();
669700

670701
String result = fixture.toString();
@@ -685,6 +716,7 @@ public void testToString_3() throws Exception {
685716
StopWatch fixture = new StopWatch("");
686717
fixture.setKeepTaskList(true);
687718
fixture.start("");
719+
halt();
688720
fixture.stop();
689721

690722
String result = fixture.toString();

0 commit comments

Comments
 (0)