delegate creation of tested class to a factory so that the derived class

SynchronizedDescriptiveStatisticsTest can override it and ... really test
SynchronizedDescriptiveStatistics

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@796003 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2009-07-20 20:51:56 +00:00
parent 7b6cd406a2
commit be3c1e1170
1 changed files with 8 additions and 4 deletions

View File

@ -37,9 +37,13 @@ public class DescriptiveStatisticsTest extends TestCase {
suite.setName("DescriptiveStatistics Tests");
return suite;
}
protected DescriptiveStatistics createDescriptiveStatistics() {
return new DescriptiveStatistics();
}
public void testSetterInjection() throws Exception {
DescriptiveStatistics stats = new DescriptiveStatistics();
DescriptiveStatistics stats = createDescriptiveStatistics();
stats.addValue(1);
stats.addValue(3);
assertEquals(2, stats.getMean(), 1E-10);
@ -49,7 +53,7 @@ public class DescriptiveStatisticsTest extends TestCase {
}
public void testPercentileSetter() throws Exception {
DescriptiveStatistics stats = new DescriptiveStatistics();
DescriptiveStatistics stats = createDescriptiveStatistics();
stats.addValue(1);
stats.addValue(2);
stats.addValue(3);
@ -73,7 +77,7 @@ public class DescriptiveStatisticsTest extends TestCase {
}
public void testRemoval() {
final DescriptiveStatistics dstat = new DescriptiveStatistics();
final DescriptiveStatistics dstat = createDescriptiveStatistics();
checkremoval(dstat, 1, 6.0, 0.0, Double.NaN);
checkremoval(dstat, 3, 5.0, 3.0, 4.5);