|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.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, counterWrapper, expectedEnumCounters, expectedOutputs, expectedStringCounters |
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)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
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(boolean orderMatters)
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)
Deprecated. No replacement due to lack of type safety and incompatibility with non Text Writables |
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, getExpectedEnumCounters, getExpectedOutputs, getExpectedStringCounters, parseCommaDelimitedList, parseTabbedPair, resetExpectedCounters, resetOutput, runTest, setConfiguration, validate, validate, withCounter, withCounter |
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)
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)
@Deprecated public void setInputFromString(String input)
input
- A string of the form "key \t val".@Deprecated 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(boolean orderMatters)
TestDriver
runTest
in class TestDriver<K1,V1,K2,V2>
orderMatters
- Whether or not output ordering is important
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |