diff options
author | Julien Lancelot <julien.lancelot@gmail.com> | 2013-04-15 11:04:56 +0200 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@gmail.com> | 2013-04-15 11:04:56 +0200 |
commit | 6a668ae51997916091378a9cc7295f5578cc9416 (patch) | |
tree | 78312f5880a2c0830e788fa400e64fdc2cd22547 | |
parent | 949a8872ccb966569da2f7b905e9f2bccb0367eb (diff) | |
parent | 0d23f4f179fc5dd6bebd6729369bbba6ac9292b3 (diff) | |
download | sonarqube-6a668ae51997916091378a9cc7295f5578cc9416.tar.gz sonarqube-6a668ae51997916091378a9cc7295f5578cc9416.zip |
Merge remote-tracking branch 'origin/master'
-rw-r--r-- | sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml | 2 | ||||
-rw-r--r-- | sonar-server/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java | 41 |
2 files changed, 28 insertions, 15 deletions
diff --git a/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml b/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml index f2338f3bddc..b8f800fbb70 100644 --- a/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/user/AuthorizationMapper.xml @@ -12,7 +12,7 @@ and gr.resource_id = s.root_project_id and s.project_id in <foreach item="componentId" index="index" collection="componentIds" open="(" separator="," close=")">#{componentId}</foreach> and s.islast = ${_true} - UNION DISTINCT + UNION SELECT s.project_id FROM user_roles ur, snapshots s WHERE diff --git a/sonar-server/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java b/sonar-server/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java index bb51977f1f2..d3bbfdb535f 100644 --- a/sonar-server/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java +++ b/sonar-server/src/test/java/org/sonar/server/plugins/PluginDownloaderTest.java @@ -19,6 +19,7 @@ */ package org.sonar.server.plugins; +import org.apache.commons.io.FilenameUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; @@ -33,19 +34,15 @@ import org.sonar.updatecenter.common.UpdateCenter; import org.sonar.updatecenter.common.Version; import java.io.File; -import java.io.IOException; import java.net.URI; import static com.google.common.collect.Lists.newArrayList; import static org.fest.assertions.Assertions.assertThat; +import static org.fest.assertions.Fail.fail; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.argThat; -import static org.mockito.Mockito.doThrow; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; public class PluginDownloaderTest { @@ -60,7 +57,7 @@ public class PluginDownloaderTest { private PluginDownloader pluginDownloader; @Before - public void before() throws IOException { + public void before() throws Exception { updateCenterMatrixFactory = mock(UpdateCenterMatrixFactory.class); updateCenter = mock(UpdateCenter.class); when(updateCenterMatrixFactory.getUpdateCenter(anyBoolean())).thenReturn(updateCenter); @@ -86,13 +83,19 @@ public class PluginDownloaderTest { verify(httpDownloader).download(any(URI.class), argThat(new HasFileName("test-1.0.jar"))); } - @Test(expected = SonarException.class) + @Test public void should_throw_exception_if_download_dir_is_invalid() throws Exception { DefaultServerFileSystem defaultServerFileSystem = mock(DefaultServerFileSystem.class); // download dir is a file instead of being a directory File downloadDir = testFolder.newFile(); when(defaultServerFileSystem.getDownloadedPluginsDir()).thenReturn(downloadDir); - new PluginDownloader(updateCenterMatrixFactory, httpDownloader, defaultServerFileSystem); + + try { + new PluginDownloader(updateCenterMatrixFactory, httpDownloader, defaultServerFileSystem); + fail(); + } catch (SonarException e) { + // ok + } } @Test @@ -100,7 +103,7 @@ public class PluginDownloaderTest { Plugin test = new Plugin("test"); File file = testFolder.newFile("test-1.0.jar"); file.createNewFile(); - Release test10 = new Release(test, "1.0").setDownloadUrl("file://"+ file.getAbsoluteFile()); + Release test10 = new Release(test, "1.0").setDownloadUrl("file://" + FilenameUtils.separatorsToUnix(file.getCanonicalPath())); test.addRelease(test10); when(updateCenter.findInstallablePlugins("foo", Version.create("1.0"))).thenReturn(newArrayList(test10)); @@ -110,7 +113,7 @@ public class PluginDownloaderTest { assertThat(pluginDownloader.hasDownloads()).isTrue(); } - @Test(expected = SonarException.class) + @Test public void should_throw_exception_if_could_not_download() throws Exception { Plugin test = new Plugin("test"); Release test10 = new Release(test, "1.0").setDownloadUrl("file://not_found"); @@ -118,10 +121,15 @@ public class PluginDownloaderTest { when(updateCenter.findInstallablePlugins("foo", Version.create("1.0"))).thenReturn(newArrayList(test10)); - pluginDownloader.download("foo", Version.create("1.0")); + try { + pluginDownloader.download("foo", Version.create("1.0")); + fail(); + } catch (SonarException e) { + // ok + } } - @Test(expected = SonarException.class) + @Test public void should_throw_exception_if_download_fail() throws Exception { Plugin test = new Plugin("test"); Release test10 = new Release(test, "1.0").setDownloadUrl("http://server/test-1.0.jar"); @@ -130,7 +138,12 @@ public class PluginDownloaderTest { doThrow(new RuntimeException()).when(httpDownloader).download(any(URI.class), any(File.class)); - pluginDownloader.download("foo", Version.create("1.0")); + try { + pluginDownloader.download("foo", Version.create("1.0")); + fail(); + } catch (SonarException e) { + // ok + } } @Test |