diff options
Diffstat (limited to 'sonar-ws-client/src/test')
4 files changed, 89 insertions, 0 deletions
diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerSetupQueryTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerSetupQueryTest.java new file mode 100644 index 00000000000..bd405916329 --- /dev/null +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/services/ServerSetupQueryTest.java @@ -0,0 +1,34 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.wsclient.services; + +import static org.hamcrest.Matchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.Test; + +public class ServerSetupQueryTest extends QueryTestCase { + @Test + public void index() { + ServerSetupQuery query = new ServerSetupQuery(); + assertThat(query.getUrl(), is("/api/server/setup")); + assertThat(query.getModelClass().getName(), is(ServerSetup.class.getName())); + } +} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshallerTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshallerTest.java new file mode 100644 index 00000000000..60df75b7bdd --- /dev/null +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshallerTest.java @@ -0,0 +1,48 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2011 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.wsclient.unmarshallers; + +import org.junit.Test; +import org.sonar.wsclient.services.Server; +import org.sonar.wsclient.services.ServerSetup; + +import static org.hamcrest.CoreMatchers.nullValue; +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +public class ServerSetupUnmarshallerTest extends UnmarshallerTestCase { + + @Test + public void testSuccessfulSetup() { + ServerSetup setup = new ServerSetupUnmarshaller().toModel(loadFile("/server_setup/ok.json")); + assertThat(setup.getStatus(), is("ok")); + assertThat(setup.getMessage(), nullValue()); + assertThat(setup.isSuccessful(), is(true)); + } + + @Test + public void testFailedSetup() { + ServerSetup setup = new ServerSetupUnmarshaller().toModel(loadFile("/server_setup/ko.json")); + assertThat(setup.getStatus(), is("ko")); + assertThat(setup.getMessage(), is("error")); + assertThat(setup.isSuccessful(), is(false)); + } + +} diff --git a/sonar-ws-client/src/test/resources/server_setup/ko.json b/sonar-ws-client/src/test/resources/server_setup/ko.json new file mode 100644 index 00000000000..3cbef3d1a36 --- /dev/null +++ b/sonar-ws-client/src/test/resources/server_setup/ko.json @@ -0,0 +1,4 @@ +{ + "status" : "ko", + "msg": "error" +}
\ No newline at end of file diff --git a/sonar-ws-client/src/test/resources/server_setup/ok.json b/sonar-ws-client/src/test/resources/server_setup/ok.json new file mode 100644 index 00000000000..6518b73dc3b --- /dev/null +++ b/sonar-ws-client/src/test/resources/server_setup/ok.json @@ -0,0 +1,3 @@ +{ + "status" : "ok" +}
\ No newline at end of file |