You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hama.apache.org by ed...@apache.org on 2008/09/03 23:18:24 UTC
svn commit: r691779 - in /incubator/hama/trunk/src/test/org/apache/hama:
HCluster.java HamaTestCase.java TestDenseMatrix.java TestDenseVector.java
mapred/TestMatrixMapReduce.java
Author: edwardyoon
Date: Wed Sep 3 14:18:23 2008
New Revision: 691779
URL: http://svn.apache.org/viewvc?rev=691779&view=rev
Log: (empty)
Added:
incubator/hama/trunk/src/test/org/apache/hama/HCluster.java
- copied, changed from r691689, incubator/hama/trunk/src/test/org/apache/hama/HamaTestCase.java
Removed:
incubator/hama/trunk/src/test/org/apache/hama/HamaTestCase.java
Modified:
incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java
incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java
Copied: incubator/hama/trunk/src/test/org/apache/hama/HCluster.java (from r691689, incubator/hama/trunk/src/test/org/apache/hama/HamaTestCase.java)
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/HCluster.java?p2=incubator/hama/trunk/src/test/org/apache/hama/HCluster.java&p1=incubator/hama/trunk/src/test/org/apache/hama/HamaTestCase.java&r1=691689&r2=691779&rev=691779&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/HamaTestCase.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/HCluster.java Wed Sep 3 14:18:23 2008
@@ -24,12 +24,10 @@
/**
* Forming up the miniDfs and miniHbase
*/
-public class HamaTestCase extends HBaseClusterTestCase {
- protected int SIZE = 5;
+public class HCluster extends HBaseClusterTestCase {
protected final HamaConfiguration conf = new HamaConfiguration();
-
- /** constructor */
- public HamaTestCase() {
- super();
+
+ public void setUp() throws Exception {
+ super.setUp();
}
}
Modified: incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java?rev=691779&r1=691778&r2=691779&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseMatrix.java Wed Sep 3 14:18:23 2008
@@ -22,22 +22,38 @@
import java.io.IOException;
import java.util.Iterator;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
import org.apache.hama.io.VectorEntry;
import org.apache.log4j.Logger;
/**
* Matrix test
*/
-public class TestDenseMatrix extends HamaTestCase {
+public class TestDenseMatrix extends TestCase {
static final Logger LOG = Logger.getLogger(TestDenseMatrix.class);
+ private static int SIZE = 5;
+ private static Matrix m1;
+ private static Matrix m2;
- private Matrix m1;
- private Matrix m2;
-
- public void setUp() throws Exception{
- super.setUp();
- m1 = DenseMatrix.random(conf, SIZE, SIZE);
- m2 = DenseMatrix.random(conf, SIZE, SIZE);
+ public static Test suite() {
+ TestSetup setup = new TestSetup(new TestSuite(TestDenseMatrix.class)) {
+ protected void setUp() throws Exception {
+ HCluster hCluster = new HCluster();
+ hCluster.setUp();
+
+ m1 = DenseMatrix.random(hCluster.conf, SIZE, SIZE);
+ m2 = DenseMatrix.random(hCluster.conf, SIZE, SIZE);
+ }
+
+ protected void tearDown() {
+ LOG.info("tearDown()");
+ }
+ };
+ return setup;
}
/**
Modified: incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java?rev=691779&r1=691778&r2=691779&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/TestDenseVector.java Wed Sep 3 14:18:23 2008
@@ -21,27 +21,46 @@
import java.util.Iterator;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.apache.hama.io.VectorEntry;
-public class TestDenseVector extends HamaTestCase {
+public class TestDenseVector extends TestCase {
+ final static Log LOG = LogFactory.getLog(TestDenseVector.class.getName());
private static final double cosine = 0.6978227007909176;
private static final double norm1 = 12.0;
private static final double norm2 = 6.782329983125268;
private static double[][] values = { { 2, 5, 1, 4 }, { 4, 1, 3, 3 } };
- private Matrix m1;
- private Vector v1;
- private Vector v2;
-
- public void setUp() throws Exception {
- super.setUp();
- m1 = new DenseMatrix(conf, "vectorTest");
-
- for (int i = 0; i < 2; i++)
- for (int j = 0; j < 4; j++)
- m1.set(i, j, values[i][j]);
-
- v1 = m1.getRow(0);
- v2 = m1.getRow(1);
+ private static Matrix m1;
+ private static Vector v1;
+ private static Vector v2;
+
+ public static Test suite() {
+ TestSetup setup = new TestSetup(new TestSuite(TestDenseVector.class)) {
+ protected void setUp() throws Exception {
+ HCluster hCluster = new HCluster();
+ hCluster.setUp();
+
+ m1 = new DenseMatrix(hCluster.conf, "vectorTest");
+
+ for (int i = 0; i < 2; i++)
+ for (int j = 0; j < 4; j++)
+ m1.set(i, j, values[i][j]);
+
+ v1 = m1.getRow(0);
+ v2 = m1.getRow(1);
+ }
+
+ protected void tearDown() {
+ LOG.info("tearDown()");
+ }
+ };
+ return setup;
}
/**
@@ -56,14 +75,16 @@
* Test norm one
*/
public void testNom1() {
- assertEquals(norm1, ((DenseVector) v1).getNorm1());
+ double result = ((DenseVector) v1).getNorm1();
+ assertEquals(norm1, result);
}
/**
* Test norm two
*/
public void testNom2() {
- assertEquals(norm2, ((DenseVector) v1).getNorm2());
+ double result = ((DenseVector) v1).getNorm2();
+ assertEquals(norm2, result);
}
/**
Modified: incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java
URL: http://svn.apache.org/viewvc/incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java?rev=691779&r1=691778&r2=691779&view=diff
==============================================================================
--- incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java (original)
+++ incubator/hama/trunk/src/test/org/apache/hama/mapred/TestMatrixMapReduce.java Wed Sep 3 14:18:23 2008
@@ -26,7 +26,7 @@
import org.apache.hadoop.mapred.JobConf;
import org.apache.hama.DenseMatrix;
import org.apache.hama.DenseVector;
-import org.apache.hama.HamaTestCase;
+import org.apache.hama.HCluster;
import org.apache.hama.Matrix;
import org.apache.hama.algebra.AdditionMap;
import org.apache.hama.algebra.AdditionReduce;
@@ -35,7 +35,7 @@
/**
* Test Matrix Map/Reduce job
*/
-public class TestMatrixMapReduce extends HamaTestCase {
+public class TestMatrixMapReduce extends HCluster {
static final Logger LOG = Logger.getLogger(TestMatrixMapReduce.class);
private String A = "matrixA";
private String B = "matrixB";