1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package net.grinder.console.model;
23
24 import net.grinder.common.StubTest;
25 import net.grinder.common.Test;
26 import net.grinder.statistics.StatisticsServices;
27 import net.grinder.statistics.StatisticsServicesImplementation;
28 import net.grinder.statistics.StatisticsSet;
29 import junit.framework.TestCase;
30
31
32
33
34
35
36
37 public class TestModelTestIndex extends TestCase {
38
39 public void testConstruction() throws Exception {
40 final ModelTestIndex nullModelTestIndex = new ModelTestIndex();
41 assertEquals(0, nullModelTestIndex.getNumberOfTests());
42 assertEquals(0, nullModelTestIndex.getAccumulatorArray().length);
43
44 final StatisticsServices statisticsServices =
45 StatisticsServicesImplementation.getInstance();
46
47 final Test[] tests =
48 new Test[] {
49 new StubTest(100, "first test"),
50 new StubTest(101, "second test"),
51 };
52
53 final SampleAccumulator[] accumulators =
54 new SampleAccumulator[] {
55 new SampleAccumulator(
56 null, null, statisticsServices.getStatisticsSetFactory()),
57 new SampleAccumulator(
58 null, null, statisticsServices.getStatisticsSetFactory()),
59 };
60
61 final ModelTestIndex modelTestIndex =
62 new ModelTestIndex(tests, accumulators);
63
64 assertEquals(tests.length, modelTestIndex.getNumberOfTests());
65 assertSame(tests[0], modelTestIndex.getTest(0));
66 assertSame(tests[1], modelTestIndex.getTest(1));
67
68 final StatisticsSet cumulativeStatistics0 =
69 modelTestIndex.getCumulativeStatistics(0);
70
71 assertNotNull(cumulativeStatistics0);
72 assertSame(cumulativeStatistics0, cumulativeStatistics0);
73 assertNotSame(cumulativeStatistics0,
74 modelTestIndex.getCumulativeStatistics(1));
75
76 final StatisticsSet lastSampleStatistics0 =
77 modelTestIndex.getLastSampleStatistics(0);
78
79 assertNotNull(lastSampleStatistics0);
80 assertSame(lastSampleStatistics0, lastSampleStatistics0);
81 assertNotSame(lastSampleStatistics0,
82 modelTestIndex.getLastSampleStatistics(1));
83
84 assertNotSame(cumulativeStatistics0, lastSampleStatistics0);
85 }
86 }