use of org.sonar.scanner.bootstrap.ScannerWsClient in project sonarqube by SonarSource.
the class DefaultServerTest method publicRootUrl.
@Test
public void publicRootUrl() {
Settings settings = new MapSettings();
ScannerWsClient client = mock(ScannerWsClient.class);
when(client.baseUrl()).thenReturn("http://foo.com/");
DefaultServer metadata = new DefaultServer(settings, client, null);
settings.setProperty(CoreProperties.SERVER_BASE_URL, "http://server.com/");
assertThat(metadata.getPublicRootUrl()).isEqualTo("http://server.com");
settings.removeProperty(CoreProperties.SERVER_BASE_URL);
assertThat(metadata.getPublicRootUrl()).isEqualTo("http://foo.com");
}
use of org.sonar.scanner.bootstrap.ScannerWsClient in project sonarqube by SonarSource.
the class DefaultRulesLoaderTest method testParseServerResponse.
@Test
public void testParseServerResponse() throws IOException {
ScannerWsClient wsClient = mock(ScannerWsClient.class);
InputStream is = Resources.asByteSource(this.getClass().getResource("DefaultRulesLoaderTest/response.protobuf")).openBufferedStream();
WsTestUtil.mockStream(wsClient, is);
DefaultRulesLoader loader = new DefaultRulesLoader(wsClient);
List<Rule> ruleList = loader.load();
assertThat(ruleList).hasSize(318);
}
use of org.sonar.scanner.bootstrap.ScannerWsClient in project sonarqube by SonarSource.
the class DefaultRulesLoaderTest method testError.
@Test
public void testError() throws IOException {
ScannerWsClient wsClient = mock(ScannerWsClient.class);
InputStream is = ByteSource.wrap(new String("trash").getBytes()).openBufferedStream();
WsTestUtil.mockStream(wsClient, is);
DefaultRulesLoader loader = new DefaultRulesLoader(wsClient);
exception.expect(IllegalStateException.class);
exception.expectMessage("Unable to get rules");
loader.load();
}
use of org.sonar.scanner.bootstrap.ScannerWsClient in project sonarqube by SonarSource.
the class DefaultServerTest method invalid_startup_date_throws_exception.
@Test(expected = RuntimeException.class)
public void invalid_startup_date_throws_exception() {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.SERVER_STARTTIME, "invalid");
ScannerWsClient client = mock(ScannerWsClient.class);
DefaultServer metadata = new DefaultServer(settings, client, null);
metadata.getStartedAt();
}
use of org.sonar.scanner.bootstrap.ScannerWsClient in project sonarqube by SonarSource.
the class DefaultServerTest method shouldLoadServerProperties.
@Test
public void shouldLoadServerProperties() {
Settings settings = new MapSettings();
settings.setProperty(CoreProperties.SERVER_ID, "123");
settings.setProperty(CoreProperties.SERVER_STARTTIME, "2010-05-18T17:59:00+0000");
settings.setProperty(CoreProperties.PERMANENT_SERVER_ID, "abcde");
ScannerWsClient client = mock(ScannerWsClient.class);
when(client.baseUrl()).thenReturn("http://foo.com");
DefaultServer metadata = new DefaultServer(settings, client, SonarRuntimeImpl.forSonarQube(Version.parse("2.2"), SonarQubeSide.SCANNER));
assertThat(metadata.getId()).isEqualTo("123");
assertThat(metadata.getVersion()).isEqualTo("2.2");
assertThat(metadata.getStartedAt()).isNotNull();
assertThat(metadata.getURL()).isEqualTo("http://foo.com");
assertThat(metadata.getPermanentServerId()).isEqualTo("abcde");
assertThat(metadata.getRootDir()).isNull();
assertThat(metadata.getDeployDir()).isNull();
assertThat(metadata.getContextPath()).isNull();
assertThat(metadata.isDev()).isFalse();
assertThat(metadata.isSecured()).isFalse();
}
Aggregations