Buggy code:
@ Category ( MediumTests . class ) public class TestMobSweepReducer { private static final HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility ( ) ; private static final String tableName = "testSweepReducer" ; private static final String row = "row" ; private static final String family = "family" ; private static final String qf = "qf" ; private static HTable table ; private static Admin admin ; @ BeforeClass public static void setUpBeforeClass ( ) throws Exception { } @ AfterClass public static void tearDownAfterClass ( ) throws Exception { } @ SuppressWarnings ( "deprecation" ) @ Before public void setUp ( ) throws Exception { } @ After public void tearDown ( ) throws Exception { } private List < String > getKeyFromSequenceFile ( FileSystem fs , Path path , Configuration conf ) throws Exception { } @ Test public void testRun ( ) throws Exception { TableName tn = TableName . valueOf ( TestMobSweepReducer . tableName ) ; byte [ ] mobValueBytes = new byte [ 100 ] ; Path mobFamilyPath = MobUtils . getMobFamilyPath ( TestMobSweepReducer . TEST_UTIL . getConfiguration ( ) , tn , TestMobSweepReducer . family ) ; Put put = new Put ( Bytes . toBytes ( TestMobSweepReducer . row ) ) ; put . add ( Bytes . toBytes ( TestMobSweepReducer . family ) , Bytes . toBytes ( TestMobSweepReducer . qf ) , 1 , mobValueBytes ) ; Put put2 = new Put ( Bytes . toBytes ( ( ( TestMobSweepReducer . row ) + "ignore" ) ) ) ; put2 . add ( Bytes . toBytes ( TestMobSweepReducer . family ) , Bytes . toBytes ( TestMobSweepReducer . qf ) , 1 , mobValueBytes ) ; TestMobSweepReducer . table . put ( put ) ; TestMobSweepReducer . table . put ( put2 ) ; TestMobSweepReducer . table . flushCommits ( ) ; TestMobSweepReducer . admin . flush ( tn ) ; FileStatus [ ] fileStatuses = TestMobSweepReducer . TEST_UTIL . getTestFileSystem ( ) . listStatus ( mobFamilyPath ) ; assertEquals ( 1 , fileStatuses . length ) ; String mobFile1 = fileStatuses [ 0 ] . getPath ( ) . getName ( ) ; Configuration configuration = new Configuration ( TestMobSweepReducer . TEST_UTIL . getConfiguration ( ) ) ; configuration . setFloat ( MOB_SWEEP_TOOL_COMPACTION_RATIO , 0.6F ) ; configuration . setStrings ( INPUT_TABLE , TestMobSweepReducer . tableName ) ; configuration . setStrings ( SCAN_COLUMN_FAMILY , TestMobSweepReducer . family ) ; configuration . setStrings ( WORKING_VISITED_DIR_KEY , "jobWorkingNamesDir" ) ; configuration . setStrings ( WORKING_FILES_DIR_KEY , "compactionFileDir" ) ; configuration . setStrings ( IO_SERIALIZATIONS_KEY , JavaSerialization . class . getName ( ) ) ; configuration . set ( WORKING_VISITED_DIR_KEY , "compactionVisitedDir" ) ; configuration . setLong ( MOB_SWEEP_TOOL_COMPACTION_START_DATE , ( ( System . currentTimeMillis ( ) ) + ( ( 24 * 3600 ) * 1000 ) ) ) ; ZooKeeperWatcher zkw = new ZooKeeperWatcher ( configuration , "1" , new DummyMobAbortable ( ) ) ; String znode = ZKUtil . joinZNode ( zkw . tableLockZNode , tn . getNameAsString ( ) ) ; configuration . set ( SWEEP_JOB_ID , "1" ) ; configuration . set ( SWEEP_JOB_TABLE_NODE , znode ) ; ServerName serverName = SweepJob . getCurrentServerName ( configuration ) ; configuration . set ( SWEEP_JOB_SERVERNAME , serverName . toString ( ) ) ; TableLockManager tableLockManager = TableLockManager . createTableLockManager ( configuration , zkw , serverName ) ; TableLock lock = tableLockManager . writeLock ( tn , "Run<seq2seq4repair_space>sweep<seq2seq4repair_space>tool" ) ; lock . acquire ( ) ; Counter counter = new GenericCounter ( ) ; Context ctx = mock ( Context . class ) ; when ( ctx . getConfiguration ( ) ) . thenReturn ( configuration ) ; when ( ctx . getCounter ( Matchers . any ( SweepCounter . class ) ) ) . thenReturn ( counter ) ; when ( ctx . nextKey ( ) ) . thenReturn ( true ) . thenReturn ( false ) ; when ( ctx . getCurrentKey ( ) ) . thenReturn ( new Text ( mobFile1 ) ) ; byte [ ] refBytes = Bytes . toBytes ( mobFile1 ) ; long valueLength = refBytes . length ; byte [ ] newValue = Bytes . add ( Bytes . toBytes ( valueLength ) , refBytes ) ; KeyValue kv2 = new KeyValue ( Bytes . toBytes ( TestMobSweepReducer . row ) , Bytes . toBytes ( TestMobSweepReducer . family ) , Bytes . toBytes ( TestMobSweepReducer . qf ) , 1 , Type . Put , newValue ) ; List < KeyValue > list = new ArrayList < KeyValue > ( ) ; list . add ( kv2 ) ; when ( ctx . getValues ( ) ) . thenReturn ( list ) ; SweepReducer reducer = new SweepReducer ( ) ; reducer . run ( ctx ) ; lock . release ( ) ; FileStatus [ ] filsStatuses2 = TestMobSweepReducer . TEST_UTIL . getTestFileSystem ( ) . listStatus ( mobFamilyPath ) ; String mobFile2 = filsStatuses2 [ 0 ] . getPath ( ) . getName ( ) ; assertEquals ( 1 , filsStatuses2 . length ) ; assertEquals ( false , mobFile2 . equalsIgnoreCase ( mobFile1 ) ) ; <START_BUG> String workingPath = configuration . get ( "mob.compaction.visited.dir" ) ; <END_BUG> FileStatus [ ] statuses = TestMobSweepReducer . TEST_UTIL . getTestFileSystem ( ) . listStatus ( new Path ( workingPath ) ) ; Set < String > files = new TreeSet < String > ( ) ; for ( FileStatus st : statuses ) { files . addAll ( getKeyFromSequenceFile ( TestMobSweepReducer . TEST_UTIL . getTestFileSystem ( ) , st . getPath ( ) , configuration ) ) ; } assertEquals ( 1 , files . size ( ) ) ; assertEquals ( true , files . contains ( mobFile1 ) ) ; } }

Fix:
String workingPath = configuration . get ( WORKING_VISITED_DIR_KEY ) ;