org.apache.hadoop.mrunit
Class TestDriver<K1,V1,K2,V2>

java.lang.Object
  extended by org.apache.hadoop.mrunit.TestDriver<K1,V1,K2,V2>
Direct Known Subclasses:
MapDriverBase, MapReduceDriverBase, PipelineMapReduceDriver, ReduceDriverBase

public abstract class TestDriver<K1,V1,K2,V2>
extends Object


Field Summary
protected  org.apache.hadoop.conf.Configuration configuration
           
protected  List<Pair<K2,V2>> expectedOutputs
           
static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
TestDriver()
           
 
Method Summary
protected static void formatValueList(List<?> values, StringBuilder sb)
           
 org.apache.hadoop.conf.Configuration getConfiguration()
           
 List<Pair<K2,V2>> getExpectedOutputs()
           
protected static List<org.apache.hadoop.io.Text> parseCommaDelimitedList(String commaDelimList)
          Split "val,val,val,val..." into a List of Text(val) objects.
static Pair<org.apache.hadoop.io.Text,org.apache.hadoop.io.Text> parseTabbedPair(String tabSeparatedPair)
          Split "key \t val" into Pair(Text(key), Text(val))
 void resetOutput()
          Clears the list of outputs expected from this driver
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)
abstract  void runTest()
          Runs the test and validates the results
 void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
           
protected  void validate(List<Pair<K2,V2>> outputs)
          check the outputs against the expected inputs in record
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

expectedOutputs

protected List<Pair<K2,V2>> expectedOutputs

configuration

protected org.apache.hadoop.conf.Configuration configuration
Constructor Detail

TestDriver

public TestDriver()
Method Detail

getExpectedOutputs

public List<Pair<K2,V2>> getExpectedOutputs()
Returns:
the list of (k, v) pairs expected as output from this driver

resetOutput

public void resetOutput()
Clears the list of outputs expected from this driver


run

public abstract List<Pair<K2,V2>> run()
                               throws IOException
Runs the test but returns the result set instead of validating it (ignores any addOutput(), etc calls made before this)

Returns:
the list of (k, v) pairs returned as output from the test
Throws:
IOException

runTest

public abstract void runTest()
                      throws RuntimeException
Runs the test and validates the results

Throws:
RuntimeException - if they don't *

parseTabbedPair

public static Pair<org.apache.hadoop.io.Text,org.apache.hadoop.io.Text> parseTabbedPair(String tabSeparatedPair)
Split "key \t val" into Pair(Text(key), Text(val))

Parameters:
tabSeparatedPair -

parseCommaDelimitedList

protected static List<org.apache.hadoop.io.Text> parseCommaDelimitedList(String commaDelimList)
Split "val,val,val,val..." into a List of Text(val) objects.

Parameters:
commaDelimList - A list of values separated by commas

validate

protected void validate(List<Pair<K2,V2>> outputs)
                 throws RuntimeException
check the outputs against the expected inputs in record

Parameters:
outputs - The actual output (k, v) pairs from the Mapper
Throws:
RuntimeException - if they don't

formatValueList

protected static void formatValueList(List<?> values,
                                      StringBuilder sb)

getConfiguration

public org.apache.hadoop.conf.Configuration getConfiguration()
Returns:
The configuration object that will given to the mapper and/or reducer associated with the driver (new API only)

setConfiguration

public void setConfiguration(org.apache.hadoop.conf.Configuration configuration)
Parameters:
configuration - The configuration object that will given to the mapper and/or reducer associated with the driver (new API only)


Copyright © 2012 Apache Software Foundation. All Rights Reserved.