.setSince("2.10");
defineIndexAction(controller);
- defineSystemAction(controller);
defineSetupAction(controller);
controller.done();
RailsHandler.addFormatParam(action);
}
- private void defineSystemAction(NewController controller) {
- NewAction action = controller.createAction("system")
- .setDescription("Get the system properties, server info (Java, OS), database configuration, JVM statistics and installed plugins. Requires Administer System permission")
- .setSince("2.10")
- .setHandler(RailsHandler.INSTANCE)
- .setResponseExample(Resources.getResource(this.getClass(), "example-system.json"));
-
- RailsHandler.addFormatParam(action);
- }
-
private void defineSetupAction(NewController controller) {
NewAction action = controller.createAction("setup")
.setDescription("Upgrade the SonarQube database")
+++ /dev/null
-[
- {
- "system_info": {
- "System date": "Wed Oct 10 19:15:20 CEST 2012",
- "JVM Vendor": "Sun Microsystems Inc.",
- "JVM Name": "Java HotSpot(TM) Client VM"
- },
- "system_statistics": {
- "Total Memory": "316 MB",
- "Free Memory": "195 MB"
- },
- "sonar_info": {
- "Version": "4.3",
- "Started at": "Mon May 05 09:06:52 CEST 2014",
- "Database": "PostgreSQL 9.1.9"
- },
- "sonar_plugins": {
- "JaCoCo": "2.1",
- "Java": "2.1"
- },
- "system_properties": {
- "LANG": "en_US.UTF-8",
- "LC_ALL": "en_US.UTF-8",
- "LC_CTYPE": "UTF-8"
- }
- }
-]
package org.sonar.server.platform.ws;
-import org.junit.Before;
import org.junit.Test;
import org.sonar.api.server.ws.RailsHandler;
import org.sonar.api.server.ws.WebService;
public class ServerWsTest {
- WsTester tester;
-
- @Before
- public void setUp() throws Exception {
- tester = new WsTester(new ServerWs());
- }
+ WsTester tester = new WsTester(new ServerWs());
@Test
public void define_controller() throws Exception {
assertThat(controller).isNotNull();
assertThat(controller.since()).isEqualTo("2.10");
assertThat(controller.description()).isNotEmpty();
- assertThat(controller.actions()).hasSize(3);
+ assertThat(controller.actions()).hasSize(2);
}
@Test
assertThat(action.params()).hasSize(1);
}
- @Test
- public void define_system_action() throws Exception {
- WebService.Controller controller = tester.controller("api/server");
-
- WebService.Action action = controller.action("system");
- assertThat(action).isNotNull();
- assertThat(action.handler()).isInstanceOf(RailsHandler.class);
- assertThat(action.responseExampleAsString()).isNotEmpty();
- assertThat(action.params()).hasSize(1);
- }
-
@Test
public void define_setup_action() throws Exception {
WebService.Controller controller = tester.controller("api/server");