From 0e6bbcd5b74db75652fc848054db4c51785f4bd1 Mon Sep 17 00:00:00 2001 From: hudajkhan Date: Fri, 4 Apr 2014 15:22:13 -0400 Subject: [PATCH 1/2] getting rid of problematic file --- .../utilities/testing/VitroTestRunner.java | 153 ------------------ 1 file changed, 153 deletions(-) delete mode 100644 utilities/buildutils/src/edu/cornell/mannlib/vitro/utilities/testing/VitroTestRunner.java diff --git a/utilities/buildutils/src/edu/cornell/mannlib/vitro/utilities/testing/VitroTestRunner.java b/utilities/buildutils/src/edu/cornell/mannlib/vitro/utilities/testing/VitroTestRunner.java deleted file mode 100644 index 76664d4e3..000000000 --- a/utilities/buildutils/src/edu/cornell/mannlib/vitro/utilities/testing/VitroTestRunner.java +++ /dev/null @@ -1,153 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -package edu.cornell.mannlib.vitro.utilities.testing; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.SortedSet; -import java.util.TreeSet; - -import org.junit.runner.JUnitCore; - -/** - * A Java application that will run the Vitro unit tests. It searches for unit - * tests in the supplied source directory (any file whose name is *Test.Java). - * It runs the tests with a variety of reporting detail, depending on the level - * selected. If the level selector is absent or unrecognized, the medium level - * is used. - * - * @author jeb228 - */ -public class VitroTestRunner { - public enum ReportLevel { - /** Report only the one-line summary. */ - BRIEF, - /** Report times and statistics for each test class. */ - MORE, - /** Report times and statistics for each test method. */ - FULL - } - - private final List> classes; - private final VitroTestRunListener listener; - - /** - * Locate the test classes. Initialize the test listener. - */ - public VitroTestRunner(File sourceRootDir, ReportLevel reportLevel) { - List classNames = getListOfTestClassNames(sourceRootDir); - this.classes = getTestClasses(classNames); - this.listener = new VitroTestRunListener(reportLevel); - } - - /** - * Start a recursive search through the source directory. - */ - private List getListOfTestClassNames(File sourceRootDir) { - SortedSet names = new TreeSet(); - searchForTestClasses(names, "", sourceRootDir); - return new ArrayList(names); - } - - /** - * Recursively search the directory for files in the form "*Test.java". - * Ignore any files or directories whose names start with a "." - */ - private void searchForTestClasses(SortedSet names, String prefix, - File directory) { - for (File file : directory.listFiles()) { - String filename = file.getName(); - if (filename.startsWith(".")) { - // ignore .svn, etc. - } else if (file.isDirectory()) { - searchForTestClasses(names, prefix + filename + ".", file); - } else if (filename.endsWith("Test.java")) { - String classname = filename.substring(0, filename.length() - 5); - names.add(prefix + classname); - } - } - } - - /** - * Instantiate a class for each test class name. - */ - private List> getTestClasses(List classNames) { - List> classes = new ArrayList>(); - for (String classname : classNames) { - try { - classes.add(Class.forName(classname)); - } catch (ClassNotFoundException e) { - throw new IllegalArgumentException("Can't load test class: " - + classname, e); - } - } - return classes; - } - - /** - * We've located all of the test clases. Now run them. - */ - private void run() { - JUnitCore junitCore = new JUnitCore(); - junitCore.addListener(this.listener); - junitCore.run(this.classes.toArray(new Class[0])); - } - - /** - * Did any of the tests fail? - */ - private boolean didEverythingPass() { - return this.listener.didEverythingPass(); - } - - /** - *

- * You must provide a path to the source directory of the test classes. - *

- *

- * You may also provide a reporting level of "BRIEF", "MORE", or "FULL". If - * no level is provided, or if it is not recognized, "BRIEF" is used. - *

- */ - public static void main(String[] args) { - if ((args.length < 1) || (args.length > 2)) { - usage("Wrong number of arguments: expecting 1 or 2, but found " - + args.length + "."); - } - File sourceRootDir = new File(args[0]); - - if (!sourceRootDir.exists()) { - usage(sourceRootDir + " does not exist."); - } - if (!sourceRootDir.isDirectory()) { - usage(sourceRootDir + " is not a directory."); - } - - ReportLevel reportLevel = ReportLevel.MORE; - if (args.length == 2) { - for (ReportLevel level : ReportLevel.values()) { - if (level.toString().equalsIgnoreCase(args[1])) { - reportLevel = level; - } - } - } - - VitroTestRunner runner = new VitroTestRunner(sourceRootDir, reportLevel); - runner.run(); - - if (!runner.didEverythingPass()) { - System.exit(1); - } - } - - /** - * Tell them how it should have been done. - */ - private static void usage(String message) { - System.out.println(message); - System.out.println("usage: " + VitroTestRunner.class.getSimpleName() - + " sourceRootDirectory [ BRIEF | MORE | FULL ]"); - System.exit(1); - } -} From 824848323c5f1dcbf1406f742277c671009af5d0 Mon Sep 17 00:00:00 2001 From: brianjlowe Date: Fri, 4 Apr 2014 16:01:21 -0400 Subject: [PATCH 2/2] avoiding NPEs in DataPropertyStatementDaoJena stemming from list view problems --- .../vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java index 9abceea00..f6a11c787 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/DataPropertyStatementDaoJena.java @@ -447,7 +447,9 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro while (results.hasNext()) { QuerySolution sol = results.next(); Literal value = sol.getLiteral("value"); - values.add(value); + if(value != null) { + values.add(value); + } } log.debug("values = " + values); return values;