use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class IndexActionTest method support_BCP47_formatted_language_tags.
@Test
public void support_BCP47_formatted_language_tags() throws Exception {
String key1 = "key1";
when(i18n.getPropertyKeys()).thenReturn(ImmutableSet.of(key1));
when(i18n.message(UK, key1, key1)).thenReturn(key1);
TestResponse result = call("en-GB", null);
verify(i18n).getPropertyKeys();
verify(i18n).message(UK, key1, key1);
assertJson(result.getInput()).isSimilarTo("{\"key1\":\"key1\"}");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class IndexActionTest method return_all_l10n_messages_using_accept_header_with_cache_expired.
@Test
public void return_all_l10n_messages_using_accept_header_with_cache_expired() throws Exception {
Date now = new Date();
Date aBitEarlier = new Date(now.getTime() - 1000);
when(server.getStartedAt()).thenReturn(now);
when(i18n.getPropertyKeys()).thenReturn(ImmutableSet.of(KEY_1, KEY_2, KEY_3));
when(i18n.message(PRC, KEY_1, KEY_1)).thenReturn(KEY_1);
when(i18n.message(PRC, KEY_2, KEY_2)).thenReturn(KEY_2);
when(i18n.message(PRC, KEY_3, KEY_3)).thenReturn(KEY_3);
TestResponse result = call(PRC.toLanguageTag(), DateUtils.formatDateTime(aBitEarlier));
verify(i18n).getPropertyKeys();
verify(i18n).message(PRC, KEY_1, KEY_1);
verify(i18n).message(PRC, KEY_2, KEY_2);
verify(i18n).message(PRC, KEY_3, KEY_3);
assertJson(result.getInput()).isSimilarTo("{\"key1\":\"key1\",\"key2\":\"key2\",\"key3\":\"key3\"}");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class IndexActionTest method default_locale_is_english.
@Test
public void default_locale_is_english() throws Exception {
String key1 = "key1";
String key2 = "key2";
String key3 = "key3";
when(i18n.getPropertyKeys()).thenReturn(ImmutableSet.of(key1, key2, key3));
when(i18n.message(ENGLISH, key1, key1)).thenReturn(key1);
when(i18n.message(ENGLISH, key2, key2)).thenReturn(key2);
when(i18n.message(ENGLISH, key3, key3)).thenReturn(key3);
TestResponse result = call(null, null);
verify(i18n).getPropertyKeys();
verify(i18n).message(ENGLISH, key1, key1);
verify(i18n).message(ENGLISH, key2, key2);
verify(i18n).message(ENGLISH, key3, key3);
assertJson(result.getInput()).isSimilarTo("{\"key1\":\"key1\",\"key2\":\"key2\",\"key3\":\"key3\"}");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class LogsActionTest method do_not_return_rotated_files.
@Test
public void do_not_return_rotated_files() throws IOException {
logInAsSystemAdministrator();
File dir = createLogsDir();
FileUtils.write(new File(dir, "sonar.1.log"), "{old}");
FileUtils.write(new File(dir, "sonar.log"), "{recent}");
TestResponse response = actionTester.newRequest().setParam("process", "app").execute();
assertThat(response.getMediaType()).isEqualTo(MediaTypes.TXT);
assertThat(response.getInput()).isEqualTo("{recent}");
}
use of org.sonar.server.ws.TestResponse in project sonarqube by SonarSource.
the class LogsActionTest method get_web_logs.
@Test
public void get_web_logs() throws IOException {
logInAsSystemAdministrator();
createAllLogsFiles();
TestResponse response = actionTester.newRequest().setParam("process", "web").execute();
assertThat(response.getMediaType()).isEqualTo(MediaTypes.TXT);
assertThat(response.getInput()).isEqualTo("{web}");
}
Aggregations