diff --git a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java index 733a4a13932..3f8326cedcd 100644 --- a/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/CreateCollectionCleanupTest.java @@ -21,11 +21,11 @@ import static org.hamcrest.CoreMatchers.hasItem; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.not; +import java.nio.file.Path; import java.util.Properties; +import org.apache.solr.client.solrj.impl.BaseHttpSolrClient; import org.apache.solr.client.solrj.impl.CloudSolrClient; -import org.apache.solr.client.solrj.impl.HttpSolrClient; import org.apache.solr.client.solrj.request.CollectionAdminRequest; -import org.apache.solr.client.solrj.response.CollectionAdminResponse; import org.apache.solr.client.solrj.response.RequestStatusState; import org.apache.solr.common.params.CoreAdminParams; import org.junit.BeforeClass; @@ -77,10 +77,12 @@ public class CreateCollectionCleanupTest extends SolrCloudTestCase { CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,"conf1",1,1); Properties properties = new Properties(); - properties.put(CoreAdminParams.DATA_DIR, "/some_invalid_dir/foo"); + Path tmpDir = createTempDir(); + tmpDir.toFile().setWritable(false); + properties.put(CoreAdminParams.DATA_DIR, tmpDir.toString()); create.setProperties(properties); - expectThrows(HttpSolrClient.RemoteSolrException.class, () -> { - CollectionAdminResponse rsp = create.process(cloudClient); + expectThrows(BaseHttpSolrClient.RemoteSolrException.class, () -> { + create.process(cloudClient); }); // Confirm using LIST that the collection does not exist @@ -99,7 +101,9 @@ public class CreateCollectionCleanupTest extends SolrCloudTestCase { CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName,"conf1",1,1); Properties properties = new Properties(); - properties.put(CoreAdminParams.DATA_DIR, "/some_invalid_dir/foo2"); + Path tmpDir = createTempDir(); + tmpDir.toFile().setWritable(false); + properties.put(CoreAdminParams.DATA_DIR, tmpDir.toString()); create.setProperties(properties); create.setAsyncId("testAsyncCreateCollectionCleanup"); create.process(cloudClient);