From b7c25bdf45bea2b1ccd027817dd24d754b4ae0fb Mon Sep 17 00:00:00 2001 From: jglick Date: Tue, 7 Jul 2009 19:44:20 +0000 Subject: [PATCH] [FIXED HUDSON-3989] Installation of JDK 1.4.x did not work due to to "j2sdk" dir name. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@19476 71c3de6d-444a-0410-be80-ed276b4c234a --- .../main/java/hudson/tools/JDKInstaller.java | 5 +++-- .../java/hudson/tools/JDKInstallerTest.java | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/hudson/tools/JDKInstaller.java b/core/src/main/java/hudson/tools/JDKInstaller.java index 5111c6c073..91ab8b8ed5 100644 --- a/core/src/main/java/hudson/tools/JDKInstaller.java +++ b/core/src/main/java/hudson/tools/JDKInstaller.java @@ -215,9 +215,9 @@ public class JDKInstaller extends ToolInstaller { private static class JdkFinder implements FileFilter, Serializable { private static final long serialVersionUID = 1L; public boolean accept(File f) { - return f.isDirectory() && f.getName().startsWith("jdk"); + return f.isDirectory() && f.getName().matches("j(2s)?dk.*"); } - }; + } /** * Performs a license click through and obtains the one-time URL for downloading bits. @@ -229,6 +229,7 @@ public class JDKInstaller extends ToolInstaller { return locateStage2(log, page); } + @SuppressWarnings("unchecked") // dom4j doesn't do generics, apparently... should probably switch to XOM private HttpURLConnection locateStage1(Platform platform, CPU cpu) throws IOException { URL url = new URL("https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef="+id); HttpURLConnection con = (HttpURLConnection) url.openConnection(); diff --git a/test/src/test/java/hudson/tools/JDKInstallerTest.java b/test/src/test/java/hudson/tools/JDKInstallerTest.java index aff5d864aa..32874defc5 100644 --- a/test/src/test/java/hudson/tools/JDKInstallerTest.java +++ b/test/src/test/java/hudson/tools/JDKInstallerTest.java @@ -8,6 +8,7 @@ import hudson.tasks.Shell; import java.io.File; import java.util.Arrays; +import org.jvnet.hudson.test.Bug; /** * @author Kohsuke Kawaguchi @@ -34,13 +35,21 @@ public class JDKInstallerTest extends HudsonTestCase { /** * Tests the auto installation. */ - public void testAutoInstallation() throws Exception { + public void testAutoInstallation6u13() throws Exception { + doTestAutoInstallation("jdk-6u13-oth-JPR@CDS-CDS_Developer", "1.6.0_13-b03"); + } + @Bug(3989) + public void testAutoInstallation142_17() throws Exception { + doTestAutoInstallation("j2sdk-1.4.2_17-oth-JPR@CDS-CDS_Developer", "1.4.2_17-b06"); + } + + private void doTestAutoInstallation(String id, String fullversion) throws Exception { // this is a really time consuming test, so only run it when we really want if(!Boolean.getBoolean("hudson.sunTests")) return; File tmp = env.temporaryDirectoryAllocator.allocate(); - JDKInstaller installer = new JDKInstaller("jdk-6u13-oth-JPR@CDS-CDS_Developer", true); + JDKInstaller installer = new JDKInstaller(id, true); JDK jdk = new JDK("test", tmp.getAbsolutePath(), Arrays.asList( new InstallSourceProperty(Arrays.asList(installer)))); @@ -51,9 +60,11 @@ public class JDKInstallerTest extends HudsonTestCase { p.setJDK(jdk); p.getBuildersList().add(new Shell("java -fullversion\necho $JAVA_HOME")); FreeStyleBuild b = assertBuildStatusSuccess(p.scheduleBuild2(0).get()); - System.out.println(b.getLog()); + @SuppressWarnings("deprecation") String log = b.getLog(); + System.out.println(log); // make sure it runs with the JDK that just got installed - assertTrue(b.getLog().contains("1.6.0_13-b03")); - assertTrue(b.getLog().contains(tmp.getAbsolutePath())); + assertTrue(log.contains(fullversion)); + assertTrue(log.contains(tmp.getAbsolutePath())); } + } -- GitLab