Checking JUnit Hadoop Writable

I am writing some custom Hadoop Writable classes. I would like to use JUnit to test the readFields () and write () functions.

Is there a way to redirect a record (DataOutput out) to readFields (DataInput in)? I would like to do something like:

CustomWritable writeable1 = new CustomWritable(); CustomWritable writeable2 = new CustomWritable(); //build writable1 with some data. DataInputAndOutput io = ... writeable1.write(io); writable2.read(io); assertEquals(writable1,writable2); 

Thoughts?

+4
source share
1 answer

Finished using ByteArrayOutputStream byteout = ... and ByteArrayInputStream (byteout.toByteArray ()) to accomplish this.

I tried using:

http://docs.oracle.com/javase/7/docs/api/java/io/PipedOutputStream.html http://docs.oracle.com/javase/7/docs/api/java/io/PipedInputStream.html

But I found that sometimes they come to a standstill if they start from the same thread.

+2
source

Source: https://habr.com/ru/post/1395853/


All Articles