properties,
Problems problems ) {
Index: dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java
===================================================================
--- dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java (revision 886)
+++ dna-repository/src/main/java/org/jboss/dna/repository/sequencer/Sequencer.java (working copy)
@@ -24,17 +24,14 @@
package org.jboss.dna.repository.sequencer;
import java.util.Set;
-import javax.jcr.Node;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.component.Component;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.observation.NodeChangeListener;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.observation.ObservationService;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -52,9 +49,8 @@
/**
* Execute the sequencing operation on the supplied node, which has recently been created or changed. The implementation of
- * this method is responsible for {@link JcrExecutionContext#getSessionFactory() getting sessions}, modifying the appropriate
- * nodes, {@link Session#save() saving} any changes made by this sequencer, and {@link Session#logout() closing} all sessions
- * (and any other acquired resources), even in the case of exceptions.
+ * this method is responsible for modifying the appropriate nodes and {@link Destination#submit()) saving} any changes made by
+ * this sequencer, and closing any other acquired resources, even in the case of exceptions.
*
* The {@link SequencingService} determines the sequencers that should be executed by monitoring the changes to one or more
* workspaces (it is a {@link NodeChangeListener} registered with the {@link ObservationService}). Changes in those workspaces
@@ -76,17 +72,16 @@
* @param changes the immutable summary of changes that occurred on the input
node within the transaction; never
* null
* @param outputPaths the paths to the nodes where the sequencing content should be placed; never null and never empty, but
- * the set may contain paths for non-existant nodes or may reference the input
node
+ * the set may contain paths for non-existent nodes or may reference the input
node
* @param context the context in which this sequencer is executing; never null
* @param problems the interface used for recording problems; never null
- * @throws RepositoryException if there is a problem while working with the repository
* @throws SequencerException if there is an error in this sequencer
*/
void execute( Node input,
String sequencedPropertyName,
NodeChange changes,
Set outputPaths,
- JcrExecutionContext context,
- Problems problems ) throws RepositoryException, SequencerException;
+ SequencerContext context,
+ Problems problems ) throws SequencerException;
}
Index: dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java
===================================================================
--- dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java (revision 0)
+++ dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerContext.java (revision 0)
@@ -0,0 +1,57 @@
+package org.jboss.dna.repository.sequencer;
+
+import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.io.Destination;
+import org.jboss.dna.graph.io.GraphBatchDestination;
+
+/**
+ * The sequencer context represents the complete context of a sequencer invocation, including the execution context
+ * (which contains JAAS credentials, namespace mappings, and value factories) and the I/O environment for writing
+ * output.
+ *
+ *
+ * This class is not thread safe due to its use of {@link Destination a destination}.
+ *
+ */
+@NotThreadSafe
+public class SequencerContext {
+
+ private final ExecutionContext executionContext;
+ private final Graph graph;
+ private final Destination destination;
+
+ public SequencerContext( ExecutionContext executionContext,
+ Graph graph ) {
+ super();
+
+ assert executionContext != null;
+ assert graph != null;
+
+ this.executionContext = executionContext;
+ this.graph = graph;
+ this.destination = new GraphBatchDestination(graph.batch());
+ }
+
+ /**
+ * Returns the execution context under which this sequencer context operates
+ * @return the execution context under which this sequencer context operates
+ */
+ public ExecutionContext getExecutionContext() {
+ return executionContext;
+ }
+
+ /**
+ * Returns the I/O environment in which this sequencer context operates
+ * @return the I/O environment in which this sequencer context operates
+ */
+ public Destination getDestination() {
+ return destination;
+ }
+
+ Graph graph() {
+ return this.graph;
+ }
+
+}
Property changes on: dna-repository\src\main\java\org\jboss\dna\repository\sequencer\SequencerContext.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Index: dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerOutputMap.java
===================================================================
--- dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerOutputMap.java (revision 886)
+++ dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencerOutputMap.java (working copy)
@@ -50,18 +50,14 @@
@NotThreadSafe
public class SequencerOutputMap implements SequencerOutput, Iterable {
- private static final String JCR_NAME_PROPERTY_NAME = "jcr:name";
-
private final Map> data;
private transient boolean valuesSorted = true;
private final ValueFactories factories;
- private final Name jcrName;
public SequencerOutputMap( ValueFactories factories ) {
CheckArg.isNotNull(factories, "factories");
this.data = new HashMap>();
this.factories = factories;
- this.jcrName = this.factories.getNameFactory().create(JCR_NAME_PROPERTY_NAME);
}
ValueFactories getFactories() {
@@ -76,8 +72,6 @@
Object... values ) {
CheckArg.isNotNull(nodePath, "nodePath");
CheckArg.isNotNull(propertyName, "property");
- // Ignore the "jcr:name" property, as that's handled by the path ...
- if (this.jcrName.equals(propertyName)) return;
// Find or create the entry for this node ...
List properties = this.data.get(nodePath);
Index: dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
===================================================================
--- dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java (revision 886)
+++ dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java (working copy)
@@ -34,10 +34,6 @@
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
-import javax.jcr.Node;
-import javax.jcr.Repository;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
import javax.jcr.observation.Event;
import net.jcip.annotations.Immutable;
import net.jcip.annotations.ThreadSafe;
@@ -48,18 +44,22 @@
import org.jboss.dna.common.util.CheckArg;
import org.jboss.dna.common.util.HashCode;
import org.jboss.dna.common.util.Logger;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.repository.RepositoryI18n;
+import org.jboss.dna.repository.RepositoryLibrary;
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.observation.NodeChangeListener;
import org.jboss.dna.repository.observation.NodeChanges;
import org.jboss.dna.repository.service.AbstractServiceAdministrator;
import org.jboss.dna.repository.service.AdministeredService;
import org.jboss.dna.repository.service.ServiceAdministrator;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
- * A sequencing system is used to monitor changes in the content of {@link Repository JCR repositories} and to sequence the
+ * A sequencing system is used to monitor changes in the content of DNA repositories and to sequence the
* content to extract or to generate structured information.
*
* @author Randall Hauch
@@ -198,11 +198,12 @@
}
- private JcrExecutionContext executionContext;
+ private ExecutionContext executionContext;
private SequencerLibrary sequencerLibrary = new SequencerLibrary();
private Selector sequencerSelector = DEFAULT_SEQUENCER_SELECTOR;
private NodeFilter nodeFilter = DEFAULT_NODE_FILTER;
private ExecutorService executorService;
+ private RepositoryLibrary repositoryLibrary;
private final Statistics statistics = new Statistics();
private final Administrator administrator = new Administrator();
@@ -286,14 +287,14 @@
/**
* @return executionContext
*/
- public JcrExecutionContext getExecutionContext() {
+ public ExecutionContext getExecutionContext() {
return this.executionContext;
}
/**
* @param executionContext Sets executionContext to the specified value.
*/
- public void setExecutionContext( JcrExecutionContext executionContext ) {
+ public void setExecutionContext( ExecutionContext executionContext ) {
CheckArg.isNotNull(executionContext, "execution context");
if (this.getAdministrator().isStarted()) {
throw new IllegalStateException(RepositoryI18n.unableToChangeExecutionContextWhileRunning.text());
@@ -303,6 +304,19 @@
}
/**
+ * Get the repository library to be used for repository lookup
+ *
+ * @return the repository library
+ */
+ public RepositoryLibrary getRepositoryLibrary() {
+ return this.repositoryLibrary;
+ }
+
+ public void setRepositoryLibrary(RepositoryLibrary repositoryLibrary) {
+ this.repositoryLibrary = repositoryLibrary;
+ }
+
+ /**
* Get the executor service used to run the sequencers.
*
* @return the executor service
@@ -448,100 +462,88 @@
* @param changedNode the node to be processed.
*/
protected void processChangedNode( NodeChange changedNode ) {
- final JcrExecutionContext context = this.getExecutionContext();
+ final ExecutionContext context = this.getExecutionContext();
final Logger logger = context.getLogger(getClass());
assert logger != null;
+
try {
+ final String repositorySourceName = changedNode.getRepositorySourceName();
final String repositoryWorkspaceName = changedNode.getRepositoryWorkspaceName();
- Session session = null;
- try {
- // Figure out which sequencers accept this path,
- // and track which output nodes should be passed to each sequencer...
- final String nodePath = changedNode.getAbsolutePath();
- Map> sequencerCalls = new HashMap>();
- List allSequencers = this.sequencerLibrary.getInstances();
- List sequencers = new ArrayList(allSequencers.size());
- for (Sequencer sequencer : allSequencers) {
- final SequencerConfig config = sequencer.getConfiguration();
- for (SequencerPathExpression pathExpression : config.getPathExpressions()) {
- for (String propertyName : changedNode.getModifiedProperties()) {
- String path = nodePath + "/@" + propertyName;
- SequencerPathExpression.Matcher matcher = pathExpression.matcher(path);
- if (matcher.matches()) {
- // String selectedPath = matcher.getSelectedPath();
- RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(),
- repositoryWorkspaceName);
- SequencerCall call = new SequencerCall(sequencer, propertyName);
- // Record the output path ...
- Set outputPaths = sequencerCalls.get(call);
- if (outputPaths == null) {
- outputPaths = new HashSet();
- sequencerCalls.put(call, outputPaths);
- }
- outputPaths.add(outputPath);
- sequencers.add(sequencer);
- break;
+
+ // Figure out which sequencers accept this path,
+ // and track which output nodes should be passed to each sequencer...
+ final String nodePath = changedNode.getAbsolutePath();
+ Map> sequencerCalls = new HashMap>();
+ List allSequencers = this.sequencerLibrary.getInstances();
+ List sequencers = new ArrayList(allSequencers.size());
+ for (Sequencer sequencer : allSequencers) {
+ final SequencerConfig config = sequencer.getConfiguration();
+ for (SequencerPathExpression pathExpression : config.getPathExpressions()) {
+ for (String propertyName : changedNode.getModifiedProperties()) {
+ String path = nodePath + "/@" + propertyName;
+ SequencerPathExpression.Matcher matcher = pathExpression.matcher(path);
+ if (matcher.matches()) {
+ // String selectedPath = matcher.getSelectedPath();
+ RepositoryNodePath outputPath = RepositoryNodePath.parse(matcher.getOutputPath(),
+ repositorySourceName,
+ repositoryWorkspaceName);
+ SequencerCall call = new SequencerCall(sequencer, propertyName);
+ // Record the output path ...
+ Set outputPaths = sequencerCalls.get(call);
+ if (outputPaths == null) {
+ outputPaths = new HashSet();
+ sequencerCalls.put(call, outputPaths);
}
+ outputPaths.add(outputPath);
+ sequencers.add(sequencer);
+ break;
}
}
}
+ }
- Node node = null;
- if (!sequencers.isEmpty()) {
- // Create a session that we'll use for all sequencing ...
- session = context.getSessionFactory().createSession(repositoryWorkspaceName);
+ RepositorySource source = repositoryLibrary.getSource(repositorySourceName);
+ Graph graph = Graph.create(source, context);
+ Node node = null;
+ if (!sequencers.isEmpty()) {
- // Find the changed node ...
- String relPath = changedNode.getAbsolutePath().replaceAll("^/+", "");
- node = session.getRootNode().getNode(relPath);
+ // Find the changed node ...
+ String relPath = changedNode.getAbsolutePath().replaceAll("^/+", "");
+ node = graph.getNodeAt(relPath);
- // Figure out which sequencers should run ...
- sequencers = this.sequencerSelector.selectSequencers(sequencers, node, changedNode);
+ // Figure out which sequencers should run ...
+ sequencers = this.sequencerSelector.selectSequencers(sequencers, node, changedNode);
+ }
+ if (sequencers.isEmpty()) {
+ this.statistics.recordNodeSkipped();
+ if (logger.isDebugEnabled()) {
+ logger.trace("Skipping '{0}': no sequencers matched this condition", changedNode);
}
- if (sequencers.isEmpty()) {
- this.statistics.recordNodeSkipped();
- if (logger.isDebugEnabled()) {
- logger.trace("Skipping '{0}': no sequencers matched this condition", changedNode);
- }
- } else {
- // Run each of those sequencers ...
- for (Map.Entry> entry : sequencerCalls.entrySet()) {
- final SequencerCall sequencerCall = entry.getKey();
- final Set outputPaths = entry.getValue();
- final Sequencer sequencer = sequencerCall.getSequencer();
- final String sequencerName = sequencer.getConfiguration().getName();
- final String propertyName = sequencerCall.getSequencedPropertyName();
+ } else {
+ // Run each of those sequencers ...
+ for (Map.Entry> entry : sequencerCalls.entrySet()) {
- // Get the paths to the nodes where the sequencer should write it's output ...
- assert outputPaths != null && outputPaths.size() != 0;
+ final SequencerCall sequencerCall = entry.getKey();
+ final Set outputPaths = entry.getValue();
+ final Sequencer sequencer = sequencerCall.getSequencer();
+ final String sequencerName = sequencer.getConfiguration().getName();
+ final String propertyName = sequencerCall.getSequencedPropertyName();
- // Create a new execution context for each sequencer
- final SimpleProblems problems = new SimpleProblems();
- JcrExecutionContext sequencerContext = context.clone();
- try {
- sequencer.execute(node, propertyName, changedNode, outputPaths, sequencerContext, problems);
- } catch (RepositoryException e) {
- logger.error(e, RepositoryI18n.errorInRepositoryWhileSequencingNode, sequencerName, changedNode);
- } catch (SequencerException e) {
- logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, changedNode);
- } finally {
- try {
- // Save the changes made by each sequencer ...
- if (session != null) session.save();
- } finally {
- // And always close the context.
- // This closes all sessions that may have been created by the sequencer.
- sequencerContext.close();
- }
- }
+ // Get the paths to the nodes where the sequencer should write it's output ...
+ assert outputPaths != null && outputPaths.size() != 0;
+
+ // Create a new execution context for each sequencer
+ final SimpleProblems problems = new SimpleProblems();
+ SequencerContext sequencerContext = new SequencerContext(context, graph);
+ try {
+ sequencer.execute(node, propertyName, changedNode, outputPaths, sequencerContext, problems);
+ sequencerContext.getDestination().submit();
+ } catch (SequencerException e) {
+ logger.error(e, RepositoryI18n.errorWhileSequencingNode, sequencerName, changedNode);
}
- this.statistics.recordNodeSequenced();
}
- } finally {
- if (session != null) session.logout();
+ this.statistics.recordNodeSequenced();
}
- } catch (RepositoryException e) {
- logger.error(e, RepositoryI18n.errorInRepositoryWhileFindingSequencersToRunAgainstNode, changedNode);
} catch (Throwable e) {
logger.error(e, RepositoryI18n.errorFindingSequencersToRunAgainstNode, changedNode);
}
Index: dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java
===================================================================
--- dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java (revision 886)
+++ dna-repository/src/main/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapter.java (working copy)
@@ -23,38 +23,26 @@
*/
package org.jboss.dna.repository.sequencer;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.math.BigDecimal;
-import java.util.Calendar;
import java.util.Collections;
-import java.util.Date;
import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Set;
-import javax.jcr.Node;
-import javax.jcr.PathNotFoundException;
-import javax.jcr.Property;
-import javax.jcr.PropertyIterator;
-import javax.jcr.PropertyType;
-import javax.jcr.RepositoryException;
-import javax.jcr.Session;
-import javax.jcr.Value;
import org.jboss.dna.common.collection.Problems;
-import org.jboss.dna.common.util.Logger;
-import org.jboss.dna.graph.ExecutionContext;
-import org.jboss.dna.graph.property.Binary;
-import org.jboss.dna.graph.property.DateTime;
-import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.property.NamespaceRegistry;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
+import org.jboss.dna.graph.property.Property;
+import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.ValueFactories;
-import org.jboss.dna.graph.sequencer.SequencerContext;
import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.repository.RepositoryI18n;
import org.jboss.dna.repository.mimetype.MimeType;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -93,30 +81,33 @@
String sequencedPropertyName,
NodeChange changes,
Set outputPaths,
- JcrExecutionContext execContext,
- Problems problems ) throws RepositoryException, SequencerException {
+ SequencerContext context,
+ Problems problems ) throws SequencerException {
// 'sequencedPropertyName' contains the name of the modified property on 'input' that resulted in the call to this
// sequencer.
// 'changes' contains all of the changes to this node that occurred in the transaction.
// 'outputPaths' contains the paths of the node(s) where this sequencer is to save it's data.
// Get the property that contains the data, given by 'propertyName' ...
- Property sequencedProperty = null;
- try {
- sequencedProperty = input.getProperty(sequencedPropertyName);
- } catch (PathNotFoundException e) {
- String msg = RepositoryI18n.unableToFindPropertyForSequencing.text(sequencedPropertyName, input.getPath());
- throw new SequencerException(msg, e);
+ Property sequencedProperty = input.getProperty(sequencedPropertyName);
+
+ if (sequencedProperty == null) {
+ String msg = RepositoryI18n.unableToFindPropertyForSequencing.text(sequencedPropertyName, input.getLocation());
+ throw new SequencerException(msg);
}
// Get the binary property with the image content, and build the image metadata from the image ...
- SequencerOutputMap output = new SequencerOutputMap(execContext.getValueFactories());
+ SequencerOutputMap output = new SequencerOutputMap(context.getExecutionContext().getValueFactories());
InputStream stream = null;
Throwable firstError = null;
try {
- stream = sequencedProperty.getStream();
- SequencerContext sequencerContext = createSequencerContext(input, sequencedProperty, execContext, problems);
- this.streamSequencer.sequence(stream, output, sequencerContext);
+ // Parallel the JCR lemma for converting objects into streams
+ stream = new ByteArrayInputStream(sequencedProperty.toString().getBytes());
+ StreamSequencerContext StreamSequencerContext = createStreamSequencerContext(input,
+ sequencedProperty,
+ context,
+ problems);
+ this.streamSequencer.sequence(stream, output, StreamSequencerContext);
} catch (Throwable t) {
// Record the error ...
firstError = t;
@@ -139,30 +130,57 @@
// Find each output node and save the image metadata there ...
for (RepositoryNodePath outputPath : outputPaths) {
- Session session = null;
- try {
- // Get the name of the repository workspace and the path to the output node
- final String repositoryWorkspaceName = outputPath.getRepositoryWorkspaceName();
- final String nodePath = outputPath.getNodePath();
+ // Get the name of the repository workspace and the path to the output node
+ final String repositoryWorkspaceName = outputPath.getWorkspaceName();
+ final String nodePath = outputPath.getNodePath();
- // Create a session to the repository where the data should be written ...
- session = execContext.getSessionFactory().createSession(repositoryWorkspaceName);
+ // Find or create the output node in this session ...
+ context.graph().useWorkspace(repositoryWorkspaceName);
- // Find or create the output node in this session ...
- Node outputNode = execContext.getTools().findOrCreateNode(session, nodePath);
+ buildPathTo(nodePath, context);
+ Node outputNode = context.graph().getNodeAt(nodePath);
- // Now save the image metadata to the output node ...
- if (saveOutput(outputNode, output, execContext)) {
- session.save();
- }
- } finally {
- // Always close the session ...
- if (session != null) session.logout();
- }
+ // Now save the image metadata to the output node ...
+ saveOutput(outputNode, output, context);
}
+
+ context.getDestination().submit();
}
/**
+ * Creates all nodes along the given node path if they are missing. Ensures that nodePath is a valid path to a node.
+ *
+ * @param nodePath the node path to create
+ * @param context the sequencer context under which it should be created
+ */
+ private void buildPathTo( String nodePath,
+ SequencerContext context ) {
+ PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
+ Path targetPath = pathFactory.create(nodePath);
+
+ buildPathTo(targetPath, context);
+ }
+
+ /**
+ * Creates all nodes along the given node path if they are missing. Ensures that nodePath is a valid path to a node.
+ *
+ * @param nodePath the node path to create
+ * @param context the sequencer context under which it should be created
+ */
+ private void buildPathTo( Path targetPath,
+ SequencerContext context ) {
+ PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
+
+ Path workingPath = pathFactory.createRootPath();
+ Path.Segment[] segments = targetPath.getSegmentsArray();
+ for (int i = 0; i < segments.length; i++) {
+ workingPath = pathFactory.create(workingPath, segments[i]);
+
+ context.graph().createIfMissing(workingPath);
+ }
+ }
+
+ /**
* Save the sequencing output to the supplied node. This method does not need to save the output, as that is done by the
* caller of this method.
*
@@ -170,128 +188,37 @@
* @param output the (immutable) sequencing output; never null
* @param context the execution context for this sequencing operation; never null
* @return true if the output was written to the node, or false if no information was written
- * @throws RepositoryException
*/
- protected boolean saveOutput( Node outputNode,
- SequencerOutputMap output,
- JcrExecutionContext context ) throws RepositoryException {
- if (output.isEmpty()) return false;
- final PathFactory pathFactory = context.getValueFactories().getPathFactory();
- final NamespaceRegistry namespaceRegistry = context.getNamespaceRegistry();
- final Path outputNodePath = pathFactory.create(outputNode.getPath());
- final Name jcrPrimaryTypePropertyName = context.getValueFactories().getNameFactory().create("jcr:primaryType");
+ protected void saveOutput( Node outputNode,
+ SequencerOutputMap output,
+ SequencerContext context ) {
+ if (output.isEmpty()) return;
+ final PathFactory pathFactory = context.getExecutionContext().getValueFactories().getPathFactory();
+ final PropertyFactory propertyFactory = context.getExecutionContext().getPropertyFactory();
+ // TODO: Is it safe to assume that the location for this node will include a path?
+ final Path outputNodePath = pathFactory.create(outputNode.getLocation().getPath());
// Iterate over the entries in the output, in Path's natural order (shorter paths first and in lexicographical order by
// prefix and name)
for (SequencerOutputMap.Entry entry : output) {
Path targetNodePath = entry.getPath();
- Name primaryType = entry.getPrimaryTypeValue();
// Resolve this path relative to the output node path, handling any parent or self references ...
Path absolutePath = targetNodePath.isAbsolute() ? targetNodePath : outputNodePath.resolve(targetNodePath);
- Path relativePath = absolutePath.relativeTo(outputNodePath);
- // Find or add the node (which may involve adding intermediate nodes) ...
- Node targetNode = outputNode;
- for (int i = 0, max = relativePath.size(); i != max; ++i) {
- Path.Segment segment = relativePath.getSegment(i);
- String qualifiedName = segment.getString(namespaceRegistry);
- if (targetNode.hasNode(qualifiedName)) {
- targetNode = targetNode.getNode(qualifiedName);
- } else {
- // It doesn't exist, so create it ...
- if (segment.hasIndex()) {
- // Use a name without an index ...
- qualifiedName = segment.getName().getString(namespaceRegistry);
- }
- // We only have the primary type for the final one ...
- if (i == (max - 1) && primaryType != null) {
- targetNode = targetNode.addNode(qualifiedName, primaryType.getString(namespaceRegistry,
- Path.NO_OP_ENCODER));
- } else {
- targetNode = targetNode.addNode(qualifiedName);
- }
- }
- assert targetNode != null;
- }
- assert targetNode != null;
-
+ List properties = new LinkedList();
// Set all of the properties on this
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
- String propertyName = property.getName().getString(namespaceRegistry, Path.NO_OP_ENCODER);
- Object value = property.getValue();
- if (jcrPrimaryTypePropertyName.equals(property.getName())) {
- // Skip the primary type property (which is protected in Jackrabbit 1.5)
- Logger.getLogger(this.getClass()).trace("Skipping property {0}/{1}={2}",
- targetNode.getPath(),
- propertyName,
- value);
- continue;
- }
- Logger.getLogger(this.getClass()).trace("Writing property {0}/{1}={2}", targetNode.getPath(), propertyName, value);
- if (value instanceof Boolean) {
- targetNode.setProperty(propertyName, ((Boolean)value).booleanValue());
- } else if (value instanceof String) {
- targetNode.setProperty(propertyName, (String)value);
- } else if (value instanceof String[]) {
- targetNode.setProperty(propertyName, (String[])value);
- } else if (value instanceof Integer) {
- targetNode.setProperty(propertyName, ((Integer)value).intValue());
- } else if (value instanceof Short) {
- targetNode.setProperty(propertyName, ((Short)value).shortValue());
- } else if (value instanceof Long) {
- targetNode.setProperty(propertyName, ((Long)value).longValue());
- } else if (value instanceof Float) {
- targetNode.setProperty(propertyName, ((Float)value).floatValue());
- } else if (value instanceof Double) {
- targetNode.setProperty(propertyName, ((Double)value).doubleValue());
- } else if (value instanceof Binary) {
- Binary binaryValue = (Binary)value;
- try {
- binaryValue.acquire();
- targetNode.setProperty(propertyName, binaryValue.getStream());
- } finally {
- binaryValue.release();
- }
- } else if (value instanceof BigDecimal) {
- targetNode.setProperty(propertyName, ((BigDecimal)value).doubleValue());
- } else if (value instanceof DateTime) {
- targetNode.setProperty(propertyName, ((DateTime)value).toCalendar());
- } else if (value instanceof Date) {
- DateTime instant = context.getValueFactories().getDateFactory().create((Date)value);
- targetNode.setProperty(propertyName, instant.toCalendar());
- } else if (value instanceof Calendar) {
- targetNode.setProperty(propertyName, (Calendar)value);
- } else if (value instanceof Name) {
- Name nameValue = (Name)value;
- String stringValue = nameValue.getString(namespaceRegistry);
- targetNode.setProperty(propertyName, stringValue);
- } else if (value instanceof Path) {
- // Find the path to reference node ...
- Path pathToReferencedNode = (Path)value;
- if (!pathToReferencedNode.isAbsolute()) {
- // Resolve the path relative to the output node ...
- pathToReferencedNode = outputNodePath.resolve(pathToReferencedNode);
- }
- // Find the referenced node ...
- try {
- Node referencedNode = outputNode.getNode(pathToReferencedNode.getString());
- targetNode.setProperty(propertyName, referencedNode);
- } catch (PathNotFoundException e) {
- String msg = RepositoryI18n.errorGettingNodeRelativeToNode.text(value, outputNode.getPath());
- throw new SequencerException(msg, e);
- }
- } else if (value == null) {
- // Remove the property ...
- targetNode.setProperty(propertyName, (String)null);
- } else {
- String msg = RepositoryI18n.unknownPropertyValueType.text(value, value.getClass().getName());
- throw new SequencerException(msg);
- }
+ // String propertyName = property.getName().getString(namespaceRegistry, Path.NO_OP_ENCODER);
+ properties.add(propertyFactory.create(property.getName(), property.getValue()));
+ // TODO: Handle reference properties - currently passed in as Paths
}
- }
- return true;
+ if (absolutePath.getParent() != null) {
+ buildPathTo(absolutePath.getParent(), context);
+ }
+ context.getDestination().create(absolutePath, properties);
+ }
}
protected String[] extractMixinTypes( Object value ) {
@@ -300,10 +227,10 @@
return null;
}
- protected SequencerContext createSequencerContext( Node input,
- Property sequencedProperty,
- ExecutionContext context,
- Problems problems ) throws RepositoryException {
+ protected StreamSequencerContext createStreamSequencerContext( Node input,
+ Property sequencedProperty,
+ SequencerContext context,
+ Problems problems ) {
assert input != null;
assert sequencedProperty != null;
assert context != null;
@@ -312,78 +239,25 @@
// RepositoryException from being thrown by getters
// Note: getMimeType() will still operate lazily, and thus throw a SequencerException, since it is very intrusive and
// potentially slow-running.
- ValueFactories factories = context.getValueFactories();
- Path path = factories.getPathFactory().create(input.getPath());
- Set props = new HashSet();
- for (PropertyIterator iter = input.getProperties(); iter.hasNext();) {
- javax.jcr.Property jcrProp = iter.nextProperty();
- org.jboss.dna.graph.property.Property prop;
- if (jcrProp.getDefinition().isMultiple()) {
- Value[] jcrVals = jcrProp.getValues();
- Object[] vals = new Object[jcrVals.length];
- int ndx = 0;
- for (Value jcrVal : jcrVals) {
- vals[ndx++] = convert(factories, jcrProp.getName(), jcrVal);
- }
- prop = context.getPropertyFactory().create(factories.getNameFactory().create(jcrProp.getName()), vals);
- } else {
- Value jcrVal = jcrProp.getValue();
- Object val = convert(factories, jcrProp.getName(), jcrVal);
- prop = context.getPropertyFactory().create(factories.getNameFactory().create(jcrProp.getName()), val);
- }
- props.add(prop);
- }
+ ValueFactories factories = context.getExecutionContext().getValueFactories();
+ // TODO: Is this safe?
+ Path path = factories.getPathFactory().create(input.getLocation().getPath());
+
+ Set props = new HashSet(
+ input.getPropertiesByName().values());
props = Collections.unmodifiableSet(props);
String mimeType = getMimeType(sequencedProperty, path.getLastSegment().getName().getLocalName());
- return new SequencerContext(context, path, props, mimeType, problems);
+ return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems);
}
- protected Object convert( ValueFactories factories,
- String name,
- Value jcrValue ) throws RepositoryException {
- switch (jcrValue.getType()) {
- case PropertyType.BINARY: {
- return factories.getBinaryFactory().create(jcrValue.getStream());
- }
- case PropertyType.BOOLEAN: {
- return factories.getBooleanFactory().create(jcrValue.getBoolean());
- }
- case PropertyType.DATE: {
- return factories.getDateFactory().create(jcrValue.getDate());
- }
- case PropertyType.DOUBLE: {
- return factories.getDoubleFactory().create(jcrValue.getDouble());
- }
- case PropertyType.LONG: {
- return factories.getLongFactory().create(jcrValue.getLong());
- }
- case PropertyType.NAME: {
- return factories.getNameFactory().create(jcrValue.getString());
- }
- case PropertyType.PATH: {
- return factories.getPathFactory().create(jcrValue.getString());
- }
- case PropertyType.REFERENCE: {
- return factories.getReferenceFactory().create(jcrValue.getString());
- }
- case PropertyType.STRING: {
- return factories.getStringFactory().create(jcrValue.getString());
- }
- default: {
- throw new RepositoryException(RepositoryI18n.unknownPropertyValueType.text(name, jcrValue.getType()));
- }
- }
- }
-
- @SuppressWarnings( "null" )
- // The need for the SuppressWarnings looks like an Eclipse bug
protected String getMimeType( Property sequencedProperty,
String name ) {
SequencerException err = null;
String mimeType = null;
InputStream stream = null;
try {
- stream = sequencedProperty.getStream();
+ // Parallel the JCR lemma for converting objects into streams
+ stream = new ByteArrayInputStream(sequencedProperty.toString().getBytes());
mimeType = MimeType.of(name, stream);
return mimeType;
} catch (Exception error) {
Index: dna-repository/src/main/java/org/jboss/dna/repository/util/RepositoryNodePath.java
===================================================================
--- dna-repository/src/main/java/org/jboss/dna/repository/util/RepositoryNodePath.java (revision 886)
+++ dna-repository/src/main/java/org/jboss/dna/repository/util/RepositoryNodePath.java (working copy)
@@ -37,27 +37,29 @@
protected static final Pattern PATTERN = Pattern.compile("([^:/]):(/.*)");
- public static RepositoryNodePath parse( String path, String defaultRepositoryWorkspaceName ) {
+ public static RepositoryNodePath parse( String path, String repositorySourceName, String defaultRepositoryWorkspaceName ) {
Matcher matcher = PATTERN.matcher(path);
if (matcher.matches()) {
try {
- return new RepositoryNodePath(matcher.group(1), matcher.group(2));
+ return new RepositoryNodePath(repositorySourceName, matcher.group(1), matcher.group(2));
} catch (Throwable t) {
throw new IllegalArgumentException(RepositoryI18n.invalidRepositoryNodePath.text(path, t.getMessage()));
}
}
- return new RepositoryNodePath(defaultRepositoryWorkspaceName, path);
+ return new RepositoryNodePath(repositorySourceName, defaultRepositoryWorkspaceName, path);
}
- private final String repositoryName;
+ private final String repositorySourceName;
+ private final String workspaceName;
private final String nodePath;
private final int hc;
- public RepositoryNodePath( String repositoryName, String nodePath ) {
- this.repositoryName = repositoryName;
+ public RepositoryNodePath( String repositorySourceName, String workspaceName, String nodePath ) {
+ this.repositorySourceName = repositorySourceName;
+ this.workspaceName = workspaceName;
this.nodePath = nodePath;
- this.hc = HashCode.compute(this.repositoryName, this.nodePath);
+ this.hc = HashCode.compute(this.repositorySourceName, this.workspaceName, this.nodePath);
}
/**
@@ -70,11 +72,19 @@
/**
* @return repositoryName
*/
- public String getRepositoryWorkspaceName() {
- return this.repositoryName;
+ public String getRepositorySourceName() {
+ return this.repositorySourceName;
}
/**
+ *
+ * @return the workspace name
+ */
+ public String getWorkspaceName() {
+ return this.workspaceName;
+ }
+
+ /**
* {@inheritDoc}
*/
@Override
@@ -90,7 +100,8 @@
if (obj == this) return true;
if (obj instanceof RepositoryNodePath) {
RepositoryNodePath that = (RepositoryNodePath)obj;
- if (!this.repositoryName.equals(that.repositoryName)) return false;
+ if (!this.repositorySourceName.equals(that.repositorySourceName)) return false;
+ if (!this.workspaceName.equals(that.workspaceName)) return false;
if (!this.nodePath.equals(that.nodePath)) return false;
return true;
}
@@ -102,6 +113,6 @@
*/
@Override
public String toString() {
- return this.repositoryName + ":" + this.nodePath;
+ return this.repositorySourceName + ":" + this.workspaceName + ":" + this.nodePath;
}
}
Index: dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java
===================================================================
--- dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java (revision 886)
+++ dna-repository/src/test/java/org/jboss/dna/repository/DnaEngineTest.java (working copy)
@@ -163,7 +163,7 @@
SequencingService sequencer = engine.getSequencingService();
assertThat(sequencer.getStatistics().getNumberOfNodesSequenced(), is(0L));
- NodeChanges changes = NodeChanges.create("", Arrays.asList(new Event[] {}));
+ NodeChanges changes = NodeChanges.create("config repo", "", Arrays.asList(new Event[] {}));
sequencer.onNodeChanges(changes);
assertThat(sequencer.getStatistics().getNumberOfNodesSequenced(), is(0L));
Index: dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java
===================================================================
--- dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java (revision 886)
+++ dna-repository/src/test/java/org/jboss/dna/repository/observation/NodeChangeTest.java (working copy)
@@ -51,7 +51,7 @@
validModifiedProperties.add("jcr:name");
validModifiedProperties.add("jcr:title");
validRemovedProperties.add("jcr:mime");
- nodeChange = new NodeChange(validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties,
+ nodeChange = new NodeChange("", validRepositoryWorkspaceName, validAbsolutePath, validEventTypes, validModifiedProperties,
validRemovedProperties);
}
Index: dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java
===================================================================
--- dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java (revision 886)
+++ dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerA.java (working copy)
@@ -28,13 +28,10 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.jcr.Node;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.sequencer.Sequencer;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -73,7 +70,7 @@
String sequencedPropertyName,
NodeChange changes,
Set outputPaths,
- JcrExecutionContext context,
+ SequencerContext context,
Problems problems ) {
// increment the counter and record the progress ...
this.counter.incrementAndGet();
Index: dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java
===================================================================
--- dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java (revision 886)
+++ dna-repository/src/test/java/org/jboss/dna/repository/sequencer/MockSequencerB.java (working copy)
@@ -28,13 +28,10 @@
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
-import javax.jcr.Node;
import net.jcip.annotations.ThreadSafe;
import org.jboss.dna.common.collection.Problems;
+import org.jboss.dna.graph.Node;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.sequencer.Sequencer;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
/**
@@ -73,7 +70,7 @@
String sequencedPropertyName,
NodeChange changes,
Set outputPaths,
- JcrExecutionContext context,
+ SequencerContext context,
Problems problems ) {
// increment the counter and record the progress ...
this.counter.incrementAndGet();
Index: dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java
===================================================================
--- dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java (revision 886)
+++ dna-repository/src/test/java/org/jboss/dna/repository/sequencer/SequencingServiceTest.java (working copy)
@@ -39,15 +39,15 @@
import javax.jcr.observation.Event;
import org.jboss.dna.common.SystemFailureException;
import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.repository.RepositoryLibrary;
import org.jboss.dna.repository.observation.ObservationService;
-import org.jboss.dna.repository.sequencer.Sequencer;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.sequencer.SequencingService;
import org.jboss.dna.repository.service.ServiceAdministrator;
import org.jboss.dna.repository.util.JcrExecutionContext;
import org.jboss.dna.repository.util.SessionFactory;
import org.junit.After;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
/**
@@ -57,14 +57,22 @@
public static final int ALL_EVENT_TYPES = Event.NODE_ADDED | Event.NODE_REMOVED | Event.PROPERTY_ADDED
| Event.PROPERTY_CHANGED | Event.PROPERTY_REMOVED;
+
+ public static final String REPOSITORY_SOURCE_NAME = "repository";
public static final String REPOSITORY_WORKSPACE_NAME = "testRepository-Workspace";
+ private RepositoryLibrary sources;
private ObservationService observationService;
private SequencingService sequencingService;
private JcrExecutionContext executionContext;
@Before
public void beforeEach() {
+ sources = new RepositoryLibrary();
+ InMemoryRepositorySource source = new InMemoryRepositorySource();
+ source.setName(REPOSITORY_SOURCE_NAME);
+ sources.addSource(source);
+
SessionFactory sessionFactory = new SessionFactory() {
public Session createSession( String name ) throws RepositoryException {
assertThat(name, is(REPOSITORY_WORKSPACE_NAME));
@@ -78,6 +86,7 @@
this.executionContext = new JcrExecutionContext(sessionFactory, REPOSITORY_WORKSPACE_NAME);
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(this.executionContext);
+ this.sequencingService.setRepositoryLibrary(sources);
this.observationService = new ObservationService(this.executionContext.getSessionFactory());
this.observationService.addListener(this.sequencingService);
}
@@ -208,7 +217,7 @@
// Try when paused ...
assertThat(sequencingService.getAdministrator().isPaused(), is(true));
assertThat(observationService.getAdministrator().pause().isPaused(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
+ ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
assertThat(listener, is(notNullValue()));
assertThat(listener.getAbsolutePath(), is("/"));
assertThat(listener.getEventTypes(), is(Event.NODE_ADDED));
@@ -229,7 +238,7 @@
// Start the sequencing sequencingService and try monitoring the workspace ...
assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
assertThat(observationService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener2 = observationService.monitor(REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
+ ObservationService.WorkspaceListener listener2 = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
assertThat(listener2.isRegistered(), is(true));
assertThat(listener2, is(notNullValue()));
assertThat(listener2.getAbsolutePath(), is("/"));
@@ -268,7 +277,7 @@
// Start the sequencing sequencingService and try monitoring the workspace ...
assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
+ ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, Event.NODE_ADDED);
assertThat(listener.isRegistered(), is(true));
assertThat(listener, is(notNullValue()));
assertThat(listener.getAbsolutePath(), is("/"));
@@ -299,6 +308,9 @@
assertThat(listener.isRegistered(), is(false));
}
+ // FIXME: This test needs to be unignored after the observation service is re-written to not use JCR
+
+ @Ignore
@Test
public void shouldExecuteSequencersUponChangesToRepositoryThatMatchSequencerPathExpressions() throws Exception {
// Add configurations for a sequencer ...
@@ -316,7 +328,7 @@
// Start the sequencing sequencingService and try monitoring the workspace ...
assertThat(sequencingService.getAdministrator().start().isStarted(), is(true));
- ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_WORKSPACE_NAME, ALL_EVENT_TYPES);
+ ObservationService.WorkspaceListener listener = observationService.monitor(REPOSITORY_SOURCE_NAME, REPOSITORY_WORKSPACE_NAME, ALL_EVENT_TYPES);
assertThat(listener.isRegistered(), is(true));
assertThat(listener, is(notNullValue()));
assertThat(listener.getAbsolutePath(), is("/"));
Index: dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java
===================================================================
--- dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java (revision 886)
+++ dna-repository/src/test/java/org/jboss/dna/repository/sequencer/StreamSequencerAdapterTest.java (working copy)
@@ -32,31 +32,26 @@
import static org.mockito.Mockito.mock;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import javax.jcr.Node;
-import javax.jcr.Session;
import javax.jcr.observation.Event;
import org.jboss.dna.common.collection.Problems;
import org.jboss.dna.common.collection.SimpleProblems;
-import org.jboss.dna.common.jcr.AbstractJcrRepositoryTest;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.Graph;
+import org.jboss.dna.graph.Node;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.property.Path;
+import org.jboss.dna.graph.property.PathNotFoundException;
import org.jboss.dna.graph.property.Property;
-import org.jboss.dna.graph.sequencer.SequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.sequencer.SequencerConfig;
-import org.jboss.dna.repository.sequencer.SequencerException;
-import org.jboss.dna.repository.sequencer.SequencerOutputMap;
-import org.jboss.dna.repository.sequencer.StreamSequencerAdapter;
-import org.jboss.dna.repository.util.JcrExecutionContext;
-import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.RepositoryNodePath;
-import org.jboss.dna.repository.util.SessionFactory;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -64,35 +59,33 @@
* @author Randall Hauch
* @author John Verhaeg
*/
-public class StreamSequencerAdapterTest extends AbstractJcrRepositoryTest {
+public class StreamSequencerAdapterTest {
private StreamSequencer streamSequencer;
private StreamSequencerAdapter sequencer;
private String[] validExpressions = {"/a/* => /output"};
- private SequencerConfig validConfig = new SequencerConfig("name", "desc", Collections.emptyMap(), "something.class", null, validExpressions);
- private JcrTools tools;
- private Session session;
+ private SequencerConfig validConfig = new SequencerConfig("name", "desc", Collections.emptyMap(),
+ "something.class", null, validExpressions);
private SequencerOutputMap sequencerOutput;
private String sampleData = "The little brown fox didn't something bad.";
- private JcrExecutionContext context;
- private String repositoryWorkspaceName = "something";
+ private ExecutionContext context;
+ private SequencerContext seqContext;
+ private String repositorySourceName = "repository";
+ private String repositoryWorkspaceName = "";
private Problems problems;
- private javax.jcr.Property sequencedProperty;
+ private Graph graph;
+ private Property sequencedProperty;
@Before
public void beforeEach() {
- final JcrTools tools = new JcrTools();
- this.tools = tools;
- final SessionFactory sessionFactory = new SessionFactory() {
-
- public Session createSession( String name ) {
- return createTestSession();
- }
- };
problems = new SimpleProblems();
- this.context = new JcrExecutionContext(sessionFactory, "doesn't matter");
+ this.context = new ExecutionContext();
this.sequencerOutput = new SequencerOutputMap(this.context.getValueFactories());
final SequencerOutputMap finalOutput = sequencerOutput;
+
+ InMemoryRepositorySource source = new InMemoryRepositorySource();
+ source.setName("repository");
+ graph = Graph.create(source.getConnection(), context);
this.streamSequencer = new StreamSequencer() {
/**
@@ -101,7 +94,7 @@
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
for (SequencerOutputMap.Entry entry : finalOutput) {
Path nodePath = entry.getPath();
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues()) {
@@ -111,49 +104,31 @@
}
};
sequencer = new StreamSequencerAdapter(streamSequencer);
+ seqContext = new SequencerContext(context, graph);
}
- @After
- public void afterEach() {
- if (session != null) {
- try {
- session.logout();
- } finally {
- session = null;
- }
- }
- }
-
- protected Session createTestSession() {
- try {
- return getRepository().login(getTestCredentials());
- } catch (Exception e) {
- fail("Unable to create repository session: " + e.getMessage());
- return null; // won't get here
- }
- }
-
protected void testSequencer( final StreamSequencer sequencer ) throws Throwable {
StreamSequencer streamSequencer = new StreamSequencer() {
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
sequencer.sequence(stream, output, context);
}
};
StreamSequencerAdapter adapter = new StreamSequencerAdapter(streamSequencer);
- startRepository();
- session = getRepository().login(getTestCredentials());
- Node inputNode = tools.findOrCreateNode(session, "/a/b/c");
- Node outputNode = tools.findOrCreateNode(session, "/d/e");
- inputNode.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, inputNode.getPath(), Event.PROPERTY_CHANGED,
+
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node inputNode = graph.getNodeAt("/a/b/c");
+
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
Set outputPaths = new HashSet();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, outputNode.getPath()));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
- adapter.execute(inputNode, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ adapter.execute(inputNode, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
}
@Test
@@ -188,181 +163,201 @@
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToExistingNode() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- Node nodeE = tools.findOrCreateNode(session, "/d/e");
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ Node nodeE = graph.getNodeAt("/d/e");
assertThat(nodeC, is(notNullValue()));
assertThat(nodeE, is(notNullValue()));
- assertThat(nodeE.getNodes().getSize(), is(0l));
- assertThat(nodeE.getProperties().getSize(), is(1l)); // jcr:primaryType
- assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
+ assertThat(nodeE.getChildren().size(), is(0));
+ assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid
+ // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
// Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set outputPaths = new HashSet();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, nodeE.getPath()));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
}
@Test( expected = SequencerException.class )
public void shouldExecuteSequencerOnExistingNodeWithMissingSequencedPropertyAndOutputToExistingNode() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- Node nodeE = tools.findOrCreateNode(session, "/d/e");
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ Node nodeE = graph.getNodeAt("/d/e");
assertThat(nodeC, is(notNullValue()));
assertThat(nodeE, is(notNullValue()));
- assertThat(nodeE.getNodes().getSize(), is(0l));
- assertThat(nodeE.getProperties().getSize(), is(1l)); // jcr:primaryType
- assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
+ assertThat(nodeE.getChildren().size(), is(0));
+ assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid
+ // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
// Set the property that will be sequenced ...
// THIS TEST REQUIRES THIS PROPERTY TO BE NULL OR NON-EXISTANT
- nodeC.setProperty("sequencedProperty", (InputStream)null);
+ graph.set("sequencedProperty").on(nodeC.getLocation()).to((String)null);
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set outputPaths = new HashSet();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, nodeE.getPath()));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer, which should cause the exception ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
}
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToMultipleExistingNodes() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- Node nodeE = tools.findOrCreateNode(session, "/d/e");
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.create("/d").and().create("/d/e");
+
+ // Set the property that will be sequenced ...
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ Node nodeE = graph.getNodeAt("/d/e");
assertThat(nodeC, is(notNullValue()));
assertThat(nodeE, is(notNullValue()));
- assertThat(nodeE.getNodes().getSize(), is(0l));
- assertThat(nodeE.getProperties().getSize(), is(1l)); // jcr:primaryType
- assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
+ assertThat(nodeE.getChildren().size(), is(0));
+ assertThat(nodeE.getProperties().size(), is(1)); // jcr:uuid
+ // assertThat(nodeE.getProperty("jcr:primaryType").getString(), is("nt:unstructured"));
- // Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
-
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set outputPaths = new HashSet();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/d/e"));
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/x/y/z"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/x/y/z"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
// Check to see that the output nodes have been created ...
- assertThat(session.getRootNode().hasNode("d/e"), is(true));
- assertThat(session.getRootNode().hasNode("x/y/z"), is(true));
+ assertThat(graph.getNodeAt("/d/e"), is(notNullValue()));
+ assertThat(graph.getNodeAt("/x/y/z"), is(notNullValue()));
}
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToNonExistingNode() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- assertThat(session.getRootNode().hasNode("d"), is(false));
- assertThat(nodeC, is(notNullValue()));
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
// Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ try {
+ graph.getNodeAt("/d");
+ fail();
+ }
+ catch(PathNotFoundException pnfe) {
+ // Expected
+ }
+ assertThat(nodeC, is(notNullValue()));
+
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set outputPaths = new HashSet();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/d/e"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
// Check to see that the "/d/e" node has been created ...
- assertThat(session.getRootNode().hasNode("d/e"), is(true));
+ assertThat(graph.getNodeAt("/d/e"), is(notNullValue()));
}
@Test
public void shouldExecuteSequencerOnExistingNodeAndOutputToMultipleNonExistingNodes() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
// Set up the repository for the test ...
- Node nodeC = tools.findOrCreateNode(session, "/a/b/c");
- assertThat(session.getRootNode().hasNode("d"), is(false));
- assertThat(session.getRootNode().hasNode("x"), is(false));
- assertThat(nodeC, is(notNullValue()));
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
// Set the property that will be sequenced ...
- nodeC.setProperty("sequencedProperty", new ByteArrayInputStream(sampleData.getBytes()));
+ graph.set("sequencedProperty").on("/a/b/c").to(new ByteArrayInputStream(sampleData.getBytes()));
+ Node nodeC = graph.getNodeAt("/a/b/c");
+ try {
+ graph.getNodeAt("/d");
+ fail();
+ }
+ catch(PathNotFoundException pnfe) {
+ // Expected
+ }
+ try {
+ graph.getNodeAt("/x");
+ fail();
+ }
+ catch(PathNotFoundException pnfe) {
+ // Expected
+ }
+ assertThat(nodeC, is(notNullValue()));
+
// Set up the node changes ...
- NodeChange nodeChange = new NodeChange(repositoryWorkspaceName, nodeC.getPath(), Event.PROPERTY_CHANGED,
+ NodeChange nodeChange = new NodeChange(repositorySourceName, repositoryWorkspaceName, "/a/b/c", Event.PROPERTY_CHANGED,
Collections.singleton("sequencedProperty"), null);
// Set up the output directory ...
Set outputPaths = new HashSet();
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/d/e"));
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/x/y/z"));
- outputPaths.add(new RepositoryNodePath(repositoryWorkspaceName, "/x/z"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/d/e"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/x/y/z"));
+ outputPaths.add(new RepositoryNodePath(repositorySourceName, repositoryWorkspaceName, "/x/z"));
// Generate the output data that the sequencer subclass will produce and that should be saved to the repository ...
sequencerOutput.setProperty("alpha/beta", "isSomething", true);
// Call the sequencer ...
- sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, context, problems);
+ sequencer.execute(nodeC, "sequencedProperty", nodeChange, outputPaths, seqContext, problems);
// Check to see that the output nodes have been created ...
- assertThat(session.getRootNode().hasNode("d/e"), is(true));
- assertThat(session.getRootNode().hasNode("x/y/z"), is(true));
- assertThat(session.getRootNode().hasNode("x/z"), is(true));
+ assertThat(graph.getNodeAt("/d/e"), is(notNullValue()));
+ assertThat(graph.getNodeAt("/x/y/z"), is(notNullValue()));
+ assertThat(graph.getNodeAt("/x/z"), is(notNullValue()));
// Check to see that the sequencer-generated nodes have been created ...
// Node beta = session.getRootNode().getNode("d/e/alpha/beta");
// for (PropertyIterator iter = beta.getProperties(); iter.hasNext();) {
// Property property = iter.nextProperty();
- // System.out.println("Property on " + beta.getPath() + " ===> " + property.getName() + " = " + property.getValue());
+ // System.out.println("Property on " + beta.getLocation().getPath() + " ===> " + property.getName() + " = " +
+ // property.getValue());
// }
- assertThat(session.getRootNode().getNode("d/e/alpha/beta").getProperty("isSomething").getBoolean(), is(true));
- assertThat(session.getRootNode().getNode("x/y/z/alpha/beta").getProperty("isSomething").getBoolean(), is(true));
- assertThat(session.getRootNode().getNode("x/z/alpha/beta").getProperty("isSomething").getBoolean(), is(true));
+ assertThat(graph.getNodeAt("/d/e/alpha/beta").getProperty("isSomething").getFirstValue().toString(), is("true"));
+ assertThat(graph.getNodeAt("/x/y/z/alpha/beta").getProperty("isSomething").getFirstValue().toString(), is("true"));
+ assertThat(graph.getNodeAt("/x/z/alpha/beta").getProperty("isSomething").getFirstValue().toString(), is("true"));
}
@Test
@@ -376,7 +371,7 @@
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
assertThat(stream, notNullValue());
}
});
@@ -388,7 +383,7 @@
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
assertThat(output, notNullValue());
}
});
@@ -400,7 +395,7 @@
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
assertThat(context, notNullValue());
}
});
@@ -408,104 +403,111 @@
@Test( expected = java.lang.AssertionError.class )
public void shouldNotAllowNullInputNode() throws Exception {
- sequencer.createSequencerContext(null, sequencedProperty, context, problems);
+ sequencer.createStreamSequencerContext(null, sequencedProperty, seqContext, problems);
}
@Test( expected = java.lang.AssertionError.class )
public void shouldNotAllowNullSequencedProperty() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- Node input = tools.findOrCreateNode(session, "/a");
- sequencer.createSequencerContext(input, null, context, problems);
+ graph.create("/a");
+ Node input = graph.getNodeAt("/a");
+ sequencer.createStreamSequencerContext(input, null, seqContext, problems);
}
@Test( expected = java.lang.AssertionError.class )
public void shouldNotAllowNullExecutionContext() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- Node input = tools.findOrCreateNode(session, "/a");
- sequencer.createSequencerContext(input, sequencedProperty, null, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a");
+ Node input = graph.getNodeAt("/a");
+ sequencer.createStreamSequencerContext(input, sequencedProperty, null, problems);
}
@Test
public void shouldProvideNamespaceRegistry() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getNamespaceRegistry(), notNullValue());
}
@Test
public void shouldProvideValueFactories() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getValueFactories(), notNullValue());
}
@Test
public void shouldProvidePathToInput() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getInputPath(), is(context.getValueFactories().getPathFactory().create("/a/b/c")));
}
@Test
public void shouldNeverReturnNullInputProperties() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getInputProperties(), notNullValue());
assertThat(sequencerContext.getInputProperties().isEmpty(), is(false));
}
@Test
public void shouldProvideInputProperties() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- input.setProperty("x", true);
- input.setProperty("y", new String[] {"asdf", "xyzzy"});
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ graph.set("x").on("/a/b/c").to(true);
+ graph.set("y").on("/a/b/c").to(Arrays.asList(new String[] {"asdf", "xyzzy"}));
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input, sequencedProperty, seqContext, problems);
assertThat(sequencerContext.getInputProperties(), notNullValue());
assertThat(sequencerContext.getInputProperties().isEmpty(), is(false));
assertThat(sequencerContext.getInputProperties().size(), is(3));
- verifyProperty(sequencerContext,
- "jcr:primaryType",
- context.getValueFactories().getNameFactory().create("{http://www.jcp.org/jcr/nt/1.0}unstructured"));
+ // verifyProperty(sequencerContext, "jcr:uuid", /* some UUID */null );
verifyProperty(sequencerContext, "x", true);
verifyProperty(sequencerContext, "y", "asdf", "xyzzy");
}
@Test
public void shouldCreateSequencerContextThatProvidesMimeType() throws Exception {
- startRepository();
- session = getRepository().login(getTestCredentials());
- this.sequencedProperty = mock(javax.jcr.Property.class);
- Node input = tools.findOrCreateNode(session, "/a/b/c");
- SequencerContext sequencerContext = sequencer.createSequencerContext(input, sequencedProperty, context, problems);
+ this.sequencedProperty = mock(Property.class);
+ graph.create("/a").and().create("/a/b").and().create("/a/b/c");
+ Node input = graph.getNodeAt("/a/b/c");
+ StreamSequencerContext sequencerContext = sequencer.createStreamSequencerContext(input,
+ sequencedProperty,
+ seqContext,
+ problems);
assertThat(sequencerContext.getMimeType(), is("text/plain"));
}
- private void verifyProperty( SequencerContext context,
+ private void verifyProperty( StreamSequencerContext context,
String name,
Object... values ) {
Property prop = context.getInputProperty(context.getValueFactories().getNameFactory().create(name));
Index: docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java
===================================================================
--- docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java (revision 894)
+++ docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencer/SequencingClient.java (working copy)
@@ -222,9 +222,10 @@
}
this.executionContext = new JcrExecutionContext(sessionFactory, repositoryWorkspaceName);
- // Create the sequencing service, passing in the execution context ...
+ // Create the sequencing service, passing in the execution context and the repository library ...
this.sequencingService = new SequencingService();
this.sequencingService.setExecutionContext(executionContext);
+ //this.sequencingService.setRepositoryLibrary(repositoryLibrary);
// Configure the sequencers. In this example, we only two sequencers that processes image and mp3 files.
// So create a configurations. Note that the sequencing service expects the class to be on the thread's current
@@ -269,7 +270,7 @@
this.observationService = new ObservationService(this.executionContext.getSessionFactory());
this.observationService.getAdministrator().start();
this.observationService.addListener(this.sequencingService);
- this.observationService.monitor(repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
+ this.observationService.monitor(this.repositoryName, repositoryWorkspaceName, Event.NODE_ADDED | Event.PROPERTY_ADDED
| Event.PROPERTY_CHANGED);
}
// Start up the sequencing service ...
Index: extensions/dna-classloader-maven/.project
===================================================================
--- extensions/dna-classloader-maven/.project (revision 886)
+++ extensions/dna-classloader-maven/.project (working copy)
@@ -1,23 +1,24 @@
-
-
- dna-maven-classloader
-
-
-
-
-
- org.maven.ide.eclipse.maven2Builder
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
- org.maven.ide.eclipse.maven2Nature
-
-
+
+
+ dna-maven-classloader
+
+
+
+
+
+ org.maven.ide.eclipse.maven2Builder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.maven.ide.eclipse.maven2Nature
+ org.eclipse.wst.common.project.facet.core.nature
+
+
Index: extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java
===================================================================
--- extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java (revision 886)
+++ extensions/dna-common-jdbc/src/main/java/org/jboss/dna/graph/sequencers/JdbcSequencer.java (working copy)
@@ -24,7 +24,7 @@
package org.jboss.dna.graph.sequencers;
import java.sql.Connection;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
/**
@@ -46,5 +46,5 @@
*/
void sequence( Connection connection,
SequencerOutput output,
- SequencerContext context );
+ StreamSequencerContext context );
}
Index: extensions/dna-sequencer-cnd/src/main/java/org/jboss/dna/sequencer/cnd/CndSequencer.java
===================================================================
--- extensions/dna-sequencer-cnd/src/main/java/org/jboss/dna/sequencer/cnd/CndSequencer.java (revision 886)
+++ extensions/dna-sequencer-cnd/src/main/java/org/jboss/dna/sequencer/cnd/CndSequencer.java (working copy)
@@ -31,7 +31,7 @@
import org.jboss.dna.graph.io.Destination;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.Property;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -44,11 +44,11 @@
* {@inheritDoc}
*
* @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(java.io.InputStream,
- * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.SequencerContext)
+ * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
// Create the destination that forwards to the sequencer output ...
Destination destination = new OutputDestination(output, context);
// Use the CND importer ...
@@ -64,10 +64,10 @@
protected class OutputDestination implements Destination {
private final SequencerOutput output;
- private final SequencerContext context;
+ private final StreamSequencerContext context;
protected OutputDestination( SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
this.output = output;
this.context = context;
}
Index: extensions/dna-sequencer-cnd/src/test/java/org/jboss/dna/sequencer/cnd/CndSequencerTest.java
===================================================================
--- extensions/dna-sequencer-cnd/src/test/java/org/jboss/dna/sequencer/cnd/CndSequencerTest.java (revision 886)
+++ extensions/dna-sequencer-cnd/src/test/java/org/jboss/dna/sequencer/cnd/CndSequencerTest.java (working copy)
@@ -31,7 +31,7 @@
import java.net.URL;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -47,7 +47,7 @@
private URL cndImages;
private URL cndMp3;
private URL cndBuiltIns;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Index: extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/image/ImageMetadataSequencer.java
===================================================================
--- extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/image/ImageMetadataSequencer.java (revision 886)
+++ extensions/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/image/ImageMetadataSequencer.java (working copy)
@@ -27,7 +27,7 @@
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -88,11 +88,11 @@
/**
* {@inheritDoc}
*
- * @see StreamSequencer#sequence(InputStream, SequencerOutput, SequencerContext)
+ * @see StreamSequencer#sequence(InputStream, SequencerOutput, StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
ImageMetadata metadata = new ImageMetadata();
metadata.setInput(stream);
Index: extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/image/ImageMetadataSequencerTest.java
===================================================================
--- extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/image/ImageMetadataSequencerTest.java (revision 886)
+++ extensions/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/image/ImageMetadataSequencerTest.java (working copy)
@@ -32,7 +32,7 @@
import java.net.URL;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.sequencer.image.ImageMetadataSequencer;
import org.junit.After;
import org.junit.Before;
@@ -51,7 +51,7 @@
private URL cautionJpg;
private URL cautionPict;
private URL cautionPng;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Index: extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java
===================================================================
--- extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java (revision 886)
+++ extensions/dna-sequencer-java/src/main/java/org/jboss/dna/sequencer/java/JavaMetadataSequencer.java (working copy)
@@ -29,7 +29,7 @@
import org.jboss.dna.graph.property.NameFactory;
import org.jboss.dna.graph.property.Path;
import org.jboss.dna.graph.property.PathFactory;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.sequencer.java.metadata.AnnotationMetadata;
@@ -175,11 +175,11 @@
* {@inheritDoc}
*
* @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(java.io.InputStream,
- * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.SequencerContext)
+ * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
JavaMetadata javaMetadata = null;
NameFactory nameFactory = context.getValueFactories().getNameFactory();
PathFactory pathFactory = context.getValueFactories().getPathFactory();
Index: extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java
===================================================================
--- extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java (revision 886)
+++ extensions/dna-sequencer-java/src/test/java/org/jboss/dna/sequencer/java/JavaMetadataSequencerTest.java (working copy)
@@ -33,7 +33,7 @@
import java.io.InputStream;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -47,7 +47,7 @@
private InputStream content;
private MockSequencerOutput output;
private File source;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Index: extensions/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java
===================================================================
--- extensions/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java (revision 886)
+++ extensions/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java (working copy)
@@ -24,7 +24,7 @@
package org.jboss.dna.sequencer.mp3;
import java.io.InputStream;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -63,11 +63,11 @@
/**
* {@inheritDoc}
*
- * @see StreamSequencer#sequence(InputStream, SequencerOutput, SequencerContext)
+ * @see StreamSequencer#sequence(InputStream, SequencerOutput, StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
Mp3Metadata metadata = Mp3Metadata.instance(stream);
if (metadata != null) {
Index: extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java
===================================================================
--- extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java (revision 886)
+++ extensions/dna-sequencer-msoffice/src/main/java/org/jboss/dna/sequencer/msoffice/MSOfficeMetadataSequencer.java (working copy)
@@ -27,7 +27,7 @@
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.jboss.dna.sequencer.msoffice.excel.ExcelMetadata;
@@ -123,7 +123,7 @@
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
MSOfficeMetadata metadata = MSOfficeMetadataReader.instance(stream);
Index: extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencer.java
===================================================================
--- extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencer.java (revision 886)
+++ extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencer.java (working copy)
@@ -27,7 +27,7 @@
import org.jboss.dna.common.text.TextDecoder;
import org.jboss.dna.graph.JcrNtLexicon;
import org.jboss.dna.graph.property.Name;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
import org.xml.sax.InputSource;
@@ -84,11 +84,11 @@
/**
* {@inheritDoc}
*
- * @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(InputStream, SequencerOutput, SequencerContext)
+ * @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(InputStream, SequencerOutput, StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
XMLReader reader;
try {
// Set up the XML handler ...
Index: extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencerHandler.java
===================================================================
--- extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencerHandler.java (revision 886)
+++ extensions/dna-sequencer-xml/src/main/java/org/jboss/dna/sequencer/xml/XmlSequencerHandler.java (working copy)
@@ -43,7 +43,7 @@
import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.ValueFormatException;
import org.jboss.dna.graph.property.basic.LocalNamespaceRegistry;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.xml.sax.Attributes;
import org.xml.sax.SAXParseException;
@@ -55,7 +55,7 @@
public class XmlSequencerHandler extends DefaultHandler2 {
private final SequencerOutput output;
- private final SequencerContext context;
+ private final StreamSequencerContext context;
/**
* Decoder for XML names, to turn '_xHHHH_' sequences in the XML element and attribute names into the corresponding UTF-16
@@ -138,7 +138,7 @@
* @param scoping
*/
XmlSequencerHandler( SequencerOutput output,
- SequencerContext context,
+ StreamSequencerContext context,
Name nameAttribute,
Name defaultPrimaryType,
TextDecoder textDecoder,
Index: extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/InheritingXmlSequencerTest.java
===================================================================
--- extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/InheritingXmlSequencerTest.java (revision 886)
+++ extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/InheritingXmlSequencerTest.java (working copy)
@@ -33,7 +33,7 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -49,7 +49,7 @@
private InputStream stream;
private MockSequencerOutput output;
private URL xsd;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Index: extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerHandlerTest.java
===================================================================
--- extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerHandlerTest.java (revision 886)
+++ extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerHandlerTest.java (working copy)
@@ -45,7 +45,7 @@
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.Before;
import org.junit.Test;
import org.xml.sax.InputSource;
@@ -59,7 +59,7 @@
public class XmlSequencerHandlerTest {
private XmlSequencerHandler handler;
- private SequencerContext context;
+ private StreamSequencerContext context;
private MockSequencerOutput output;
private TextDecoder decoder;
private Name primaryType;
Index: extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerTest.java
===================================================================
--- extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerTest.java (revision 886)
+++ extensions/dna-sequencer-xml/src/test/java/org/jboss/dna/sequencer/xml/XmlSequencerTest.java (working copy)
@@ -33,7 +33,7 @@
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.MockSequencerOutput;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -66,7 +66,7 @@
private URL xml3;
private URL xml4;
private URL xsd;
- private SequencerContext context;
+ private StreamSequencerContext context;
@Before
public void beforeEach() {
Index: extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java
===================================================================
--- extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java (revision 886)
+++ extensions/dna-sequencer-zip/src/main/java/org/jboss/dna/sequencer/zip/ZipSequencer.java (working copy)
@@ -28,7 +28,7 @@
import java.io.InputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.jboss.dna.graph.sequencer.SequencerOutput;
import org.jboss.dna.graph.sequencer.StreamSequencer;
@@ -42,11 +42,11 @@
* {@inheritDoc}
*
* @see org.jboss.dna.graph.sequencer.StreamSequencer#sequence(java.io.InputStream,
- * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.SequencerContext)
+ * org.jboss.dna.graph.sequencer.SequencerOutput, org.jboss.dna.graph.sequencer.StreamSequencerContext)
*/
public void sequence( InputStream stream,
SequencerOutput output,
- SequencerContext context ) {
+ StreamSequencerContext context ) {
try {
ZipInputStream in = new ZipInputStream(stream);
ZipEntry entry = in.getNextEntry();
Index: extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java
===================================================================
--- extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java (revision 886)
+++ extensions/dna-sequencer-zip/src/test/java/org/jboss/dna/sequencer/zip/ZipSequencerTest.java (working copy)
@@ -28,7 +28,7 @@
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import java.io.InputStream;
-import org.jboss.dna.graph.sequencer.SequencerContext;
+import org.jboss.dna.graph.sequencer.StreamSequencerContext;
import org.junit.After;
import org.junit.Test;
@@ -58,7 +58,7 @@
InputStream is = getTestZip("testzip.zip");
ZipSequencer zs = new ZipSequencer();
SequencingOutputTestClass seqtest = new SequencingOutputTestClass();
- SequencerContext context = mock(SequencerContext.class);
+ StreamSequencerContext context = mock(StreamSequencerContext.class);
zs.sequence(is, seqtest, context);
assertThat(seqtest.properties.get(2).getPath(), is("zip:content/test subfolder/test2.txt/jcr:content"));