You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2013/09/19 11:46:41 UTC
svn commit: r1524672 -
/sling/trunk/testing/junit/scriptable/src/main/java/org/apache/sling/junit/scriptable/ScriptableTestsProvider.java
Author: bdelacretaz
Date: Thu Sep 19 09:46:41 2013
New Revision: 1524672
URL: http://svn.apache.org/r1524672
Log:
SLING-3083 - ScriptableTestsProvider propagates exceptions
Modified:
sling/trunk/testing/junit/scriptable/src/main/java/org/apache/sling/junit/scriptable/ScriptableTestsProvider.java
Modified: sling/trunk/testing/junit/scriptable/src/main/java/org/apache/sling/junit/scriptable/ScriptableTestsProvider.java
URL: http://svn.apache.org/viewvc/sling/trunk/testing/junit/scriptable/src/main/java/org/apache/sling/junit/scriptable/ScriptableTestsProvider.java?rev=1524672&r1=1524671&r2=1524672&view=diff
==============================================================================
--- sling/trunk/testing/junit/scriptable/src/main/java/org/apache/sling/junit/scriptable/ScriptableTestsProvider.java (original)
+++ sling/trunk/testing/junit/scriptable/src/main/java/org/apache/sling/junit/scriptable/ScriptableTestsProvider.java Thu Sep 19 09:46:41 2013
@@ -160,7 +160,12 @@ public class ScriptableTestsProvider imp
if(!testName.equals(TEST_CLASS_NAME)) {
throw new ClassNotFoundException(testName + " - the only valid name is " + TEST_CLASS_NAME);
}
- maybeQueryTestResources();
+
+ try {
+ maybeQueryTestResources();
+ } catch(Exception e) {
+ throw new RuntimeException("Exception in maybeQueryTestResources()", e);
+ }
if(testPaths.size() == 0) {
return ExplainTests.class;
@@ -183,39 +188,37 @@ public class ScriptableTestsProvider imp
return result;
}
- private List<String> maybeQueryTestResources() {
+ private List<String> maybeQueryTestResources() throws RepositoryException {
if(lastModified <= lastReloaded) {
log.debug("No changes detected, keeping existing list of {} test resources", testPaths.size());
return testPaths;
}
log.info("Changes detected, reloading list of test resources");
- lastReloaded = System.currentTimeMillis();
+ final long reloadTime = System.currentTimeMillis();
final List<String> newList = new LinkedList<String>();
- try {
- for(String root : allowedRoots) {
- final String statement = "/jcr:root" + root + "/element(*, " + SLING_TEST_NODETYPE + ")";
- log.debug("Querying for test nodes: {}", statement);
- final Query q = session.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
- final NodeIterator it = q.execute().getNodes();
- while(it.hasNext()) {
- final String path = it.nextNode().getPath();
- newList.add(path);
- log.debug("Test resource found: {}", path);
- }
+ for(String root : allowedRoots) {
+ final String statement = "/jcr:root" + root + "/element(*, " + SLING_TEST_NODETYPE + ")";
+ log.debug("Querying for test nodes: {}", statement);
+ final Query q = session.getWorkspace().getQueryManager().createQuery(statement, Query.XPATH);
+ final NodeIterator it = q.execute().getNodes();
+ while(it.hasNext()) {
+ final String path = it.nextNode().getPath();
+ newList.add(path);
+ log.debug("Test resource found: {}", path);
}
- log.info("List of test resources updated, {} resource(s) found under {}",
- newList.size(), Arrays.asList(allowedRoots));
- } catch(RepositoryException re) {
- log.warn("RepositoryException in getTestNames()", re);
}
+ log.info("List of test resources updated, {} resource(s) found under {}",
+ newList.size(), Arrays.asList(allowedRoots));
synchronized (testPaths) {
testPaths.clear();
testPaths.addAll(newList);
}
+ lastReloaded = reloadTime;
+
return testPaths;
}