mirror of https://github.com/jenkinsci/jenkins.git
improved the diagnosability when the explode() method fails
git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11973 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
parent
213a95c1a1
commit
2169dce3ca
|
|
@ -161,7 +161,7 @@ public abstract class HudsonTestCase extends TestCase {
|
||||||
protected ServletContext createWebServer() throws Exception {
|
protected ServletContext createWebServer() throws Exception {
|
||||||
server = new Server();
|
server = new Server();
|
||||||
|
|
||||||
WebAppContext context = new WebAppContext(WarExploder.EXPLODE_DIR.getPath(), contextPath);
|
WebAppContext context = new WebAppContext(WarExploder.getExplodedDir().getPath(), contextPath);
|
||||||
context.setClassLoader(getClass().getClassLoader());
|
context.setClassLoader(getClass().getClassLoader());
|
||||||
context.setConfigurations(new Configuration[]{new WebXmlConfiguration(),new NoListenerConfiguration()});
|
context.setConfigurations(new Configuration[]{new WebXmlConfiguration(),new NoListenerConfiguration()});
|
||||||
server.setHandler(context);
|
server.setHandler(context);
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import hudson.remoting.Which;
|
||||||
import hudson.FilePath;
|
import hudson.FilePath;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
|
|
@ -14,13 +13,30 @@ import java.net.URL;
|
||||||
* @author Kohsuke Kawaguchi
|
* @author Kohsuke Kawaguchi
|
||||||
*/
|
*/
|
||||||
final class WarExploder {
|
final class WarExploder {
|
||||||
public static final File EXPLODE_DIR = explode();
|
|
||||||
|
public static File getExplodedDir() throws Exception {
|
||||||
|
// rethrow an exception every time someone tries to do this, so that when explode()
|
||||||
|
// fails, you can see the cause no matter which test case you look at.
|
||||||
|
// see http://www.nabble.com/Failing-tests-in-test-harness-module-on-hudson.ramfelt.se-td19258722.html
|
||||||
|
if(FAILURE !=null) throw new Exception("Failed to initialize exploded war", FAILURE);
|
||||||
|
return EXPLODE_DIR;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File EXPLODE_DIR;
|
||||||
|
private static Exception FAILURE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
EXPLODE_DIR = explode();
|
||||||
|
} catch (Exception e) {
|
||||||
|
FAILURE = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Explodes hudson.war, if necesasry, and returns its root dir.
|
* Explodes hudson.war, if necesasry, and returns its root dir.
|
||||||
*/
|
*/
|
||||||
private static File explode() {
|
private static File explode() throws Exception {
|
||||||
try {
|
|
||||||
// are we in the hudson main workspace? If so, pick up hudson/main/war/resources
|
// are we in the hudson main workspace? If so, pick up hudson/main/war/resources
|
||||||
// this saves the effort of packaging a war file and makes the debug cycle faster
|
// this saves the effort of packaging a war file and makes the debug cycle faster
|
||||||
File d = new File(".").getAbsoluteFile();
|
File d = new File(".").getAbsoluteFile();
|
||||||
|
|
@ -59,12 +75,5 @@ final class WarExploder {
|
||||||
}
|
}
|
||||||
|
|
||||||
return explodeDir;
|
return explodeDir;
|
||||||
} catch (IOException e) {
|
|
||||||
throw new Error(e);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
throw new Error(e);
|
|
||||||
} catch (ClassNotFoundException e) {
|
|
||||||
throw new Error(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue