Merge branch 'develop' of github.com:vivo-project/Vitro into develop

This commit is contained in:
Brian Caruso 2013-07-17 15:03:38 -04:00
commit 7620e43209
2 changed files with 81 additions and 0 deletions

View file

@ -0,0 +1,79 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
package edu.cornell.mannlib.vitro.webapp.servlet.setup;
import java.io.File;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import edu.cornell.mannlib.vitro.webapp.startup.StartupStatus;
/**
* Test that the JVM is properly configured.
*
* For now, we just test the temp directory. Other
*/
public class JvmSmokeTests implements ServletContextListener {
@Override
public void contextInitialized(ServletContextEvent sce) {
ServletContext ctx = sce.getServletContext();
StartupStatus ss = StartupStatus.getBean(ctx);
checkTempDirectory(ss);
}
/**
* Check the Java temp directory. Make sure that it exists, it is a
* directory, we can read it, we can write to it.
*
* Create a temp file, and delete it.
*/
private void checkTempDirectory(StartupStatus ss) {
String tempDirPath = System.getProperty("java.io.tmpdir", "");
if (tempDirPath.isEmpty()) {
ss.fatal(this, "Problem with Java temp directory: "
+ "System property 'java.io.tmpdir' is not set.");
return;
}
File tempDir = new File(tempDirPath);
if (!tempDir.exists()) {
ss.fatal(this, "Problem with Java temp directory: '" + tempDirPath
+ "' does not exist.");
return;
}
if (!tempDir.isDirectory()) {
ss.fatal(this, "Problem with Java temp directory: '" + tempDirPath
+ "' exists, but is not a directory.");
return;
}
if (!tempDir.canRead()) {
ss.fatal(this, "Problem with Java temp directory: "
+ "No read access to '" + tempDirPath + "'.");
return;
}
if (!tempDir.canWrite()) {
ss.fatal(this, "Problem with Java temp directory: "
+ "No write access to '" + tempDirPath + "'.");
return;
}
try {
File testFile = File.createTempFile("smoke", null);
testFile.delete();
} catch (Exception e) {
ss.fatal(this, "Problem with Java temp directory: "
+ "Failed to create a temporary file in '" + tempDirPath
+ "'.", e);
return;
}
ss.info(this, "Java temp directory is '" + tempDirPath + "'");
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
// Nothing to do at shutdown
}
}

View file

@ -5,6 +5,8 @@
# https://sourceforge.net/apps/mediawiki/vivo/index.php?title=The_StartupManager
#
edu.cornell.mannlib.vitro.webapp.servlet.setup.JvmSmokeTests
edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesSetup
edu.cornell.mannlib.vitro.webapp.config.ConfigurationPropertiesSmokeTests