diff options
-rwxr-xr-x | config.properties.template | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | pom.xml | 0 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/Config.java | 48 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/Dao.java | 4 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/EasySSLProtocolSocketFactory.java | 232 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/EasySSLSocketFactory.java | 104 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/EasyX509TrustManager.java | 36 | ||||
-rwxr-xr-x[-rw-r--r--] | src/main/java/io/trygvis/esper/testing/Http.java | 2 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/HttpClient.java | 19 | ||||
-rwxr-xr-x[-rw-r--r--] | src/main/java/io/trygvis/esper/testing/Main.java | 25 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/gitorious/GitoriousImporter.java | 12 | ||||
-rwxr-xr-x | src/main/java/io/trygvis/esper/testing/jenkins/JenkinsImporter.java | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | src/main/resources/logback-test.xml | 2 |
13 files changed, 164 insertions, 330 deletions
diff --git a/config.properties.template b/config.properties.template index 5aba05e..3f3a0f1 100755 --- a/config.properties.template +++ b/config.properties.template @@ -2,3 +2,8 @@ gitorious.url= gitorious.sessionValue= nexus.url= + +database.driver= +database.url=jdbc:h2:tcp://127.0.0.1/esper;DB_CLOSE_DELAY=-1 +database.username= +database.password= 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<String> gitoriousSessionValue; public final String nexusUrl; - public Config(String gitoriousUrl, Option<String> gitoriousSessionValue, String nexusUrl) { + public final String databaseDriver; + public final String databaseUrl; + public final String databaseUsername; + public final String databasePassword; + + public Config(String gitoriousUrl, Option<String> 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 - * <http://www.apache.org/>. - * - */ - -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; - -/** - * <p> - * EasySSLProtocolSocketFactory can be used to creats SSL {@link Socket}s - * that accept self-signed certificates. - * </p> - * <p> - * 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 - * </p> - * - * <p> - * Example of using custom protocol socket factory for a specific host: - * <pre> - * 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); - * </pre> - * </p> - * <p> - * Example of using custom protocol socket factory per default instead of the standard one: - * <pre> - * 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); - * </pre> - * </p> - * - * @author <a href="mailto:oleg -at- ural.ru">Oleg Kalnichevski</a> - * - * <p> - * 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. - * </p> - */ - -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. - * <p> - * 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} - * </p> - * - * @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 + * <http://www.apache.org/>. + * + */ + +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; -/** - * <p> - * EasyX509TrustManager unlike default {@link X509TrustManager} accepts - * self-signed certificates. - * </p> - * <p> - * 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 - * </p> - * - * @author <a href="mailto:adrian.sutton@ephox.com">Adrian Sutton</a> - * @author <a href="mailto:oleg@ural.ru">Oleg Kalnichevski</a> - * - * <p> - * 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. - * </p> - */ 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 index 55f4714..38a66a4 100644..100755 --- 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 index 683b950..323e44f 100644..100755 --- 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 index 1dad1b1..a8416ff 100644..100755 --- a/src/main/resources/logback-test.xml +++ b/src/main/resources/logback-test.xml @@ -9,6 +9,8 @@ <logger name="org.apache.http.headers" level="INFO"/> <logger name="org.apache.http.wire" level="INFO"/> <logger name="org.apache.http" level="INFO"/> + <!-- Gitorious spews out a few invalid cookies --> + <logger name="org.apache.http.client.protocol.ResponseProcessCookies" level="ERROR"/> <root level="DEBUG"> <appender-ref ref="STDOUT"/> |