From 8596b9b566745ca65b3a75fe8b6d4c091369fedc Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 19 Nov 2012 18:47:58 +0100 Subject: o Integrating new httpcommons code. --- src/main/java/io/trygvis/esper/testing/Config.java | 48 +++-- src/main/java/io/trygvis/esper/testing/Dao.java | 4 +- .../testing/EasySSLProtocolSocketFactory.java | 232 --------------------- .../esper/testing/EasySSLSocketFactory.java | 104 +++++++++ .../esper/testing/EasyX509TrustManager.java | 36 ---- src/main/java/io/trygvis/esper/testing/Http.java | 2 +- .../java/io/trygvis/esper/testing/HttpClient.java | 19 +- src/main/java/io/trygvis/esper/testing/Main.java | 25 +-- .../esper/testing/gitorious/GitoriousImporter.java | 12 +- .../esper/testing/jenkins/JenkinsImporter.java | 5 +- src/main/resources/logback-test.xml | 2 + 11 files changed, 159 insertions(+), 330 deletions(-) delete mode 100755 src/main/java/io/trygvis/esper/testing/EasySSLProtocolSocketFactory.java create mode 100755 src/main/java/io/trygvis/esper/testing/EasySSLSocketFactory.java mode change 100644 => 100755 src/main/java/io/trygvis/esper/testing/Http.java mode change 100644 => 100755 src/main/java/io/trygvis/esper/testing/Main.java mode change 100644 => 100755 src/main/resources/logback-test.xml (limited to 'src') diff --git a/src/main/java/io/trygvis/esper/testing/Config.java b/src/main/java/io/trygvis/esper/testing/Config.java index d089511..d99a18a 100755 --- a/src/main/java/io/trygvis/esper/testing/Config.java +++ b/src/main/java/io/trygvis/esper/testing/Config.java @@ -1,48 +1,58 @@ package io.trygvis.esper.testing; +import ch.qos.logback.classic.*; +import ch.qos.logback.core.util.*; import fj.data.*; -import org.apache.commons.httpclient.protocol.*; -import static org.apache.commons.lang.StringUtils.*; -import org.apache.log4j.*; - import java.io.*; import java.util.*; +import org.apache.commons.httpclient.protocol.*; +import org.slf4j.*; + +import static org.apache.commons.lang.StringUtils.*; public class Config { public final String gitoriousUrl; public final Option gitoriousSessionValue; public final String nexusUrl; - public Config(String gitoriousUrl, Option gitoriousSessionValue, String nexusUrl) { + public final String databaseDriver; + public final String databaseUrl; + public final String databaseUsername; + public final String databasePassword; + + public Config(String gitoriousUrl, Option gitoriousSessionValue, String nexusUrl, String databaseDriver, String databaseUrl, String databaseUsername, String databasePassword) { this.gitoriousUrl = gitoriousUrl; this.gitoriousSessionValue = gitoriousSessionValue; this.nexusUrl = nexusUrl; + this.databaseDriver = databaseDriver; + this.databaseUrl = databaseUrl; + this.databaseUsername = databaseUsername; + this.databasePassword = databasePassword; } public static Config loadFromDisk() throws IOException { - configureLog4j(); - - Protocol.registerProtocol("https", new Protocol("https", (ProtocolSocketFactory) new EasySSLProtocolSocketFactory(), 443)); + initLogging(); Properties properties = new Properties(); try (FileInputStream inputStream = new FileInputStream("config.properties")) { properties.load(inputStream); } + String driver = trimToNull(properties.getProperty("database.driver")); + +// Class.forName(driver); + return new Config(trimToNull(properties.getProperty("gitorious.url")), Option.fromNull(trimToNull(properties.getProperty("gitorious.sessionValue"))), - trimToNull(properties.getProperty("nexus.url"))); + trimToNull(properties.getProperty("nexus.url")), + driver, + trimToNull(properties.getProperty("database.url")), + trimToNull(properties.getProperty("database.username")), + trimToNull(properties.getProperty("database.password"))); } - public static void configureLog4j() { - Properties properties = new Properties(); - properties.setProperty("log4j.rootLogger", "DEBUG, A1"); - properties.setProperty("log4j.logger.httpclient.wire.content", "INFO"); - properties.setProperty("log4j.logger.httpclient.wire.header", "INFO"); - properties.setProperty("log4j.logger.org.apache.commons.httpclient", "INFO"); - properties.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender"); - properties.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout"); - properties.setProperty("log4j.appender.A1.layout.ConversionPattern", "%-4r [%t] %-5p %c %x - %m%n"); - PropertyConfigurator.configure(properties); + private static void initLogging() { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + StatusPrinter.print(lc); } } diff --git a/src/main/java/io/trygvis/esper/testing/Dao.java b/src/main/java/io/trygvis/esper/testing/Dao.java index 79981ad..6c36264 100755 --- a/src/main/java/io/trygvis/esper/testing/Dao.java +++ b/src/main/java/io/trygvis/esper/testing/Dao.java @@ -21,7 +21,9 @@ public class Dao { return s; } - statements.put(sql, c.prepareStatement(sql)); + s = c.prepareStatement(sql); + + statements.put(sql, s); return s; } diff --git a/src/main/java/io/trygvis/esper/testing/EasySSLProtocolSocketFactory.java b/src/main/java/io/trygvis/esper/testing/EasySSLProtocolSocketFactory.java deleted file mode 100755 index c0bf0a5..0000000 --- a/src/main/java/io/trygvis/esper/testing/EasySSLProtocolSocketFactory.java +++ /dev/null @@ -1,232 +0,0 @@ -/* - * $HeadURL$ - * $Revision$ - * $Date$ - * - * ==================================================================== - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * . - * - */ - -package io.trygvis.esper.testing; - -import java.io.IOException; -import java.net.InetAddress; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.net.SocketAddress; -import java.net.UnknownHostException; - -import javax.net.SocketFactory; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; - -import org.apache.commons.httpclient.ConnectTimeoutException; -import org.apache.commons.httpclient.HttpClientError; -import org.apache.commons.httpclient.params.HttpConnectionParams; -import org.apache.commons.httpclient.protocol.SecureProtocolSocketFactory; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - *

- * EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s - * that accept self-signed certificates. - *

- *

- * This socket factory SHOULD NOT be used for productive systems - * due to security reasons, unless it is a concious decision and - * you are perfectly aware of security implications of accepting - * self-signed certificates - *

- * - *

- * Example of using custom protocol socket factory for a specific host: - *

- *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- *
- *     URI uri = new URI("https://localhost/", true);
- *     // use relative url only
- *     GetMethod httpget = new GetMethod(uri.getPathQuery());
- *     HostConfiguration hc = new HostConfiguration();
- *     hc.setHost(uri.getHost(), uri.getPort(), easyhttps);
- *     HttpClient client = new HttpClient();
- *     client.executeMethod(hc, httpget);
- *     
- *

- *

- * Example of using custom protocol socket factory per default instead of the standard one: - *

- *     Protocol easyhttps = new Protocol("https", new EasySSLProtocolSocketFactory(), 443);
- *     Protocol.registerProtocol("https", easyhttps);
- *
- *     HttpClient client = new HttpClient();
- *     GetMethod httpget = new GetMethod("https://localhost/");
- *     client.executeMethod(httpget);
- *     
- *

- * - * @author Oleg Kalnichevski - * - *

- * DISCLAIMER: HttpClient developers DO NOT actively support this component. - * The component is provided as a reference material, which may be inappropriate - * for use without additional customization. - *

- */ - -public class EasySSLProtocolSocketFactory implements SecureProtocolSocketFactory { - - /** Log object for this class. */ - private static final Log LOG = LogFactory.getLog(EasySSLProtocolSocketFactory.class); - - private SSLContext sslcontext = null; - - /** - * Constructor for EasySSLProtocolSocketFactory. - */ - public EasySSLProtocolSocketFactory() { - super(); - } - - private static SSLContext createEasySSLContext() { - try { - SSLContext context = SSLContext.getInstance("SSL"); - context.init( - null, - new TrustManager[] {new EasyX509TrustManager(null)}, - null); - return context; - } catch (Exception e) { - LOG.error(e.getMessage(), e); - throw new HttpClientError(e.toString()); - } - } - - private SSLContext getSSLContext() { - if (this.sslcontext == null) { - this.sslcontext = createEasySSLContext(); - } - return this.sslcontext; - } - - /** - * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int,java.net.InetAddress,int) - */ - public Socket createSocket( - String host, - int port, - InetAddress clientHost, - int clientPort) - throws IOException, UnknownHostException { - - return getSSLContext().getSocketFactory().createSocket( - host, - port, - clientHost, - clientPort - ); - } - - /** - * Attempts to get a new socket connection to the given host within the given time limit. - *

- * To circumvent the limitations of older JREs that do not support connect timeout a - * controller thread is executed. The controller thread attempts to create a new socket - * within the given limit of time. If socket constructor does not return until the - * timeout expires, the controller terminates and throws an {@link ConnectTimeoutException} - *

- * - * @param host the host name/IP - * @param port the port on the host - * @param clientHost the local host name/IP to bind the socket to - * @param clientPort the port on the local machine - * @param params {@link HttpConnectionParams Http connection parameters} - * - * @return Socket a new socket - * - * @throws IOException if an I/O error occurs while creating the socket - * @throws UnknownHostException if the IP address of the host cannot be - * determined - */ - public Socket createSocket( - final String host, - final int port, - final InetAddress localAddress, - final int localPort, - final HttpConnectionParams params - ) throws IOException, UnknownHostException, ConnectTimeoutException { - if (params == null) { - throw new IllegalArgumentException("Parameters may not be null"); - } - int timeout = params.getConnectionTimeout(); - SocketFactory socketfactory = getSSLContext().getSocketFactory(); - if (timeout == 0) { - return socketfactory.createSocket(host, port, localAddress, localPort); - } else { - Socket socket = socketfactory.createSocket(); - SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); - SocketAddress remoteaddr = new InetSocketAddress(host, port); - socket.bind(localaddr); - socket.connect(remoteaddr, timeout); - return socket; - } - } - - /** - * @see SecureProtocolSocketFactory#createSocket(java.lang.String,int) - */ - public Socket createSocket(String host, int port) - throws IOException, UnknownHostException { - return getSSLContext().getSocketFactory().createSocket( - host, - port - ); - } - - /** - * @see SecureProtocolSocketFactory#createSocket(java.net.Socket,java.lang.String,int,boolean) - */ - public Socket createSocket( - Socket socket, - String host, - int port, - boolean autoClose) - throws IOException, UnknownHostException { - return getSSLContext().getSocketFactory().createSocket( - socket, - host, - port, - autoClose - ); - } - - public boolean equals(Object obj) { - return ((obj != null) && obj.getClass().equals(EasySSLProtocolSocketFactory.class)); - } - - public int hashCode() { - return EasySSLProtocolSocketFactory.class.hashCode(); - } - -} diff --git a/src/main/java/io/trygvis/esper/testing/EasySSLSocketFactory.java b/src/main/java/io/trygvis/esper/testing/EasySSLSocketFactory.java new file mode 100755 index 0000000..b8a2904 --- /dev/null +++ b/src/main/java/io/trygvis/esper/testing/EasySSLSocketFactory.java @@ -0,0 +1,104 @@ +package io.trygvis.esper.testing; + +/* + * ==================================================================== + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + * + */ + +import java.io.*; +import java.net.*; +import javax.net.ssl.*; +import org.apache.http.conn.*; +import org.apache.http.conn.scheme.*; +import org.apache.http.params.*; + +public class EasySSLSocketFactory implements SocketFactory, LayeredSocketFactory { + + private SSLContext sslcontext = null; + + private static SSLContext createEasySSLContext() throws IOException { + try { + SSLContext context = SSLContext.getInstance("TLS"); + context.init(null, new TrustManager[]{new EasyX509TrustManager(null)}, null); + return context; + } catch (Exception e) { + throw new IOException(e.getMessage()); + } + } + + private SSLContext getSSLContext() throws IOException { + if (this.sslcontext == null) { + this.sslcontext = createEasySSLContext(); + } + return this.sslcontext; + } + + public Socket connectSocket(Socket sock, String host, int port, InetAddress localAddress, int localPort, + HttpParams params) throws IOException, ConnectTimeoutException { + int connTimeout = HttpConnectionParams.getConnectionTimeout(params); + int soTimeout = HttpConnectionParams.getSoTimeout(params); + InetSocketAddress remoteAddress = new InetSocketAddress(host, port); + SSLSocket sslSocket = (SSLSocket) ((sock != null) ? sock : createSocket()); + + if ((localAddress != null) || (localPort > 0)) { + // we need to bind explicitly + if (localPort < 0) { + localPort = 0; // indicates "any" + } + InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); + sslSocket.bind(isa); + } + + sslSocket.connect(remoteAddress, connTimeout); + sslSocket.setSoTimeout(soTimeout); + + return sslSocket; + } + + public Socket createSocket() throws IOException { + return getSSLContext().getSocketFactory().createSocket(); + } + + public boolean isSecure(Socket socket) throws IllegalArgumentException { + return true; + } + + public Socket createSocket(Socket socket, String host, int port, boolean autoClose) throws IOException { + return getSSLContext().getSocketFactory().createSocket(socket, host, port, autoClose); + } + + // ------------------------------------------------------------------- + // javadoc in org.apache.http.conn.scheme.SocketFactory says : + // Both Object.equals() and Object.hashCode() must be overridden + // for the correct operation of some connection managers + // ------------------------------------------------------------------- + + public boolean equals(Object obj) { + return ((obj != null) && obj.getClass().equals(EasySSLSocketFactory.class)); + } + + public int hashCode() { + return EasySSLSocketFactory.class.hashCode(); + } +} diff --git a/src/main/java/io/trygvis/esper/testing/EasyX509TrustManager.java b/src/main/java/io/trygvis/esper/testing/EasyX509TrustManager.java index 9e35075..1762c6f 100755 --- a/src/main/java/io/trygvis/esper/testing/EasyX509TrustManager.java +++ b/src/main/java/io/trygvis/esper/testing/EasyX509TrustManager.java @@ -35,38 +35,11 @@ import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; import java.security.cert.X509Certificate; -/** - *

- * EasyX509TrustManager unlike default {@link X509TrustManager} accepts - * self-signed certificates. - *

- *

- * This trust manager SHOULD NOT be used for productive systems - * due to security reasons, unless it is a concious decision and - * you are perfectly aware of security implications of accepting - * self-signed certificates - *

- * - * @author Adrian Sutton - * @author Oleg Kalnichevski - * - *

- * DISCLAIMER: HttpClient developers DO NOT actively support this component. - * The component is provided as a reference material, which may be inappropriate - * for use without additional customization. - *

- */ public class EasyX509TrustManager implements X509TrustManager { private X509TrustManager standardTrustManager = null; - /** Log object for this class. */ -// private static final Log LOG = LogFactory.getLog(EasyX509TrustManager.class); - - /** - * Constructor for EasyX509TrustManager. - */ public EasyX509TrustManager(KeyStore keystore) throws NoSuchAlgorithmException, KeyStoreException { super(); TrustManagerFactory factory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); @@ -78,16 +51,10 @@ public class EasyX509TrustManager implements X509TrustManager this.standardTrustManager = (X509TrustManager)trustmanagers[0]; } - /** - * @see javax.net.ssl.X509TrustManager#checkClientTrusted(X509Certificate[],String authType) - */ public void checkClientTrusted(X509Certificate[] certificates,String authType) throws CertificateException { standardTrustManager.checkClientTrusted(certificates,authType); } - /** - * @see javax.net.ssl.X509TrustManager#checkServerTrusted(X509Certificate[],String authType) - */ public void checkServerTrusted(X509Certificate[] certificates,String authType) throws CertificateException { // if (certificates != null) { // System.out.println("Server certificate chain:"); @@ -103,9 +70,6 @@ public class EasyX509TrustManager implements X509TrustManager } } - /** - * @see javax.net.ssl.X509TrustManager#getAcceptedIssuers() - */ public X509Certificate[] getAcceptedIssuers() { return this.standardTrustManager.getAcceptedIssuers(); } diff --git a/src/main/java/io/trygvis/esper/testing/Http.java b/src/main/java/io/trygvis/esper/testing/Http.java old mode 100644 new mode 100755 index 55f4714..38a66a4 --- a/src/main/java/io/trygvis/esper/testing/Http.java +++ b/src/main/java/io/trygvis/esper/testing/Http.java @@ -15,7 +15,7 @@ public class Http { static { SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); - schemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443)); + schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443)); BasicHttpParams params = new BasicHttpParams(); ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); diff --git a/src/main/java/io/trygvis/esper/testing/HttpClient.java b/src/main/java/io/trygvis/esper/testing/HttpClient.java index d9adc8d..79be578 100755 --- a/src/main/java/io/trygvis/esper/testing/HttpClient.java +++ b/src/main/java/io/trygvis/esper/testing/HttpClient.java @@ -1,9 +1,13 @@ package io.trygvis.esper.testing; import static java.lang.System.*; + +import org.apache.http.conn.scheme.*; +import org.apache.http.impl.client.*; +import org.apache.http.impl.conn.tsccm.*; +import org.apache.http.params.*; import org.codehaus.httpcache4j.*; import org.codehaus.httpcache4j.cache.*; -import org.codehaus.httpcache4j.client.*; import org.codehaus.httpcache4j.resolver.*; import java.io.*; @@ -11,11 +15,12 @@ import java.io.*; public class HttpClient { public static HTTPCache createHttpClient(Config config) { - return new HTTPCache(new MemoryCacheStorage(), createResponseResolver(config)); - } - - private static ResponseResolver createResponseResolver(final Config config) { - ResponseResolver responseResolver = HTTPClientResponseResolver.createMultithreadedInstance(); + SchemeRegistry schemeRegistry = new SchemeRegistry(); + schemeRegistry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80)); + schemeRegistry.register(new Scheme("https", new EasySSLSocketFactory(), 443)); + BasicHttpParams params = new BasicHttpParams(); + ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(params, schemeRegistry); + ResponseResolver responseResolver = new HTTPClientResponseResolver(new DefaultHttpClient(cm, new BasicHttpParams())); if (config.gitoriousSessionValue.isSome()) { responseResolver = new GitoriousResponseResolver(config.gitoriousSessionValue.some(), responseResolver); @@ -23,7 +28,7 @@ public class HttpClient { responseResolver = new TimingResponseResolver(responseResolver); - return responseResolver; + return new HTTPCache(new MemoryCacheStorage(), responseResolver); } private static class TimingResponseResolver implements ResponseResolver { diff --git a/src/main/java/io/trygvis/esper/testing/Main.java b/src/main/java/io/trygvis/esper/testing/Main.java old mode 100644 new mode 100755 index 683b950..323e44f --- a/src/main/java/io/trygvis/esper/testing/Main.java +++ b/src/main/java/io/trygvis/esper/testing/Main.java @@ -1,40 +1,17 @@ package io.trygvis.esper.testing; -import ch.qos.logback.classic.*; -import ch.qos.logback.core.util.*; import com.espertech.esper.client.*; -import org.apache.log4j.*; -import org.slf4j.*; - -import java.util.*; public class Main { // private static final String JDBC_URL = "jdbc:h2:mem:esper;DB_CLOSE_DELAY=-1"; private static final String JDBC_URL = "jdbc:h2:tcp://127.0.0.1/esper;DB_CLOSE_DELAY=-1"; public static void main(String[] args) throws Exception { - configureLog4j(); + Config.loadFromDisk(); Main main = new Main(); main.work(); } - public static void configureLog4j() { - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - StatusPrinter.print(lc); - } - -// public static void configureLog4j() { -// Properties properties = new Properties(); -// properties.setProperty("log4j.rootLogger", "DEBUG, A1"); -// properties.setProperty("log4j.logger.httpclient.wire.content", "INFO"); -// properties.setProperty("log4j.logger.httpclient.wire.header", "INFO"); -// properties.setProperty("log4j.logger.org.apache.commons.httpclient", "INFO"); -// properties.setProperty("log4j.appender.A1", "org.apache.log4j.ConsoleAppender"); -// properties.setProperty("log4j.appender.A1.layout", "org.apache.log4j.PatternLayout"); -// properties.setProperty("log4j.appender.A1.layout.ConversionPattern", "%-4r [%t] %-5p %c %x - %m%n"); -// PropertyConfigurator.configure(properties); -// } - private void work() throws Exception { Configuration config = new Configuration(); diff --git a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousImporter.java b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousImporter.java index 1e7a7fd..74e39ea 100755 --- a/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousImporter.java +++ b/src/main/java/io/trygvis/esper/testing/gitorious/GitoriousImporter.java @@ -6,13 +6,11 @@ import static fj.data.Option.*; import io.trygvis.esper.testing.*; import static java.lang.System.*; import org.apache.abdera.parser.*; -import org.apache.commons.httpclient.protocol.*; import java.io.*; import java.net.*; import java.sql.*; import java.util.Date; -import java.util.*; import java.util.List; import java.util.Set; import java.util.concurrent.*; @@ -23,14 +21,14 @@ public class GitoriousImporter { public static void main(String[] args) throws Exception { Config config = Config.loadFromDisk(); - new GitoriousImporter(config, DbMain.JDBC_URL, "esper", "esper"); + new GitoriousImporter(config); } - public GitoriousImporter(Config config, final String jdbcUrl, final String jdbcUsername, final String jdbcPassword) throws Exception { + public GitoriousImporter(final Config config) throws Exception { BoneCPConfig boneCPConfig = new BoneCPConfig(){{ - setJdbcUrl(jdbcUrl); - setUsername(jdbcUsername); - setPassword(jdbcPassword); + setJdbcUrl(config.databaseUrl); + setUsername(config.databaseUsername); + setPassword(config.databasePassword); setDefaultAutoCommit(false); setMaxConnectionsPerPartition(10); }}; diff --git a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java index 247dfe3..6a132d8 100755 --- a/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java +++ b/src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java @@ -3,7 +3,6 @@ package io.trygvis.esper.testing.jenkins; import fj.*; import fj.data.*; import io.trygvis.esper.testing.*; -import static io.trygvis.esper.testing.Http.http; import io.trygvis.esper.testing.object.*; import org.joda.time.*; @@ -13,9 +12,9 @@ import java.util.concurrent.*; public class JenkinsImporter { public static void main(String[] args) throws Exception { - Config.configureLog4j(); + Config config = Config.loadFromDisk(); - final JenkinsClient jenkinsClient = new JenkinsClient(http); + final JenkinsClient jenkinsClient = new JenkinsClient(HttpClient.createHttpClient(config)); jenkinsClient.setDebugXml(false); diff --git a/src/main/resources/logback-test.xml b/src/main/resources/logback-test.xml old mode 100644 new mode 100755 index 1dad1b1..a8416ff --- a/src/main/resources/logback-test.xml +++ b/src/main/resources/logback-test.xml @@ -9,6 +9,8 @@ + + -- cgit v1.2.3