|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.hadoop.mrunit.TestDriver<K1,V1,K2,V2>
org.apache.hadoop.mrunit.MapDriverBase<K1,V1,K2,V2>
public abstract class MapDriverBase<K1,V1,K2,V2>
Harness that allows you to test a Mapper instance. You provide the input key and value that should be sent to the Mapper, and outputs you expect to be sent by the Mapper to the collector for those inputs. By calling runTest(), the harness will deliver the input to the Mapper and will check its outputs against the expected results. This is designed to handle a single (k, v) -> (k, v)* case from the Mapper, representing a single unit test. Multiple input (k, v) pairs should go in separate unit tests.
Field Summary | |
---|---|
protected K1 |
inputKey
|
protected V1 |
inputVal
|
static org.apache.commons.logging.Log |
LOG
|
Fields inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
configuration, expectedOutputs |
Constructor Summary | |
---|---|
MapDriverBase()
|
Method Summary | |
---|---|
void |
addOutput(K2 key,
V2 val)
Adds a (k, v) pair we expect as output from the mapper |
void |
addOutput(Pair<K2,V2> outputRecord)
Adds an output (k, v) pair we expect from the Mapper |
void |
addOutputFromString(String output)
Expects an input of the form "key \t val" Forces the Mapper output types to Text. |
K1 |
getInputKey()
|
V1 |
getInputValue()
|
abstract List<Pair<K2,V2>> |
run()
Runs the test but returns the result set instead of validating it (ignores any addOutput(), etc calls made before this) |
void |
runTest()
Runs the test and validates the results |
void |
setInput(K1 key,
V1 val)
Sets the input to send to the mapper |
void |
setInput(Pair<K1,V1> inputRecord)
Sets the input to send to the mapper |
void |
setInputFromString(String input)
Expects an input of the form "key \t val" Forces the Mapper input types to Text. |
void |
setInputKey(K1 key)
Sets the input key to send to the mapper |
void |
setInputValue(V1 val)
Sets the input value to send to the mapper |
Methods inherited from class org.apache.hadoop.mrunit.TestDriver |
---|
formatValueList, getConfiguration, getExpectedOutputs, parseCommaDelimitedList, parseTabbedPair, resetOutput, setConfiguration, validate |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final org.apache.commons.logging.Log LOG
protected K1 inputKey
protected V1 inputVal
Constructor Detail |
---|
public MapDriverBase()
Method Detail |
---|
public void setInputKey(K1 key)
public K1 getInputKey()
public void setInputValue(V1 val)
val
- public V1 getInputValue()
public void setInput(K1 key, V1 val)
public void setInput(Pair<K1,V1> inputRecord)
inputRecord
- a (key, val) pairpublic void addOutput(Pair<K2,V2> outputRecord)
outputRecord
- The (k, v) pair to addpublic void addOutput(K2 key, V2 val)
public void setInputFromString(String input)
input
- A string of the form "key \t val".public void addOutputFromString(String output)
output
- A string of the form "key \t val". Trims any whitespace.public abstract List<Pair<K2,V2>> run() throws IOException
TestDriver
run
in class TestDriver<K1,V1,K2,V2>
IOException
public void runTest() throws RuntimeException
TestDriver
runTest
in class TestDriver<K1,V1,K2,V2>
RuntimeException
- if they don't
*
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |