use of org.sonar.process.Props in project sonarqube by SonarSource.
the class EsSettingsTest method minProps.
private Props minProps() throws IOException {
File homeDir = temp.newFolder();
Props props = new Props(new Properties());
ProcessProperties.completeDefaults(props);
props.set(ProcessProperties.PATH_HOME, homeDir.getAbsolutePath());
return props;
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class EmbeddedTomcatTest method start.
@Test
public void start() throws Exception {
Props props = new Props(new Properties());
// prepare file system
File home = temp.newFolder();
File data = temp.newFolder();
File webDir = new File(home, "web");
FileUtils.write(new File(home, "web/WEB-INF/web.xml"), "<web-app/>");
props.set("sonar.path.home", home.getAbsolutePath());
props.set("sonar.path.data", data.getAbsolutePath());
props.set("sonar.path.web", webDir.getAbsolutePath());
props.set("sonar.path.logs", temp.newFolder().getAbsolutePath());
// start server on a random port
int httpPort = NetworkUtils.freePort();
int ajpPort = NetworkUtils.freePort();
props.set("sonar.web.port", String.valueOf(httpPort));
props.set("sonar.ajp.port", String.valueOf(ajpPort));
EmbeddedTomcat tomcat = new EmbeddedTomcat(props);
assertThat(tomcat.getStatus()).isEqualTo(EmbeddedTomcat.Status.DOWN);
tomcat.start();
assertThat(tomcat.getStatus()).isEqualTo(EmbeddedTomcat.Status.UP);
// check that http connector accepts requests
URL url = new URL("http://" + Inet4Address.getLocalHost().getHostAddress() + ":" + httpPort);
url.openConnection().connect();
// stop server
tomcat.terminate();
// tomcat.isUp() must not be called. It is used to wait for server startup, not shutdown.
try {
url.openConnection().connect();
fail();
} catch (ConnectException e) {
// expected
}
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class TomcatConnectorsTest method test_max_post_size_for_http_connection.
@Test
public void test_max_post_size_for_http_connection() throws Exception {
Properties properties = new Properties();
Props props = new Props(properties);
TomcatConnectors.configure(tomcat, props);
verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() {
@Override
public boolean matches(Object o) {
Connector c = (Connector) o;
return c.getMaxPostSize() == -1;
}
}));
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class TomcatConnectorsTest method fail_with_ISE_if_http_port_is_invalid.
@Test
public void fail_with_ISE_if_http_port_is_invalid() {
Properties p = new Properties();
p.setProperty("sonar.web.port", "-1");
try {
TomcatConnectors.configure(tomcat, new Props(p));
fail();
} catch (IllegalStateException e) {
assertThat(e).hasMessage("HTTP port '-1' is invalid");
}
}
use of org.sonar.process.Props in project sonarqube by SonarSource.
the class TomcatConnectorsTest method bind_to_specific_address.
@Test
public void bind_to_specific_address() {
Properties p = new Properties();
p.setProperty("sonar.web.port", "9000");
p.setProperty("sonar.web.host", "1.2.3.4");
TomcatConnectors.configure(tomcat, new Props(p));
verify(tomcat.getService()).addConnector(argThat(new ArgumentMatcher<Connector>() {
@Override
public boolean matches(Object o) {
Connector c = (Connector) o;
return c.getScheme().equals("http") && c.getPort() == 9000 && ((InetAddress) c.getProperty("address")).getHostAddress().equals("1.2.3.4");
}
}));
}
Aggregations