Search in sources :

Example 16 with TestResponse

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\"}");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Example 17 with TestResponse

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\"}");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Date(java.util.Date) Test(org.junit.Test)

Example 18 with TestResponse

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\"}");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Example 19 with TestResponse

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}");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) File(java.io.File) Test(org.junit.Test)

Example 20 with TestResponse

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}");
}
Also used : TestResponse(org.sonar.server.ws.TestResponse) Test(org.junit.Test)

Aggregations

TestResponse (org.sonar.server.ws.TestResponse)67 Test (org.junit.Test)64 OrganizationDto (org.sonar.db.organization.OrganizationDto)18 WsCe (org.sonarqube.ws.WsCe)13 ComponentDto (org.sonar.db.component.ComponentDto)9 CeActivityDto (org.sonar.db.ce.CeActivityDto)4 InputStream (java.io.InputStream)2 Date (java.util.Date)2 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)2 UserDto (org.sonar.db.user.UserDto)2 ProjectRepositories (org.sonar.scanner.protocol.input.ProjectRepositories)2 File (java.io.File)1 IOException (java.io.IOException)1 LinkedHashMap (java.util.LinkedHashMap)1 CeQueueDto (org.sonar.db.ce.CeQueueDto)1 ComponentLinkDto (org.sonar.db.component.ComponentLinkDto)1 IssueDto (org.sonar.db.issue.IssueDto)1 PropertyDto (org.sonar.db.property.PropertyDto)1 RuleDto (org.sonar.db.rule.RuleDto)1 FileData (org.sonar.scanner.protocol.input.FileData)1