/**
 *
 */
package org.gbif.checklistbank.index;

import org.gbif.checklistbank.index.guice.SolrIndexingModulePrivate;
import org.gbif.checklistbank.service.mybatis.guice.ChecklistBankServiceMyBatisModule;

import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Properties;

import com.google.common.base.Throwables;
import com.google.common.io.Resources;
import com.google.inject.AbstractModule;

/**
 * Guice module that initializes the required classes and dependencies for the CLB indexer
 * using a mocked dataset service.
 */
public class SolrIndexingTestModule extends AbstractModule {

  private final Properties properties;

  public SolrIndexingTestModule(Properties properties) {
    this.properties = properties;
  }

  @Override
  protected void configure() {
    removeUnUsedSolrCfg();
    // Installs the MyBatis service layer
    install(new ChecklistBankServiceMyBatisModule(properties));

    // Installs private indexing module
    install(new SolrIndexingModulePrivate(properties));
  }

  /**
   * Removes Solr config files NOT required to run the tests.
   */
  private static void removeUnUsedSolrCfg(){
    try {
      Files.delete(Paths.get(Resources.getResource("solr/checklistbank/conf/hdfs_directory_factory.xml").toURI()));
    } catch(IllegalArgumentException e){
      // already removed
    } catch(URISyntaxException | IOException ex){
      Throwables.propagate(ex);
    }
  }
}

@@ -204,72 +204,8 @@
 e;%0A%0A
-import java.io.IOException;%0Aimport java.net.URISyntaxException;%0A
 impo
@@ -290,50 +290,8 @@
 s;%0A%0A
-import com.google.common.base.Throwables;%0A
 impo
@@ -365,16 +365,73 @@
 tModule;
+%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;
 %0A%0A/**%0A *
@@ -618,16 +618,107 @@
 Module %7B
+%0A  private static final Logger LOG = LoggerFactory.getLogger(SolrIndexingTestModule.class);
 %0A%0A  priv
@@ -1378,149 +1378,260 @@
     
-%7D catch(IllegalArgumentException e)%7B%0A      // already removed%0A    %7D catch(URISyntaxException %7C IOException ex)%7B%0A      Throwables.propagate(ex
+  LOG.info(%22Removed hdfs_directory_factory.xml from solr resources.%22);%0A    %7D catch(Exception e)%7B%0A      // already removed%0A      LOG.warn(%22Failed to remove hdfs_directory_factory.xml from solr resources. Probably has been removed before%22, e.getMessage()
 );%0A 

Fix solr testing resources