Eliminated dependency on [logging].

git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/math/trunk@141366 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Phil Steitz 2004-07-10 16:07:07 +00:00
parent a4bde1dc48
commit 9360c37834
1 changed files with 49 additions and 63 deletions

View File

@ -20,11 +20,7 @@ import junit.framework.TestCase;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import org.apache.commons.logging.LogFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.math.stat.univariate.SummaryStatistics; import org.apache.commons.math.stat.univariate.SummaryStatistics;
import org.apache.commons.math.stat.univariate.SummaryStatisticsImpl; import org.apache.commons.math.stat.univariate.SummaryStatisticsImpl;
@ -32,7 +28,7 @@ import org.apache.commons.math.stat.univariate.DescriptiveStatistics;
/** /**
* Certified data test cases. * Certified data test cases.
* @version $Revision: 1.17 $ $Date: 2004/04/12 02:27:49 $ * @version $Revision: 1.18 $ $Date: 2004/07/10 16:07:07 $
*/ */
public class CertifiedDataTest extends TestCase { public class CertifiedDataTest extends TestCase {
@ -40,8 +36,6 @@ public class CertifiedDataTest extends TestCase {
protected double std = Double.NaN; protected double std = Double.NaN;
protected Log log = LogFactory.getLog(this.getClass());
/** /**
* Certified Data Test Constructor * Certified Data Test Constructor
* @param name * @param name
@ -94,7 +88,7 @@ public class CertifiedDataTest extends TestCase {
/** /**
* Test StorelessDescriptiveStatistics * Test StorelessDescriptiveStatistics
*/ */
public void testStoredUnivariateImpl() { public void testStoredUnivariateImpl() throws Exception {
DescriptiveStatistics u = DescriptiveStatistics.newInstance(); DescriptiveStatistics u = DescriptiveStatistics.newInstance();
@ -124,60 +118,52 @@ public class CertifiedDataTest extends TestCase {
* @param file * @param file
* @param statistical summary * @param statistical summary
*/ */
private void loadStats(String resource, Object u) { private void loadStats(String resource, Object u) throws Exception {
DescriptiveStatistics d = null; DescriptiveStatistics d = null;
SummaryStatistics s = null; SummaryStatistics s = null;
if (u instanceof DescriptiveStatistics) { if (u instanceof DescriptiveStatistics) {
d = (DescriptiveStatistics) u; d = (DescriptiveStatistics) u;
} else { } else {
s = (SummaryStatistics) u; s = (SummaryStatistics) u;
} }
try {
u.getClass().getDeclaredMethod("clear", null).invoke(u, null); u.getClass().getDeclaredMethod("clear", null).invoke(u, null);
mean = Double.NaN; mean = Double.NaN;
std = Double.NaN; std = Double.NaN;
BufferedReader in = BufferedReader in =
new BufferedReader( new BufferedReader(
new InputStreamReader( new InputStreamReader(
getClass().getResourceAsStream(resource))); getClass().getResourceAsStream(resource)));
String line = null; String line = null;
for (int j = 0; j < 60; j++) { for (int j = 0; j < 60; j++) {
line = in.readLine(); line = in.readLine();
if (j == 40) { if (j == 40) {
mean = mean =
Double.parseDouble( Double.parseDouble(
line.substring(line.lastIndexOf(":") + 1).trim()); line.substring(line.lastIndexOf(":") + 1).trim());
} }
if (j == 41) { if (j == 41) {
std = std =
Double.parseDouble( Double.parseDouble(
line.substring(line.lastIndexOf(":") + 1).trim()); line.substring(line.lastIndexOf(":") + 1).trim());
} }
} }
line = in.readLine(); line = in.readLine();
while (line != null) { while (line != null) {
if (d != null) { if (d != null) {
d.addValue(Double.parseDouble(line.trim())); d.addValue(Double.parseDouble(line.trim()));
} else { } else {
s.addValue(Double.parseDouble(line.trim())); s.addValue(Double.parseDouble(line.trim()));
} }
line = in.readLine(); line = in.readLine();
} }
in.close(); in.close();
} catch (FileNotFoundException fnfe) {
log.error(fnfe.getMessage(), fnfe);
} catch (IOException ioe) {
log.error(ioe.getMessage(), ioe);
} catch (Exception ioe) {
log.error(ioe.getMessage(), ioe);
}
} }
} }