|
@@ -26,8 +26,6 @@ import java.io.IOException;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.Random;
|
|
|
|
|
|
-import junit.framework.TestCase;
|
|
|
-
|
|
|
import org.apache.hadoop.io.BooleanWritable;
|
|
|
import org.apache.hadoop.io.BytesWritable;
|
|
|
import org.apache.hadoop.io.FloatWritable;
|
|
@@ -36,8 +34,12 @@ import org.apache.hadoop.io.LongWritable;
|
|
|
import org.apache.hadoop.io.Text;
|
|
|
import org.apache.hadoop.io.Writable;
|
|
|
import org.apache.hadoop.io.WritableUtils;
|
|
|
+import org.junit.Test;
|
|
|
+import static org.junit.Assert.assertTrue;
|
|
|
+import static org.junit.Assert.assertEquals;
|
|
|
+import static org.junit.Assert.assertFalse;
|
|
|
|
|
|
-public class TestTupleWritable extends TestCase {
|
|
|
+public class TestTupleWritable {
|
|
|
|
|
|
private TupleWritable makeTuple(Writable[] writs) {
|
|
|
Writable[] sub1 = { writs[1], writs[2] };
|
|
@@ -100,6 +102,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
return i;
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testIterable() throws Exception {
|
|
|
Random r = new Random();
|
|
|
Writable[] writs = {
|
|
@@ -121,6 +124,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
verifIter(writs, t, 0);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testNestedIterable() throws Exception {
|
|
|
Random r = new Random();
|
|
|
Writable[] writs = {
|
|
@@ -139,6 +143,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
assertTrue("Bad count", writs.length == verifIter(writs, sTuple, 0));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testWritable() throws Exception {
|
|
|
Random r = new Random();
|
|
|
Writable[] writs = {
|
|
@@ -162,6 +167,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
assertTrue("Failed to write/read tuple", sTuple.equals(dTuple));
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
public void testWideWritable() throws Exception {
|
|
|
Writable[] manyWrits = makeRandomWritables(131);
|
|
|
|
|
@@ -180,7 +186,8 @@ public class TestTupleWritable extends TestCase {
|
|
|
assertTrue("Failed to write/read tuple", sTuple.equals(dTuple));
|
|
|
assertEquals("All tuple data has not been read from the stream",-1,in.read());
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ @Test
|
|
|
public void testWideWritable2() throws Exception {
|
|
|
Writable[] manyWrits = makeRandomWritables(71);
|
|
|
|
|
@@ -202,6 +209,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
* Tests a tuple writable with more than 64 values and the values set written
|
|
|
* spread far apart.
|
|
|
*/
|
|
|
+ @Test
|
|
|
public void testSparseWideWritable() throws Exception {
|
|
|
Writable[] manyWrits = makeRandomWritables(131);
|
|
|
|
|
@@ -220,7 +228,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
assertTrue("Failed to write/read tuple", sTuple.equals(dTuple));
|
|
|
assertEquals("All tuple data has not been read from the stream",-1,in.read());
|
|
|
}
|
|
|
-
|
|
|
+ @Test
|
|
|
public void testWideTuple() throws Exception {
|
|
|
Text emptyText = new Text("Should be empty");
|
|
|
Writable[] values = new Writable[64];
|
|
@@ -240,7 +248,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ @Test
|
|
|
public void testWideTuple2() throws Exception {
|
|
|
Text emptyText = new Text("Should be empty");
|
|
|
Writable[] values = new Writable[64];
|
|
@@ -264,6 +272,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
/**
|
|
|
* Tests that we can write more than 64 values.
|
|
|
*/
|
|
|
+ @Test
|
|
|
public void testWideTupleBoundary() throws Exception {
|
|
|
Text emptyText = new Text("Should not be set written");
|
|
|
Writable[] values = new Writable[65];
|
|
@@ -287,6 +296,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
/**
|
|
|
* Tests compatibility with pre-0.21 versions of TupleWritable
|
|
|
*/
|
|
|
+ @Test
|
|
|
public void testPreVersion21Compatibility() throws Exception {
|
|
|
Writable[] manyWrits = makeRandomWritables(64);
|
|
|
PreVersion21TupleWritable oldTuple = new PreVersion21TupleWritable(manyWrits);
|
|
@@ -304,7 +314,7 @@ public class TestTupleWritable extends TestCase {
|
|
|
assertTrue("Tuple writable is unable to read pre-0.21 versions of TupleWritable", oldTuple.isCompatible(dTuple));
|
|
|
assertEquals("All tuple data has not been read from the stream",-1,in.read());
|
|
|
}
|
|
|
-
|
|
|
+ @Test
|
|
|
public void testPreVersion21CompatibilityEmptyTuple() throws Exception {
|
|
|
Writable[] manyWrits = new Writable[0];
|
|
|
PreVersion21TupleWritable oldTuple = new PreVersion21TupleWritable(manyWrits);
|