import java.util.Map;
import java.util.UUID;
import java.util.Map;
import java.util.UUID;
+import javax.jcr.Credentials;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import javax.jcr.Node;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
private String uuid;
private Repository repository;
private Session session;
private String uuid;
private Repository repository;
private Session session;
+ /**
+ * For testing purposes, best practice is to not set them explicitely but
+ * via other mechanisms such as JAAS or SPring Security.
+ */
+ private Credentials credentials = null;
private String resultType = SlcTypes.SLC_TEST_RESULT;
/** cached for performance purposes */
private String nodeIdentifier = null;
private String resultType = SlcTypes.SLC_TEST_RESULT;
/** cached for performance purposes */
private String nodeIdentifier = null;
- private Boolean logoutWhenDestroyed = true;
-
private Map<String, String> attributes = new HashMap<String, String>();
public void init() {
try {
private Map<String, String> attributes = new HashMap<String, String>();
public void init() {
try {
- session = repository.login();
+ session = repository.login(credentials);
if (uuid == null) {
// create new result
uuid = UUID.randomUUID().toString();
if (uuid == null) {
// create new result
uuid = UUID.randomUUID().toString();
}
public void destroy() {
}
public void destroy() {
- if (logoutWhenDestroyed)
- JcrUtils.logoutQuietly(session);
+ JcrUtils.logoutQuietly(session);
}
public Node getNode() {
}
public Node getNode() {
+ /** JCR session is NOT logged out */
public void close() {
Node node = getNode();
try {
public void close() {
Node node = getNode();
try {
JcrUtils.discardUnderlyingSessionQuietly(node);
throw new SlcException("Cannot get close date from " + node, e);
}
JcrUtils.discardUnderlyingSessionQuietly(node);
throw new SlcException("Cannot get close date from " + node, e);
}
- if (logoutWhenDestroyed)
- JcrUtils.logoutQuietly(session);
}
public Date getCloseDate() {
}
public Date getCloseDate() {
this.attributes = attributes;
}
this.attributes = attributes;
}
+ public void setCredentials(Credentials credentials) {
+ this.credentials = credentials;
+ }
+
// public void setLogoutWhenDestroyed(Boolean logoutWhenDestroyed) {
// this.logoutWhenDestroyed = logoutWhenDestroyed;
// }
// public void setLogoutWhenDestroyed(Boolean logoutWhenDestroyed) {
// this.logoutWhenDestroyed = logoutWhenDestroyed;
// }
public static String createResultPath(Session session, String uuid)
throws RepositoryException {
Calendar now = new GregorianCalendar();
public static String createResultPath(Session session, String uuid)
throws RepositoryException {
Calendar now = new GregorianCalendar();
- return UserJcrUtils.getUserHome(session).getPath() + '/'
- + SlcNames.SLC_RESULTS + '/' + JcrUtils.dateAsPath(now, true)
- + uuid;
+ Node userHome = UserJcrUtils.getUserHome(session);
+ if (userHome == null)
+ throw new SlcException("No user home available for "
+ + session.getUserID());
+ return userHome.getPath() + '/' + SlcNames.SLC_RESULTS + '/'
+ + JcrUtils.dateAsPath(now, true) + uuid;
import org.springframework.core.io.Resource;\r
\r
/** A comparator providing structured information about the differences found. */\r
import org.springframework.core.io.Resource;\r
\r
/** A comparator providing structured information about the differences found. */\r
-public interface Diff<T> {\r
+public interface Diff {\r
/** Performs the comparison. */\r
/** Performs the comparison. */\r
- public T compare(Resource expected, Resource reached);\r
+ public void compare(Resource expected, Resource reached,\r
+ DiffResult diffResult);\r
--- /dev/null
+package org.argeo.slc.diff;
+
+/**
+ * The result of a diff, to be subclassed in order to provide richer information
+ */
+public interface DiffResult {
+ /** Adds a diff issue */
+ public void addDiffIssue(DiffIssue diffIssue);
+
+}