Author: rhauch
Date: 2009-03-05 13:02:40 -0500 (Thu, 05 Mar 2009)
New Revision: 758
Removed:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelOneTestSuite.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelTwoTestSuite.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckOptionalTestSuite.java
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyIterator.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyIteratorTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
DNA-194 Implement update JCR capability
Refactored the TCK unit tests again to make them easier to run/understand. Also improved
the implementation of some JCR API methods, and reorganized the methods in
JcrAbstractNode.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-03-05 14:55:09
UTC (rev 757)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/AbstractJcrNode.java 2009-03-05 18:02:40
UTC (rev 758)
@@ -24,11 +24,11 @@
package org.jboss.dna.jcr;
import java.io.InputStream;
-import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
@@ -48,11 +48,11 @@
import javax.jcr.lock.Lock;
import javax.jcr.nodetype.NodeDefinition;
import javax.jcr.nodetype.NodeType;
+import javax.jcr.nodetype.NodeTypeManager;
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.common.util.CheckArg;
-import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NamespaceRegistry;
import org.jboss.dna.graph.property.Path;
@@ -65,8 +65,10 @@
@NotThreadSafe
abstract class AbstractJcrNode extends AbstractJcrItem implements Node {
+ private static final NodeType[] EMPTY_NODE_TYPES = new NodeType[] {};
+
private final JcrSession session;
- Set<Property> properties;
+ Map<Name, Property> properties;
List<Path.Segment> children;
private UUID uuid;
@@ -78,137 +80,113 @@
/**
* {@inheritDoc}
*
- * @throws IllegalArgumentException if <code>visitor</code> is
<code>null</code>.
- * @see javax.jcr.Item#accept(javax.jcr.ItemVisitor)
+ * @see javax.jcr.Item#getSession()
*/
- public final void accept( ItemVisitor visitor ) throws RepositoryException {
- CheckArg.isNotNull(visitor, "visitor");
- visitor.visit(this);
+ public final Session getSession() {
+ return session;
}
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#addMixin(java.lang.String)
- */
- public final void addMixin( String mixinName ) {
- throw new UnsupportedOperationException();
+ final UUID internalUuid() {
+ return uuid;
}
/**
- * {@inheritDoc}
+ * Change the internal UUID. Technically, it is possible for this to change, but only
because a new node may be assigned a
+ * UUID when it is created within the session and (according to the spec) this UUID
can change when the new node is persisted
+ * upon {@link #save()}.
*
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#addNode(java.lang.String)
+ * @param uuid the new UUID; may not be null
*/
- public final Node addNode( String relPath ) {
- throw new UnsupportedOperationException();
+ final void setInternalUuid( UUID uuid ) {
+ assert uuid != null;
+ this.uuid = uuid;
}
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#addNode(java.lang.String, java.lang.String)
- */
- public final Node addNode( String relPath,
- String primaryNodeTypeName ) {
- throw new UnsupportedOperationException();
+ final void setChildren( List<Segment> children ) {
+ assert children != null;
+ this.children = children;
}
- /**
- * {@inheritDoc}
- *
- * @return <code>false</code>
- * @see javax.jcr.Node#canAddMixin(java.lang.String)
- */
- public final boolean canAddMixin( String mixinName ) {
- return false;
+ final void setProperties( Map<Name, Property> properties ) {
+ assert properties != null;
+ this.properties = properties;
}
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#cancelMerge(javax.jcr.version.Version)
- */
- public final void cancelMerge( Version version ) {
- throw new UnsupportedOperationException();
+ final Name nameFrom( String name ) {
+ return
session.getExecutionContext().getValueFactories().getNameFactory().create(name);
}
/**
* {@inheritDoc}
*
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#checkin()
+ * @see javax.jcr.Node#getUUID()
*/
- public final Version checkin() {
- throw new UnsupportedOperationException();
+ public final String getUUID() throws RepositoryException {
+ // Return JCR UUID only if node is referenceable
+ try {
+ Property mixinsProp = getProperty("jcr:mixinTypes");
+ if (mixinsProp != null) {
+ for (Value value : mixinsProp.getValues()) {
+ if ("mix:referenceable".equals(value.getString())) return
getProperty("jcr:uuid").getString();
+ }
+ }
+ } catch (PathNotFoundException error) {
+ throw new UnsupportedRepositoryOperationException(error);
+ }
+ throw new UnsupportedRepositoryOperationException();
}
/**
* {@inheritDoc}
*
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#checkout()
+ * @return <code>true</code>
+ * @see javax.jcr.Item#isNode()
*/
- public final void checkout() {
- throw new UnsupportedOperationException();
+ public final boolean isNode() {
+ return true;
}
/**
* {@inheritDoc}
*
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#doneMerge(javax.jcr.version.Version)
+ * @return <code>false</code>
+ * @see javax.jcr.Node#isNodeType(java.lang.String)
*/
- public final void doneMerge( Version version ) {
- throw new UnsupportedOperationException();
- }
+ public boolean isNodeType( String nodeTypeName ) throws RepositoryException {
+ NodeType nodeType = getPrimaryNodeType();
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#getBaseVersion()
- */
- public final Version getBaseVersion() throws UnsupportedRepositoryOperationException
{
- throw new UnsupportedRepositoryOperationException();
- }
+ if (nodeType.isNodeType(nodeTypeName)) {
+ return true;
+ }
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#getCorrespondingNodePath(java.lang.String)
- */
- public final String getCorrespondingNodePath( String workspaceName ) {
- throw new UnsupportedOperationException();
+ NodeType[] mixinNodeTypes = getMixinNodeTypes();
+ for (int i = 0; i < mixinNodeTypes.length; i++) {
+ if (mixinNodeTypes[i].isNodeType(nodeTypeName)) {
+ return true;
+ }
+ }
+
+ return false;
}
/**
* {@inheritDoc}
*
- * @throws UnsupportedOperationException always
* @see javax.jcr.Node#getDefinition()
*/
public NodeDefinition getDefinition() {
- throw new UnsupportedOperationException();
+ return null;
}
- final UUID getInternalUuid() {
- return uuid;
- }
-
/**
* {@inheritDoc}
*
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#getLock()
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#getPrimaryNodeType()
*/
- public final Lock getLock() throws UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
+ public NodeType getPrimaryNodeType() throws RepositoryException {
+ String nodeTypeName = getProperty(JcrLexicon.PRIMARY_TYPE).getString();
+ return session.getWorkspace().getNodeTypeManager().getNodeType(nodeTypeName);
}
/**
@@ -218,85 +196,36 @@
* @see javax.jcr.Node#getMixinNodeTypes()
*/
public NodeType[] getMixinNodeTypes() throws RepositoryException {
- PropertyIterator mixinProperties =
getProperties(JcrLexicon.MIXIN_TYPES.getString(session.getExecutionContext()
-
.getNamespaceRegistry()));
- List<NodeType> mixinNodeTypes = new
ArrayList<NodeType>((int)mixinProperties.getSize());
-
- while (mixinProperties.hasNext()) {
- Property property = mixinProperties.nextProperty();
-
- String nodeTypeName = property.getValue().getString();
- NodeType nodeType =
session.getWorkspace().getNodeTypeManager().getNodeType(nodeTypeName);
-
- mixinNodeTypes.add(nodeType);
+ NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
+ Property mixinTypesProperty = getProperty(JcrLexicon.MIXIN_TYPES);
+ if (mixinTypesProperty == null) return EMPTY_NODE_TYPES;
+ List<NodeType> mixinNodeTypes = new LinkedList<NodeType>();
+ for (Value value : mixinTypesProperty.getValues()) {
+ String nodeTypeName = value.getString();
+ NodeType nodeType = nodeTypeManager.getNodeType(nodeTypeName);
+ if (nodeType != null) mixinNodeTypes.add(nodeType);
}
-
return mixinNodeTypes.toArray(new NodeType[mixinNodeTypes.size()]);
}
/**
* {@inheritDoc}
*
- * @throws IllegalArgumentException if <code>relativePath</code> is empty
or <code>null</code>.
- * @see javax.jcr.Node#getNode(java.lang.String)
+ * @return <code>false</code>
+ * @see javax.jcr.Node#canAddMixin(java.lang.String)
*/
- public final Node getNode( String relativePath ) throws RepositoryException {
- CheckArg.isNotEmpty(relativePath, "relativePath");
- String path = getPath(getPath(), relativePath);
- Item item = getSession().getItem(path);
- if (item instanceof Node) {
- return (Node)item;
- }
- throw new PathNotFoundException();
+ public final boolean canAddMixin( String mixinName ) {
+ return false;
}
/**
* {@inheritDoc}
*
- * @see javax.jcr.Node#getNodes()
- */
- public final NodeIterator getNodes() {
- if (children == null) {
- return new JcrEmptyNodeIterator();
- }
- return new JcrChildNodeIterator(this,
this.session.getExecutionContext().getNamespaceRegistry(), children);
- }
-
- /**
- * {@inheritDoc}
- *
* @throws UnsupportedOperationException always
- * @see javax.jcr.Node#getNodes(java.lang.String)
+ * @see javax.jcr.Node#removeMixin(java.lang.String)
*/
- public NodeIterator getNodes( String namePattern ) throws RepositoryException {
- CheckArg.isNotNull(namePattern, "namePattern");
- namePattern = namePattern.trim();
- if (namePattern.length() == 0) return new JcrEmptyNodeIterator();
- if ("*".equals(namePattern)) return getNodes();
- List<Object> patterns = createPatternsFor(namePattern);
-
- // Implementing exact-matching only for now to prototype types as properties
- List<Path.Segment> matchingChildren = new
LinkedList<Path.Segment>();
- NamespaceRegistry registry = session.executionContext.getNamespaceRegistry();
- boolean foundMatch = false;
- for (Path.Segment child : children) {
- String childName = child.getName().getString(registry);
- for (Object patternOrMatch : patterns) {
- if (patternOrMatch instanceof Pattern) {
- Pattern pattern = (Pattern)patternOrMatch;
- if (pattern.matcher(childName).matches()) foundMatch = true;
- } else {
- String match = (String)patternOrMatch;
- if (childName.equals(match)) foundMatch = true;
- }
- if (foundMatch) {
- foundMatch = false;
- matchingChildren.add(child);
- break;
- }
- }
- }
- return new JcrChildNodeIterator(this,
this.session.executionContext.getNamespaceRegistry(), matchingChildren);
+ public final void removeMixin( String mixinName ) {
+ throw new UnsupportedOperationException();
}
/**
@@ -317,19 +246,45 @@
/**
* {@inheritDoc}
*
- * @throws UnsupportedOperationException always
- * @see javax.jcr.Node#getPrimaryNodeType()
+ * @throws IllegalArgumentException if <code>otherItem</code> is
<code>null</code>.
+ * @see javax.jcr.Item#isSame(javax.jcr.Item)
*/
- public NodeType getPrimaryNodeType() throws RepositoryException {
- String primaryTypeName =
JcrLexicon.PRIMARY_TYPE.getString(session.getExecutionContext().getNamespaceRegistry());
- Property primaryNodeTypeProperty = getProperty(primaryTypeName);
- Value nodeValue = primaryNodeTypeProperty.getValue();
+ @Override
+ public final boolean isSame( Item otherItem ) throws RepositoryException {
+ CheckArg.isNotNull(otherItem, "otherItem");
+ if (super.isSame(otherItem) && otherItem instanceof Node) {
+ if (otherItem instanceof AbstractJcrNode) {
+ return
internalUuid().equals(((AbstractJcrNode)otherItem).internalUuid());
+ }
+ // If not our implementation, let the other item figure out whether we are
the same.
+ return otherItem.isSame(this);
+ }
+ return false;
+ }
- ExecutionContext context = session.getExecutionContext();
- Name nodeValueAsName =
context.getValueFactories().getNameFactory().create(nodeValue.getString());
+ /**
+ * {@inheritDoc}
+ *
+ * @see javax.jcr.Node#hasProperties()
+ */
+ public final boolean hasProperties() {
+ assert properties != null;
+ return !properties.isEmpty();
+ }
- String nodeTypeName = nodeValueAsName.getString(context.getNamespaceRegistry());
- return session.getWorkspace().getNodeTypeManager().getNodeType(nodeTypeName);
+ /**
+ * {@inheritDoc}
+ *
+ * @throws IllegalArgumentException if <code>relativePath</code> is empty
or <code>null</code>.
+ * @see javax.jcr.Node#hasProperty(java.lang.String)
+ */
+ public final boolean hasProperty( String relativePath ) throws RepositoryException {
+ CheckArg.isNotEmpty(relativePath, "relativePath");
+ if (relativePath.indexOf('/') >= 0) {
+ return (getProperty(relativePath) != null);
+ }
+ assert properties != null;
+ return properties.containsKey(nameFrom(relativePath));
}
/**
@@ -338,7 +293,7 @@
* @see javax.jcr.Node#getProperties()
*/
public final PropertyIterator getProperties() {
- return new JcrPropertyIterator(properties);
+ return new JcrPropertyIterator(properties.values());
}
/**
@@ -350,84 +305,40 @@
CheckArg.isNotNull(namePattern, "namePattern");
namePattern = namePattern.trim();
if (namePattern.length() == 0) return new JcrEmptyPropertyIterator();
- if ("*".equals(namePattern)) return new
JcrPropertyIterator(properties);
+ if ("*".equals(namePattern)) return new
JcrPropertyIterator(properties.values());
List<Object> patterns = createPatternsFor(namePattern);
// Implementing exact-matching only for now to prototype types as properties
Set<Property> matchingProps = new HashSet<Property>();
- for (Object patternOrMatch : patterns) {
- if (patternOrMatch instanceof Pattern) {
- Pattern pattern = (Pattern)patternOrMatch;
- for (Property prop : properties) {
- String propName = prop.getName();
- if (pattern.matcher(propName).matches()) matchingProps.add(prop);
+ boolean foundMatch = false;
+ for (Property property : properties.values()) {
+ String propName = property.getName();
+ for (Object patternOrMatch : patterns) {
+ if (patternOrMatch instanceof Pattern) {
+ Pattern pattern = (Pattern)patternOrMatch;
+ if (pattern.matcher(propName).matches()) foundMatch = true;
+ } else {
+ String match = (String)patternOrMatch;
+ if (propName.equals(match)) foundMatch = true;
}
- } else {
- String match = (String)patternOrMatch;
- for (Property prop : properties) {
- String propName = prop.getName();
- if (propName.equals(match)) matchingProps.add(prop);
+ if (foundMatch) {
+ foundMatch = false;
+ matchingProps.add(property);
+ break;
}
}
}
return new JcrPropertyIterator(matchingProps);
}
- protected static List<Object> createPatternsFor( String namePattern ) throws
RepositoryException {
- List<Object> patterns = new LinkedList<Object>();
- for (String stringPattern : namePattern.split("[|]")) {
- stringPattern = stringPattern.trim();
- int length = stringPattern.length();
- if (length == 0) continue;
- if (stringPattern.indexOf("*") == -1) {
- // Doesn't use wildcard, so use String not Pattern
- patterns.add(stringPattern);
- } else {
- // We need to escape the regular expression characters ...
- StringBuilder sb = new StringBuilder(length);
- for (int i = 0; i != length; i++) {
- char c = stringPattern.charAt(i);
- switch (c) {
- // Per the spec, the the following characters are not allowed in
patterns:
- case '/':
- case '[':
- case ']':
- case '\'':
- case '"':
- case '|':
- case '\t':
- case '\n':
- case '\r':
- String msg = JcrI18n.invalidNamePattern.text(c,
namePattern);
- throw new RepositoryException(msg);
- // The following characters must be escaped when used in
regular expressions ...
- case '?':
- case '(':
- case ')':
- case '$':
- case '^':
- case '.':
- case '{':
- case '}':
- case '\\':
- sb.append("\\");
- sb.append(c);
- break;
- case '*':
- // replace with the regular expression wildcard
- sb.append(".*");
- break;
- default:
- sb.append(c);
- break;
- }
- }
- String escapedString = sb.toString();
- Pattern pattern = Pattern.compile(escapedString);
- patterns.add(pattern);
- }
- }
- return patterns;
+ /**
+ * A non-standard method to obtain a property given the {@link Name DNA Name} object.
This method is faster
+ *
+ * @param propertyName the property name
+ * @return the JCR property with the supplied name, or null if the property
doesn't exist
+ */
+ public final Property getProperty( Name propertyName ) {
+ return properties.get(propertyName);
}
/**
@@ -450,9 +361,8 @@
return ((Node)item).getParent().getProperty(item.getName());
}
assert properties != null;
- for (Property property : properties) {
- if (relativePath.equals(property.getName())) return property;
- }
+ Property property = properties.get(nameFrom(relativePath));
+ if (property != null) return property;
throw new PathNotFoundException();
}
@@ -465,7 +375,7 @@
public final PropertyIterator getReferences() throws RepositoryException {
// Iterate through the properties to see which ones have a REFERENCE type ...
Set<Property> references = new HashSet<Property>();
- for (Property property : properties) {
+ for (Property property : properties.values()) {
if (property.getType() == PropertyType.REFERENCE) references.add(property);
}
if (references.isEmpty()) return new JcrEmptyPropertyIterator();
@@ -475,45 +385,6 @@
/**
* {@inheritDoc}
*
- * @see javax.jcr.Item#getSession()
- */
- public final Session getSession() {
- return session;
- }
-
- /**
- * {@inheritDoc}
- *
- * @see javax.jcr.Node#getUUID()
- */
- public final String getUUID() throws RepositoryException {
- // Return JCR UUID only if node is referenceable
- try {
- Property mixinsProp = getProperty("jcr:mixinTypes");
- if (mixinsProp != null) {
- for (Value value : mixinsProp.getValues()) {
- if ("mix:referenceable".equals(value.getString())) return
getProperty("jcr:uuid").getString();
- }
- }
- } catch (PathNotFoundException error) {
- throw new UnsupportedRepositoryOperationException(error);
- }
- throw new UnsupportedRepositoryOperationException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#getVersionHistory()
- */
- public final VersionHistory getVersionHistory() throws
UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
- }
-
- /**
- * {@inheritDoc}
- *
* @throws IllegalArgumentException if <code>relativePath</code> is empty
or <code>null</code>.
* @see javax.jcr.Node#hasNode(java.lang.String)
*/
@@ -550,221 +421,123 @@
/**
* {@inheritDoc}
*
- * @see javax.jcr.Node#hasProperties()
- */
- public final boolean hasProperties() {
- assert properties != null;
- return !properties.isEmpty();
- }
-
- /**
- * {@inheritDoc}
- *
* @throws IllegalArgumentException if <code>relativePath</code> is empty
or <code>null</code>.
- * @see javax.jcr.Node#hasProperty(java.lang.String)
+ * @see javax.jcr.Node#getNode(java.lang.String)
*/
- public final boolean hasProperty( String relativePath ) throws RepositoryException {
+ public final Node getNode( String relativePath ) throws RepositoryException {
CheckArg.isNotEmpty(relativePath, "relativePath");
- if (relativePath.indexOf('/') >= 0) {
- return (getProperty(relativePath) != null);
+ String path = getPath(getPath(), relativePath);
+ Item item = getSession().getItem(path);
+ if (item instanceof Node) {
+ return (Node)item;
}
- assert properties != null;
- for (Property property : properties) {
- if (relativePath.equals(property.getName())) {
- return true;
- }
- }
- return false;
+ throw new PathNotFoundException();
}
/**
* {@inheritDoc}
*
- * @return <code>false</code>
- * @see javax.jcr.Node#holdsLock()
+ * @see javax.jcr.Node#getNodes()
*/
- public final boolean holdsLock() {
- return false;
+ public final NodeIterator getNodes() {
+ if (children == null) {
+ return new JcrEmptyNodeIterator();
+ }
+ return new JcrChildNodeIterator(this,
this.session.getExecutionContext().getNamespaceRegistry(), children);
}
/**
* {@inheritDoc}
*
- * @return <code>false</code>
- * @see javax.jcr.Node#isCheckedOut()
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#getNodes(java.lang.String)
*/
- public final boolean isCheckedOut() {
- return false;
- }
+ public NodeIterator getNodes( String namePattern ) throws RepositoryException {
+ CheckArg.isNotNull(namePattern, "namePattern");
+ namePattern = namePattern.trim();
+ if (namePattern.length() == 0) return new JcrEmptyNodeIterator();
+ if ("*".equals(namePattern)) return getNodes();
+ List<Object> patterns = createPatternsFor(namePattern);
- /**
- * {@inheritDoc}
- *
- * @return <code>false</code>
- * @see javax.jcr.Node#isLocked()
- */
- public final boolean isLocked() {
- return false;
- }
-
- /**
- * {@inheritDoc}
- *
- * @return <code>true</code>
- * @see javax.jcr.Item#isNode()
- */
- public final boolean isNode() {
- return true;
- }
-
- /**
- * {@inheritDoc}
- *
- * @return <code>false</code>
- * @see javax.jcr.Node#isNodeType(java.lang.String)
- */
- public boolean isNodeType( String nodeTypeName ) throws RepositoryException {
- NodeType nodeType = getPrimaryNodeType();
-
- if (nodeType.isNodeType(nodeTypeName)) {
- return true;
- }
-
- NodeType[] mixinNodeTypes = getMixinNodeTypes();
- for (int i = 0; i < mixinNodeTypes.length; i++) {
- if (mixinNodeTypes[i].isNodeType(nodeTypeName)) {
- return true;
+ // Implementing exact-matching only for now to prototype types as properties
+ List<Path.Segment> matchingChildren = new
LinkedList<Path.Segment>();
+ NamespaceRegistry registry = session.executionContext.getNamespaceRegistry();
+ boolean foundMatch = false;
+ for (Path.Segment child : children) {
+ String childName = child.getName().getString(registry);
+ for (Object patternOrMatch : patterns) {
+ if (patternOrMatch instanceof Pattern) {
+ Pattern pattern = (Pattern)patternOrMatch;
+ if (pattern.matcher(childName).matches()) foundMatch = true;
+ } else {
+ String match = (String)patternOrMatch;
+ if (childName.equals(match)) foundMatch = true;
+ }
+ if (foundMatch) {
+ foundMatch = false;
+ matchingChildren.add(child);
+ break;
+ }
}
}
-
- return false;
+ return new JcrChildNodeIterator(this,
this.session.executionContext.getNamespaceRegistry(), matchingChildren);
}
/**
* {@inheritDoc}
*
- * @throws IllegalArgumentException if <code>otherItem</code> is
<code>null</code>.
- * @see javax.jcr.Item#isSame(javax.jcr.Item)
+ * @throws IllegalArgumentException if <code>visitor</code> is
<code>null</code>.
+ * @see javax.jcr.Item#accept(javax.jcr.ItemVisitor)
*/
- @Override
- public final boolean isSame( Item otherItem ) throws RepositoryException {
- CheckArg.isNotNull(otherItem, "otherItem");
- if (super.isSame(otherItem) && otherItem instanceof Node) {
- if (otherItem instanceof AbstractJcrNode) {
- return
getInternalUuid().equals(((AbstractJcrNode)otherItem).getInternalUuid());
- }
- // If not our implementation, let the other item figure out whether we are
the same.
- return otherItem.isSame(this);
- }
- return false;
+ public final void accept( ItemVisitor visitor ) throws RepositoryException {
+ CheckArg.isNotNull(visitor, "visitor");
+ visitor.visit(this);
}
/**
* {@inheritDoc}
*
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#lock(boolean, boolean)
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#addMixin(java.lang.String)
*/
- public final Lock lock( boolean isDeep,
- boolean isSessionScoped ) throws
UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
+ public final void addMixin( String mixinName ) {
+ throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*
* @throws UnsupportedOperationException always
- * @see javax.jcr.Node#merge(java.lang.String, boolean)
+ * @see javax.jcr.Node#addNode(java.lang.String)
*/
- public final NodeIterator merge( String srcWorkspace,
- boolean bestEffort ) {
+ public final Node addNode( String relPath ) {
throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#orderBefore(java.lang.String, java.lang.String)
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#addNode(java.lang.String, java.lang.String)
*/
- public final void orderBefore( String srcChildRelPath,
- String destChildRelPath ) throws
UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
+ public final Node addNode( String relPath,
+ String primaryNodeTypeName ) {
+ throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*
* @throws UnsupportedOperationException always
- * @see javax.jcr.Node#removeMixin(java.lang.String)
+ * @see javax.jcr.Node#update(java.lang.String)
*/
- public final void removeMixin( String mixinName ) {
+ public final void update( String srcWorkspaceName ) {
throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#restore(java.lang.String, boolean)
- */
- public final void restore( String versionName,
- boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#restore(javax.jcr.version.Version, boolean)
- */
- public final void restore( Version version,
- boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#restore(javax.jcr.version.Version, java.lang.String, boolean)
- */
- public final void restore( Version version,
- String relPath,
- boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
- }
-
- /**
- * {@inheritDoc}
- *
- * @throws UnsupportedRepositoryOperationException always
- * @see javax.jcr.Node#restoreByLabel(java.lang.String, boolean)
- */
- public final void restoreByLabel( String versionLabel,
- boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
- throw new UnsupportedRepositoryOperationException();
- }
-
- final void setChildren( List<Segment> children ) {
- assert children != null;
- this.children = children;
- }
-
- final void setInternalUuid( UUID uuid ) {
- assert uuid != null;
- this.uuid = uuid;
- }
-
- final void setProperties( Set<Property> properties ) {
- assert properties != null;
- this.properties = properties;
- }
-
- /**
- * {@inheritDoc}
- *
* @throws UnsupportedOperationException always
* @see javax.jcr.Node#setProperty(java.lang.String, boolean)
*/
@@ -923,7 +696,68 @@
/**
* {@inheritDoc}
*
+ * @return <code>false</code>
+ * @see javax.jcr.Node#isCheckedOut()
+ */
+ public final boolean isCheckedOut() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#checkin()
+ */
+ public final Version checkin() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#checkout()
+ */
+ public final void checkout() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return <code>false</code>
+ * @see javax.jcr.Node#holdsLock()
+ */
+ public final boolean holdsLock() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return <code>false</code>
+ * @see javax.jcr.Node#isLocked()
+ */
+ public final boolean isLocked() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#lock(boolean, boolean)
+ */
+ public final Lock lock( boolean isDeep,
+ boolean isSessionScoped ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
* @see javax.jcr.Node#unlock()
*/
public final void unlock() throws UnsupportedRepositoryOperationException {
@@ -933,10 +767,184 @@
/**
* {@inheritDoc}
*
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#getLock()
+ */
+ public final Lock getLock() throws UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
* @throws UnsupportedOperationException always
- * @see javax.jcr.Node#update(java.lang.String)
+ * @see javax.jcr.Node#merge(java.lang.String, boolean)
*/
- public final void update( String srcWorkspaceName ) {
+ public final NodeIterator merge( String srcWorkspace,
+ boolean bestEffort ) {
throw new UnsupportedOperationException();
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#cancelMerge(javax.jcr.version.Version)
+ */
+ public final void cancelMerge( Version version ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#doneMerge(javax.jcr.version.Version)
+ */
+ public final void doneMerge( Version version ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedOperationException always
+ * @see javax.jcr.Node#getCorrespondingNodePath(java.lang.String)
+ */
+ public final String getCorrespondingNodePath( String workspaceName ) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#getVersionHistory()
+ */
+ public final VersionHistory getVersionHistory() throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#getBaseVersion()
+ */
+ public final Version getBaseVersion() throws UnsupportedRepositoryOperationException
{
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#restore(java.lang.String, boolean)
+ */
+ public final void restore( String versionName,
+ boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#restore(javax.jcr.version.Version, boolean)
+ */
+ public final void restore( Version version,
+ boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#restore(javax.jcr.version.Version, java.lang.String, boolean)
+ */
+ public final void restore( Version version,
+ String relPath,
+ boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#restoreByLabel(java.lang.String, boolean)
+ */
+ public final void restoreByLabel( String versionLabel,
+ boolean removeExisting ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @throws UnsupportedRepositoryOperationException always
+ * @see javax.jcr.Node#orderBefore(java.lang.String, java.lang.String)
+ */
+ public final void orderBefore( String srcChildRelPath,
+ String destChildRelPath ) throws
UnsupportedRepositoryOperationException {
+ throw new UnsupportedRepositoryOperationException();
+ }
+
+ protected static List<Object> createPatternsFor( String namePattern ) throws
RepositoryException {
+ List<Object> patterns = new LinkedList<Object>();
+ for (String stringPattern : namePattern.split("[|]")) {
+ stringPattern = stringPattern.trim();
+ int length = stringPattern.length();
+ if (length == 0) continue;
+ if (stringPattern.indexOf("*") == -1) {
+ // Doesn't use wildcard, so use String not Pattern
+ patterns.add(stringPattern);
+ } else {
+ // We need to escape the regular expression characters ...
+ StringBuilder sb = new StringBuilder(length);
+ for (int i = 0; i != length; i++) {
+ char c = stringPattern.charAt(i);
+ switch (c) {
+ // Per the spec, the the following characters are not allowed in
patterns:
+ case '/':
+ case '[':
+ case ']':
+ case '\'':
+ case '"':
+ case '|':
+ case '\t':
+ case '\n':
+ case '\r':
+ String msg = JcrI18n.invalidNamePattern.text(c,
namePattern);
+ throw new RepositoryException(msg);
+ // The following characters must be escaped when used in
regular expressions ...
+ case '?':
+ case '(':
+ case ')':
+ case '$':
+ case '^':
+ case '.':
+ case '{':
+ case '}':
+ case '\\':
+ sb.append("\\");
+ sb.append(c);
+ break;
+ case '*':
+ // replace with the regular expression wildcard
+ sb.append(".*");
+ break;
+ default:
+ sb.append(c);
+ break;
+ }
+ }
+ String escapedString = sb.toString();
+ Pattern pattern = Pattern.compile(escapedString);
+ patterns.add(pattern);
+ }
+ }
+ return patterns;
+ }
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyIterator.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyIterator.java 2009-03-05
14:55:09 UTC (rev 757)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrPropertyIterator.java 2009-03-05
18:02:40 UTC (rev 758)
@@ -23,8 +23,8 @@
*/
package org.jboss.dna.jcr;
+import java.util.Collection;
import java.util.Iterator;
-import java.util.Set;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
import net.jcip.annotations.Immutable;
@@ -40,7 +40,7 @@
private int ndx;
private int size;
- JcrPropertyIterator( Set<Property> properties ) {
+ JcrPropertyIterator( Collection<Property> properties ) {
assert properties != null;
iterator = properties.iterator();
size = properties.size();
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-03-05 14:55:09
UTC (rev 757)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-03-05 18:02:40
UTC (rev 758)
@@ -121,7 +121,7 @@
}
// Initialize required JCR descriptors.
modifiableDescriptors.put(Repository.LEVEL_1_SUPPORTED, "true");
- modifiableDescriptors.put(Repository.LEVEL_2_SUPPORTED, "false");
+ modifiableDescriptors.put(Repository.LEVEL_2_SUPPORTED, "true");
modifiableDescriptors.put(Repository.OPTION_LOCKING_SUPPORTED,
"false");
modifiableDescriptors.put(Repository.OPTION_OBSERVATION_SUPPORTED,
"false");
modifiableDescriptors.put(Repository.OPTION_QUERY_SQL_SUPPORTED,
"false");
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-03-05 14:55:09 UTC
(rev 757)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-03-05 18:02:40 UTC
(rev 758)
@@ -30,7 +30,6 @@
import java.util.Calendar;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -404,8 +403,8 @@
// If not create a new one & populate it
JcrNode node;
Path parentPath = path.getParent();
- if (parentPath.isRoot()) node = new JcrNode(this,
((JcrRootNode)getRootNode()).getInternalUuid(), path.getLastSegment());
- else node = new JcrNode(this, ((JcrNode)getNode(parentPath)).getInternalUuid(),
path.getLastSegment());
+ if (parentPath.isRoot()) node = new JcrNode(this,
((JcrRootNode)getRootNode()).internalUuid(), path.getLastSegment());
+ else node = new JcrNode(this, ((JcrNode)getNode(parentPath)).internalUuid(),
path.getLastSegment());
populateNode(node, graphNode);
return node;
}
@@ -747,13 +746,13 @@
}
// Now create the JCR property object wrapper around the "jcr:uuid"
property ...
- Set<Property> properties = new HashSet<Property>();
+ Map<Name, Property> properties = new HashMap<Name, Property>();
if (uuid == null) uuid = UUID.randomUUID();
if (referenceable) {
if (uuidProperty == null) uuidProperty =
executionContext.getPropertyFactory().create(JcrLexicon.UUID, uuid);
PropertyDefinition propertyDefinition =
propertyDefinitionsByPropertyName.get(JcrLexicon.UUID);
- properties.add(new JcrSingleValueProperty(node, executionContext,
propertyDefinition, PropertyType.STRING,
- uuidProperty));
+ properties.put(JcrLexicon.UUID, new JcrSingleValueProperty(node,
executionContext, propertyDefinition,
+
PropertyType.STRING, uuidProperty));
}
// Now create the JCR property object wrappers around the other properties ...
@@ -814,16 +813,16 @@
}
// Figure out the property type ...
- int propertyType = propertyDefinition.getRequiredType();
- if (propertyType == PropertyType.UNDEFINED) {
- propertyType = jcrPropertyTypeFor(dnaProp);
+ int type = propertyDefinition.getRequiredType();
+ if (type == PropertyType.UNDEFINED) {
+ type = jcrPropertyTypeFor(dnaProp);
}
// Create the appropriate JCR property wrapper ...
if (isMultiple) {
- properties.add(new JcrMultiValueProperty(node, executionContext,
propertyDefinition, propertyType, dnaProp));
+ properties.put(name, new JcrMultiValueProperty(node, executionContext,
propertyDefinition, type, dnaProp));
} else {
- properties.add(new JcrSingleValueProperty(node, executionContext,
propertyDefinition, propertyType, dnaProp));
+ properties.put(name, new JcrSingleValueProperty(node, executionContext,
propertyDefinition, type, dnaProp));
}
}
@@ -844,11 +843,9 @@
/**
* {@inheritDoc}
*
- * @throws UnsupportedOperationException always
* @see javax.jcr.Session#refresh(boolean)
*/
public void refresh( boolean keepChanges ) {
- throw new UnsupportedOperationException();
}
/**
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java 2009-03-05
14:55:09 UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/AbstractJcrNodeTest.java 2009-03-05
18:02:40 UTC (rev 758)
@@ -30,9 +30,9 @@
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Calendar;
-import java.util.HashSet;
+import java.util.HashMap;
import java.util.List;
-import java.util.Set;
+import java.util.Map;
import java.util.UUID;
import javax.jcr.Item;
import javax.jcr.ItemNotFoundException;
@@ -48,6 +48,7 @@
import javax.jcr.Workspace;
import javax.jcr.version.Version;
import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path.Segment;
import org.junit.Before;
import org.junit.Test;
@@ -117,19 +118,24 @@
@Mock
private Repository repository;
private List<Segment> children;
- private Set<Property> properties;
+ private Map<Name, Property> properties;
+ private ExecutionContext context;
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
- ExecutionContext context = new ExecutionContext();
+ context = new ExecutionContext();
stub(session.getExecutionContext()).toReturn(context);
children = new ArrayList<Segment>();
- properties = new HashSet<Property>();
+ properties = new HashMap<Name, Property>();
node = new MockAbstractJcrNode(session, "node", null);
node.setProperties(properties);
}
+ protected Name name( String name ) {
+ return context.getValueFactories().getNameFactory().create(name);
+ }
+
@Test
public void shouldAllowVisitation() throws Exception {
ItemVisitor visitor = Mockito.mock(ItemVisitor.class);
@@ -161,14 +167,14 @@
public void shouldProvideInternalUuid() throws Exception {
UUID uuid = UUID.randomUUID();
node.setInternalUuid(uuid);
- assertThat(node.getInternalUuid(), is(uuid));
+ assertThat(node.internalUuid(), is(uuid));
}
@Test
public void shouldProvideNamedProperty() throws Exception {
Property property = Mockito.mock(Property.class);
stub(property.getName()).toReturn("test");
- properties.add(property);
+ properties.put(name(property.getName()), property);
assertThat(node.getProperty("test"), is(property));
}
@@ -262,7 +268,7 @@
Property property = Mockito.mock(Property.class);
stub(property.getName()).toReturn("jcr:primaryItemName");
stub(property.getString()).toReturn("primaryItem");
- properties.add(property);
+ properties.put(name(property.getName()), property);
Item primaryItem = Mockito.mock(Item.class);
stub(session.getItem("/node/primaryItem")).toReturn(primaryItem);
assertThat(node.getPrimaryItem(), is(primaryItem));
@@ -277,29 +283,29 @@
public void shouldProvideProperty() throws Exception {
Property prop1 = Mockito.mock(Property.class);
stub(prop1.getName()).toReturn("prop1");
- properties.add(prop1);
+ properties.put(name(prop1.getName()), prop1);
assertThat(node.getProperty("prop1"), is(prop1));
MockAbstractJcrNode child = createChild(session, "child", 1, children,
node);
- Set<Property> properties = new HashSet<Property>();
+ Map<Name, Property> properties = new HashMap<Name, Property>();
child.setProperties(properties);
Property prop2 = Mockito.mock(Property.class);
stub(prop2.getName()).toReturn("prop2");
stub(session.getItem("/node/child/prop2")).toReturn(prop2);
- properties.add(prop2);
+ properties.put(name(prop2.getName()), prop2);
MockAbstractJcrNode prop3Node = createChild(session, "prop3", 1,
children, child);
node.setChildren(children);
assertThat(node.getProperty("child/prop2"), is(prop2));
// Ensure we return a property even when a child exists with the same name
Property prop3 = Mockito.mock(Property.class);
stub(prop3.getName()).toReturn("prop3");
- properties.add(prop3);
+ properties.put(name(prop3.getName()), prop3);
stub(session.getItem("/node/child/prop3")).toReturn(prop3Node);
assertThat(node.getProperty("child/prop3"), is(prop3));
}
@Test( expected = IllegalArgumentException.class )
public void shouldNotAllowGetPropertyWithNullPath() throws Exception {
- node.getProperty(null);
+ node.getProperty((String)null);
}
@Test( expected = IllegalArgumentException.class )
@@ -315,7 +321,7 @@
@Test( expected = PathNotFoundException.class )
public void shouldNotProvideDescendentPropertyIfNotAvailable() throws Exception {
MockAbstractJcrNode child = createChild(session, "child", 1, children,
node);
- Set<Property> properties = new HashSet<Property>();
+ Map<Name, Property> properties = new HashMap<Name, Property>();
child.setProperties(properties);
MockAbstractJcrNode propNode = createChild(session, "prop", 1,
children, child);
node.setChildren(children);
@@ -343,11 +349,11 @@
Value value = Mockito.mock(Value.class);
stub(value.getString()).toReturn("mix:referenceable");
stub(mixinProp.getValues()).toReturn(new Value[] {value});
- properties.add(mixinProp);
+ properties.put(name(mixinProp.getName()), mixinProp);
Property uuidProp = Mockito.mock(Property.class);
stub(uuidProp.getName()).toReturn("jcr:uuid");
stub(uuidProp.getString()).toReturn(uuid);
- properties.add(uuidProp);
+ properties.put(name(uuidProp.getName()), uuidProp);
assertThat(node.getUUID(), is(uuid));
}
@@ -358,11 +364,11 @@
stub(mixinProp.getName()).toReturn("jcr:mixinTypes");
Value value = Mockito.mock(Value.class);
stub(mixinProp.getValues()).toReturn(new Value[] {value});
- properties.add(mixinProp);
+ properties.put(name(mixinProp.getName()), mixinProp);
Property uuidProp = Mockito.mock(Property.class);
stub(uuidProp.getName()).toReturn("jcr:uuid");
stub(uuidProp.getString()).toReturn(uuid);
- properties.add(uuidProp);
+ properties.put(name(uuidProp.getName()), uuidProp);
node.getUUID();
}
@@ -372,7 +378,7 @@
Property uuidProp = Mockito.mock(Property.class);
stub(uuidProp.getName()).toReturn("jcr:uuid");
stub(uuidProp.getString()).toReturn(uuid);
- properties.add(uuidProp);
+ properties.put(name(uuidProp.getName()), uuidProp);
node.getUUID();
}
@@ -386,7 +392,7 @@
assertThat(node.hasNode("{}child"), is(false));
Property prop = Mockito.mock(Property.class);
stub(prop.getName()).toReturn("prop");
- properties.add(prop);
+ properties.put(name(prop.getName()), prop);
assertThat(node.hasNode("prop"), is(false));
Node child = createChild(session, "child", 1, children, node);
Node child2 = createChild(session, "child2", 1, children, child);
@@ -417,7 +423,7 @@
@Test
public void shouldProvideHasProperties() throws Exception {
assertThat(node.hasProperties(), is(false));
- properties.add(Mockito.mock(Property.class));
+ properties.put(name("something"), Mockito.mock(Property.class));
assertThat(node.hasProperties(), is(true));
}
@@ -429,13 +435,13 @@
assertThat(node.hasProperty("child"), is(false));
Property prop = Mockito.mock(Property.class);
stub(prop.getName()).toReturn("prop");
- properties.add(prop);
+ properties.put(name(prop.getName()), prop);
assertThat(node.hasProperty("prop"), is(true));
- Set<Property> properties = new HashSet<Property>();
+ Map<Name, Property> properties = new HashMap<Name, Property>();
child.setProperties(properties);
Property prop2 = Mockito.mock(Property.class);
stub(prop2.getName()).toReturn("prop2");
- properties.add(prop2);
+ properties.put(name(prop2.getName()), prop2);
stub(session.getItem("/node/child/prop2")).toReturn(prop2);
assertThat(node.hasProperty("child/prop2"), is(true));
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java 2009-03-05 14:55:09 UTC
(rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrNodeTest.java 2009-03-05 18:02:40 UTC
(rev 758)
@@ -28,7 +28,7 @@
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.stub;
import java.util.ArrayList;
-import java.util.HashSet;
+import java.util.HashMap;
import java.util.UUID;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
@@ -67,7 +67,7 @@
ExecutionContext context = Mockito.mock(ExecutionContext.class);
stub(session.getExecutionContext()).toReturn(context);
stub(session.getNode(uuid)).toReturn(root);
- node.setProperties(new HashSet<Property>());
+ node.setProperties(new HashMap<Name, Property>());
node.setChildren(new ArrayList<Segment>());
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyIteratorTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyIteratorTest.java 2009-03-05
14:55:09 UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrPropertyIteratorTest.java 2009-03-05
18:02:40 UTC (rev 758)
@@ -26,10 +26,12 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
import javax.jcr.Property;
import javax.jcr.PropertyIterator;
+import org.jboss.dna.graph.ExecutionContext;
+import org.jboss.dna.graph.property.Name;
import org.jboss.dna.jcr.AbstractJcrNodeTest.MockAbstractJcrNode;
import org.junit.Before;
import org.junit.Test;
@@ -45,22 +47,28 @@
private AbstractJcrNode node;
@Mock
private JcrSession session;
- private Set<Property> properties;
+ private Map<Name, Property> properties;
+ private ExecutionContext context;
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
- properties = new HashSet<Property>();
+ context = new ExecutionContext();
+ properties = new HashMap<Name, Property>();
node = new MockAbstractJcrNode(session, "node", null);
node.setProperties(properties);
}
+ protected Name name( String name ) {
+ return context.getValueFactories().getNameFactory().create(name);
+ }
+
@Test
public void shouldProvidePropertyIterator() throws Exception {
- properties.add(Mockito.mock(Property.class));
- properties.add(Mockito.mock(Property.class));
- properties.add(Mockito.mock(Property.class));
- properties.add(Mockito.mock(Property.class));
+ properties.put(name("prop1"), Mockito.mock(Property.class));
+ properties.put(name("prop2"), Mockito.mock(Property.class));
+ properties.put(name("prop3"), Mockito.mock(Property.class));
+ properties.put(name("prop4"), Mockito.mock(Property.class));
PropertyIterator iter = node.getProperties();
assertThat(iter, notNullValue());
assertThat(iter.getSize(), is(4L));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-03-05
14:55:09 UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRepositoryTest.java 2009-03-05
18:02:40 UTC (rev 758)
@@ -253,7 +253,7 @@
private void testDescriptorValues( Repository repository ) {
assertThat(repository.getDescriptor(Repository.LEVEL_1_SUPPORTED),
is("true"));
- assertThat(repository.getDescriptor(Repository.LEVEL_2_SUPPORTED),
is("false"));
+ assertThat(repository.getDescriptor(Repository.LEVEL_2_SUPPORTED),
is("true"));
assertThat(repository.getDescriptor(Repository.OPTION_LOCKING_SUPPORTED),
is("false"));
assertThat(repository.getDescriptor(Repository.OPTION_OBSERVATION_SUPPORTED),
is("false"));
assertThat(repository.getDescriptor(Repository.OPTION_QUERY_SQL_SUPPORTED),
is("false"));
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java 2009-03-05 14:55:09
UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrRootNodeTest.java 2009-03-05 18:02:40
UTC (rev 758)
@@ -26,10 +26,11 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
import static org.junit.Assert.assertThat;
-import java.util.HashSet;
-import java.util.Set;
+import java.util.HashMap;
+import java.util.Map;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Property;
+import org.jboss.dna.graph.property.Name;
import org.junit.Before;
import org.junit.Test;
import org.mockito.MockitoAnnotations;
@@ -43,12 +44,12 @@
private JcrRootNode root;
@Mock
private JcrSession session;
- private Set<Property> properties;
+ private Map<Name, Property> properties;
@Before
public void before() throws Exception {
MockitoAnnotations.initMocks(this);
- properties = new HashSet<Property>();
+ properties = new HashMap<Name, Property>();
root = new JcrRootNode(session);
root.setProperties(properties);
}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-03-05 14:55:09
UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrSessionTest.java 2009-03-05 18:02:40
UTC (rev 758)
@@ -285,7 +285,7 @@
assertThat(nodesByUuid.isEmpty(), is(true));
Node root = session.getRootNode();
assertThat(root, notNullValue());
- UUID uuid = ((JcrRootNode)root).getInternalUuid();
+ UUID uuid = ((JcrRootNode)root).internalUuid();
assertThat(uuid, notNullValue());
assertThat(nodesByUuid.get(uuid), is(root));
}
Deleted: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelOneTestSuite.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelOneTestSuite.java 2009-03-05
14:55:09 UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelOneTestSuite.java 2009-03-05
18:02:40 UTC (rev 758)
@@ -1,95 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * Unless otherwise indicated, all code in JBoss DNA is licensed
- * to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test suite that includes the Level 1 JCR TCK API tests from the Jackrabbit project.
- *
- * @see JcrTckLevelTwoTestSuite
- * @see JcrTckOptionalTestSuite
- * @see JcrTckTest
- */
-public class JcrTckLevelOneTestSuite extends TestCase {
-
- /**
- * Returns a <code>Test</code> suite that executes all tests inside this
package.
- *
- * @return a <code>Test</code> suite that executes all tests inside this
package.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite("JCR 1.0 Level 1 API tests");
-
- // We currently don't pass the tests in those suites that are commented out
- // See
https://jira.jboss.org/jira/browse/DNA-285
-
- suite.addTestSuite(org.apache.jackrabbit.test.api.RootNodeTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.NodeReadMethodsTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.PropertyTypeTest.class);
-
suite.addTestSuite(org.apache.jackrabbit.test.api.NodeDiscoveringNodeTypesTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.BinaryPropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.BooleanPropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.DatePropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.DoublePropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.LongPropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.NamePropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.PathPropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.ReferencePropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.StringPropertyTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.UndefinedPropertyTest.class);
-
suite.addTestSuite(org.apache.jackrabbit.test.api.NamespaceRegistryReadMethodsTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.NamespaceRemappingTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.NodeIteratorTest.class);
-
suite.addTestSuite(org.apache.jackrabbit.test.api.PropertyReadMethodsTest.class);
-
suite.addTestSuite(org.apache.jackrabbit.test.api.RepositoryDescriptorTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.SessionReadMethodsTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.WorkspaceReadMethodsTest.class);
-
suite.addTestSuite(org.apache.jackrabbit.test.api.ReferenceableRootNodesTest.class);
- // suite.addTestSuite(org.apache.jackrabbit.test.api.ExportSysViewTest.class);
- // suite.addTestSuite(org.apache.jackrabbit.test.api.ExportDocViewTest.class);
- suite.addTestSuite(org.apache.jackrabbit.test.api.RepositoryLoginTest.class);
-
- // These might not all be level one tests
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.XPathPosIndexTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.XPathDocOrderTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.XPathOrderByTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.XPathJcrPathTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.DerefQueryLevel1Test.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.GetLanguageTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.GetPersistentQueryPathLevel1Test.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.GetStatementTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.GetSupportedQueryLanguagesTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.GetPropertyNamesTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.PredicatesTest.class);
- //
suite.addTestSuite(org.apache.jackrabbit.test.api.query.SimpleSelectionTest.class);
-
- // The tests in this suite are level one
- // suite.addTest(org.apache.jackrabbit.test.api.nodetype.TestAll.suite());
-
- return suite;
- }
-}
Deleted: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelTwoTestSuite.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelTwoTestSuite.java 2009-03-05
14:55:09 UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckLevelTwoTestSuite.java 2009-03-05
18:02:40 UTC (rev 758)
@@ -1,178 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * Unless otherwise indicated, all code in JBoss DNA is licensed
- * to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.jackrabbit.test.api.AddNodeTest;
-import org.apache.jackrabbit.test.api.CheckPermissionTest;
-import org.apache.jackrabbit.test.api.DocumentViewImportTest;
-import org.apache.jackrabbit.test.api.ImpersonateTest;
-import org.apache.jackrabbit.test.api.NamespaceRegistryTest;
-import org.apache.jackrabbit.test.api.NodeAddMixinTest;
-import org.apache.jackrabbit.test.api.NodeCanAddMixinTest;
-import org.apache.jackrabbit.test.api.NodeItemIsModifiedTest;
-import org.apache.jackrabbit.test.api.NodeItemIsNewTest;
-import org.apache.jackrabbit.test.api.NodeOrderableChildNodesTest;
-import org.apache.jackrabbit.test.api.NodeRemoveMixinTest;
-import org.apache.jackrabbit.test.api.NodeTest;
-import org.apache.jackrabbit.test.api.NodeUUIDTest;
-import org.apache.jackrabbit.test.api.PropertyItemIsModifiedTest;
-import org.apache.jackrabbit.test.api.PropertyItemIsNewTest;
-import org.apache.jackrabbit.test.api.PropertyTest;
-import org.apache.jackrabbit.test.api.ReferencesTest;
-import org.apache.jackrabbit.test.api.RepositoryLoginTest;
-import org.apache.jackrabbit.test.api.SerializationTest;
-import org.apache.jackrabbit.test.api.SessionTest;
-import org.apache.jackrabbit.test.api.SessionUUIDTest;
-import org.apache.jackrabbit.test.api.SetPropertyAssumeTypeTest;
-import org.apache.jackrabbit.test.api.SetPropertyBooleanTest;
-import org.apache.jackrabbit.test.api.SetPropertyCalendarTest;
-import org.apache.jackrabbit.test.api.SetPropertyConstraintViolationExceptionTest;
-import org.apache.jackrabbit.test.api.SetPropertyDoubleTest;
-import org.apache.jackrabbit.test.api.SetPropertyInputStreamTest;
-import org.apache.jackrabbit.test.api.SetPropertyLongTest;
-import org.apache.jackrabbit.test.api.SetPropertyNodeTest;
-import org.apache.jackrabbit.test.api.SetPropertyStringTest;
-import org.apache.jackrabbit.test.api.SetPropertyValueTest;
-import org.apache.jackrabbit.test.api.SetValueBinaryTest;
-import org.apache.jackrabbit.test.api.SetValueBooleanTest;
-import org.apache.jackrabbit.test.api.SetValueConstraintViolationExceptionTest;
-import org.apache.jackrabbit.test.api.SetValueDateTest;
-import org.apache.jackrabbit.test.api.SetValueDoubleTest;
-import org.apache.jackrabbit.test.api.SetValueLongTest;
-import org.apache.jackrabbit.test.api.SetValueReferenceTest;
-import org.apache.jackrabbit.test.api.SetValueStringTest;
-import org.apache.jackrabbit.test.api.SetValueValueFormatExceptionTest;
-import org.apache.jackrabbit.test.api.SetValueVersionExceptionTest;
-import org.apache.jackrabbit.test.api.ValueFactoryTest;
-import org.apache.jackrabbit.test.api.WorkspaceCloneReferenceableTest;
-import org.apache.jackrabbit.test.api.WorkspaceCloneSameNameSibsTest;
-import org.apache.jackrabbit.test.api.WorkspaceCloneTest;
-import org.apache.jackrabbit.test.api.WorkspaceCloneVersionableTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopyBetweenWorkspacesReferenceableTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopyBetweenWorkspacesSameNameSibsTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopyBetweenWorkspacesTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopyBetweenWorkspacesVersionableTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopyReferenceableTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopySameNameSibsTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopyTest;
-import org.apache.jackrabbit.test.api.WorkspaceCopyVersionableTest;
-import org.apache.jackrabbit.test.api.WorkspaceMoveReferenceableTest;
-import org.apache.jackrabbit.test.api.WorkspaceMoveSameNameSibsTest;
-import org.apache.jackrabbit.test.api.WorkspaceMoveTest;
-import org.apache.jackrabbit.test.api.WorkspaceMoveVersionableTest;
-
-/**
- * Test suite that includes the Level 2 JCR TCK API tests from the Jackrabbit project.
- *
- * @see JcrTckLevelOneTestSuite
- * @see JcrTckOptionalTestSuite
- * @see JcrTckTest
- */
-public class JcrTckLevelTwoTestSuite extends TestCase {
-
- /**
- * Returns a <code>Test</code> suite that executes all tests inside this
package.
- *
- * @return a <code>Test</code> suite that executes all tests inside this
package.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite("JCR 1.0 Level 2 API tests");
-
- // We currently don't pass the tests in those suites that are commented out
- // See
https://jira.jboss.org/jira/browse/DNA-285
-
- // level 2 tests
- suite.addTestSuite(AddNodeTest.class);
- suite.addTestSuite(NamespaceRegistryTest.class);
- suite.addTestSuite(ReferencesTest.class);
- suite.addTestSuite(SessionTest.class);
- suite.addTestSuite(SessionUUIDTest.class);
- suite.addTestSuite(NodeTest.class);
- suite.addTestSuite(NodeUUIDTest.class);
- suite.addTestSuite(NodeOrderableChildNodesTest.class);
- suite.addTestSuite(PropertyTest.class);
-
- suite.addTestSuite(SetValueBinaryTest.class);
- suite.addTestSuite(SetValueBooleanTest.class);
- suite.addTestSuite(SetValueDateTest.class);
- suite.addTestSuite(SetValueDoubleTest.class);
- suite.addTestSuite(SetValueLongTest.class);
- suite.addTestSuite(SetValueReferenceTest.class);
- suite.addTestSuite(SetValueStringTest.class);
- suite.addTestSuite(SetValueConstraintViolationExceptionTest.class);
- suite.addTestSuite(SetValueValueFormatExceptionTest.class);
- suite.addTestSuite(SetValueVersionExceptionTest.class);
-
- suite.addTestSuite(SetPropertyBooleanTest.class);
- suite.addTestSuite(SetPropertyCalendarTest.class);
- suite.addTestSuite(SetPropertyDoubleTest.class);
- suite.addTestSuite(SetPropertyInputStreamTest.class);
- suite.addTestSuite(SetPropertyLongTest.class);
- suite.addTestSuite(SetPropertyNodeTest.class);
- suite.addTestSuite(SetPropertyStringTest.class);
- suite.addTestSuite(SetPropertyValueTest.class);
- suite.addTestSuite(SetPropertyConstraintViolationExceptionTest.class);
- suite.addTestSuite(SetPropertyAssumeTypeTest.class);
-
- suite.addTestSuite(NodeItemIsModifiedTest.class);
- suite.addTestSuite(NodeItemIsNewTest.class);
- suite.addTestSuite(PropertyItemIsModifiedTest.class);
- suite.addTestSuite(PropertyItemIsNewTest.class);
-
- suite.addTestSuite(NodeAddMixinTest.class);
- suite.addTestSuite(NodeCanAddMixinTest.class);
- suite.addTestSuite(NodeRemoveMixinTest.class);
-
- suite.addTestSuite(WorkspaceCloneReferenceableTest.class);
- suite.addTestSuite(WorkspaceCloneSameNameSibsTest.class);
- suite.addTestSuite(WorkspaceCloneTest.class);
- suite.addTestSuite(WorkspaceCloneVersionableTest.class);
- suite.addTestSuite(WorkspaceCopyBetweenWorkspacesReferenceableTest.class);
- suite.addTestSuite(WorkspaceCopyBetweenWorkspacesSameNameSibsTest.class);
- suite.addTestSuite(WorkspaceCopyBetweenWorkspacesTest.class);
- suite.addTestSuite(WorkspaceCopyBetweenWorkspacesVersionableTest.class);
- suite.addTestSuite(WorkspaceCopyReferenceableTest.class);
- suite.addTestSuite(WorkspaceCopySameNameSibsTest.class);
- suite.addTestSuite(WorkspaceCopyTest.class);
- suite.addTestSuite(WorkspaceCopyVersionableTest.class);
- suite.addTestSuite(WorkspaceMoveReferenceableTest.class);
- suite.addTestSuite(WorkspaceMoveSameNameSibsTest.class);
- suite.addTestSuite(WorkspaceMoveTest.class);
- suite.addTestSuite(WorkspaceMoveVersionableTest.class);
-
- suite.addTestSuite(RepositoryLoginTest.class);
- suite.addTestSuite(ImpersonateTest.class);
- suite.addTestSuite(CheckPermissionTest.class);
-
- suite.addTestSuite(DocumentViewImportTest.class);
- suite.addTestSuite(SerializationTest.class);
-
- suite.addTestSuite(ValueFactoryTest.class);
-
- return suite;
- }
-}
Deleted: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckOptionalTestSuite.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckOptionalTestSuite.java 2009-03-05
14:55:09 UTC (rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckOptionalTestSuite.java 2009-03-05
18:02:40 UTC (rev 758)
@@ -1,57 +0,0 @@
-/*
- * JBoss DNA (
http://www.jboss.org/dna)
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * Unless otherwise indicated, all code in JBoss DNA is licensed
- * to you under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * JBoss DNA is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.dna.jcr;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-/**
- * Test suite that includes the Optional JCR TCK API tests from the Jackrabbit project.
- *
- * @see JcrTckLevelOneTestSuite
- * @see JcrTckLevelTwoTestSuite
- * @see JcrTckTest
- */
-public class JcrTckOptionalTestSuite extends TestCase {
-
- /**
- * Returns a <code>Test</code> suite that executes all tests inside this
package.
- *
- * @return a <code>Test</code> suite that executes all tests inside this
package.
- */
- public static Test suite() {
- TestSuite suite = new TestSuite("JCR 1.0 Optional API tests");
-
- // We currently don't pass the tests in those suites that are commented out
- // See
https://jira.jboss.org/jira/browse/DNA-285
-
- suite.addTest(org.apache.jackrabbit.test.api.observation.TestAll.suite());
- suite.addTest(org.apache.jackrabbit.test.api.version.TestAll.suite());
- suite.addTest(org.apache.jackrabbit.test.api.lock.TestAll.suite());
- suite.addTest(org.apache.jackrabbit.test.api.util.TestAll.suite());
-
- return suite;
- }
-}
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-03-05 14:55:09 UTC
(rev 757)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-03-05 18:02:40 UTC
(rev 758)
@@ -35,6 +35,7 @@
import junit.framework.TestSuite;
import org.apache.jackrabbit.test.JCRTestSuite;
import org.apache.jackrabbit.test.RepositoryStub;
+import org.apache.jackrabbit.test.api.RepositoryLoginTest;
import org.jboss.dna.graph.DnaLexicon;
import org.jboss.dna.graph.ExecutionContext;
import org.jboss.dna.graph.Graph;
@@ -48,14 +49,16 @@
/**
* Test suite to wrap Apache Jackrabbit JCR technology compatibility kit (TCK) unit
tests.
- *
- * @see JcrTckLevelOneTestSuite
- * @see JcrTckLevelTwoTestSuite
- * @see JcrTckOptionalTestSuite
*/
public class JcrTckTest {
/**
+ *
+ */
+ public JcrTckTest() {
+ }
+
+ /**
* Wrapper so that the Jackrabbit TCK test suite gets picked up by the DNA Maven test
target.
*
* @return a new instance of {@link JCRTestSuite}.
@@ -66,14 +69,164 @@
// Or uncomment the following lines to execute the different sets/suites of tests
...
TestSuite suite = new TestSuite("JCR 1.0 API tests");
- suite.addTest(JcrTckLevelOneTestSuite.suite());
- // suite.addTest(JcrTckLevelTwoTestSuite.suite());
- // suite.addTest(JcrTckOptionalTestSuite.suite());
+ suite.addTest(new LevelOneFeatureTests());
+ suite.addTest(new LevelTwoFeatureTests());
+ suite.addTest(new OptionalFeatureTests());
+
return suite;
}
/**
+ * Test suite that includes the Level 1 JCR TCK API tests from the Jackrabbit
project.
+ */
+ private static class LevelOneFeatureTests extends TestSuite {
+ protected LevelOneFeatureTests() {
+ super("JCR Level 1 API Tests");
+ // We currently don't pass the tests in those suites that are commented
out
+ // See
https://jira.jboss.org/jira/browse/DNA-285
+
+ addTestSuite(org.apache.jackrabbit.test.api.RootNodeTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.NodeReadMethodsTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.PropertyTypeTest.class);
+
addTestSuite(org.apache.jackrabbit.test.api.NodeDiscoveringNodeTypesTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.BinaryPropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.BooleanPropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.DatePropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.DoublePropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.LongPropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.NamePropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.PathPropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.ReferencePropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.StringPropertyTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.UndefinedPropertyTest.class);
+
addTestSuite(org.apache.jackrabbit.test.api.NamespaceRegistryReadMethodsTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.NamespaceRemappingTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.NodeIteratorTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.PropertyReadMethodsTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.RepositoryDescriptorTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.SessionReadMethodsTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.WorkspaceReadMethodsTest.class);
+
addTestSuite(org.apache.jackrabbit.test.api.ReferenceableRootNodesTest.class);
+ // addTestSuite(org.apache.jackrabbit.test.api.ExportSysViewTest.class);
+ // addTestSuite(org.apache.jackrabbit.test.api.ExportDocViewTest.class);
+ addTestSuite(org.apache.jackrabbit.test.api.RepositoryLoginTest.class);
+
+ // These might not all be level one tests
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.XPathPosIndexTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.XPathDocOrderTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.XPathOrderByTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.XPathJcrPathTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.DerefQueryLevel1Test.class);
+ // addTestSuite(org.apache.jackrabbit.test.api.query.GetLanguageTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.GetPersistentQueryPathLevel1Test.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.GetStatementTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.GetSupportedQueryLanguagesTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.GetPropertyNamesTest.class);
+ // addTestSuite(org.apache.jackrabbit.test.api.query.PredicatesTest.class);
+ //
addTestSuite(org.apache.jackrabbit.test.api.query.SimpleSelectionTest.class);
+
+ // The tests in this suite are level one
+ // addTest(org.apache.jackrabbit.test.api.nodetype.TestAll.suite());
+ }
+ }
+
+ /**
+ * Test suite that includes the Level 2 JCR TCK API tests from the Jackrabbit
project.
+ */
+ private static class LevelTwoFeatureTests extends TestSuite {
+ protected LevelTwoFeatureTests() {
+ super("JCR Level 2 API Tests");
+ // We currently don't pass the tests in those suites that are commented
out
+ // See
https://jira.jboss.org/jira/browse/DNA-285
+
+ // level 2 tests
+ // addTestSuite(AddNodeTest.class);
+ // addTestSuite(NamespaceRegistryTest.class);
+ // addTestSuite(ReferencesTest.class);
+ // addTestSuite(SessionTest.class);
+ // addTestSuite(SessionUUIDTest.class);
+ // addTestSuite(NodeTest.class);
+ // addTestSuite(NodeUUIDTest.class);
+ // addTestSuite(NodeOrderableChildNodesTest.class);
+ // addTestSuite(PropertyTest.class);
+ //
+ // addTestSuite(SetValueBinaryTest.class);
+ // addTestSuite(SetValueBooleanTest.class);
+ // addTestSuite(SetValueDateTest.class);
+ // addTestSuite(SetValueDoubleTest.class);
+ // addTestSuite(SetValueLongTest.class);
+ // addTestSuite(SetValueReferenceTest.class);
+ // addTestSuite(SetValueStringTest.class);
+ // addTestSuite(SetValueConstraintViolationExceptionTest.class);
+ // addTestSuite(SetValueValueFormatExceptionTest.class);
+ // addTestSuite(SetValueVersionExceptionTest.class);
+ //
+ // addTestSuite(SetPropertyBooleanTest.class);
+ // addTestSuite(SetPropertyCalendarTest.class);
+ // addTestSuite(SetPropertyDoubleTest.class);
+ // addTestSuite(SetPropertyInputStreamTest.class);
+ // addTestSuite(SetPropertyLongTest.class);
+ // addTestSuite(SetPropertyNodeTest.class);
+ // addTestSuite(SetPropertyStringTest.class);
+ // addTestSuite(SetPropertyValueTest.class);
+ // addTestSuite(SetPropertyConstraintViolationExceptionTest.class);
+ // addTestSuite(SetPropertyAssumeTypeTest.class);
+ //
+ // addTestSuite(NodeItemIsModifiedTest.class);
+ // addTestSuite(NodeItemIsNewTest.class);
+ // addTestSuite(PropertyItemIsModifiedTest.class);
+ // addTestSuite(PropertyItemIsNewTest.class);
+ //
+ // addTestSuite(NodeAddMixinTest.class);
+ // addTestSuite(NodeCanAddMixinTest.class);
+ // addTestSuite(NodeRemoveMixinTest.class);
+ //
+ // addTestSuite(WorkspaceCloneReferenceableTest.class);
+ // addTestSuite(WorkspaceCloneSameNameSibsTest.class);
+ // addTestSuite(WorkspaceCloneTest.class);
+ // addTestSuite(WorkspaceCloneVersionableTest.class);
+ // addTestSuite(WorkspaceCopyBetweenWorkspacesReferenceableTest.class);
+ // addTestSuite(WorkspaceCopyBetweenWorkspacesSameNameSibsTest.class);
+ // addTestSuite(WorkspaceCopyBetweenWorkspacesTest.class);
+ // addTestSuite(WorkspaceCopyBetweenWorkspacesVersionableTest.class);
+ // addTestSuite(WorkspaceCopyReferenceableTest.class);
+ // addTestSuite(WorkspaceCopySameNameSibsTest.class);
+ // addTestSuite(WorkspaceCopyTest.class);
+ // addTestSuite(WorkspaceCopyVersionableTest.class);
+ // addTestSuite(WorkspaceMoveReferenceableTest.class);
+ // addTestSuite(WorkspaceMoveSameNameSibsTest.class);
+ // addTestSuite(WorkspaceMoveTest.class);
+ // addTestSuite(WorkspaceMoveVersionableTest.class);
+ //
+ addTestSuite(RepositoryLoginTest.class);
+ // addTestSuite(ImpersonateTest.class);
+ // addTestSuite(CheckPermissionTest.class);
+ //
+ // addTestSuite(DocumentViewImportTest.class);
+ // addTestSuite(SerializationTest.class);
+ //
+ // addTestSuite(ValueFactoryTest.class);
+ }
+ }
+
+ /**
+ * Test suite that includes the Optional JCR TCK API tests from the Jackrabbit
project.
+ */
+ private static class OptionalFeatureTests extends TestSuite {
+ protected OptionalFeatureTests() {
+ super("JCR Optional API Tests");
+ // We currently don't pass the tests in those suites that are commented
out
+ // See
https://jira.jboss.org/jira/browse/DNA-285
+
+ // addTest(org.apache.jackrabbit.test.api.observation.TestAll.suite());
+ // addTest(org.apache.jackrabbit.test.api.version.TestAll.suite());
+ // addTest(org.apache.jackrabbit.test.api.lock.TestAll.suite());
+ // addTest(org.apache.jackrabbit.test.api.util.TestAll.suite());
+ }
+ }
+
+ /**
* Concrete implementation of {@link RepositoryStub} based on DNA-specific
configuration.
*/
public static class InMemoryRepositoryStub extends RepositoryStub {