Allon Mureinik has uploaded a new change for review. Change subject: core: Enable ServletUtilsTest.testCanReadFile() ......................................................................
core: Enable ServletUtilsTest.testCanReadFile() This test was disabled in commit efa1582eafeac05b5f911dd2ce93fdfe8aa0e542 as it fails when run as root. This patch offers a cleaner way to make sure the build passes - instead of ignoring the test, Assume is used to make sure the user is not root, and if it is, silently skip the test. Using this technique we can make sure that the test is run at least some of time, and gain some extra stability. Change-Id: I754a358221d9fc370d6418a06baf08b97c25b4fa Signed-off-by: Allon Mureinik <[email protected]> --- M backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/servlet/ServletUtilsTest.java 1 file changed, 6 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/23713/1 diff --git a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/servlet/ServletUtilsTest.java b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/servlet/ServletUtilsTest.java index 1dde817..64753be 100644 --- a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/servlet/ServletUtilsTest.java +++ b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/servlet/ServletUtilsTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; import static org.mockito.Matchers.anyInt; import static org.mockito.Matchers.anyObject; import static org.mockito.Matchers.anyString; @@ -26,7 +27,6 @@ import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; -import org.junit.Ignore; import org.junit.Test; public class ServletUtilsTest { @@ -34,9 +34,13 @@ /** * Test method for {@link org.ovirt.engine.core.utils.servlet.ServletUtils#canReadFile(java.io.File)}. */ - @Ignore("Fails when run as root") @Test public void testCanReadFile() { + // Make sure the user is not root + // This tests relies on EXISTING files which only root can access + String userName = System.getProperty("user.name"); + assumeTrue(!"root".equals(userName)); + //Does not exist. File file = new File("/doesnotexist/iamprettysure"); assertFalse("We should not be able to read this file.", ServletUtils.canReadFile(file)); -- To view, visit http://gerrit.ovirt.org/23713 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I754a358221d9fc370d6418a06baf08b97c25b4fa Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
