@PrepareForTest(value=org.apache.hadoop.mapreduce.lib.output.MultipleOutputs.class) public class MapDriver<K1,V1,K2,V2> extends MapDriverBase<K1,V1,K2,V2,MapDriver<K1,V1,K2,V2>> implements org.apache.hadoop.mrunit.internal.mapreduce.ContextDriver
| Modifier and Type | Field and Description |
|---|---|
static org.apache.commons.logging.Log |
LOG |
inputKey, inputs, inputVal, mapInputPath, mockOutputCreatorcounterWrapper, expectedEnumCounters, expectedMultipleOutputs, expectedOutputs, expectedPathOutputs, expectedStringCounters, mos| Constructor and Description |
|---|
MapDriver() |
MapDriver(org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> m) |
| Modifier and Type | Method and Description |
|---|---|
org.apache.hadoop.mapreduce.Mapper.Context |
getContext()
Obtain Context object for furthering mocking with Mockito.
|
org.apache.hadoop.mapreduce.Counters |
getCounters() |
org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> |
getMapper() |
static <K1,V1,K2,V2> |
newMapDriver()
Returns a new MapDriver without having to specify the generic types on the
right hand side of the object create statement.
|
static <K1,V1,K2,V2> |
newMapDriver(org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> mapper)
Returns a new MapDriver without having to specify the generic types on the
right hand side of the object create statement.
|
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 |
setCounters(org.apache.hadoop.mapreduce.Counters ctrs)
Sets the counters object to use for this test.
|
void |
setMapper(org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> m)
Set the Mapper instance to use with this test driver
|
String |
toString() |
MapDriver<K1,V1,K2,V2> |
withCounters(org.apache.hadoop.mapreduce.Counters ctrs)
Sets the counters to use and returns self for fluent style
|
MapDriver<K1,V1,K2,V2> |
withMapper(org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> m)
Sets the Mapper instance to use and returns self for fluent style
|
MapDriver<K1,V1,K2,V2> |
withOutputFormat(Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass,
Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass)
Configure
Mapper to output with a real OutputFormat. |
addAll, addInput, addInput, clearInput, getInputKey, getInputValue, getMapInputPath, preRunChecks, printPreTestDebugLog, setInput, setInput, setInputFromString, setInputKey, setInputValue, setMapInputPath, withAll, withInput, withInput, withInputFromString, withInputKey, withInputValue, withMapInputPathaddAllOutput, addCacheArchive, addCacheArchive, addCacheFile, addCacheFile, addMultiOutput, addMultiOutput, addOutput, addOutput, addOutputFromString, cleanupDistributedCache, copy, copyPair, driverReused, formatPairList, formatValueList, getConfiguration, getExpectedEnumCounters, getExpectedOutputs, getExpectedStringCounters, getKeyComparator, getOutputSerializationConfiguration, getValueComparator, initDistributedCache, parseCommaDelimitedList, parseTabbedPair, resetExpectedCounters, resetOutput, run, runTest, runTest, setCacheArchives, setCacheFiles, setConfiguration, setKeyComparator, setOutputSerializationConfiguration, setUsedOnceStatus, setValueComparator, thisAsTestDriver, validate, validate, validate, validateOutputList, withAllOutput, withCacheArchive, withCacheArchive, withCacheFile, withCacheFile, withConfiguration, withCounter, withCounter, withMultiOutput, withMultiOutput, withOutput, withOutput, withOutputFromString, withOutputSerializationConfiguration, withPathOutput, withPathOutput, withStrictCounterCheckingpublic void setMapper(org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> m)
m - the Mapper instance to usepublic MapDriver<K1,V1,K2,V2> withMapper(org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> m)
public org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> getMapper()
public org.apache.hadoop.mapreduce.Counters getCounters()
getCounters in interface org.apache.hadoop.mrunit.internal.mapreduce.ContextDriverpublic void setCounters(org.apache.hadoop.mapreduce.Counters ctrs)
ctrs - The counters object to use.public MapDriver<K1,V1,K2,V2> withCounters(org.apache.hadoop.mapreduce.Counters ctrs)
public MapDriver<K1,V1,K2,V2> withOutputFormat(Class<? extends org.apache.hadoop.mapreduce.OutputFormat> outputFormatClass, Class<? extends org.apache.hadoop.mapreduce.InputFormat> inputFormatClass)
Mapper to output with a real OutputFormat. Set
InputFormat to read output back in for use with run* methodsoutputFormatClass - inputFormatClass - public List<Pair<K2,V2>> run() throws IOException
TestDriverpublic org.apache.hadoop.mapreduce.Mapper.Context getContext()
Obtain Context object for furthering mocking with Mockito. For example, causing write() to throw an exception:
import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; doThrow(new IOException()).when(context).write(any(), any());
Or implement other logic:
import static org.mockito.Matchers.*; import static org.mockito.Mockito.*; doAnswer(new Answer
public static <K1,V1,K2,V2> MapDriver<K1,V1,K2,V2> newMapDriver()
public static <K1,V1,K2,V2> MapDriver<K1,V1,K2,V2> newMapDriver(org.apache.hadoop.mapreduce.Mapper<K1,V1,K2,V2> mapper)
mapper - passed to MapDriver constructorCopyright © 2014 The Apache Software Foundation. All Rights Reserved.