From 2edba3d455d44a08b4ad0483f0aa31e1aa5747f3 Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Fri, 9 Jun 2017 12:33:27 +0200 Subject: Rewrite test so that it works even when running as root --- .../yahoo/config/subscription/impl/FileConfigSubscriptionTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'config') diff --git a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java index ce9323f0ec7..850c875cae4 100644 --- a/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java +++ b/config/src/test/java/com/yahoo/config/subscription/impl/FileConfigSubscriptionTest.java @@ -1,7 +1,6 @@ // Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.config.subscription.impl; -import com.yahoo.config.ConfigurationRuntimeException; import com.yahoo.foo.SimpletypesConfig; import com.yahoo.foo.TestReferenceConfig; import com.yahoo.config.subscription.ConfigSubscriber; @@ -15,6 +14,7 @@ import org.junit.Test; import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.nio.file.Files; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertFalse; @@ -89,7 +89,7 @@ public class FileConfigSubscriptionTest { assertThat(sub.config.configId(), is(cfgId)); } - @Test(expected = ConfigurationRuntimeException.class) + @Test(expected = IllegalArgumentException.class) public void require_that_bad_file_throws_exception() throws IOException { // A little trick to ensure that we can create the subscriber, but that we get an error when reading. writeConfig("intval", "23"); @@ -99,7 +99,7 @@ public class FileConfigSubscriptionTest { subscriber, TEST_TYPES_FILE); sub.reload(1); - assertTrue(TEST_TYPES_FILE.setReadable(false)); + Files.delete(TEST_TYPES_FILE.toPath()); // delete file so the below statement throws exception sub.nextConfig(0); } } -- cgit v1.2.3