List of usage examples for org.apache.solr.core CoreDescriptor getInstanceDir
public Path getInstanceDir()
From source file:org.springframework.data.solr.AbstractITestWithEmbeddedSolrServer.java
License:Apache License
@BeforeClass public static void initSolrServer() throws IOException, ParserConfigurationException, SAXException, InterruptedException { String solrHome = ResourceUtils.getURL("classpath:org/springframework/data/solr").getPath(); CoreContainer coreContainer = CoreContainer.createAndLoad(solrHome, new File(solrHome + "/solr.xml")); for (SolrCore core : coreContainer.getCores()) { core.addCloseHook(new CloseHook() { @Override// ww w. j a v a 2 s . c o m public void preClose(SolrCore core) { } @Override public void postClose(SolrCore core) { CoreDescriptor cd = core.getCoreDescriptor(); if (cd != null) { File dataDir = new File(cd.getInstanceDir() + File.separator + "data"); try { FileUtils.deleteDirectory(dataDir); } catch (IOException e) { e.printStackTrace(); } } } }); } solrServer = new EmbeddedSolrServer(coreContainer, "collection1"); }