use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class DevelopmentAgent method main.
public static void main(String[] args) throws Exception {
new ProcessRunner().command("curl", "http://localhost:8153/go/admin/agent-plugins.zip", "--fail", "--silent", "--output", "agent-plugins.zip").failOnError(false).run();
new ProcessRunner().command("curl", "http://localhost:8153/go/admin/tfs-impl.jar", "--fail", "--silent", "--output", "tfs-impl.jar").failOnError(false).run();
new SystemEnvironment().set(SystemEnvironment.PLUGIN_ACTIVATOR_JAR_PATH, "go-plugin-activator.jar");
assertActivationJarPresent();
AgentMain.main("-serverUrl", "https://localhost:8154/go");
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class DevelopmentServer method main.
public static void main(String[] args) throws Exception {
LogConfigurator logConfigurator = new LogConfigurator(DEFAULT_LOGBACK_CONFIGURATION_FILE);
logConfigurator.initialize();
copyDbFiles();
copyPluginAssets();
File webApp = new File("webapp");
if (!webApp.exists()) {
throw new RuntimeException("No webapp found in " + webApp.getAbsolutePath());
}
assertActivationJarPresent();
SystemEnvironment systemEnvironment = new SystemEnvironment();
systemEnvironment.setProperty(GENERATE_STATISTICS, "true");
systemEnvironment.setProperty(SystemEnvironment.PARENT_LOADER_PRIORITY, "true");
systemEnvironment.setProperty(SystemEnvironment.CRUISE_SERVER_WAR_PROPERTY, webApp.getAbsolutePath());
systemEnvironment.set(SystemEnvironment.PLUGIN_LOCATION_MONITOR_INTERVAL_IN_SECONDS, 5);
systemEnvironment.set(SystemEnvironment.DEFAULT_PLUGINS_ZIP, "/plugins.zip");
systemEnvironment.set(SystemEnvironment.PLUGIN_ACTIVATOR_JAR_PATH, "go-plugin-activator.jar");
// 0 means reload when stale
systemEnvironment.setProperty(GoConstants.I18N_CACHE_LIFE, "0");
systemEnvironment.set(SystemEnvironment.GO_SERVER_MODE, "development");
setupPeriodicGC(systemEnvironment);
assertPluginsZipExists();
GoServer server = new GoServer();
systemEnvironment.setProperty(GoConstants.USE_COMPRESSED_JAVASCRIPT, Boolean.toString(false));
try {
server.startServer();
String hostName = systemEnvironment.getListenHost();
if (hostName == null) {
hostName = "localhost";
}
System.out.println("Go server dashboard started on http://" + hostName + ":" + systemEnvironment.getServerPort());
System.out.println("* credentials: \"admin\" / \"badger\"");
} catch (Exception e) {
System.err.println("Failed to start Go server. Exception:");
e.printStackTrace();
}
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class Jetty9ServerTest method setUp.
@Before
public void setUp() throws Exception {
server = mock(Server.class);
Answer<Void> setHandlerMock = new Answer<Void>() {
@Override
public Void answer(InvocationOnMock invocation) throws Throwable {
Handler handler = (Handler) invocation.getArguments()[0];
handler.setServer((Server) invocation.getMock());
return null;
}
};
Mockito.doAnswer(setHandlerMock).when(server).setHandler(any(Handler.class));
systemEnvironment = mock(SystemEnvironment.class);
when(systemEnvironment.getServerPort()).thenReturn(1234);
when(systemEnvironment.keystore()).thenReturn(temporaryFolder.newFolder());
when(systemEnvironment.truststore()).thenReturn(temporaryFolder.newFolder());
when(systemEnvironment.getWebappContextPath()).thenReturn("context");
when(systemEnvironment.getCruiseWar()).thenReturn("cruise.war");
when(systemEnvironment.getParentLoaderPriority()).thenReturn(true);
when(systemEnvironment.useCompressedJs()).thenReturn(true);
when(systemEnvironment.get(SystemEnvironment.RESPONSE_BUFFER_SIZE)).thenReturn(1000);
when(systemEnvironment.get(SystemEnvironment.IDLE_TIMEOUT)).thenReturn(2000);
when(systemEnvironment.configDir()).thenReturn(configDir = temporaryFolder.newFile());
when(systemEnvironment.get(SystemEnvironment.GO_SSL_CONFIG_ALLOW)).thenReturn(true);
when(systemEnvironment.get(SystemEnvironment.GO_SSL_RENEGOTIATION_ALLOWED)).thenReturn(true);
when(systemEnvironment.getJettyConfigFile()).thenReturn(new File("foo"));
when(systemEnvironment.isSessionCookieSecure()).thenReturn(false);
when(systemEnvironment.sessionTimeoutInSeconds()).thenReturn(1234);
when(systemEnvironment.sessionCookieMaxAgeInSeconds()).thenReturn(5678);
SSLSocketFactory sslSocketFactory = mock(SSLSocketFactory.class);
when(sslSocketFactory.getSupportedCipherSuites()).thenReturn(new String[] {});
jetty9Server = new Jetty9Server(systemEnvironment, "pwd", sslSocketFactory, server);
ReflectionUtil.setStaticField(Jetty9Server.class, "JETTY_XML_LOCATION_IN_JAR", "config");
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class GoPlainSocketConnectorTest method setUp.
@Before
public void setUp() {
SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
when(systemEnvironment.getServerPort()).thenReturn(1234);
when(systemEnvironment.get(SystemEnvironment.RESPONSE_BUFFER_SIZE)).thenReturn(100);
when(systemEnvironment.get(SystemEnvironment.IDLE_TIMEOUT)).thenReturn(200);
when(systemEnvironment.getListenHost()).thenReturn("foo");
when(systemEnvironment.get(SystemEnvironment.GO_SSL_CONFIG_ALLOW)).thenReturn(true);
when(systemEnvironment.get(SystemEnvironment.GO_SSL_RENEGOTIATION_ALLOWED)).thenReturn(true);
Jetty9Server server = new Jetty9Server(systemEnvironment, null, mock(SSLSocketFactory.class));
connector = (ServerConnector) new GoPlainSocketConnector(server, systemEnvironment).getConnector();
HttpConnectionFactory connectionFactory = (HttpConnectionFactory) connector.getDefaultConnectionFactory();
configuration = connectionFactory.getHttpConfiguration();
}
use of com.thoughtworks.go.util.SystemEnvironment in project gocd by gocd.
the class H2DatabaseTest method shouldThrowUpWhenBackupFails.
@Test
public void shouldThrowUpWhenBackupFails() throws Exception {
File destDir = new File(".");
SystemEnvironment systemEnvironment = mock(SystemEnvironment.class);
Database database = new H2Database(systemEnvironment);
Database spy = spy(database);
BasicDataSource dataSource = mock(BasicDataSource.class);
Connection connection = mock(Connection.class);
Statement statement = mock(Statement.class);
doReturn(dataSource).when(spy).createDataSource();
when(dataSource.getConnection()).thenReturn(connection);
when(connection.createStatement()).thenReturn(statement);
when(statement.execute(anyString())).thenThrow(new SQLException("i failed"));
try {
spy.backup(destDir);
} catch (RuntimeException e) {
assertThat(e.getMessage(), is("i failed"));
}
verify(statement).execute(anyString());
}
Aggregations