From 848a410ca1e4be7b27fe7d338e64fe599351c9c2 Mon Sep 17 00:00:00 2001 From: markrmiller Date: Thu, 22 Mar 2018 09:32:37 -0500 Subject: [PATCH] SOLR-10075: TestNonWritablePersistFile fails when run as a single test under root. --- .../TestNonWritablePersistFile.java | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestNonWritablePersistFile.java b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestNonWritablePersistFile.java index a7d3d0afec3..4d43ff6bc1b 100644 --- a/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestNonWritablePersistFile.java +++ b/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestNonWritablePersistFile.java @@ -70,10 +70,24 @@ public class TestNonWritablePersistFile extends AbstractDataImportHandlerTestCas try { // execute the test only if we are able to set file to read only mode - assumeTrue("No dataimport.properties file", f.exists() || f.createNewFile()); - assumeTrue("dataimport.properties can't be set read only", f.setReadOnly()); - assumeFalse("dataimport.properties is still writable even though " + - "marked readonly - test running as superuser?", f.canWrite()); + // we don't use assume because if no tests executes when you run a single test + // it's considered a fail + + if (!(f.exists() || f.createNewFile())) { + System.err.println("No dataimport.properties file, skipping rest of test ..."); + return; + } + + if (!f.setReadOnly()) { + System.err.println("dataimport.properties can't be set read only, skipping rest of test ..."); + return; + } + + if (f.canWrite()) { + System.err.println("dataimport.properties is still writable even though \" + \n" + + " \"marked readonly - test running as superuser?, skipping rest of test ..."); + return; + } ignoreException("Properties is not writable");