From d80d2affad5cfef2c65b0f0af41c889d51907d6b Mon Sep 17 00:00:00 2001 From: Julien HENRY Date: Wed, 8 Oct 2014 12:18:37 +0200 Subject: [PATCH] Fix UT --- .../sonar/server/startup/GeneratePluginIndexTest.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java b/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java index 0fbabca058e..cc96395bc62 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/startup/GeneratePluginIndexTest.java @@ -22,7 +22,9 @@ package org.sonar.server.startup; import org.apache.commons.io.FileUtils; import org.hamcrest.core.Is; import org.junit.Before; +import org.junit.Rule; import org.junit.Test; +import org.junit.rules.TemporaryFolder; import org.sonar.api.platform.PluginMetadata; import org.sonar.api.platform.PluginRepository; import org.sonar.core.plugins.DefaultPluginMetadata; @@ -40,6 +42,9 @@ import static org.mockito.Mockito.when; public class GeneratePluginIndexTest { + @Rule + public TemporaryFolder temp = new TemporaryFolder(); + private DefaultServerFileSystem fileSystem; private File index; @@ -65,10 +70,11 @@ public class GeneratePluginIndexTest { assertThat(lines.get(1), containsString("checkstyle")); } - private PluginMetadata newMetadata(String pluginKey) { + private PluginMetadata newMetadata(String pluginKey) throws IOException { PluginMetadata plugin = mock(DefaultPluginMetadata.class); when(plugin.getKey()).thenReturn(pluginKey); - when(plugin.getFile()).thenReturn(new File(pluginKey + ".jar")); + File pluginFile = temp.newFile(pluginKey + ".jar"); + when(plugin.getFile()).thenReturn(pluginFile); return plugin; } } -- 2.39.5