Buggy code:
public class ZkCLITest extends SolrTestCaseJ4 { protected static Logger log = LoggerFactory . getLogger ( AbstractZkTestCase . class ) ; private static final boolean VERBOSE = false ; protected ZkTestServer zkServer ; protected String zkDir ; private String solrHome ; private SolrZkClient zkClient ; @ BeforeClass public static void beforeClass ( ) { } @ AfterClass public static void afterClass ( ) throws InterruptedException { } @ Override public void setUp ( ) throws Exception { } @ Test public void testBootstrap ( ) throws Exception { } @ Test public void testBootstrapWithChroot ( ) throws Exception { } @ Test public void testMakePath ( ) throws Exception { } @ Test public void testList ( ) throws Exception { } @ Test public void testUpConfigLinkConfigClearZk ( ) throws Exception { String confsetname = "confsetone" ; String [ ] args = new String [ ] { "-zkhost" , zkServer . getZkAddress ( ) , "-cmd" , "upconfig" , "-confdir" , ( ( ( ( ExternalPaths . EXAMPLE_HOME ) + ( File . separator ) ) + "collection1" ) + ( File . separator ) ) + "conf" , "-confname" , confsetname } ; ZkCLI . main ( args ) ; assertTrue ( zkClient . exists ( ( ( ( ZkController . CONFIGS_ZKNODE ) + "//" ) + confsetname ) , true ) ) ; args = new String [ ] { "-zkhost" , zkServer . getZkAddress ( ) , "-cmd" , "linkconfig" , "-collection" , "collection1" , "-confname" , confsetname } ; ZkCLI . main ( args ) ; ZkNodeProps collectionProps = ZkNodeProps . load ( zkClient . getData ( ( ( ZkStateReader . COLLECTIONS_ZKNODE ) + "//collection1" ) , null , null , true ) ) ; assertTrue ( collectionProps . containsKey ( "configName" ) ) ; assertEquals ( confsetname , collectionProps . getStr ( "configName" ) ) ; File confDir = new File ( TEMP_DIR , ( ( ( "solrtest-confdropspot-" + ( this . getClass ( ) . getName ( ) ) ) + "-" ) + ( System . currentTimeMillis ( ) ) ) ) ; assertFalse ( confDir . exists ( ) ) ; args = new String [ ] { "-zkhost" , zkServer . getZkAddress ( ) , "-cmd" , "downconfig" , "-confdir" , confDir . getAbsolutePath ( ) , "-confname" , confsetname } ; ZkCLI . main ( args ) ; File [ ] files = confDir . listFiles ( ) ; List < String > zkFiles = zkClient . getChildren ( ( ( ( ZkController . CONFIGS_ZKNODE ) + "//" ) + confsetname ) , null , true ) ; assertEquals ( files . length , zkFiles . size ( ) ) ; File sourceConfDir = new File ( ( ( ( ( ( ExternalPaths . EXAMPLE_HOME ) + ( File . separator ) ) + "collection1" ) + ( File . separator ) ) + "conf" ) ) ; Collection < File > sourceFiles = FileUtils . listFiles ( sourceConfDir , TrueFileFilter . INSTANCE , new RegexFileFilter ( "[^\\.].*" ) ) ; for ( File sourceFile : sourceFiles ) { <START_BUG> int indexOfRelativePath = sourceFile . getAbsolutePath ( ) . lastIndexOf ( "collection1//conf" ) ; <END_BUG> String relativePathofFile = sourceFile . getAbsolutePath ( ) . substring ( ( indexOfRelativePath + 17 ) , sourceFile . getAbsolutePath ( ) . length ( ) ) ; File downloadedFile = new File ( confDir , relativePathofFile ) ; assertTrue ( ( ( ( downloadedFile . getAbsolutePath ( ) ) + "<seq2seq4repair_space>does<seq2seq4repair_space>not<seq2seq4repair_space>exist<seq2seq4repair_space>source:" ) + ( sourceFile . getAbsolutePath ( ) ) ) , downloadedFile . exists ( ) ) ; assertTrue ( "Content<seq2seq4repair_space>didn't<seq2seq4repair_space>change" , FileUtils . contentEquals ( sourceFile , downloadedFile ) ) ; } args = new String [ ] { "-zkhost" , zkServer . getZkAddress ( ) , "-cmd" , "clear" , "//" } ; ZkCLI . main ( args ) ; assertEquals ( 0 , zkClient . getChildren ( "//" , null , true ) . size ( ) ) ; } @ Override public void tearDown ( ) throws Exception { } private void printLayout ( String zkHost ) throws Exception { } }

Fix:
int indexOfRelativePath = sourceFile . getAbsolutePath ( ) . lastIndexOf ( ( ( "collection1" + ( File . separator ) ) + "conf" ) ) ;