aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-12-10 15:16:36 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2012-12-10 15:16:36 +0100
commite16e32c653cda7e47a6b9dc8515f187658549921 (patch)
treebebfb7c15bbf7b5ab39dfdcd6627bf79d765b256 /src/test/java
parent34f5ac99c81dfe39f986e8133fb7fff22c0d30bc (diff)
downloadesper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.tar.gz
esper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.tar.bz2
esper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.tar.xz
esper-testing-e16e32c653cda7e47a6b9dc8515f187658549921.zip
o Adding some utilities.
Diffstat (limited to 'src/test/java')
-rwxr-xr-xsrc/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java73
-rwxr-xr-xsrc/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java12
-rwxr-xr-xsrc/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java62
3 files changed, 143 insertions, 4 deletions
diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java b/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
new file mode 100755
index 0000000..9cc47ad
--- /dev/null
+++ b/src/test/java/io/trygvis/esper/testing/jenkins/CreateMissingMavenModuleJobsApp.java
@@ -0,0 +1,73 @@
+package io.trygvis.esper.testing.jenkins;
+
+import java.net.URI;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.List;
+import java.util.UUID;
+
+import org.apache.abdera.Abdera;
+import org.codehaus.httpcache4j.cache.HTTPCache;
+
+import com.jolbox.bonecp.BoneCPDataSource;
+
+import fj.data.Option;
+import io.trygvis.esper.testing.Config;
+import io.trygvis.esper.testing.util.HttpClient;
+
+import static io.trygvis.esper.testing.jenkins.JenkinsClient.apiXml;
+
+public class CreateMissingMavenModuleJobsApp {
+ public static void main(String[] args) throws Exception {
+ final Config config = Config.loadFromDisk();
+ final BoneCPDataSource boneCp = config.createBoneCp();
+ HTTPCache httpCache = HttpClient.createHttpCache(config);
+ Abdera abdera = config.createAbdera();
+ final JenkinsClient client = new JenkinsClient(httpCache, abdera);
+
+ try (Connection c = boneCp.getConnection()) {
+
+// PreparedStatement s2 = c.prepareStatement("UPDATE jenkins_job SET job_type=? WHERE uuid=?");
+
+ PreparedStatement s = c.prepareStatement("SELECT " + JenkinsDao.JENKINS_JOB + " FROM jenkins_job WHERE job_type='MAVEN_MODULE'");
+ ResultSet rs = s.executeQuery();
+
+ JenkinsDao dao = new JenkinsDao(c);
+
+ List<JenkinsJobDto> jobs = dao.toJobList(rs);
+
+ System.out.println("jobs.size() = " + jobs.size());
+
+ for (JenkinsJobDto jobDto : jobs) {
+ System.out.println("job = " + jobDto.url);
+
+ String u = JenkinsServerActor.extrapolateMavenModuleFromMavenModuleSetUrl(jobDto.url.toASCIIString());
+
+ System.out.println("u = " + u);
+
+ URI url = URI.create(u);
+
+ Option<JenkinsJobXml> xmlOption = client.fetchJob(apiXml(url));
+
+ if(xmlOption.isNone()) {
+ System.out.println("None");
+ continue;
+ }
+
+ JenkinsJobXml jobXml = xmlOption.some();
+
+ if(dao.selectJobByUrl(jobXml.url).isSome()) {
+ System.out.println("Duplicate");
+ continue;
+ }
+
+ UUID uuid = dao.insertJob(jobDto.server, url, jobXml.type, jobXml.displayName);
+
+ System.out.println("New job: " + uuid);
+ }
+
+ c.commit();
+ }
+ }
+}
diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java b/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java
index 9a673e9..8b1eacc 100755
--- a/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java
+++ b/src/test/java/io/trygvis/esper/testing/jenkins/JenkinsServerActorTest.java
@@ -6,12 +6,16 @@ import static io.trygvis.esper.testing.jenkins.JenkinsServerActor.*;
public class JenkinsServerActorTest extends TestCase {
public void testUrlGeneration() {
-// assertEquals("https://jenkins.puppetlabs.com/job/Hiera%20%28master%29/74/api/xml", createJobUrl("https://jenkins.puppetlabs.com/job/Hiera%20%28master%29/facter=1.6.x,puppet=2.7.x,ruby=ruby-1.8.7,rvm=%23rvm/74/api/xml").toASCIIString());
+// assertEquals("https://jenkins.puppetlabs.com/job/Hiera%20%28master%29/74/api/xml", extrapolateJobUrlFromBuildUrl("https://jenkins.puppetlabs.com/job/Hiera%20%28master%29/facter=1.6.x,puppet=2.7.x,ruby=ruby-1.8.7,rvm=%23rvm/74/api/xml").toASCIIString());
- assertEquals("https://builds.apache.org/job/james-server-trunk/org.apache.james$james-server-dnsservice-library/", createJobUrl("https://builds.apache.org/job/james-server-trunk/org.apache.james$james-server-dnsservice-library/3417/").toASCIIString());
+ assertEquals("https://builds.apache.org/job/james-server-trunk/org.apache.james$james-server-dnsservice-library/", extrapolateJobUrlFromBuildUrl("https://builds.apache.org/job/james-server-trunk/org.apache.james$james-server-dnsservice-library/3417/").toASCIIString());
- assertEquals("http://ci.jruby.org/job/rails-master/component=activeresource,label=master/", createJobUrl("http://ci.jruby.org/job/rails-master/component=activeresource,label=master/3577/").toASCIIString());
+ assertEquals("http://ci.jruby.org/job/rails-master/component=activeresource,label=master/", extrapolateJobUrlFromBuildUrl("http://ci.jruby.org/job/rails-master/component=activeresource,label=master/3577/").toASCIIString());
- assertEquals("http://ci.jruby.org/job/rails-master/", createJobUrl("http://ci.jruby.org/job/rails-master/3577/").toASCIIString());
+ assertEquals("http://ci.jruby.org/job/rails-master/", extrapolateJobUrlFromBuildUrl("http://ci.jruby.org/job/rails-master/3577/").toASCIIString());
+ }
+
+ public void test2() {
+ assertEquals("http://vm-pbuild-4:8080/job/admin-web/", extrapolateMavenModuleFromMavenModuleSetUrl("http://vm-pbuild-4:8080/job/admin-web/eu.nets.efaktura.adminweb$efaktura-admin-web-wsclient/"));
}
}
diff --git a/src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java b/src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java
new file mode 100755
index 0000000..46060a9
--- /dev/null
+++ b/src/test/java/io/trygvis/esper/testing/jenkins/SetJobTypeApp.java
@@ -0,0 +1,62 @@
+package io.trygvis.esper.testing.jenkins;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.List;
+
+import org.apache.abdera.Abdera;
+import org.codehaus.httpcache4j.cache.HTTPCache;
+
+import com.jolbox.bonecp.BoneCPDataSource;
+
+import fj.data.Option;
+import io.trygvis.esper.testing.Config;
+import io.trygvis.esper.testing.util.HttpClient;
+
+import static io.trygvis.esper.testing.jenkins.JenkinsClient.apiXml;
+
+public class SetJobTypeApp {
+ public static void main(String[] args) throws Exception {
+ final Config config = Config.loadFromDisk();
+ final BoneCPDataSource boneCp = config.createBoneCp();
+ HTTPCache httpCache = HttpClient.createHttpCache(config);
+ Abdera abdera = config.createAbdera();
+ final JenkinsClient jenkinsClient = new JenkinsClient(httpCache, abdera);
+
+ try (Connection c = boneCp.getConnection()) {
+
+ PreparedStatement s2 = c.prepareStatement("UPDATE jenkins_job SET job_type=? WHERE uuid=?");
+
+ PreparedStatement s = c.prepareStatement("SELECT " + JenkinsDao.JENKINS_JOB + " FROM jenkins_job WHERE job_type IS NULL");
+ ResultSet rs = s.executeQuery();
+
+ JenkinsDao dao = new JenkinsDao(c);
+
+ List<JenkinsJobDto> jobs = dao.toJobList(rs);
+
+ System.out.println("jobs.size() = " + jobs.size());
+
+ for (JenkinsJobDto jobDto : jobs) {
+ System.out.println("job = " + jobDto.url);
+
+ Option<JenkinsJobXml> xmlOption = jenkinsClient.fetchJob(apiXml(jobDto.url));
+
+ if(xmlOption.isNone()) {
+ System.out.println("None");
+ continue;
+ }
+
+ JenkinsJobXml jobXml = xmlOption.some();
+
+ System.out.println("jobXml.type = " + jobXml.type);
+
+ s2.setString(1, jobXml.type.name());
+ s2.setString(2, jobDto.uuid.toString());
+ s2.executeUpdate();
+ }
+
+ c.commit();
+ }
+ }
+}