aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/test/java/org/sonar/server/exceptions/HttpExceptionTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/test/java/org/sonar/server/exceptions/HttpExceptionTest.java')
-rw-r--r--sonar-server/src/test/java/org/sonar/server/exceptions/HttpExceptionTest.java57
1 files changed, 57 insertions, 0 deletions
diff --git a/sonar-server/src/test/java/org/sonar/server/exceptions/HttpExceptionTest.java b/sonar-server/src/test/java/org/sonar/server/exceptions/HttpExceptionTest.java
new file mode 100644
index 00000000000..7b6619bab65
--- /dev/null
+++ b/sonar-server/src/test/java/org/sonar/server/exceptions/HttpExceptionTest.java
@@ -0,0 +1,57 @@
+/*
+ * SonarQube, open source software quality management tool.
+ * Copyright (C) 2008-2013 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * SonarQube 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.
+ *
+ * SonarQube 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 this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.sonar.server.exceptions;
+
+import org.junit.Test;
+
+import static org.fest.assertions.Assertions.assertThat;
+
+public class HttpExceptionTest {
+
+ @Test
+ public void should_create_exception_with_status(){
+ HttpException exception = new HttpException(400);
+ assertThat(exception.httpCode()).isEqualTo(400);
+ }
+
+ @Test
+ public void should_create_exception_with_status_and_message(){
+ HttpException exception = new HttpException(404, "Not found");
+ assertThat(exception.httpCode()).isEqualTo(404);
+ assertThat(exception.getMessage()).isEqualTo("Not found");
+ }
+
+ @Test
+ public void should_create_exception_with_status_and_l10n_message_with_param(){
+ HttpException exception = new HttpException(404, null, "key", new String[]{"value"});
+ assertThat(exception.httpCode()).isEqualTo(404);
+ assertThat(exception.l10nKey()).isEqualTo("key");
+ assertThat(exception.l10nParams()).containsOnly("value");
+ }
+
+ @Test
+ public void should_create_exception_with_status_and_l10n_message_without_param(){
+ HttpException exception = new HttpException(404, null, "key", null);
+ assertThat(exception.httpCode()).isEqualTo(404);
+ assertThat(exception.l10nKey()).isEqualTo("key");
+ assertThat(exception.l10nParams()).isEmpty();
+ }
+}