aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@gmail.com>2014-03-21 16:40:07 +0100
committerSimon Brandhof <simon.brandhof@gmail.com>2014-03-21 16:40:15 +0100
commit4a77e99189510fd586d57900a7e9d7742647ff58 (patch)
tree732bcf005828d824bb4ed5ac86b6d08828d148aa /sonar-server
parentbe698baf4b4519eb43b5494be23a04703a550c9a (diff)
downloadsonarqube-4a77e99189510fd586d57900a7e9d7742647ff58.tar.gz
sonarqube-4a77e99189510fd586d57900a7e9d7742647ff58.zip
SONAR-4843 move URL to /api/system/restart and complete ws-client
Diffstat (limited to 'sonar-server')
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java4
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/ws/RestartHandler.java6
-rw-r--r--sonar-server/src/main/java/org/sonar/server/platform/ws/SystemWs.java (renamed from sonar-server/src/main/java/org/sonar/server/platform/ws/PlatformWs.java)6
-rw-r--r--sonar-server/src/test/java/org/sonar/server/platform/ws/RestartHandlerTest.java10
-rw-r--r--sonar-server/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java (renamed from sonar-server/src/test/java/org/sonar/server/platform/ws/PlatformWsTest.java)8
5 files changed, 16 insertions, 18 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
index d9dd54c0e01..2c8b84ed6fa 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/ServerComponents.java
@@ -95,7 +95,7 @@ import org.sonar.server.notifications.NotificationService;
import org.sonar.server.permission.InternalPermissionService;
import org.sonar.server.permission.InternalPermissionTemplateService;
import org.sonar.server.permission.PermissionFinder;
-import org.sonar.server.platform.ws.PlatformWs;
+import org.sonar.server.platform.ws.SystemWs;
import org.sonar.server.platform.ws.RestartHandler;
import org.sonar.server.plugins.*;
import org.sonar.server.qualitygate.QgateProjectFinder;
@@ -191,7 +191,7 @@ class ServerComponents {
// ws
RestartHandler.class,
- PlatformWs.class
+ SystemWs.class
);
}
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ws/RestartHandler.java b/sonar-server/src/main/java/org/sonar/server/platform/ws/RestartHandler.java
index 75b080a21f3..d40d0651887 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/ws/RestartHandler.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/ws/RestartHandler.java
@@ -26,7 +26,7 @@ import org.sonar.api.server.ws.Request;
import org.sonar.api.server.ws.RequestHandler;
import org.sonar.api.server.ws.Response;
import org.sonar.api.server.ws.WebService;
-import org.sonar.server.exceptions.BadRequestException;
+import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.platform.Platform;
public class RestartHandler implements RequestHandler {
@@ -41,7 +41,7 @@ public class RestartHandler implements RequestHandler {
void define(WebService.NewController controller) {
controller.createAction("restart")
- .setDescription("Restart server. Available only in development mode.")
+ .setDescription("Restart server. Available only on development mode (sonar.dev=true)")
.setPost(true)
.setHandler(this);
}
@@ -56,7 +56,7 @@ public class RestartHandler implements RequestHandler {
response.noContent();
} else {
- throw new BadRequestException("Available in development mode only (sonar.dev=true)");
+ throw new ForbiddenException();
}
}
}
diff --git a/sonar-server/src/main/java/org/sonar/server/platform/ws/PlatformWs.java b/sonar-server/src/main/java/org/sonar/server/platform/ws/SystemWs.java
index ee9b878e103..282eb8b840f 100644
--- a/sonar-server/src/main/java/org/sonar/server/platform/ws/PlatformWs.java
+++ b/sonar-server/src/main/java/org/sonar/server/platform/ws/SystemWs.java
@@ -21,17 +21,17 @@ package org.sonar.server.platform.ws;
import org.sonar.api.server.ws.WebService;
-public class PlatformWs implements WebService {
+public class SystemWs implements WebService {
private final RestartHandler restartHandler;
- public PlatformWs(RestartHandler restartHandler) {
+ public SystemWs(RestartHandler restartHandler) {
this.restartHandler = restartHandler;
}
@Override
public void define(Context context) {
- NewController controller = context.createController("api/platform")
+ NewController controller = context.createController("api/system")
.setSince("4.3");
restartHandler.define(controller);
diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ws/RestartHandlerTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ws/RestartHandlerTest.java
index 03b2b3d6428..ca18bb20d2f 100644
--- a/sonar-server/src/test/java/org/sonar/server/platform/ws/RestartHandlerTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/platform/ws/RestartHandlerTest.java
@@ -22,10 +22,9 @@ package org.sonar.server.platform.ws;
import org.junit.Test;
import org.sonar.api.config.Settings;
import org.sonar.api.server.ws.WsTester;
-import org.sonar.server.exceptions.BadRequestException;
+import org.sonar.server.exceptions.ForbiddenException;
import org.sonar.server.platform.Platform;
-import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
@@ -39,7 +38,7 @@ public class RestartHandlerTest {
Settings settings = new Settings();
settings.setProperty("sonar.dev", true);
RestartHandler restartHandler = new RestartHandler(settings, platform);
- PlatformWs ws = new PlatformWs(restartHandler);
+ SystemWs ws = new SystemWs(restartHandler);
WsTester tester = new WsTester(ws);
tester.newRequest("restart").execute();
@@ -52,14 +51,13 @@ public class RestartHandlerTest {
Platform platform = mock(Platform.class);
Settings settings = new Settings();
RestartHandler restartHandler = new RestartHandler(settings, platform);
- PlatformWs ws = new PlatformWs(restartHandler);
+ SystemWs ws = new SystemWs(restartHandler);
WsTester tester = new WsTester(ws);
try {
tester.newRequest("restart").execute();
fail();
- } catch (BadRequestException e) {
- assertThat(e).hasMessage("Available in development mode only (sonar.dev=true)");
+ } catch (ForbiddenException e) {
verifyZeroInteractions(platform);
}
}
diff --git a/sonar-server/src/test/java/org/sonar/server/platform/ws/PlatformWsTest.java b/sonar-server/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
index bd29268a20b..97800606bb3 100644
--- a/sonar-server/src/test/java/org/sonar/server/platform/ws/PlatformWsTest.java
+++ b/sonar-server/src/test/java/org/sonar/server/platform/ws/SystemWsTest.java
@@ -27,20 +27,20 @@ import org.sonar.server.platform.Platform;
import static org.fest.assertions.Assertions.assertThat;
import static org.mockito.Mockito.mock;
-public class PlatformWsTest {
+public class SystemWsTest {
@Test
public void define() throws Exception {
Platform platform = mock(Platform.class);
Settings settings = new Settings();
RestartHandler restartHandler = new RestartHandler(settings, platform);
- PlatformWs ws = new PlatformWs(restartHandler);
+ SystemWs ws = new SystemWs(restartHandler);
WebService.Context context = new WebService.Context();
ws.define(context);
assertThat(context.controllers()).hasSize(1);
- assertThat(context.controller("api/platform")).isNotNull();
- assertThat(context.controller("api/platform").actions()).isNotEmpty();
+ assertThat(context.controller("api/system")).isNotNull();
+ assertThat(context.controller("api/system").actions()).isNotEmpty();
}
}