Index: deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-config.xml =================================================================== --- deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-config.xml (revision 2433) +++ deploy/jbossas/modeshape-jbossas-service/src/kit/modeshape-config.xml (working copy) @@ -35,24 +35,24 @@ Sequences *.csv text files loaded into the repository under '/files', extracting comma-separated and delimited files into columnar information. /files//(*.csv[*])/jcr:content[@jcr:data] => /sequenced/text/delimited/$1 - - , + + , Sequences *.txt fixed-width text files loaded into the repository under '/files', extracting splitting rows into columns based on predefined positions. /files//(*.txt[*])/jcr:content[@jcr:data] => /sequenced/text/fixedWidth/$1 - - + + Sequences Teiid relational models (e.g., *.xmi) loaded into the repository under '/files', extracting the structure defined in the models. @@ -63,7 +63,7 @@ @@ -79,11 +79,25 @@ Sequences CND files loaded into the repository under '/files', extracting the contained node type definitions. - /files//(*.cnd[*])/jcr:content[@jcr:data] => /sequenced/cnd/$1 + + /files(//(*.cnd[*]))/jcr:content[@jcr:data] => /sequenced/cnd/$1 Sequences DDL files loaded into the repository under '/files', extracting the structured abstract syntax tree of the DDL commands and expressions. - /files//(*.ddl[*])/jcr:content[@jcr:data] => /sequenced/ddl/$1 + + /files(//(*.ddl[*]))/jcr:content[@jcr:data] => /sequenced/ddl/$1 Sequences Microsoft Office documents and presentations under '/files', extracting summary information and structure. @@ -91,18 +105,25 @@ Sequences XML files loaded into the repository under '/files', extracting the contents into the equivalent JCR graph structure. - /files//(*.xml[*])/jcr:content[@jcr:data] => /sequenced/xml/$1 + + /files(//(*.xml[*]))/jcr:content[@jcr:data] => /sequenced/xml/$1 Sequences ZIP files loaded into the repository under '/files', extracting the archive file contents into the equivalent JCR graph structure of 'nt:file' and 'nt:folder' nodes. - /files//(*.zip[*])/jcr:content[@jcr:data] => /sequenced/zip/$1 + + /files(//)(*.zip[*])/jcr:content[@jcr:data] => /sequenced/zip/$1 - Index: docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd =================================================================== --- docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd (revision 2433) +++ docs/examples/gettingstarted/sequencers/src/main/resources/sequencing.cnd (working copy) @@ -262,9 +262,9 @@ // ModeShape Zip Sequencer // ------------------- -/** - * Primary type for root of generated structure - */ +[zip:file] > nt:folder, mix:mimeType + +/* Deprecated */ [zip:content] > nt:unstructured, mix:mimeType + * (nt:folder) + * (nt:file) Index: extensions/modeshape-sequencer-cnd/src/main/java/org/modeshape/sequencer/cnd/CndSequencer.java =================================================================== --- extensions/modeshape-sequencer-cnd/src/main/java/org/modeshape/sequencer/cnd/CndSequencer.java (revision 2433) +++ extensions/modeshape-sequencer-cnd/src/main/java/org/modeshape/sequencer/cnd/CndSequencer.java (working copy) @@ -25,11 +25,16 @@ package org.modeshape.sequencer.cnd; import java.io.IOException; import java.io.InputStream; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import org.modeshape.cnd.CndImporter; import org.modeshape.graph.ExecutionContext; +import org.modeshape.graph.JcrLexicon; import org.modeshape.graph.io.Destination; import org.modeshape.graph.property.Path; +import org.modeshape.graph.property.PathFactory; import org.modeshape.graph.property.Property; import org.modeshape.graph.sequencer.SequencerOutput; import org.modeshape.graph.sequencer.StreamSequencer; @@ -54,7 +59,11 @@ public class CndSequencer implements StreamSequencer { // Use the CND importer ... Path root = context.getValueFactories().getPathFactory().createRootPath(); CndImporter importer = new CndImporter(destination, root); - String resourceName = context.getInputPath().getString(context.getNamespaceRegistry()); + Path inputPath = context.getInputPath(); + if (inputPath.getLastSegment().getName().equals(JcrLexicon.CONTENT)) { + inputPath = inputPath.getParent(); + } + String resourceName = inputPath.getLastSegment().getString(context.getNamespaceRegistry()); try { importer.importFrom(stream, context.getProblems(), resourceName); } catch (IOException e) { @@ -65,11 +74,14 @@ public class CndSequencer implements StreamSequencer { protected class OutputDestination implements Destination { private final SequencerOutput output; private final StreamSequencerContext context; + private final Map paths = new HashMap(); + private final PathFactory pathFactory; protected OutputDestination( SequencerOutput output, StreamSequencerContext context ) { this.output = output; this.context = context; + this.pathFactory = context.getValueFactories().getPathFactory(); } /** @@ -81,6 +93,24 @@ public class CndSequencer implements StreamSequencer { return context; } + protected Path checkPath( Path path ) { + path = path.relativeToRoot(); + AtomicInteger count = paths.get(path); + if (count == null) { + count = new AtomicInteger(1); + paths.put(path, count); + return path; + } + int snsIndex = count.incrementAndGet(); + Path parent = path.getParent(); + if (parent == null) { + // We've actually seen this node type name before (an artifact of the way the CndImporter works), + // so just use it ... + return path; + } + return pathFactory.create(parent, path.getLastSegment().getName(), snsIndex); + } + /** * {@inheritDoc} * @@ -88,6 +118,7 @@ public class CndSequencer implements StreamSequencer { */ public void create( Path path, List properties ) { + path = checkPath(path); for (Property property : properties) { output.setProperty(path, property.getName(), property.getValuesAsArray()); } @@ -102,6 +133,7 @@ public class CndSequencer implements StreamSequencer { public void create( Path path, Property firstProperty, Property... additionalProperties ) { + path = checkPath(path); output.setProperty(path, firstProperty.getName(), firstProperty.getValues()); for (Property property : additionalProperties) { output.setProperty(path, property.getName(), property.getValuesAsArray()); @@ -116,6 +148,7 @@ public class CndSequencer implements StreamSequencer { */ public void setProperties( Path path, Property... properties ) { + path = checkPath(path); for (Property property : properties) { output.setProperty(path, property.getName(), property.getValuesAsArray()); } Index: extensions/modeshape-sequencer-ddl/src/main/resources/org/modeshape/sequencer/ddl/StandardDdl.cnd =================================================================== --- extensions/modeshape-sequencer-ddl/src/main/resources/org/modeshape/sequencer/ddl/StandardDdl.cnd (revision 2433) +++ extensions/modeshape-sequencer-ddl/src/main/resources/org/modeshape/sequencer/ddl/StandardDdl.cnd (working copy) @@ -49,7 +49,7 @@ - ddl:startColumnNumber (long) mandatory // The starting column number for the statement - ddl:startCharIndex (long) mandatory // The starting content character index for the statement - ddl:length (long) mandatory // The string length - + ddl:problem (ddl:ddlProblem) = ddl:ddlProblem sns // Problems encountered during parsing. + + ddl:problem (ddl:ddlProblem) = ddl:ddlProblem sns // Problems encountered during parsing. // ============================================================================= // CREATE, ALTER, DROP, INSERT, SET, GRANT, REVOKE @@ -81,6 +81,28 @@ [ddl:tableConstraintOperand] > ddl:operand abstract [ddl:referenceOperand] > ddl:operand abstract + +// ============================================================================= +// SIMPLE STRING PROPERTY +// ============================================================================= +[ddl:simpleProperty] mixin + - ddl:propValue (STRING) mandatory + +[ddl:constraintAttribute] > ddl:simpleProperty mixin + +// ============================================================================= +// STATEMENT OPTION +// ============================================================================= +[ddl:statementOption] mixin + - ddl:value (STRING) mandatory + +// ============================================================================= +// DDL PROBLEM +// ============================================================================= +[ddl:ddlProblem] mixin + - ddl:problemLevel (LONG) mandatory + - ddl:message (STRING) mandatory + // ============================================================================= // COLUMN // ============================================================================= @@ -101,17 +123,17 @@ // ============================================================================= // TABLE CONSTRAINT // ============================================================================= -[ddl:tableConstraintDefinition] > ddl:creatable, ddl:tableConstraintOperand mixin +[ddl:tableConstraint] > ddl:creatable, ddl:tableConstraintOperand mixin - ddl:constraintType (STRING) mandatory < 'UNIQUE', 'PRIMARY KEY', 'FOREIGN KEY', 'CHECK' - ddl:deferrable (STRING) < 'DEFERRABLE', 'NOT DEFERRABLE' - ddl:checkSearchCondition (STRING) < 'INITIALLY DEFERRED', 'INITIALLY IMMEDIATE' - + * (ddl:columnReference) = ddl:columnReference sns // the column(s) referenced by the constraint - + * (ddl:tableReference) = ddl:tableReference // the table(s) referenced by the foreign key - + * (ddl:fkColumnReference) = ddl:fkColumnReference sns // the columns in the table referenced by the foreign key - + ddl:constraintAttribute (ddl:simpleProperty) = ddl:simpleProperty sns + + * (ddl:columnReference) = ddl:columnReference sns + + * (ddl:tableReference) = ddl:tableReference + + * (ddl:fkColumnReference) = ddl:fkColumnReference sns + + ddl:constAttribute (ddl:constraintAttribute) = ddl:constraintAttribute sns // ============================================================================= // REFERENCE @@ -122,28 +144,9 @@ [ddl:grantee] > ddl:referenceOperand mixin // ============================================================================= -// SIMPLE STRING PROPERTY -// ============================================================================= -[ddl:simpleProperty] mixin - - ddl:propValue (STRING) mandatory - -// ============================================================================= -// STATEMENT OPTION -// ============================================================================= -[ddl:statementOption] mixin - - ddl:value (STRING) mandatory - -// ============================================================================= -// DDL PROBLEM -// ============================================================================= -[ddl:ddlProblem] mixin - - ddl:problemLevel (LONG) mandatory - - ddl:message (STRING) mandatory - -// ============================================================================= // CREATE SCHEMA // ============================================================================= -[ddl:schemaDefinition] > ddl:statement, ddl:creatable, ddl:schemaOperand mixin +[ddl:createSchemaStatement] > ddl:statement, ddl:creatable, ddl:schemaOperand mixin - ddl:defaultCharacterSetName (STRING) + * (ddl:statement) = ddl:statement sns @@ -156,7 +159,7 @@ - ddl:onCommitValue (STRING) < 'DELETE ROWS', 'PRESERVE ROWS' + * (ddl:columnDefinition) = ddl:columnDefinition sns - + * (ddl:tableConstraintDefinition) = ddl:tableConstraintDefinition sns + + * (ddl:tableConstraint) = ddl:tableConstraint sns + * (ddl:statementOption) = ddl:statementOption sns // ============================================================================= @@ -181,15 +184,14 @@ - ddl:defaultValue (STRING) - ddl:defaultPrecision (LONG) - ddl:collationName (STRING) - + ddl:domainConstraintDefinition (ddl:tableConstraintDefinition) = ddl:tableConstraintDefinition sns + + ddl:domainConstraintDefinition (ddl:tableConstraint) = ddl:tableConstraint sns // ============================================================================= // CREATE ASSERTION // ============================================================================= -[ddl:createAssertionStatement] > ddl:statement, ddl:creatable, ddl:assertionOperand mixin - - ddl:constraintName (STRING) mandatory +[ddl:createAssertionStatement] > ddl:statement, ddl:creatable, ddl:tableConstraintOperand mixin - ddl:searchCondition (STRING) mandatory - + ddl:constraintAttribute (ddl:simpleProperty) = ddl:simpleProperty sns + + ddl:constAttribute (ddl:constraintAttribute) = ddl:constraintAttribute sns // ============================================================================= // CREATE CHARACTER SET @@ -248,8 +250,8 @@ [ddl:alterColumnDefinition] > ddl:columnDefinition, ddl:alterable mixin [ddl:addColumnDefinition] > ddl:columnDefinition, ddl:creatable mixin [ddl:dropColumnDefinition] > ddl:columnDefinition, ddl:droppable mixin -[ddl:addTableConstraintDefinition] > ddl:tableConstraintDefinition, ddl:creatable mixin -[ddl:dropTableConstraintDefinition] > ddl:tableConstraintDefinition, ddl:droppable mixin +[ddl:addTableConstraintDefinition] > ddl:tableConstraint, ddl:creatable mixin +[ddl:dropTableConstraintDefinition] > ddl:tableConstraint, ddl:droppable mixin // ============================================================================= // MISC STATEMENTS @@ -278,3 +280,18 @@ [ddl:grantOnCollationStatement] > ddl:grantStatement, ddl:collationOperand mixin [ddl:grantOnCharacterSetStatement] > ddl:grantStatement, ddl:characterSetOperand mixin [ddl:grantOnTranslationStatement] > ddl:grantStatement, ddl:translationOperand mixin + +// ============================================================================= +// REVOKE STATEMENTS +// ============================================================================= + +[ddl:revokeStatement] > ddl:statement, ddl:revokable, ddl:droppable mixin + - ddl:allPrivileges (boolean) + + * (ddl:grantPrivilege) = ddl:grantPrivilege sns + + * (ddl:grantee) = ddl:grantee sns + +[ddl:revokeOnTableStatement] > ddl:revokeStatement, ddl:tableOperand mixin +[ddl:revokeOnDomainStatement] > ddl:revokeStatement, ddl:domainOperand mixin +[ddl:revokeOnCollationStatement] > ddl:revokeStatement, ddl:collationOperand mixin +[ddl:revokeOnCharacterSetStatement] > ddl:revokeStatement, ddl:characterSetOperand mixin +[ddl:revokeOnTranslationStatement] > ddl:revokeStatement, ddl:translationOperand mixin Index: extensions/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/ModeShapeXmlLexicon.java =================================================================== --- extensions/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/ModeShapeXmlLexicon.java (revision 2433) +++ extensions/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/ModeShapeXmlLexicon.java (working copy) @@ -41,6 +41,7 @@ public class ModeShapeXmlLexicon { public static final Name COMMENT = new BasicName(Namespace.URI, "comment"); public static final Name COMMENT_CONTENT = new BasicName(Namespace.URI, "commentContent"); public static final Name DOCUMENT = new BasicName(Namespace.URI, "document"); + public static final Name ELEMENT = new BasicName(Namespace.URI, "element"); public static final Name ELEMENT_CONTENT = new BasicName(Namespace.URI, "elementContent"); public static final Name PROCESSING_INSTRUCTION = new BasicName(Namespace.URI, "processingInstruction"); public static final Name PROCESSING_INSTRUCTION_CONTENT = new BasicName(Namespace.URI, "processingInstructionContent"); Index: extensions/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencerHandler.java =================================================================== --- extensions/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencerHandler.java (revision 2433) +++ extensions/modeshape-sequencer-xml/src/main/java/org/modeshape/sequencer/xml/XmlSequencerHandler.java (working copy) @@ -432,7 +432,7 @@ public class XmlSequencerHandler extends DefaultHandler2 { public void endCDATA() { // Output CDATA built in characters() method startNode(ModeShapeXmlLexicon.CDATA); - output.setProperty(currentPath, JcrLexicon.PRIMARY_TYPE, defaultPrimaryType); + output.setProperty(currentPath, JcrLexicon.PRIMARY_TYPE, ModeShapeXmlLexicon.CDATA); output.setProperty(currentPath, ModeShapeXmlLexicon.CDATA_CONTENT, cDataContent.toString()); endNode(); // Null-out builder to free memory @@ -528,7 +528,7 @@ public class XmlSequencerHandler extends DefaultHandler2 { // Set the type of the node ... if (defaultPrimaryType != null) { - output.setProperty(currentPath, JcrLexicon.PRIMARY_TYPE, defaultPrimaryType); + output.setProperty(currentPath, JcrLexicon.PRIMARY_TYPE, ModeShapeXmlLexicon.ELEMENT); } // Now, set each attribute as a property ... Index: extensions/modeshape-sequencer-xml/src/main/resources/org/modeshape/sequencer/xml/xml.cnd =================================================================== --- extensions/modeshape-sequencer-xml/src/main/resources/org/modeshape/sequencer/xml/xml.cnd (revision 2433) +++ extensions/modeshape-sequencer-xml/src/main/resources/org/modeshape/sequencer/xml/xml.cnd (working copy) @@ -28,34 +28,35 @@ - - + + //------------------------------------------------------------------------------ // N O D E T Y P E S //------------------------------------------------------------------------------ -[dnaxml:document] > nt:unstructured, mix:mimeType - - dnaxml:cDataContent (string) +[modexml:document] > nt:unstructured, mix:mimeType + - modexml:cDataContent (string) -[dnaxml:comment] > nt:unstructured, mix:mimeType - - dnaxml:commentContent (string) +[modexml:comment] > nt:unstructured + - modexml:commentContent (string) -[dnaxml:element] > nt:unstructured, mix:mimeType - - dnaxml:elementContent (string) +[modexml:element] > nt:unstructured -[dnaxml:cData] > nt:unstructured, mix:mimeType - - dnaxml:cDataContent (string) +[modexml:elementContent] > nt:unstructured + - modexml:elementContent (string) -[dnaxml:processingInstruction] > nt:unstructured, mix:mimeType - - dnaxml:processingInstruction (string) - - dnaxml:target (string) - +[modexml:cData] > nt:unstructured + - modexml:cDataContent (string) + +[modexml:processingInstruction] > nt:unstructured + - modexml:processingInstruction (string) + - modexml:target (string) -[dnadtd:entity] > nt:unstructured, mix:mimeType - - dnaxml:name (string) - - dnaxml:value (string) - - dnaxml:publicId (string) - - dnaxml:systemId (string) +[modedtd:entity] > nt:unstructured + - modexml:name (string) + - modexml:value (string) + - modexml:publicId (string) + - modexml:systemId (string) Index: extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/InheritingXmlSequencerTest.java =================================================================== --- extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/InheritingXmlSequencerTest.java (revision 2433) +++ extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/InheritingXmlSequencerTest.java (working copy) @@ -75,10 +75,10 @@ public class InheritingXmlSequencerTest { public void shouldSequenceXsds() throws IOException { assertThat(sequencer.getAttributeScoping(), is(XmlSequencer.AttributeScoping.INHERIT_ELEMENT_NAMESPACE)); verifyDocument(xsd); - verifyName("xs:schema", "jcr:primaryType", "nt:unstructured"); + verifyName("xs:schema", "jcr:primaryType", "modexml:element"); verifyString("xs:schema", "xs:targetNamespace", "http://ns.adobe.com/air/application/1.0"); verifyString("xs:schema", "xs:elementFormDefault", "qualified"); - verifyName("xs:schema/xs:element", "jcr:primaryType", "nt:unstructured"); + verifyName("xs:schema/xs:element", "jcr:primaryType", "modexml:element"); verifyString("xs:schema/xs:element", "xs:name", "application"); } Index: extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/XmlSequencerHandlerTest.java =================================================================== --- extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/XmlSequencerHandlerTest.java (revision 2433) +++ extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/XmlSequencerHandlerTest.java (working copy) @@ -111,14 +111,14 @@ public class XmlSequencerHandlerTest { parse("docWithoutNamespaces.xml"); // Check the generated content; note that the attribute name doesn't match, so the nodes don't get special names assertDocumentNode(); - assertNode("Cars"); - assertNode("Cars/Hybrid"); - assertNode("Cars/Hybrid/car[1]", "name=Toyota Prius", "maker=Toyota", "model=Prius"); - assertNode("Cars/Hybrid/car[2]", "name=Toyota Highlander", "maker=Toyota", "model=Highlander"); - assertNode("Cars/Hybrid/car[3]", "name=Nissan Altima", "maker=Nissan", "model=Altima"); - assertNode("Cars/Sports"); - assertNode("Cars/Sports/car[1]", "name=Aston Martin DB9", "maker=Aston Martin", "model=DB9"); - assertNode("Cars/Sports/car[2]", "name=Infiniti G37", "maker=Infiniti", "model=G37"); + assertElement("Cars"); + assertElement("Cars/Hybrid"); + assertElement("Cars/Hybrid/car[1]", "name=Toyota Prius", "maker=Toyota", "model=Prius"); + assertElement("Cars/Hybrid/car[2]", "name=Toyota Highlander", "maker=Toyota", "model=Highlander"); + assertElement("Cars/Hybrid/car[3]", "name=Nissan Altima", "maker=Nissan", "model=Altima"); + assertElement("Cars/Sports"); + assertElement("Cars/Sports/car[1]", "name=Aston Martin DB9", "maker=Aston Martin", "model=DB9"); + assertElement("Cars/Sports/car[2]", "name=Infiniti G37", "maker=Infiniti", "model=G37"); assertNoMoreNodes(); } @@ -130,14 +130,14 @@ public class XmlSequencerHandlerTest { // Note that the attribute name DOES match, so the nodes names come from "jcr:name" attribute // Also, the "jcr:name" attribute values use the default namespace, which is "c" in the registry assertDocumentNode(); - assertNode("c:Cars"); - assertNode("c:Cars/c:Hybrid"); - assertNode("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); - assertNode("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); - assertNode("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); - assertNode("c:Cars/c:Sports"); - assertNode("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); - assertNode("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); + assertElement("c:Cars"); + assertElement("c:Cars/c:Hybrid"); + assertElement("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); + assertElement("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); + assertElement("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); + assertElement("c:Cars/c:Sports"); + assertElement("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); + assertElement("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); assertNoMoreNodes(); } @@ -148,14 +148,14 @@ public class XmlSequencerHandlerTest { parse("docWithNestedNamespaces.xml"); // Check the generated content; note that the attribute name DOES match, so the nodes names come from "jcr:name" attribute assertDocumentNode(); - assertNode("Cars"); - assertNode("Cars/c:Hybrid"); - assertNode("Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); - assertNode("Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); - assertNode("Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); - assertNode("Cars/Sports"); - assertNode("Cars/Sports/Aston Martin DB9", "i:maker=Aston Martin", "model=DB9"); - assertNode("Cars/Sports/Infiniti G37", "i:maker=Infiniti", "model=G37"); + assertElement("Cars"); + assertElement("Cars/c:Hybrid"); + assertElement("Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); + assertElement("Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); + assertElement("Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); + assertElement("Cars/Sports"); + assertElement("Cars/Sports/Aston Martin DB9", "i:maker=Aston Martin", "model=DB9"); + assertElement("Cars/Sports/Infiniti G37", "i:maker=Infiniti", "model=G37"); assertNoMoreNodes(); } @@ -165,14 +165,14 @@ public class XmlSequencerHandlerTest { parse("docWithNamespaces.xml"); // Check the generated content; note that the attribute name DOES match, so the nodes names come from "jcr:name" attribute assertDocumentNode(); - assertNode("c:Cars"); - assertNode("c:Cars/c:Hybrid"); - assertNode("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); - assertNode("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); - assertNode("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); - assertNode("c:Cars/c:Sports"); - assertNode("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); - assertNode("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); + assertElement("c:Cars"); + assertElement("c:Cars/c:Hybrid"); + assertElement("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); + assertElement("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); + assertElement("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); + assertElement("c:Cars/c:Sports"); + assertElement("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); + assertElement("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); assertNoMoreNodes(); } @@ -199,14 +199,14 @@ public class XmlSequencerHandlerTest { if (i.length() != 0) i = i + ":"; // Check the generated content; note that the attribute name DOES match, so the nodes names come from "jcr:name" attribute assertDocumentNode(); - assertNode(d + "Cars"); - assertNode(d + "Cars/" + c + "Hybrid"); - assertNode(d + "Cars/" + c + "Hybrid/" + c + "Toyota Prius", c + "maker=Toyota", c + "model=Prius"); - assertNode(d + "Cars/" + c + "Hybrid/" + c + "Toyota Highlander", c + "maker=Toyota", c + "model=Highlander"); - assertNode(d + "Cars/" + c + "Hybrid/" + c + "Nissan Altima", c + "maker=Nissan", c + "model=Altima"); - assertNode(d + "Cars/" + d + "Sports"); - assertNode(d + "Cars/" + d + "Sports/Aston Martin DB9", i + "maker=Aston Martin", "model=DB9"); - assertNode(d + "Cars/" + d + "Sports/Infiniti G37", i + "maker=Infiniti", "model=G37"); + assertElement(d + "Cars"); + assertElement(d + "Cars/" + c + "Hybrid"); + assertElement(d + "Cars/" + c + "Hybrid/" + c + "Toyota Prius", c + "maker=Toyota", c + "model=Prius"); + assertElement(d + "Cars/" + c + "Hybrid/" + c + "Toyota Highlander", c + "maker=Toyota", c + "model=Highlander"); + assertElement(d + "Cars/" + c + "Hybrid/" + c + "Nissan Altima", c + "maker=Nissan", c + "model=Altima"); + assertElement(d + "Cars/" + d + "Sports"); + assertElement(d + "Cars/" + d + "Sports/Aston Martin DB9", i + "maker=Aston Martin", "model=DB9"); + assertElement(d + "Cars/" + d + "Sports/Infiniti G37", i + "maker=Infiniti", "model=G37"); assertNoMoreNodes(); } @@ -216,14 +216,14 @@ public class XmlSequencerHandlerTest { parse("docWithNamespaces.xml"); // Check the generated content; note that the attribute name DOES match, so the nodes names come from "jcr:name" attribute assertDocumentNode(); - assertNode("c:Cars"); - assertNode("c:Cars/c:Hybrid"); - assertNode("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); - assertNode("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); - assertNode("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); - assertNode("c:Cars/c:Sports"); - assertNode("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); - assertNode("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); + assertElement("c:Cars"); + assertElement("c:Cars/c:Hybrid"); + assertElement("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); + assertElement("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); + assertElement("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); + assertElement("c:Cars/c:Sports"); + assertElement("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); + assertElement("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); assertNoMoreNodes(); } @@ -232,14 +232,14 @@ public class XmlSequencerHandlerTest { parse("docWithNamespacesWithoutDefault.xml"); // Check the generated content; note that the attribute name DOES match, so the nodes names come from "jcr:name" attribute assertDocumentNode(); - assertNode("Cars"); - assertNode("Cars/Hybrid"); - assertNode("Cars/Hybrid/Toyota Prius", "maker=Toyota", "model=Prius"); - assertNode("Cars/Hybrid/Toyota Highlander", "maker=Toyota", "model=Highlander"); - assertNode("Cars/Hybrid/Nissan Altima", "maker=Nissan", "model=Altima"); - assertNode("Cars/Sports"); - assertNode("Cars/Sports/Aston Martin DB9", "maker=Aston Martin", "model=DB9"); - assertNode("Cars/Sports/Infiniti G37", "maker=Infiniti", "model=G37"); + assertElement("Cars"); + assertElement("Cars/Hybrid"); + assertElement("Cars/Hybrid/Toyota Prius", "maker=Toyota", "model=Prius"); + assertElement("Cars/Hybrid/Toyota Highlander", "maker=Toyota", "model=Highlander"); + assertElement("Cars/Hybrid/Nissan Altima", "maker=Nissan", "model=Altima"); + assertElement("Cars/Sports"); + assertElement("Cars/Sports/Aston Martin DB9", "maker=Aston Martin", "model=DB9"); + assertElement("Cars/Sports/Infiniti G37", "maker=Infiniti", "model=G37"); assertNoMoreNodes(); } @@ -250,22 +250,22 @@ public class XmlSequencerHandlerTest { parse("docWithNamespacesWithoutDefault.xml"); // Check the generated content; note that the attribute name DOES match, so the nodes names come from "jcr:name" attribute assertDocumentNode(); - assertNode("Cars"); - assertNode("Cars/Hybrid"); - assertNode("Cars/Hybrid/car[1]", "maker=Toyota", "model=Prius"); - assertNode("Cars/Hybrid/car[2]", "maker=Toyota", "model=Highlander"); - assertNode("Cars/Hybrid/car[3]", "maker=Nissan", "model=Altima"); - assertNode("Cars/Sports"); - assertNode("Cars/Sports/car[1]", "maker=Aston Martin", "model=DB9"); - assertNode("Cars/Sports/car[2]", "maker=Infiniti", "model=G37"); + assertElement("Cars"); + assertElement("Cars/Hybrid"); + assertElement("Cars/Hybrid/car[1]", "maker=Toyota", "model=Prius"); + assertElement("Cars/Hybrid/car[2]", "maker=Toyota", "model=Highlander"); + assertElement("Cars/Hybrid/car[3]", "maker=Nissan", "model=Altima"); + assertElement("Cars/Sports"); + assertElement("Cars/Sports/car[1]", "maker=Aston Martin", "model=DB9"); + assertElement("Cars/Sports/car[2]", "maker=Infiniti", "model=G37"); assertNoMoreNodes(); } @Test public void shouldParseXmlDocumentThatContainsNoContent() throws IOException, SAXException { parse("docWithOnlyRootElement.xml"); - assertNode("", "jcr:primaryType={http://www.modeshape.org/xml/1.0}document"); - assertNode("Cars"); + assertElement("", "jcr:primaryType={http://www.modeshape.org/xml/1.0}document"); + assertElement("Cars"); assertNoMoreNodes(); } @@ -274,16 +274,87 @@ public class XmlSequencerHandlerTest { context.getNamespaceRegistry().register("c", "http://default.namespace.com"); parse("docWithComments.xml"); assertDocumentNode(); - assertNode("c:Cars"); + assertElement("c:Cars"); assertComment("c:Cars/modexml:comment[1]", "This is a comment"); - assertNode("c:Cars/c:Hybrid"); - assertNode("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); - assertNode("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); - assertNode("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); + assertElement("c:Cars/c:Hybrid"); + assertElement("c:Cars/c:Hybrid/c:Toyota Prius", "c:maker=Toyota", "c:model=Prius"); + assertElement("c:Cars/c:Hybrid/c:Toyota Highlander", "c:maker=Toyota", "c:model=Highlander"); + assertElement("c:Cars/c:Hybrid/c:Nissan Altima", "c:maker=Nissan", "c:model=Altima"); assertComment("c:Cars/modexml:comment[2]", "This is another comment"); - assertNode("c:Cars/c:Sports"); - assertNode("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); - assertNode("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); + assertElement("c:Cars/c:Sports"); + assertElement("c:Cars/c:Sports/c:Aston Martin DB9", "c:maker=Aston Martin", "c:model=DB9"); + assertElement("c:Cars/c:Sports/c:Infiniti G37", "c:maker=Infiniti", "c:model=G37"); + assertNoMoreNodes(); + } + + @Test + public void shouldParseXmlDocumentWithXmlElementsContainingOnlyChildElements() throws IOException, SAXException { + context.getNamespaceRegistry().register("xhtml", "http://www.w3.org/1999/xhtml"); + context.getNamespaceRegistry().register("mathml", "http://www.w3.org/1998/Math/MathML"); + context.getNamespaceRegistry().register("svg", "http://www.w3.org/2000/svg"); + context.getNamespaceRegistry().register("dnaxml", "http://www.modeshape.org/xml/1.0"); + context.getNamespaceRegistry().register("dnadtd", "http://www.modeshape.org/dtd/1.0"); + parse("docWithElementsContainingElements.xml"); + assertDocumentNode(); + assertElement("xhtml:html"); + assertElement("xhtml:html/xhtml:head"); + assertElement("xhtml:html/xhtml:head/xhtml:title"); + assertContent("xhtml:html/xhtml:head/xhtml:title/dnaxml:elementContent", "Three Namespaces"); + assertElement("xhtml:html/xhtml:body"); + assertElement("xhtml:html/xhtml:body/xhtml:h1", "{}align=center"); + assertContent("xhtml:html/xhtml:body/xhtml:h1/dnaxml:elementContent", "An Ellipse and a Rectangle"); + assertElement("xhtml:html/xhtml:body/svg:svg", "{}width=12cm", "{}height=10cm"); + assertElement("xhtml:html/xhtml:body/svg:svg/svg:ellipse", "{}rx=110", "{}ry=130"); + assertElement("xhtml:html/xhtml:body/svg:svg/svg:rect", "{}x=4cm", "{}y=1cm", "{}width=3cm", "{}height=6cm"); + assertElement("xhtml:html/xhtml:body/xhtml:p"); + assertContent("xhtml:html/xhtml:body/xhtml:p/dnaxml:elementContent", "The equation for ellipses"); + assertElement("xhtml:html/xhtml:body/mathml:math"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:eq"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:cn"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:cn/dnaxml:elementContent", "1"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:plus"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:divide"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply/mathml:power"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply/mathml:ci"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply/mathml:ci/dnaxml:elementContent", + "x"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply/mathml:cn"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply/mathml:cn/dnaxml:elementContent", + "2"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply[2]"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply[2]/mathml:power"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply[2]/mathml:ci"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply[2]/mathml:ci/dnaxml:elementContent", + "a"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply[2]/mathml:cn"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply/mathml:apply[2]/mathml:cn/dnaxml:elementContent", + "2"); + + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:divide"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply/mathml:power"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply/mathml:ci"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply/mathml:ci/dnaxml:elementContent", + "y"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply/mathml:cn"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply/mathml:cn/dnaxml:elementContent", + "2"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply[2]"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply[2]/mathml:power"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply[2]/mathml:ci"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply[2]/mathml:ci/dnaxml:elementContent", + "b"); + assertElement("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply[2]/mathml:cn"); + assertContent("xhtml:html/xhtml:body/mathml:math/mathml:apply/mathml:apply/mathml:apply[2]/mathml:apply[2]/mathml:cn/dnaxml:elementContent", + "2"); + assertElement("xhtml:html/xhtml:body/xhtml:hr"); + assertElement("xhtml:html/xhtml:body/xhtml:p[2]"); + assertContent("xhtml:html/xhtml:body/xhtml:p[2]/dnaxml:elementContent", "Last Modified January 10, 2002"); assertNoMoreNodes(); } @@ -307,42 +378,26 @@ public class XmlSequencerHandlerTest { assertEntity(2, "versionNumber", "0.1"); assertEntity(3, "copyrightYear", "2008"); assertEntity(4, "copyrightHolder", "Red Hat Middleware, LLC."); - assertNode("book"); - assertNode("book/bookinfo"); - assertNode("book/bookinfo/title"); - assertNode("book/bookinfo/title/modexml:elementContent", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=ModeShape"); - assertNode("book/bookinfo/releaseinfo"); - assertNode("book/bookinfo/releaseinfo/modexml:elementContent", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=&versionNumber;"); - assertNode("book/bookinfo/productnumber"); - assertNode("book/bookinfo/productnumber/modexml:elementContent", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=some text with &versionNumber;inside"); - assertNode("book/bookinfo/abstract"); - assertNode("book/bookinfo/abstract/modexml:elementContent", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=" + longContent); - assertNode("book/programlisting1"); - assertNode("book/programlisting1/modexml:elementContent", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=<dependency> </dependency>"); - assertNode("book/programlisting2"); - assertNode("book/programlisting2/modexml:cData", "modexml:cDataContent=\n<dependency>\n</dependency>\n"); - assertNode("book/programlisting3"); - assertNode("book/programlisting3/modexml:elementContent[1]", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=mixture of text and"); - assertNode("book/programlisting3/modexml:cData", "modexml:cDataContent=\n<dependency>\n</dependency>\n"); - assertNode("book/programlisting3/modexml:elementContent[2]", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=and some text"); + assertElement("book"); + assertElement("book/bookinfo"); + assertElement("book/bookinfo/title"); + assertContent("book/bookinfo/title/modexml:elementContent", "ModeShape"); + assertElement("book/bookinfo/releaseinfo"); + assertContent("book/bookinfo/releaseinfo/modexml:elementContent", "&versionNumber;"); + assertElement("book/bookinfo/productnumber"); + assertContent("book/bookinfo/productnumber/modexml:elementContent", "some text with &versionNumber;inside"); + assertElement("book/bookinfo/abstract"); + assertContent("book/bookinfo/abstract/modexml:elementContent", longContent); + assertElement("book/programlisting1"); + assertContent("book/programlisting1/modexml:elementContent", "<dependency> </dependency>"); + assertElement("book/programlisting2"); + assertCData("book/programlisting2/modexml:cData", "modexml:cDataContent=\n<dependency>\n</dependency>\n"); + assertElement("book/programlisting3"); + assertContent("book/programlisting3/modexml:elementContent[1]", "mixture of text and"); + assertCData("book/programlisting3/modexml:cData", "modexml:cDataContent=\n<dependency>\n</dependency>\n"); + assertContent("book/programlisting3/modexml:elementContent[2]", "and some text"); assertComment("book/programlisting3/modexml:comment", "comment in content"); - assertNode("book/programlisting3/modexml:elementContent[3]", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=after."); + assertContent("book/programlisting3/modexml:elementContent[3]", "after."); assertNoMoreNodes(); } @@ -352,11 +407,11 @@ public class XmlSequencerHandlerTest { assertDocumentNode(); assertPI(1, "target", "content"); assertPI(2, "target2", "other stuff in the processing instruction"); - assertNode("Cars"); + assertElement("Cars"); assertComment("Cars/modexml:comment", "This is a comment"); - assertNode("Cars/Hybrid"); - assertNode("Cars/Hybrid/Toyota Prius"); - assertNode("Cars/Sports"); + assertElement("Cars/Hybrid"); + assertElement("Cars/Hybrid/Toyota Prius"); + assertElement("Cars/Sports"); assertNoMoreNodes(); } @@ -376,30 +431,24 @@ public class XmlSequencerHandlerTest { parse("docWithCDATA.xml"); assertDocumentNode(); assertComment("modexml:comment", "Simple example to demonstrate the CurrencyFormatter."); - assertNode("mx:Application"); - assertNode("mx:Application/mx:Script"); + assertElement("mx:Application"); + assertElement("mx:Application/mx:Script"); assertCdata("mx:Application/mx:Script/modexml:cData", cdata); // Now there's an element that contains a mixture of regular element content, CDATA content, and comments - assertNode("mx:Application/programlisting3"); - assertNode("mx:Application/programlisting3/modexml:elementContent[1]", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=mixture of text and"); - assertNode("mx:Application/programlisting3/modexml:cData", - "modexml:cDataContent=\nentities like > are not replaced in a CDATA\n\n"); - assertNode("mx:Application/programlisting3/modexml:elementContent[2]", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=and some text"); + assertElement("mx:Application/programlisting3"); + assertContent("mx:Application/programlisting3/modexml:elementContent[1]", "mixture of text and"); + assertCdata("mx:Application/programlisting3/modexml:cData", + "\nentities like > are not replaced in a CDATA\n\n"); + assertContent("mx:Application/programlisting3/modexml:elementContent[2]", "and some text"); assertComment("mx:Application/programlisting3/modexml:comment", "comment in content"); - assertNode("mx:Application/programlisting3/modexml:elementContent[3]", - "jcr:primaryType={http://www.modeshape.org/xml/1.0}elementContent", - "modexml:elementContent=after."); + assertContent("mx:Application/programlisting3/modexml:elementContent[3]", "after."); // Now the final element - assertNode("mx:Application/mx:NumberValidator", - "id=numVal", - "source={priceUS}", - "property=text", - "allowNegative=true", - "domain=real"); + assertElement("mx:Application/mx:NumberValidator", + "id=numVal", + "source={priceUS}", + "property=text", + "allowNegative=true", + "domain=real"); assertNoMoreNodes(); } @@ -415,6 +464,38 @@ public class XmlSequencerHandlerTest { } } + protected void assertElement( String path, + String... properties ) { + assertNodeWithType(path, "{http://www.modeshape.org/xml/1.0}element", properties); + } + + protected void assertCData( String path, + String... properties ) { + assertNodeWithType(path, "{http://www.modeshape.org/xml/1.0}cData", properties); + } + + protected void assertContent( String path, + String content, + String... properties ) { + String[] props = add("{http://www.modeshape.org/xml/1.0}elementContent=" + content, properties); + assertNodeWithType(path, "{http://www.modeshape.org/xml/1.0}elementContent", props); + } + + protected void assertNodeWithType( String path, + String type, + String... properties ) { + String[] props = add("jcr:primaryType=" + type, properties); + assertNode(path, props); + } + + protected String[] add( String str, + String[] array ) { + String[] props = new String[array.length + 1]; + props[0] = str; + System.arraycopy(array, 0, props, 1, array.length); + return props; + } + protected void assertNode( String path, String... properties ) { // Append an index to the path if not there ... @@ -494,7 +575,7 @@ public class XmlSequencerHandlerTest { // There should be a single property ... Property actualPrimaryType = output.getProperty(expectedPath, JcrLexicon.PRIMARY_TYPE); - assertThat(actualPrimaryType.getValues().next(), is((Object)JcrNtLexicon.UNSTRUCTURED)); + assertThat(actualPrimaryType.getValues().next(), is((Object)ModeShapeXmlLexicon.CDATA)); Property actual = output.getProperty(expectedPath, ModeShapeXmlLexicon.CDATA_CONTENT); assertThat("expected one CDATA property", actual, is(notNullValue())); Property expected = context.getPropertyFactory().create(ModeShapeXmlLexicon.CDATA_CONTENT, content); Index: extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/XmlSequencerTest.java =================================================================== --- extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/XmlSequencerTest.java (revision 2433) +++ extensions/modeshape-sequencer-xml/src/test/java/org/modeshape/sequencer/xml/XmlSequencerTest.java (working copy) @@ -49,6 +49,7 @@ public class XmlSequencerTest { private static final String DTD_NAME = "modedtd:name"; private static final String DTD_SYSTEM_ID = "modedtd:systemId"; private static final String DTD_VALUE = "modedtd:value"; + private static final String ELEMENT = "modexml:element"; private static final String ELEMENT_CONTENT = "modexml:elementContent"; private static final String ENTITY = "modedtd:entity"; private static final String PI = "modexml:processingInstruction"; @@ -93,9 +94,9 @@ public class XmlSequencerTest { @Test public void shouldHandleNamespaces() throws IOException { verifyDocument(xml2); - verifyName("book[1]/bookinfo[1]/xi:include[1]", "jcr:primaryType", "nt:unstructured"); + verifyName("book[1]/bookinfo[1]/xi:include[1]", "jcr:primaryType", ELEMENT); verifyString("book[1]/bookinfo[1]/xi:include[1]", "href", "Author_Group.xml"); - verifyName("book[1]/bookinfo[1]/xi:include[2]", "jcr:primaryType", "nt:unstructured"); + verifyName("book[1]/bookinfo[1]/xi:include[2]", "jcr:primaryType", ELEMENT); verifyString("book[1]/bookinfo[1]/xi:include[2]", "href", "Legal_Notice.xml"); } @@ -154,10 +155,10 @@ public class XmlSequencerTest { public void shouldSequenceXsds() throws IOException { sequencer.setAttributeScoping(XmlSequencer.AttributeScoping.INHERIT_ELEMENT_NAMESPACE); verifyDocument(xsd); - verifyName("xs:schema", "jcr:primaryType", "nt:unstructured"); + verifyName("xs:schema", "jcr:primaryType", ELEMENT); verifyString("xs:schema", "xs:targetNamespace", "http://ns.adobe.com/air/application/1.0"); verifyString("xs:schema", "xs:elementFormDefault", "qualified"); - verifyName("xs:schema/xs:element", "jcr:primaryType", "nt:unstructured"); + verifyName("xs:schema/xs:element", "jcr:primaryType", ELEMENT); verifyString("xs:schema/xs:element", "xs:name", "application"); } Index: extensions/modeshape-sequencer-xml/src/test/resources/docWithElementsContainingElements.xml new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ extensions/modeshape-sequencer-xml/src/test/resources/docWithElementsContainingElements.xml (working copy) @@ -0,0 +1,51 @@ + + Three Namespaces + + An Ellipse and a Rectangle + + + + + The equation for ellipses + + + + 1 + + + + + + + x + 2 + + + + a + 2 + + + + + + + y + 2 + + + + b + 2 + + + + + + + Last Modified January 10, 2002 + + + Index: extensions/modeshape-sequencer-zip/src/main/java/org/modeshape/sequencer/zip/ZipLexicon.java =================================================================== --- extensions/modeshape-sequencer-zip/src/main/java/org/modeshape/sequencer/zip/ZipLexicon.java (revision 2433) +++ extensions/modeshape-sequencer-zip/src/main/java/org/modeshape/sequencer/zip/ZipLexicon.java (working copy) @@ -15,5 +15,6 @@ public class ZipLexicon { } public static final Name CONTENT = new BasicName(Namespace.URI, "content"); + public static final Name FILE = new BasicName(Namespace.URI, "file"); } Index: extensions/modeshape-sequencer-zip/src/main/java/org/modeshape/sequencer/zip/ZipSequencer.java =================================================================== --- extensions/modeshape-sequencer-zip/src/main/java/org/modeshape/sequencer/zip/ZipSequencer.java (revision 2433) +++ extensions/modeshape-sequencer-zip/src/main/java/org/modeshape/sequencer/zip/ZipSequencer.java (working copy) @@ -31,7 +31,9 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import org.modeshape.graph.JcrLexicon; import org.modeshape.graph.JcrNtLexicon; +import org.modeshape.graph.mimetype.MimeTypeDetector; import org.modeshape.graph.property.BinaryFactory; +import org.modeshape.graph.property.DateTime; import org.modeshape.graph.property.DateTimeFactory; import org.modeshape.graph.property.Name; import org.modeshape.graph.property.NameFactory; @@ -72,6 +74,10 @@ public class ZipSequencer implements StreamSequencer { zipFileName = ZipLexicon.CONTENT; } + DateTime now = dateFactory.create(); + String username = context.getSecurityContext().getUserName(); + MimeTypeDetector mimeDetector = context.getMimeTypeDetector(); + ZipInputStream in = null; try { in = new ZipInputStream(stream); @@ -80,7 +86,7 @@ public class ZipSequencer implements StreamSequencer { // Create top-level node Path zipPath = pathFactory.createRelativePath(zipFileName); - output.setProperty(zipPath, JcrLexicon.PRIMARY_TYPE, ZipLexicon.CONTENT); + output.setProperty(zipPath, JcrLexicon.PRIMARY_TYPE, ZipLexicon.FILE); while (entry != null) { Path entryPath = zipPath; String entryName = entry.getName(); @@ -88,6 +94,12 @@ public class ZipSequencer implements StreamSequencer { entryPath = pathFactory.create(entryPath, nameFactory.create(segment)); } + // Set the timestamp and username .... + long time = entry.getTime(); + DateTime dateTime = time != -1 ? dateFactory.create(time) : now; + output.setProperty(entryPath, JcrLexicon.CREATED, dateTime); + if (username != null) output.setProperty(entryPath, JcrLexicon.CREATED_BY, username); + if (entry.isDirectory()) { // If entry is directory, create nt:folder node output.setProperty(entryPath, JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.FOLDER); } else { // If entry is File, create nt:file @@ -104,9 +116,13 @@ public class ZipSequencer implements StreamSequencer { output.setProperty(contentPath, JcrLexicon.DATA, binaryFactory.create(bytes)); // all other nt:file properties should be generated by other sequencers (mimetype, encoding,...) but we'll // default them here - output.setProperty(contentPath, JcrLexicon.ENCODING, "binary"); - output.setProperty(contentPath, JcrLexicon.LAST_MODIFIED, dateFactory.create(entry.getTime()).toString()); - output.setProperty(contentPath, JcrLexicon.MIMETYPE, "application/octet-stream"); + // output.setProperty(contentPath, JcrLexicon.ENCODING, "binary"); + output.setProperty(contentPath, JcrLexicon.LAST_MODIFIED, dateTime); + if (username != null) output.setProperty(contentPath, JcrLexicon.LAST_MODIFIED_BY, username); + + // Figure out the mime type ... + String mimeType = mimeDetector.mimeTypeOf(entryName, null); + if (mimeType != null) output.setProperty(contentPath, JcrLexicon.MIMETYPE, mimeType); } in.closeEntry(); Index: extensions/modeshape-sequencer-zip/src/main/resources/org/modeshape/sequencer/zip/zip.cnd =================================================================== --- extensions/modeshape-sequencer-zip/src/main/resources/org/modeshape/sequencer/zip/zip.cnd (revision 2433) +++ extensions/modeshape-sequencer-zip/src/main/resources/org/modeshape/sequencer/zip/zip.cnd (working copy) @@ -34,6 +34,9 @@ // N O D E T Y P E S //------------------------------------------------------------------------------ +[zip:file] > nt:folder, mix:mimeType + +/* Deprecated */ [zip:content] > nt:unstructured, mix:mimeType + * (nt:folder) + * (nt:file) Index: extensions/modeshape-sequencer-zip/src/test/java/org/modeshape/sequencer/zip/ZipSequencerTest.java =================================================================== --- extensions/modeshape-sequencer-zip/src/test/java/org/modeshape/sequencer/zip/ZipSequencerTest.java (revision 2433) +++ extensions/modeshape-sequencer-zip/src/test/java/org/modeshape/sequencer/zip/ZipSequencerTest.java (working copy) @@ -75,7 +75,7 @@ public class ZipSequencerTest { PathFactory pathFactory = context.getValueFactories().getPathFactory(); NameFactory nameFactory = context.getValueFactories().getNameFactory(); ValueFactory stringFactory = context.getValueFactories().getStringFactory(); - + Name folderName = nameFactory.create("test subfolder"); Name fileName = nameFactory.create("test2.txt"); Index: modeshape-cnd/src/main/java/org/modeshape/cnd/CndImporter.java =================================================================== --- modeshape-cnd/src/main/java/org/modeshape/cnd/CndImporter.java (revision 2433) +++ modeshape-cnd/src/main/java/org/modeshape/cnd/CndImporter.java (working copy) @@ -225,6 +225,7 @@ public class CndImporter { Path nodeTypePath = pathFactory.create(path, name); List properties = new ArrayList(); properties.add(propertyFactory.create(JcrLexicon.NODE_TYPE_NAME, name)); + properties.add(propertyFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.NODE_TYPE)); // Read the (optional) supertypes ... List supertypes = parseSupertypes(tokens); @@ -403,6 +404,7 @@ public class CndImporter { Path path = pathFactory.create(nodeTypePath, JcrLexicon.PROPERTY_DEFINITION); List properties = new ArrayList(); properties.add(propertyFactory.create(JcrLexicon.NAME, name)); + properties.add(propertyFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.PROPERTY_DEFINITION)); // Parse the (optional) required type ... parsePropertyType(tokens, properties, PropertyType.STRING.getName()); @@ -593,6 +595,7 @@ public class CndImporter { Path path = pathFactory.create(nodeTypePath, JcrLexicon.CHILD_NODE_DEFINITION); List properties = new ArrayList(); properties.add(propertyFactory.create(JcrLexicon.NAME, name)); + properties.add(propertyFactory.create(JcrLexicon.PRIMARY_TYPE, JcrNtLexicon.CHILD_NODE_DEFINITION)); parseRequiredPrimaryTypes(tokens, properties); parseDefaultType(tokens, properties); Index: modeshape-graph/src/main/java/org/modeshape/graph/query/parse/SqlQueryParser.java =================================================================== --- modeshape-graph/src/main/java/org/modeshape/graph/query/parse/SqlQueryParser.java (revision 2433) +++ modeshape-graph/src/main/java/org/modeshape/graph/query/parse/SqlQueryParser.java (working copy) @@ -1096,7 +1096,7 @@ public class SqlQueryParser implements QueryParser { } else if (tokens.canConsume("NAME", "(")) { if (tokens.canConsume(")")) { if (source instanceof Selector) { - return new NodeName(((Selector)source).name()); + return nodeName(((Selector)source).name()); } String msg = GraphI18n.functionIsAmbiguous.text("NAME()", pos.getLine(), pos.getColumn()); throw new ParsingException(pos, msg); Index: modeshape-integration-tests/pom.xml =================================================================== --- modeshape-integration-tests/pom.xml (revision 2433) +++ modeshape-integration-tests/pom.xml (working copy) @@ -119,6 +119,12 @@ org.modeshape + modeshape-sequencer-cnd + ${project.version} + test + + + org.modeshape modeshape-sequencer-classfile ${project.version} test Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/filesystem/FileSystemRepositoryDeleteTest.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/filesystem/FileSystemRepositoryDeleteTest.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/filesystem/FileSystemRepositoryDeleteTest.java (working copy) @@ -30,7 +30,6 @@ import javax.jcr.RepositoryException; import javax.jcr.Session; import org.junit.After; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.modeshape.common.FixFor; import org.modeshape.common.collection.Problem; Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/AbstractSequencerTest.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/AbstractSequencerTest.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/AbstractSequencerTest.java (working copy) @@ -151,6 +151,13 @@ public abstract class AbstractSequencerTest { } + protected void uploadFiles( String destinationPath, + String... resourcePaths ) throws Exception { + for (String resourcePath : resourcePaths) { + uploadFile(resourcePath, destinationPath); + } + } + /** * Get the sequencing statistics. * @@ -205,6 +212,7 @@ public abstract class AbstractSequencerTest { Thread.sleep(100); actualMillis += 100; } + Thread.sleep(100); fail("Expected to find " + totalNumberOfNodesSequenced + " nodes sequenced, but found " + numFound); } @@ -549,6 +557,9 @@ public abstract class AbstractSequencerTest { sb.append("/"); } else { sb.append(node.getName()); + if (node.getIndex() != 1) { + sb.append('[').append(node.getIndex()).append(']'); + } } sb.append(" jcr:primaryType=" + node.getPrimaryNodeType().getName()); boolean referenceable = false; Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/CndSequencerIntegrationTest.java new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/CndSequencerIntegrationTest.java (working copy) @@ -0,0 +1,97 @@ +/* + * ModeShape (http://www.modeshape.org) + * 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. + * + * ModeShape is free software. Unless otherwise indicated, all code in ModeShape + * 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. + * + * ModeShape 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.modeshape.test.integration.sequencer; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; +import javax.jcr.Node; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class CndSequencerIntegrationTest extends AbstractSequencerTest { + + /** + * {@inheritDoc} + * + * @see org.modeshape.test.integration.sequencer.AbstractSequencerTest#getResourcePathToConfigurationFile() + */ + @Override + protected String getResourcePathToConfigurationFile() { + return "config/configRepositoryForCndSequencing.xml"; + } + + @Before + @Override + public void beforeEach() throws Exception { + super.beforeEach(); + } + + @After + @Override + public void afterEach() { + super.afterEach(); + } + + @Test + public void shouldSequenceJsr283CndFile() throws Exception { + // print = true; + uploadFile("sequencers/cnd/jsr_283_builtins.cnd", "/files/"); + waitUntilSequencedNodesIs(1); + // printSubgraph(assertNode("/")); + + // Find the sequenced node ... + String path = "/sequenced/cnd/jsr_283_builtins.cnd"; + Node cnd = assertNode(path, "nt:unstructured"); + printSubgraph(cnd); + + Node file1 = assertNode(path + "/nt:activity", "nt:nodeType"); + assertThat(file1, is(notNullValue())); + + printQuery("SELECT * FROM [nt:nodeType]", 34); + printQuery("SELECT * FROM [nt:propertyDefinition]", 86); + printQuery("SELECT * FROM [nt:childNodeDefinition]", 10); + } + + @Test + public void shouldSequenceJsr283CndFileBelowSequencedPath() throws Exception { + // print = true; + uploadFile("sequencers/cnd/jsr_283_builtins.cnd", "/files/a/b"); + waitUntilSequencedNodesIs(1); + // printSubgraph(assertNode("/")); + + // Find the sequenced node ... + String path = "/sequenced/cnd/a/b/jsr_283_builtins.cnd"; + Node cnd = assertNode(path, "nt:unstructured"); + printSubgraph(cnd); + + Node file1 = assertNode(path + "/nt:activity", "nt:nodeType"); + assertThat(file1, is(notNullValue())); + + printQuery("SELECT * FROM [nt:nodeType]", 34); + printQuery("SELECT * FROM [nt:propertyDefinition]", 86); + printQuery("SELECT * FROM [nt:childNodeDefinition]", 10); + } +} Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/TeiidSequencerIntegrationTest.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/TeiidSequencerIntegrationTest.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/TeiidSequencerIntegrationTest.java (working copy) @@ -229,13 +229,6 @@ public class TeiidSequencerIntegrationTest extends AbstractSequencerTest { var("maxVersion", "3")); } - protected void uploadFiles( String destinationPath, - String... resourcePaths ) throws Exception { - for (String resourcePath : resourcePaths) { - uploadFile(resourcePath, destinationPath); - } - } - protected void uploadVdbs( String destinationPath, String... resourcePaths ) throws Exception { for (String resourcePath : resourcePaths) { Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/XmlSequencerIntegrationTest.java new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/XmlSequencerIntegrationTest.java (working copy) @@ -0,0 +1,105 @@ +/* + * ModeShape (http://www.modeshape.org) + * 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. + * + * ModeShape is free software. Unless otherwise indicated, all code in ModeShape + * 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. + * + * ModeShape 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.modeshape.test.integration.sequencer; + +import javax.jcr.Node; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class XmlSequencerIntegrationTest extends AbstractSequencerTest { + + /** + * {@inheritDoc} + * + * @see org.modeshape.test.integration.sequencer.AbstractSequencerTest#getResourcePathToConfigurationFile() + */ + @Override + protected String getResourcePathToConfigurationFile() { + return "config/configRepositoryForXmlSequencing.xml"; + } + + @Before + @Override + public void beforeEach() throws Exception { + super.beforeEach(); + session.getWorkspace().getNamespaceRegistry().registerNamespace("xhtml", "http://www.w3.org/1999/xhtml"); + session.getWorkspace().getNamespaceRegistry().registerNamespace("mathml", "http://www.w3.org/1998/Math/MathML"); + session.getWorkspace().getNamespaceRegistry().registerNamespace("svg", "http://www.w3.org/2000/svg"); + } + + @After + @Override + public void afterEach() { + super.afterEach(); + } + + @Test + public void shouldSequenceXmlFile() throws Exception { + // print = true; + uploadFile("jcr-import-test.xml", "/files/"); + waitUntilSequencedNodesIs(1); + // printSubgraph(assertNode("/")); + + // Find the sequenced node ... + String path = "/sequenced/xml/jcr-import-test.xml"; + Node xml = assertNode(path, "nt:unstructured"); + printSubgraph(xml); + + // Node file1 = assertNode(path + "/nt:activity", "nt:nodeType"); + // assertThat(file1, is(notNullValue())); + + printQuery("SELECT * FROM [modexml:document]", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'xhtml:head'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'xhtml:title'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'svg:ellipse'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'svg:rect'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'xhtml:p'", 2); + printQuery("SELECT * FROM [modexml:elementContent]", 13); + } + + @Test + public void shouldSequenceXmlFileBelowSequencedPath() throws Exception { + // print = true; + uploadFile("jcr-import-test.xml", "/files/a/b"); + waitUntilSequencedNodesIs(1); + // printSubgraph(assertNode("/")); + + // Find the sequenced node ... + String path = "/sequenced/xml/a/b/jcr-import-test.xml"; + Node xml = assertNode(path, "nt:unstructured"); + printSubgraph(xml); + + // Node file1 = assertNode(path + "/nt:activity", "nt:nodeType"); + // assertThat(file1, is(notNullValue())); + + printQuery("SELECT * FROM [modexml:document]", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'xhtml:head'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'xhtml:title'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'svg:ellipse'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'svg:rect'", 1); + printQuery("SELECT * FROM [modexml:element] WHERE NAME() = 'xhtml:p'", 2); + printQuery("SELECT * FROM [modexml:elementContent]", 13); + } +} Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ZipSequencerIntegrationTest.java new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ZipSequencerIntegrationTest.java (working copy) @@ -0,0 +1,135 @@ +/* + * ModeShape (http://www.modeshape.org) + * 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. + * + * ModeShape is free software. Unless otherwise indicated, all code in ModeShape + * 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. + * + * ModeShape 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.modeshape.test.integration.sequencer; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; +import javax.jcr.Node; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class ZipSequencerIntegrationTest extends AbstractSequencerTest { + + /** + * {@inheritDoc} + * + * @see org.modeshape.test.integration.sequencer.AbstractSequencerTest#getResourcePathToConfigurationFile() + */ + @Override + protected String getResourcePathToConfigurationFile() { + return "config/configRepositoryForZipSequencing.xml"; + } + + @Before + @Override + public void beforeEach() throws Exception { + super.beforeEach(); + } + + @After + @Override + public void afterEach() { + super.afterEach(); + } + + @Test + public void shouldStartEngineWithRegisteredZipNodeTypes() throws Exception { + assertNodeType("zip:content", false, false, true, false, null, 2, 0, "nt:unstructured", "mix:mimeType"); + } + + @Test + public void shouldSequenceZipFile() throws Exception { + // print = true; + uploadFile("sequencers/zip/test-files.zip", "/files/"); + waitUntilSequencedNodesIs(1); + + // Find the sequenced node ... + String path = "/sequenced/zip/test-files.zip"; + Node zipped = assertNode(path, "zip:file"); + Node file1 = assertNode(path + "/MODE-966-fix.patch", "nt:file"); + Node data1 = assertNode(path + "/MODE-966-fix.patch/jcr:content", "nt:resource"); + Node fold1 = assertNode(path + "/testFolder", "nt:folder"); + Node file2 = assertNode(path + "/testFolder/MODE-962-fix.patch", "nt:file"); + Node data2 = assertNode(path + "/testFolder/MODE-962-fix.patch/jcr:content", "nt:resource"); + Node fold3 = assertNode(path + "/testFolder/testInnerFolder", "nt:folder"); + Node file4 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix.patch", "nt:file"); + Node data4 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix.patch/jcr:content", "nt:resource"); + Node file5 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix2.patch", "nt:file"); + Node data5 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix2.patch/jcr:content", "nt:resource"); + assertThat(file1, is(notNullValue())); + assertThat(data1, is(notNullValue())); + assertThat(file2, is(notNullValue())); + assertThat(data2, is(notNullValue())); + assertThat(fold1, is(notNullValue())); + assertThat(fold3, is(notNullValue())); + assertThat(file4, is(notNullValue())); + assertThat(data4, is(notNullValue())); + assertThat(file5, is(notNullValue())); + assertThat(data5, is(notNullValue())); + printSubgraph(zipped); + + printQuery("SELECT * FROM [nt:file]", 5); + printQuery("SELECT * FROM [nt:folder]", 4); + printQuery("SELECT * FROM [zip:file]", 1); + } + + @Test + public void shouldSequenceZipFileBelowSequencedPath() throws Exception { + // print = true; + uploadFile("sequencers/zip/test-files.zip", "/files/a/b"); + waitUntilSequencedNodesIs(1); + + // Find the sequenced node ... + String path = "/sequenced/zip/a/b/test-files.zip"; + Node zipped = assertNode(path, "zip:file"); + Node file1 = assertNode(path + "/MODE-966-fix.patch", "nt:file"); + Node data1 = assertNode(path + "/MODE-966-fix.patch/jcr:content", "nt:resource"); + Node fold1 = assertNode(path + "/testFolder", "nt:folder"); + Node file2 = assertNode(path + "/testFolder/MODE-962-fix.patch", "nt:file"); + Node data2 = assertNode(path + "/testFolder/MODE-962-fix.patch/jcr:content", "nt:resource"); + Node fold3 = assertNode(path + "/testFolder/testInnerFolder", "nt:folder"); + Node file4 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix.patch", "nt:file"); + Node data4 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix.patch/jcr:content", "nt:resource"); + Node file5 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix2.patch", "nt:file"); + Node data5 = assertNode(path + "/testFolder/testInnerFolder/MODE-960-fix2.patch/jcr:content", "nt:resource"); + assertThat(file1, is(notNullValue())); + assertThat(data1, is(notNullValue())); + assertThat(file2, is(notNullValue())); + assertThat(data2, is(notNullValue())); + assertThat(fold1, is(notNullValue())); + assertThat(fold3, is(notNullValue())); + assertThat(file4, is(notNullValue())); + assertThat(data4, is(notNullValue())); + assertThat(file5, is(notNullValue())); + assertThat(data5, is(notNullValue())); + printSubgraph(zipped); + printSubgraph(assertNode("/sequenced/zip")); + + printQuery("SELECT * FROM [nt:file]", 5); + printQuery("SELECT * FROM [nt:folder]", 6); // 2 extra folders + printQuery("SELECT * FROM [zip:file]", 1); + } +} Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/DdlIntegrationTestUtil.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/DdlIntegrationTestUtil.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/DdlIntegrationTestUtil.java (working copy) @@ -29,18 +29,21 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.fail; import java.io.IOException; import java.net.URL; -import java.util.Calendar; -import javax.jcr.Binary; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; import javax.jcr.Node; import javax.jcr.NodeIterator; 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 javax.jcr.ValueFormatException; import javax.jcr.nodetype.NodeType; +import org.modeshape.common.util.StringUtil; import org.modeshape.graph.SecurityContext; import org.modeshape.jcr.JcrEngine; import org.modeshape.jcr.JcrTools; @@ -54,6 +57,7 @@ public class DdlIntegrationTestUtil { public Session session; public JcrTools tools; public static final String ddlTestResourceRootFolder = "org/modeshape/test/integration/sequencer/ddl/"; + protected boolean print = false; protected URL getUrl( String urlStr ) { return this.getClass().getClassLoader().getResource(urlStr); @@ -72,19 +76,20 @@ public class DdlIntegrationTestUtil { // Grab the last segment of the URL path, using it as the filename String filename = url.getPath().replaceAll("([^/]*/)*", ""); String nodePath = "/a/b/" + filename; - String mimeType = "ddl"; + // String mimeType = "ddl"; // Now use the JCR API to upload the file ... // Create the node at the supplied path ... - Node node = tools.findOrCreateNode(session.getRootNode(), nodePath, "nt:folder", "nt:file"); + // Node node = tools.findOrCreateNode(session.getRootNode(), nodePath, "nt:folder", "nt:file"); // Upload the file to that node ... - Node contentNode = tools.findOrCreateChild(node, "jcr:content", "nt:resource"); - contentNode.setProperty("jcr:mimeType", mimeType); - contentNode.setProperty("jcr:lastModified", Calendar.getInstance()); - Binary binary = session.getValueFactory().createBinary(url.openStream()); - contentNode.setProperty("jcr:data", binary); + tools.uploadFile(session, nodePath, url); + // Node contentNode = tools.findOrCreateChild(node, "jcr:content", "nt:resource"); + // contentNode.setProperty("jcr:mimeType", mimeType); + // contentNode.setProperty("jcr:lastModified", Calendar.getInstance()); + // Binary binary = session.getValueFactory().createBinary(url.openStream()); + // contentNode.setProperty("jcr:data", binary); // Save the session ... session.save(); @@ -434,4 +439,129 @@ public class DdlIntegrationTestUtil { String testMethod ) { System.out.println("ENDED: " + testMethod + "(" + fileName + ")"); } + + /** + * Load the subgraph below this node, and print it to System.out if printing is enabled. + * + * @param node the root of the subgraph + * @throws RepositoryException + */ + protected void printSubgraph( Node node ) throws RepositoryException { + printSubgraph(node, Integer.MAX_VALUE); + } + + /** + * Load the subgraph below this node, and print it to System.out if printing is enabled. + * + * @param node the root of the subgraph + * @param maxDepth the maximum depth of the subgraph that should be printed + * @throws RepositoryException + */ + protected void printSubgraph( Node node, + int maxDepth ) throws RepositoryException { + printSubgraph(node, " ", node.getDepth(), maxDepth); + } + + /** + * Print this node and its properties to System.out if printing is enabled. + * + * @param node the node to be printed + * @throws RepositoryException + */ + protected void printNode( Node node ) throws RepositoryException { + printSubgraph(node, " ", node.getDepth(), 1); + } + + /** + * Load the subgraph below this node, and print it to System.out if printing is enabled. + * + * @param node the root of the subgraph + * @param lead the string that each line should begin with; may be null if there is no such string + * @param depthOfSubgraph the depth of this subgraph's root node + * @param maxDepthOfSubgraph the maximum depth of the subgraph that should be printed + * @throws RepositoryException + */ + private void printSubgraph( Node node, + String lead, + int depthOfSubgraph, + int maxDepthOfSubgraph ) throws RepositoryException { + if (!print) return; + int currentDepth = node.getDepth() - depthOfSubgraph + 1; + if (currentDepth > maxDepthOfSubgraph) return; + if (lead == null) lead = ""; + String nodeLead = lead + StringUtil.createString(' ', (currentDepth - 1) * 2); + + StringBuilder sb = new StringBuilder(); + sb.append(nodeLead); + if (node.getDepth() == 0) { + sb.append("/"); + } else { + sb.append(node.getName()); + if (node.getIndex() != 1) { + sb.append('[').append(node.getIndex()).append(']'); + } + } + sb.append(" jcr:primaryType=" + node.getPrimaryNodeType().getName()); + boolean referenceable = false; + if (node.getMixinNodeTypes().length != 0) { + sb.append(" jcr:mixinTypes=["); + boolean first = true; + for (NodeType mixin : node.getMixinNodeTypes()) { + if (first) first = false; + else sb.append(','); + sb.append(mixin.getName()); + if (mixin.getName().equals("mix:referenceable")) referenceable = true; + } + sb.append(']'); + } + if (referenceable) { + sb.append(" jcr:uuid=" + node.getIdentifier()); + } + System.out.println(sb); + + List propertyNames = new LinkedList(); + for (PropertyIterator iter = node.getProperties(); iter.hasNext();) { + Property property = iter.nextProperty(); + String name = property.getName(); + if (name.equals("jcr:primaryType") || name.equals("jcr:mixinTypes") || name.equals("jcr:uuid")) continue; + propertyNames.add(property.getName()); + } + Collections.sort(propertyNames); + for (String propertyName : propertyNames) { + Property property = node.getProperty(propertyName); + sb = new StringBuilder(); + sb.append(nodeLead).append(" - ").append(propertyName).append('='); + boolean binary = property.getType() == PropertyType.BINARY; + if (property.isMultiple()) { + sb.append('['); + boolean first = true; + for (Value value : property.getValues()) { + if (first) first = false; + else sb.append(','); + if (binary) { + sb.append(value.getBinary()); + } else { + sb.append(value.getString()); + } + } + sb.append(']'); + } else { + Value value = property.getValue(); + if (binary) { + sb.append(value.getBinary()); + } else { + sb.append(value.getString()); + } + } + System.out.println(sb); + } + + if (currentDepth < maxDepthOfSubgraph) { + for (NodeIterator iter = node.getNodes(); iter.hasNext();) { + Node child = iter.nextNode(); + printSubgraph(child, lead, depthOfSubgraph, maxDepthOfSubgraph); + } + } + } + } Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java (working copy) @@ -57,12 +57,13 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { @Before public void beforeEach() throws Exception { + print = false; + tools = new JcrTools(); + // Configure the ModeShape configuration. This could be done by loading a configuration from a file, or by // using a (local or remote) configuration repository, or by setting up the configuration programmatically. // This test uses the programmatic approach... - tools = new JcrTools(); - repositoryName = "ddlRepository"; workspaceName = "default"; String repositorySource = "ddlRepositorySource"; @@ -75,7 +76,7 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { .setProperty("defaultWorkspaceName", workspaceName); // Set up the JCR repository to use the source ... config.repository(repositoryName) - .addNodeTypes(getUrl(ddlTestResourceRootFolder + "StandardDdl.cnd")) + .addNodeTypes(getUrl("org/modeshape/sequencer/ddl/StandardDdl.cnd")) .registerNamespace(StandardDdlLexicon.Namespace.PREFIX, StandardDdlLexicon.Namespace.URI) .setSource(repositorySource); // Set up the DDL sequencer ... @@ -83,7 +84,7 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { .usingClass("org.modeshape.sequencer.ddl.DdlSequencer") .loadedFromClasspath() .setDescription("Sequences DDL files to extract individual statements and accompanying statement properties and values") - .sequencingFrom("//(*.(ddl)[*])/jcr:content[@jcr:data]") + .sequencingFrom("(//(*.(ddl)[*]))/jcr:content[@jcr:data]") .andOutputtingTo("/ddls/$1"); config.save(); this.engine = config.build(); @@ -110,6 +111,7 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { uploadFile(ddlTestResourceRootFolder, "create_schema.ddl", "shouldSequenceCreateSchemaDdlFile"); waitUntilSequencedNodesIs(1); + // print = true; // Find the node ... Node root = session.getRootNode(); @@ -117,6 +119,7 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { if (root.hasNode("ddls")) { if (root.hasNode("ddls")) { Node ddlsNode = root.getNode("ddls"); + printSubgraph(ddlsNode); // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { Node ddlNode = iter.nextNode(); @@ -142,7 +145,7 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { Node root = session.getRootNode(); if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); + Node ddlsNode = root.getNode("ddls/a/b"); // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { Node ddlNode = iter.nextNode(); @@ -231,32 +234,29 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { Node root = session.getRootNode(); if (root.hasNode("ddls")) { - if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); - // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); - for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { - Node ddlNode = iter.nextNode(); - - // printNodeProperties(ddlNode); - - long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); - assertEquals(numStatements, 4); + Node ddlsNode = root.getNode("ddls/a/b"); + // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); + for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { + Node ddlNode = iter.nextNode(); - // GRANT SELECT ON TABLE purchaseOrders TO maria,harry; - Node grantNode = assertNode(ddlNode, "purchaseOrders", "ddl:grantOnTableStatement"); - assertNode(grantNode, "maria", "ddl:grantee"); - Node privNode = assertNode(grantNode, "privilege", "ddl:grantPrivilege"); - verifySingleValueProperty(privNode, "ddl:type", "SELECT"); + // printNodeProperties(ddlNode); - // GRANT UPDATE, USAGE ON TABLE purchaseOrders FROM anita,zhi; - grantNode = assertNode(ddlNode, "billedOrders", "ddl:grantOnTableStatement"); - privNode = assertNode(grantNode, "privilege", "ddl:grantPrivilege"); - verifySingleValueProperty(privNode, "ddl:type", "UPDATE"); - assertNode(grantNode, "anita", "ddl:grantee"); - } + long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); + assertEquals(numStatements, 4); + + // GRANT SELECT ON TABLE purchaseOrders TO maria,harry; + Node grantNode = assertNode(ddlNode, "purchaseOrders", "ddl:grantOnTableStatement"); + assertNode(grantNode, "maria", "ddl:grantee"); + Node privNode = assertNode(grantNode, "privilege", "ddl:grantPrivilege"); + verifySingleValueProperty(privNode, "ddl:type", "SELECT"); + + // GRANT UPDATE, USAGE ON TABLE purchaseOrders FROM anita,zhi; + grantNode = assertNode(ddlNode, "billedOrders", "ddl:grantOnTableStatement"); + privNode = assertNode(grantNode, "privilege", "ddl:grantPrivilege"); + verifySingleValueProperty(privNode, "ddl:type", "UPDATE"); + assertNode(grantNode, "anita", "ddl:grantee"); } } - } @Test @@ -270,29 +270,27 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { Node root = session.getRootNode(); if (root.hasNode("ddls")) { - if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); - // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); - for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { - Node ddlNode = iter.nextNode(); - - // printNodeProperties(ddlNode); - - long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); - assertEquals(numStatements, 4); + Node ddlsNode = root.getNode("ddls/a/b"); + // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); + for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { + Node ddlNode = iter.nextNode(); - // REVOKE SELECT ON TABLE purchaseOrders FROM maria,harry; - Node revokeNode = assertNode(ddlNode, "purchaseOrders", "ddl:revokeOnTableStatement"); - assertNode(revokeNode, "maria", "ddl:grantee"); - Node privNode = assertNode(revokeNode, "privilege", "ddl:grantPrivilege"); - verifySingleValueProperty(privNode, "ddl:type", "SELECT"); + // printNodeProperties(ddlNode); - // REVOKE UPDATE, USAGE ON TABLE purchaseOrders FROM anita,zhi CASCADE; - revokeNode = assertNode(ddlNode, "orderDetails", "ddl:revokeOnTableStatement"); - privNode = assertNode(revokeNode, "privilege", "ddl:grantPrivilege"); - verifySingleValueProperty(privNode, "ddl:type", "UPDATE"); - assertNode(revokeNode, "anita", "ddl:grantee"); - } + long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); + assertEquals(numStatements, 4); + + // REVOKE SELECT ON TABLE purchaseOrders FROM maria,harry; + Node revokeNode = assertNode(ddlNode, "purchaseOrders", "ddl:revokeOnTableStatement"); + assertNode(revokeNode, "maria", "ddl:grantee"); + Node privNode = assertNode(revokeNode, "privilege", "ddl:grantPrivilege"); + verifySingleValueProperty(privNode, "ddl:type", "SELECT"); + + // REVOKE UPDATE, USAGE ON TABLE purchaseOrders FROM anita,zhi CASCADE; + revokeNode = assertNode(ddlNode, "orderDetails", "ddl:revokeOnTableStatement"); + privNode = assertNode(revokeNode, "privilege", "ddl:grantPrivilege"); + verifySingleValueProperty(privNode, "ddl:type", "UPDATE"); + assertNode(revokeNode, "anita", "ddl:grantee"); } } } @@ -308,58 +306,56 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { Node root = session.getRootNode(); if (root.hasNode("ddls")) { - if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); - // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); - for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { - Node ddlNode = iter.nextNode(); + Node ddlsNode = root.getNode("ddls/a/b"); + // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); + for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { + Node ddlNode = iter.nextNode(); - // printNodeProperties(ddlNode); + // printNodeProperties(ddlNode); - long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); - assertEquals(numStatements, 14); - - // ALTER TABLE table_name_1 ADD COLUMN column_name VARCHAR(25) NOT NULL; - Node alterNode = assertNode(ddlNode, "table_name_1", "ddl:alterTableStatement"); - assertEquals(alterNode.getNodes().getSize(), 1); - Node addColumnNode = assertNode(alterNode, "column_name", "ddl:columnDefinition"); - verifySingleValueProperty(addColumnNode, "ddl:datatypeName", "VARCHAR"); - verifySingleValueProperty(addColumnNode, "ddl:datatypeLength", 25); - verifySingleValueProperty(addColumnNode, "ddl:nullable", "NOT NULL"); - - // ALTER TABLE schema_2.table_name_2 ADD schema_2.table_name_2.column_name INTEGER NOT NULL DEFAULT (25); - alterNode = assertNode(ddlNode, "schema_2.table_name_2", "ddl:alterTableStatement"); - assertEquals(alterNode.getNodes().getSize(), 1); - addColumnNode = assertNode(alterNode, "schema_2.table_name_2.column_name", "ddl:columnDefinition"); - verifySingleValueProperty(addColumnNode, "ddl:datatypeName", "INTEGER"); - verifySingleValueProperty(addColumnNode, "ddl:nullable", "NOT NULL"); - verifySingleValueProperty(addColumnNode, "ddl:defaultValue", "25"); - - // ALTER TABLE table_name_4 ALTER COLUMN column_name SET DEFAULT (0); - alterNode = assertNode(ddlNode, "table_name_4", "ddl:alterTableStatement"); - assertEquals(alterNode.getNodes().getSize(), 1); - addColumnNode = assertNode(alterNode, "column_name", "ddl:alterColumnDefinition"); - verifySingleValueProperty(addColumnNode, "ddl:defaultValue", "0"); - - // ALTER TABLE table_name_7 DROP COLUMN column_name RESTRICT; - alterNode = assertNode(ddlNode, "table_name_7", "ddl:alterTableStatement"); - assertEquals(alterNode.getNodes().getSize(), 1); - Node dropColumnNode = assertNode(alterNode, "column_name", "ddl:dropColumnDefinition"); - verifySingleValueProperty(dropColumnNode, "ddl:dropBehavior", "RESTRICT"); - - // ALTER TABLE table_name_10 ADD CONSTRAINT pk_name PRIMARY KEY (column_name); - alterNode = assertNode(ddlNode, "table_name_10", "ddl:alterTableStatement"); - assertEquals(alterNode.getNodes().getSize(), 1); - Node constraintNode = assertNode(alterNode, "pk_name", "ddl:addTableConstraintDefinition"); - verifySingleValueProperty(constraintNode, "ddl:constraintType", "PRIMARY KEY"); - assertNode(constraintNode, "column_name", "ddl:columnReference"); - - // ALTER TABLE table_name_14 DROP CONSTRAINT fk_name RESTRICT; - alterNode = assertNode(ddlNode, "table_name_14", "ddl:alterTableStatement"); - assertEquals(alterNode.getNodes().getSize(), 1); - Node dropConstraintNode = assertNode(alterNode, "fk_name", "ddl:dropTableConstraintDefinition"); - verifySingleValueProperty(dropConstraintNode, "ddl:dropBehavior", "RESTRICT"); - } + long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); + assertEquals(numStatements, 14); + + // ALTER TABLE table_name_1 ADD COLUMN column_name VARCHAR(25) NOT NULL; + Node alterNode = assertNode(ddlNode, "table_name_1", "ddl:alterTableStatement"); + assertEquals(alterNode.getNodes().getSize(), 1); + Node addColumnNode = assertNode(alterNode, "column_name", "ddl:columnDefinition"); + verifySingleValueProperty(addColumnNode, "ddl:datatypeName", "VARCHAR"); + verifySingleValueProperty(addColumnNode, "ddl:datatypeLength", 25); + verifySingleValueProperty(addColumnNode, "ddl:nullable", "NOT NULL"); + + // ALTER TABLE schema_2.table_name_2 ADD schema_2.table_name_2.column_name INTEGER NOT NULL DEFAULT (25); + alterNode = assertNode(ddlNode, "schema_2.table_name_2", "ddl:alterTableStatement"); + assertEquals(alterNode.getNodes().getSize(), 1); + addColumnNode = assertNode(alterNode, "schema_2.table_name_2.column_name", "ddl:columnDefinition"); + verifySingleValueProperty(addColumnNode, "ddl:datatypeName", "INTEGER"); + verifySingleValueProperty(addColumnNode, "ddl:nullable", "NOT NULL"); + verifySingleValueProperty(addColumnNode, "ddl:defaultValue", "25"); + + // ALTER TABLE table_name_4 ALTER COLUMN column_name SET DEFAULT (0); + alterNode = assertNode(ddlNode, "table_name_4", "ddl:alterTableStatement"); + assertEquals(alterNode.getNodes().getSize(), 1); + addColumnNode = assertNode(alterNode, "column_name", "ddl:alterColumnDefinition"); + verifySingleValueProperty(addColumnNode, "ddl:defaultValue", "0"); + + // ALTER TABLE table_name_7 DROP COLUMN column_name RESTRICT; + alterNode = assertNode(ddlNode, "table_name_7", "ddl:alterTableStatement"); + assertEquals(alterNode.getNodes().getSize(), 1); + Node dropColumnNode = assertNode(alterNode, "column_name", "ddl:dropColumnDefinition"); + verifySingleValueProperty(dropColumnNode, "ddl:dropBehavior", "RESTRICT"); + + // ALTER TABLE table_name_10 ADD CONSTRAINT pk_name PRIMARY KEY (column_name); + alterNode = assertNode(ddlNode, "table_name_10", "ddl:alterTableStatement"); + assertEquals(alterNode.getNodes().getSize(), 1); + Node constraintNode = assertNode(alterNode, "pk_name", "ddl:addTableConstraintDefinition"); + verifySingleValueProperty(constraintNode, "ddl:constraintType", "PRIMARY KEY"); + assertNode(constraintNode, "column_name", "ddl:columnReference"); + + // ALTER TABLE table_name_14 DROP CONSTRAINT fk_name RESTRICT; + alterNode = assertNode(ddlNode, "table_name_14", "ddl:alterTableStatement"); + assertEquals(alterNode.getNodes().getSize(), 1); + Node dropConstraintNode = assertNode(alterNode, "fk_name", "ddl:dropTableConstraintDefinition"); + verifySingleValueProperty(dropConstraintNode, "ddl:dropBehavior", "RESTRICT"); } } } @@ -404,7 +400,7 @@ public class DdlSequencerIntegrationTest extends DdlIntegrationTestUtil { QueryResult result = query.execute(); // System.out.println(result); assertThat(result, is(notNullValue())); - assertThat(result.getRows().getSize(), is(14L)); + assertThat(result.getRows().getSize(), is(16L)); RowIterator iter = result.getRows(); String primaryType = ""; while (iter.hasNext()) { Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/derby/DerbyDdlSequencerIntegrationTest.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/derby/DerbyDdlSequencerIntegrationTest.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/derby/DerbyDdlSequencerIntegrationTest.java (working copy) @@ -58,22 +58,30 @@ public class DerbyDdlSequencerIntegrationTest extends DdlIntegrationTestUtil { JcrConfiguration config = new JcrConfiguration(); // Set up the in-memory source where we'll upload the content and where the sequenced output will be stored ... - config.repositorySource(repositorySource).usingClass(InMemoryRepositorySource.class).setDescription("The repository for our content").setProperty("defaultWorkspaceName", - workspaceName); + config.repositorySource(repositorySource) + .usingClass(InMemoryRepositorySource.class) + .setDescription("The repository for our content") + .setProperty("defaultWorkspaceName", workspaceName); // Set up the JCR repository to use the source ..protected. - config.repository(repositoryName).addNodeTypes(getUrl(ddlTestResourceRootFolder + "StandardDdl.cnd")).addNodeTypes(getUrl(resourceFolder - + "DerbyDdl.cnd")).registerNamespace(StandardDdlLexicon.Namespace.PREFIX, - StandardDdlLexicon.Namespace.URI).registerNamespace(DerbyDdlLexicon.Namespace.PREFIX, - DerbyDdlLexicon.Namespace.URI).setSource(repositorySource); + config.repository(repositoryName) + .addNodeTypes(getUrl("org/modeshape/sequencer/ddl/StandardDdl.cnd")) + .addNodeTypes(getUrl(resourceFolder + "DerbyDdl.cnd")) + .registerNamespace(StandardDdlLexicon.Namespace.PREFIX, StandardDdlLexicon.Namespace.URI) + .registerNamespace(DerbyDdlLexicon.Namespace.PREFIX, DerbyDdlLexicon.Namespace.URI) + .setSource(repositorySource); // Set up the DDL sequencer ... - config.sequencer("DDL Sequencer").usingClass("org.modeshape.sequencer.ddl.DdlSequencer").loadedFromClasspath().setDescription("Sequences DDL files to extract individual statements and accompanying statement properties and values").sequencingFrom("//(*.(ddl)[*])/jcr:content[@jcr:data]").andOutputtingTo("/ddls/$1"); + config.sequencer("DDL Sequencer") + .usingClass("org.modeshape.sequencer.ddl.DdlSequencer") + .loadedFromClasspath() + .setDescription("Sequences DDL files to extract individual statements and accompanying statement properties and values") + .sequencingFrom("(//(*.(ddl)[*]))/jcr:content[@jcr:data]") + .andOutputtingTo("/ddls/$1"); config.save(); this.engine = config.build(); this.engine.start(); - this.session = this.engine.getRepository(repositoryName).login(new JcrSecurityContextCredentials( - new MyCustomSecurityContext()), - workspaceName); + this.session = this.engine.getRepository(repositoryName) + .login(new JcrSecurityContextCredentials(new MyCustomSecurityContext()), workspaceName); } @@ -99,7 +107,7 @@ public class DerbyDdlSequencerIntegrationTest extends DdlIntegrationTestUtil { if (root.hasNode("ddls")) { if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); + Node ddlsNode = root.getNode("ddls/a/b"); // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { Node ddlNode = iter.nextNode(); Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/oracle/OracleDdlSequencerIntegrationTest.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/oracle/OracleDdlSequencerIntegrationTest.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/oracle/OracleDdlSequencerIntegrationTest.java (working copy) @@ -57,22 +57,30 @@ public class OracleDdlSequencerIntegrationTest extends DdlIntegrationTestUtil { JcrConfiguration config = new JcrConfiguration(); // Set up the in-memory source where we'll upload the content and where the sequenced output will be stored ... - config.repositorySource(repositorySource).usingClass(InMemoryRepositorySource.class).setDescription("The repository for our content").setProperty("defaultWorkspaceName", - workspaceName); + config.repositorySource(repositorySource) + .usingClass(InMemoryRepositorySource.class) + .setDescription("The repository for our content") + .setProperty("defaultWorkspaceName", workspaceName); // Set up the JCR repository to use the source ... - config.repository(repositoryName).addNodeTypes(getUrl(ddlTestResourceRootFolder + "StandardDdl.cnd")).addNodeTypes(getUrl(resourceFolder - + "OracleDdl.cnd")).registerNamespace(StandardDdlLexicon.Namespace.PREFIX, - StandardDdlLexicon.Namespace.URI).registerNamespace(OracleDdlLexicon.Namespace.PREFIX, - OracleDdlLexicon.Namespace.URI).setSource(repositorySource); + config.repository(repositoryName) + .addNodeTypes(getUrl("org/modeshape/sequencer/ddl/StandardDdl.cnd")) + .addNodeTypes(getUrl(resourceFolder + "OracleDdl.cnd")) + .registerNamespace(StandardDdlLexicon.Namespace.PREFIX, StandardDdlLexicon.Namespace.URI) + .registerNamespace(OracleDdlLexicon.Namespace.PREFIX, OracleDdlLexicon.Namespace.URI) + .setSource(repositorySource); // Set up the DDL sequencer ... - config.sequencer("DDL Sequencer").usingClass("org.modeshape.sequencer.ddl.DdlSequencer").loadedFromClasspath().setDescription("Sequences DDL files to extract individual statements and accompanying statement properties and values").sequencingFrom("//(*.(ddl)[*])/jcr:content[@jcr:data]").andOutputtingTo("/ddls/$1"); + config.sequencer("DDL Sequencer") + .usingClass("org.modeshape.sequencer.ddl.DdlSequencer") + .loadedFromClasspath() + .setDescription("Sequences DDL files to extract individual statements and accompanying statement properties and values") + .sequencingFrom("(//(*.(ddl)[*]))/jcr:content[@jcr:data]") + .andOutputtingTo("/ddls/$1"); config.save(); this.engine = config.build(); this.engine.start(); - this.session = this.engine.getRepository(repositoryName).login(new JcrSecurityContextCredentials( - new MyCustomSecurityContext()), - workspaceName); + this.session = this.engine.getRepository(repositoryName) + .login(new JcrSecurityContextCredentials(new MyCustomSecurityContext()), workspaceName); } @@ -97,25 +105,23 @@ public class OracleDdlSequencerIntegrationTest extends DdlIntegrationTestUtil { Node root = session.getRootNode(); if (root.hasNode("ddls")) { - if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); - // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); - for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { - Node ddlNode = iter.nextNode(); - - long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); - assertEquals(numStatements, 50); - - // printNodeProperties(ddlNode); - - verifyNode(ddlNode, "address", "ddl:startLineNumber"); - verifyNode(ddlNode, "cust_orders", "ddl:expression"); - verifyMixin(ddlNode, "cust_orders", "oracleddl:createIndexStatement"); - verifyNodeType(ddlNode, "cust_orders", "oracleddl:createIndexStatement"); - verifyNodeType(ddlNode, "cust_orders", "ddl:creatable"); - verifyNode(ddlNode, "cust_orders", "ddl:startCharIndex", 1698); - verifyNode(ddlNode, "customers_dim", "ddl:startColumnNumber"); - } + Node ddlsNode = root.getNode("ddls/a/b"); + // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); + for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { + Node ddlNode = iter.nextNode(); + + long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); + assertEquals(numStatements, 50); + + // printNodeProperties(ddlNode); + + verifyNode(ddlNode, "address", "ddl:startLineNumber"); + verifyNode(ddlNode, "cust_orders", "ddl:expression"); + verifyMixin(ddlNode, "cust_orders", "oracleddl:createIndexStatement"); + verifyNodeType(ddlNode, "cust_orders", "oracleddl:createIndexStatement"); + verifyNodeType(ddlNode, "cust_orders", "ddl:creatable"); + verifyNode(ddlNode, "cust_orders", "ddl:startCharIndex", 1698); + verifyNode(ddlNode, "customers_dim", "ddl:startColumnNumber"); } } } @@ -131,67 +137,65 @@ public class OracleDdlSequencerIntegrationTest extends DdlIntegrationTestUtil { Node root = session.getRootNode(); if (root.hasNode("ddls")) { - if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); - // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); - for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { - Node ddlNode = iter.nextNode(); - - long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); - assertEquals(4, numStatements); - - // printNodeProperties(ddlNode); - // remove_emp - // employee_id - - Node node = assertNode(ddlNode, "remove_emp", "oracleddl:createProcedureStatement"); - assertEquals(1, node.getNodes().getSize()); - Node paramNode = assertNode(node, "employee_id", "oracleddl:functionParameter"); - verifySimpleStringProperty(paramNode, "ddl:datatypeName", "NUMBER"); - - // find_root - // x - node = assertNode(ddlNode, "find_root", "oracleddl:createProcedureStatement"); - assertEquals(1, node.getNodes().getSize()); - paramNode = assertNode(node, "x", "oracleddl:functionParameter"); - verifySimpleStringProperty(paramNode, "ddl:datatypeName", "REAL"); - verifySimpleStringProperty(paramNode, "oracleddl:inOutNoCopy", "IN"); - - // CREATE FUNCTION SecondMax (input NUMBER) RETURN NUMBER - // PARALLEL_ENABLE AGGREGATE USING SecondMaxImpl; - node = assertNode(ddlNode, "SecondMax", "oracleddl:createFunctionStatement"); - assertEquals(1, node.getNodes().getSize()); - paramNode = assertNode(node, "input", "oracleddl:functionParameter"); - verifySimpleStringProperty(paramNode, "ddl:datatypeName", "NUMBER"); - - // CREATE OR REPLACE FUNCTION text_length(a CLOB) - // RETURN NUMBER DETERMINISTIC IS - // BEGIN - // RETURN DBMS_LOB.GETLENGTH(a); - // END; - // / - node = assertNode(ddlNode, "text_length", "oracleddl:createFunctionStatement"); - assertEquals(1, node.getNodes().getSize()); - verifySimpleStringProperty(node, "ddl:datatypeName", "NUMBER"); - paramNode = assertNode(node, "a", "oracleddl:functionParameter"); - verifySimpleStringProperty(paramNode, "ddl:datatypeName", "CLOB"); - } + Node ddlsNode = root.getNode("ddls/a/b"); + // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); + for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { + Node ddlNode = iter.nextNode(); + + long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); + assertEquals(4, numStatements); + + // printNodeProperties(ddlNode); + // remove_emp + // employee_id + + Node node = assertNode(ddlNode, "remove_emp", "oracleddl:createProcedureStatement"); + assertEquals(1, node.getNodes().getSize()); + Node paramNode = assertNode(node, "employee_id", "oracleddl:functionParameter"); + verifySimpleStringProperty(paramNode, "ddl:datatypeName", "NUMBER"); + + // find_root + // x + node = assertNode(ddlNode, "find_root", "oracleddl:createProcedureStatement"); + assertEquals(1, node.getNodes().getSize()); + paramNode = assertNode(node, "x", "oracleddl:functionParameter"); + verifySimpleStringProperty(paramNode, "ddl:datatypeName", "REAL"); + verifySimpleStringProperty(paramNode, "oracleddl:inOutNoCopy", "IN"); + + // CREATE FUNCTION SecondMax (input NUMBER) RETURN NUMBER + // PARALLEL_ENABLE AGGREGATE USING SecondMaxImpl; + node = assertNode(ddlNode, "SecondMax", "oracleddl:createFunctionStatement"); + assertEquals(1, node.getNodes().getSize()); + paramNode = assertNode(node, "input", "oracleddl:functionParameter"); + verifySimpleStringProperty(paramNode, "ddl:datatypeName", "NUMBER"); + + // CREATE OR REPLACE FUNCTION text_length(a CLOB) + // RETURN NUMBER DETERMINISTIC IS + // BEGIN + // RETURN DBMS_LOB.GETLENGTH(a); + // END; + // / + node = assertNode(ddlNode, "text_length", "oracleddl:createFunctionStatement"); + assertEquals(1, node.getNodes().getSize()); + verifySimpleStringProperty(node, "ddl:datatypeName", "NUMBER"); + paramNode = assertNode(node, "a", "oracleddl:functionParameter"); + verifySimpleStringProperty(paramNode, "ddl:datatypeName", "CLOB"); } } } Index: modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/postgres/PostgresDdlSequencerIntegrationTest.java =================================================================== --- modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/postgres/PostgresDdlSequencerIntegrationTest.java (revision 2433) +++ modeshape-integration-tests/src/test/java/org/modeshape/test/integration/sequencer/ddl/dialect/postgres/PostgresDdlSequencerIntegrationTest.java (working copy) @@ -58,22 +58,30 @@ public class PostgresDdlSequencerIntegrationTest extends DdlIntegrationTestUtil JcrConfiguration config = new JcrConfiguration(); // Set up the in-memory source where we'll upload the content and where the sequenced output will be stored ... - config.repositorySource(repositorySource).usingClass(InMemoryRepositorySource.class).setDescription("The repository for our content").setProperty("defaultWorkspaceName", - workspaceName); + config.repositorySource(repositorySource) + .usingClass(InMemoryRepositorySource.class) + .setDescription("The repository for our content") + .setProperty("defaultWorkspaceName", workspaceName); // Set up the JCR repository to use the source ... - config.repository(repositoryName).addNodeTypes(getUrl(ddlTestResourceRootFolder + "StandardDdl.cnd")).addNodeTypes(getUrl(resourceFolder - + "PostgresDdl.cnd")).registerNamespace(StandardDdlLexicon.Namespace.PREFIX, - StandardDdlLexicon.Namespace.URI).registerNamespace(PostgresDdlLexicon.Namespace.PREFIX, - PostgresDdlLexicon.Namespace.URI).setSource(repositorySource); + config.repository(repositoryName) + .addNodeTypes(getUrl("org/modeshape/sequencer/ddl/StandardDdl.cnd")) + .addNodeTypes(getUrl(resourceFolder + "PostgresDdl.cnd")) + .registerNamespace(StandardDdlLexicon.Namespace.PREFIX, StandardDdlLexicon.Namespace.URI) + .registerNamespace(PostgresDdlLexicon.Namespace.PREFIX, PostgresDdlLexicon.Namespace.URI) + .setSource(repositorySource); // Set up the DDL sequencer ... - config.sequencer("DDL Sequencer").usingClass("org.modeshape.sequencer.ddl.DdlSequencer").loadedFromClasspath().setDescription("Sequences DDL files to extract individual statements and accompanying statement properties and values").sequencingFrom("//(*.(ddl)[*])/jcr:content[@jcr:data]").andOutputtingTo("/ddls/$1"); + config.sequencer("DDL Sequencer") + .usingClass("org.modeshape.sequencer.ddl.DdlSequencer") + .loadedFromClasspath() + .setDescription("Sequences DDL files to extract individual statements and accompanying statement properties and values") + .sequencingFrom("(//(*.(ddl)[*]))/jcr:content[@jcr:data]") + .andOutputtingTo("/ddls/$1"); config.save(); this.engine = config.build(); this.engine.start(); - this.session = this.engine.getRepository(repositoryName).login(new JcrSecurityContextCredentials( - new MyCustomSecurityContext()), - workspaceName); + this.session = this.engine.getRepository(repositoryName) + .login(new JcrSecurityContextCredentials(new MyCustomSecurityContext()), workspaceName); } @@ -98,46 +106,44 @@ public class PostgresDdlSequencerIntegrationTest extends DdlIntegrationTestUtil Node root = session.getRootNode(); if (root.hasNode("ddls")) { - if (root.hasNode("ddls")) { - Node ddlsNode = root.getNode("ddls"); - // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); - for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { - Node ddlNode = iter.nextNode(); - - long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); - assertEquals(numStatements, 106); - - // printNodeProperties(ddlNode); - - verifyNodeType(ddlNode, "increment", "postgresddl:createFunctionStatement"); - verifyNode(ddlNode, "increment", "ddl:expression"); - verifyNodeType(ddlNode, "increment", "ddl:creatable"); - verifyNodeType(ddlNode, "increment", "postgresddl:functionOperand"); - verifyNode(ddlNode, "increment", "ddl:startLineNumber", 214); - verifyNode(ddlNode, "increment", "ddl:startCharIndex", 7604); - - // COMMENT ON FUNCTION my_function (timestamp) IS ’Returns Roman Numeral’; - verifyNodeType(ddlNode, "my_function", "postgresddl:commentOnStatement"); - verifyNode(ddlNode, "my_function", "ddl:expression"); - verifyNodeType(ddlNode, "my_function", "postgresddl:commentOperand"); - verifyNode(ddlNode, "my_function", "ddl:startLineNumber", 44); - verifyNode(ddlNode, "my_function", "ddl:startCharIndex", 1573); - verifyNode(ddlNode, "my_function", "postgresddl:comment", "'Returns Roman Numeral'"); - - // ALTER TABLE foreign_companies RENAME COLUMN address TO city; - Node alterTableNode = findNode(ddlNode, "foreign_companies", "postgresddl:alterTableStatement"); - assertNotNull(alterTableNode); - Node renameColNode = findNode(alterTableNode, "address", "postgresddl:renamedColumn"); - assertNotNull(renameColNode); - verifySingleValueProperty(renameColNode, "ddl:newName", "city"); - - // GRANT EXECUTE ON FUNCTION divideByTwo(numerator int, IN demoninator int) TO george; - Node grantNode = findNode(ddlNode, "divideByTwo", "postgresddl:grantOnFunctionStatement"); - assertNotNull(grantNode); - Node parameter_1 = findNode(grantNode, "numerator", "postgresddl:functionParameter"); - assertNotNull(parameter_1); - verifySingleValueProperty(parameter_1, "ddl:datatypeName", "int"); - } + Node ddlsNode = root.getNode("ddls/a/b"); + // System.out.println(" | NAME: " + ddlsNode.getName() + " PATH: " + ddlsNode.getPath()); + for (NodeIterator iter = ddlsNode.getNodes(); iter.hasNext();) { + Node ddlNode = iter.nextNode(); + + long numStatements = ddlNode.getNodes().nextNode().getNodes().getSize(); + assertEquals(numStatements, 106); + + // printNodeProperties(ddlNode); + + verifyNodeType(ddlNode, "increment", "postgresddl:createFunctionStatement"); + verifyNode(ddlNode, "increment", "ddl:expression"); + verifyNodeType(ddlNode, "increment", "ddl:creatable"); + verifyNodeType(ddlNode, "increment", "postgresddl:functionOperand"); + verifyNode(ddlNode, "increment", "ddl:startLineNumber", 214); + verifyNode(ddlNode, "increment", "ddl:startCharIndex", 7604); + + // COMMENT ON FUNCTION my_function (timestamp) IS ’Returns Roman Numeral’; + verifyNodeType(ddlNode, "my_function", "postgresddl:commentOnStatement"); + verifyNode(ddlNode, "my_function", "ddl:expression"); + verifyNodeType(ddlNode, "my_function", "postgresddl:commentOperand"); + verifyNode(ddlNode, "my_function", "ddl:startLineNumber", 44); + verifyNode(ddlNode, "my_function", "ddl:startCharIndex", 1573); + verifyNode(ddlNode, "my_function", "postgresddl:comment", "'Returns Roman Numeral'"); + + // ALTER TABLE foreign_companies RENAME COLUMN address TO city; + Node alterTableNode = findNode(ddlNode, "foreign_companies", "postgresddl:alterTableStatement"); + assertNotNull(alterTableNode); + Node renameColNode = findNode(alterTableNode, "address", "postgresddl:renamedColumn"); + assertNotNull(renameColNode); + verifySingleValueProperty(renameColNode, "ddl:newName", "city"); + + // GRANT EXECUTE ON FUNCTION divideByTwo(numerator int, IN demoninator int) TO george; + Node grantNode = findNode(ddlNode, "divideByTwo", "postgresddl:grantOnFunctionStatement"); + assertNotNull(grantNode); + Node parameter_1 = findNode(grantNode, "numerator", "postgresddl:functionParameter"); + assertNotNull(parameter_1); + verifySingleValueProperty(parameter_1, "ddl:datatypeName", "int"); } } } Index: modeshape-integration-tests/src/test/resources/config/configRepositoryForCndSequencing.xml new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/resources/config/configRepositoryForCndSequencing.xml (working copy) @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + + + + Sequences CND files loaded into the repository under '/files', extracting the contained node type definitions. + /files(//(*.cnd[*]))/jcr:content[@jcr:data] => /sequenced/cnd/$1 + + + Index: modeshape-integration-tests/src/test/resources/config/configRepositoryForXmlSequencing.xml new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/resources/config/configRepositoryForXmlSequencing.xml (working copy) @@ -0,0 +1,54 @@ + + + + + + + + + + + /org/modeshape/sequencer/xml/xml.cnd + + + + + + + + + + + + + Sequences XML files loaded into the repository under '/files', extracting the contents into the equivalent JCR graph structure. + /files(//(*.xml[*]))/jcr:content[@jcr:data] => /sequenced/xml/$1 + + + Index: modeshape-integration-tests/src/test/resources/config/configRepositoryForZipSequencing.xml new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/resources/config/configRepositoryForZipSequencing.xml (working copy) @@ -0,0 +1,54 @@ + + + + + + + + + + + /org/modeshape/sequencer/zip/zip.cnd + + + + + + + + + + + + + Sequences ZIP files loaded into the repository under '/files', extracting the archive file contents into the equivalent JCR graph structure of 'nt:file' and 'nt:folder' nodes. + /files(//)(*.zip[*])/jcr:content[@jcr:data] => /sequenced/zip/$1 + + + Index: modeshape-integration-tests/src/test/resources/org/modeshape/test/integration/sequencer/ddl/StandardDdl.cnd deleted file mode 100755 =================================================================== --- modeshape-integration-tests/src/test/resources/org/modeshape/test/integration/sequencer/ddl/StandardDdl.cnd (revision 2433) +++ /dev/null (working copy) @@ -1,297 +0,0 @@ -/* - * ModeShape (http://www.modeshape.org) - * 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. - * - * ModeShape is free software. Unless otherwise indicated, all code in ModeShape - * 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. - * - * ModeShape 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. - */ - - //------------------------------------------------------------------------------ -// N A M E S P A C E S -//------------------------------------------------------------------------------ - - - - - - -//------------------------------------------------------------------------------ -// N O D E T Y P E S -//------------------------------------------------------------------------------ - -[ddl:operation] mixin abstract -[ddl:operand] mixin abstract - - ddl:name (STRING) mandatory - -// ============================================================================= -// STATEMENT -// ============================================================================= -[ddl:statement] mixin abstract - - ddl:expression (string) mandatory // The string fragment encompassing the statement expression. - - ddl:originalExpression (string) mandatory // The string fragment encompassing the original statement expression. - - ddl:startLineNumber (long) mandatory // The starting line number for the statement - - ddl:startColumnNumber (long) mandatory // The starting column number for the statement - - ddl:startCharIndex (long) mandatory // The starting content character index for the statement - - ddl:length (long) mandatory // The string length - + ddl:problem (ddl:ddlProblem) = ddl:ddlProblem multiple // Problems encountered during parsing. - -// ============================================================================= -// CREATE, ALTER, DROP, INSERT, SET, GRANT, REVOKE -// ============================================================================= -[ddl:creatable] > ddl:operation abstract -[ddl:alterable] > ddl:operation abstract -[ddl:droppable] > ddl:operation abstract - - ddl:dropBehavior (STRING) - + ddl:dropOption (ddl:statementOption) = ddl:statementOption multiple -[ddl:insertable] > ddl:operation abstract -[ddl:settable] > ddl:operation abstract -[ddl:grantable] > ddl:operation abstract -[ddl:revokable] > ddl:operation abstract -[ddl:renamable] > ddl:operation abstract - - ddl:newName (STRING) - -// ============================================================================= -// OPERANDS: SCHEMA, TABLE, DOMAIN, VIEW, ASSERTION, CHARACTER SET, COLLATION, TRANSLATION -// ============================================================================= -[ddl:schemaOperand] > ddl:operand abstract -[ddl:tableOperand] > ddl:operand abstract -[ddl:domainOperand] > ddl:operand abstract -[ddl:viewOperand] > ddl:operand abstract -[ddl:assertionOperand] > ddl:operand abstract -[ddl:characterSetOperand] > ddl:operand abstract -[ddl:collationOperand] > ddl:operand abstract -[ddl:translationOperand] > ddl:operand abstract -[ddl:columnOperand] > ddl:operand abstract -[ddl:tableConstraintOperand] > ddl:operand abstract -[ddl:referenceOperand] > ddl:operand abstract - - -// ============================================================================= -// SIMPLE STRING PROPERTY -// ============================================================================= -[ddl:simpleProperty] mixin - - ddl:propValue (STRING) mandatory - -[ddl:constraintAttribute] > ddl:simpleProperty mixin - -// ============================================================================= -// STATEMENT OPTION -// ============================================================================= -[ddl:statementOption] mixin - - ddl:value (STRING) mandatory - -// ============================================================================= -// DDL PROBLEM -// ============================================================================= -[ddl:ddlProblem] mixin - - ddl:problemLevel (LONG) mandatory - - ddl:message (STRING) mandatory - -// ============================================================================= -// COLUMN -// ============================================================================= -[ddl:columnDefinition] > ddl:creatable, ddl:columnOperand mixin - - ddl:datatypeName (STRING) mandatory - - ddl:datatypeLength (LONG) - - ddl:datatypePrecision (LONG) - - ddl:datatypeScale (LONG) - - ddl:nullable (STRING) - - ddl:defaultOption (STRING) - < 'LITERAL', 'DATETIME', 'USER', 'CURRENT_USER', 'SESSION_USER', 'SYSTEM_USER', 'NULL' - - ddl:defaultValue (STRING) - - ddl:defaultPrecision (LONG) - - ddl:collationName (STRING) - + ddl:dropBehavior (ddl:simpleProperty) = ddl:simpleProperty - + ddl:columnAttribute (ddl:simpleProperty) = ddl:simpleProperty multiple - -// ============================================================================= -// TABLE CONSTRAINT -// ============================================================================= -[ddl:tableConstraint] > ddl:creatable, ddl:tableConstraintOperand mixin - - ddl:constraintType (STRING) mandatory - < 'UNIQUE', 'PRIMARY KEY', 'FOREIGN KEY', 'CHECK' - - ddl:deferrable (STRING) - < 'DEFERRABLE', 'NOT DEFERRABLE' - - ddl:checkSearchCondition (STRING) - < 'INITIALLY DEFERRED', 'INITIALLY IMMEDIATE' - + * (ddl:columnReference) = ddl:columnReference multiple - + * (ddl:tableReference) = ddl:tableReference - + * (ddl:fkColumnReference) = ddl:fkColumnReference multiple - + ddl:constAttribute (ddl:constraintAttribute) = ddl:constraintAttribute multiple - -// ============================================================================= -// REFERENCE -// ============================================================================= -[ddl:columnReference] > ddl:referenceOperand mixin -[ddl:tableReference] > ddl:referenceOperand mixin -[ddl:fkColumnReference] > ddl:referenceOperand mixin -[ddl:grantee] > ddl:referenceOperand mixin - -// ============================================================================= -// CREATE SCHEMA -// ============================================================================= -[ddl:schemaDefinition] > ddl:statement, ddl:creatable, ddl:schemaOperand mixin - - ddl:defaultCharacterSetName (STRING) - + * (ddl:statement) = ddl:statement multiple - -// ============================================================================= -// CREATE TABLE -// ============================================================================= -[ddl:createTableStatement] > ddl:statement, ddl:creatable, ddl:tableOperand mixin - - ddl:temporary (STRING) - < 'GLOBAL', 'LOCAL' - - ddl:onCommitValue (STRING) - < 'DELETE ROWS', 'PRESERVE ROWS' - + * (ddl:columnDefinition) = ddl:columnDefinition multiple - + * (ddl:tableConstraint) = ddl:tableConstraint multiple - + * (ddl:statementOption) = ddl:statementOption multiple - -// ============================================================================= -// CREATE VIEW -// ============================================================================= -[ddl:createViewStatement] > ddl:statement, ddl:creatable, ddl:viewOperand mixin - - ddl:sqlExpression (STRING) mandatory - - ddl:checkOption (STRING) - + * (ddl:columnReference) = ddl:columnReference multiple - -// ============================================================================= -// CREATE DOMAIN -// ============================================================================= -[ddl:createDomainStatement] > ddl:statement, ddl:creatable, ddl:domainOperand mixin - - ddl:datatypeName (STRING) mandatory - - ddl:datatypeLength (LONG) - - ddl:datatypePrecision (LONG) - - ddl:datatypeScale (LONG) - - ddl:nullable (STRING) - - ddl:defaultOption (STRING) - < 'LITERAL', 'DATETIME', 'USER', 'CURRENT_USER', 'SESSION_USER', 'SYSTEM_USER', 'NULL' - - ddl:defaultValue (STRING) - - ddl:defaultPrecision (LONG) - - ddl:collationName (STRING) - + ddl:domainConstraintDefinition (ddl:tableConstraint) = ddl:tableConstraint multiple - -// ============================================================================= -// CREATE ASSERTION -// ============================================================================= -[ddl:createAssertionStatement] > ddl:statement, ddl:creatable, ddl:tableConstraintOperand mixin - - ddl:searchCondition (STRING) mandatory - + ddl:constAttribute (ddl:constraintAttribute) = ddl:constraintAttribute multiple - -// ============================================================================= -// CREATE CHARACTER SET -// ============================================================================= -[ddl:createCharacterSetStatement] > ddl:statement, ddl:creatable, ddl:characterSetOperand mixin - - ddl:existingName (STRING) mandatory - - ddl:collateClause (STRING) // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN - - ddl:limitedCollationDefinition (STRING) // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN - -// ============================================================================= -// CREATE COLLATION -// ============================================================================= -[ddl:createCollationStatement] > ddl:statement, ddl:creatable, ddl:collationOperand mixin - - ddl:characterSetName (STRING) mandatory - - ddl:collationSource (STRING) // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN - - ddl:padAttribute (STRING) - < 'NO PAD', 'PAD SPACE' - -// ============================================================================= -// CREATE TRANSLATION -// ============================================================================= -[ddl:createTranslationStatement] > ddl:statement, ddl:creatable, ddl:translationOperand mixin - - ddl:sourceCharacterSetName (STRING) mandatory - - ddl:targetCharacterSetName (STRING) mandatory - - ddl:translationSource (STRING) // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN - -// ============================================================================= -// ALTER TABLE -// ============================================================================= -[ddl:alterTableStatement] > ddl:statement, ddl:alterable, ddl:tableOperand mixin - + * (ddl:addColumnDefinition) = ddl:addColumnDefinition multiple - + * (ddl:dropColumnDefinition) = ddl:dropColumnDefinition multiple - + * (ddl:alterColumnDefinition) = ddl:alterColumnDefinition multiple - + * (ddl:addTableConstraintDefinition) = ddl:addTableConstraintDefinition multiple - + * (ddl:dropTableConstraintDefinition) = ddl:dropTableConstraintDefinition multiple - + * (ddl:statementOption) = ddl:statementOption multiple - -// ============================================================================= -// ALTER DOMAIN -// ============================================================================= -[ddl:alterDomainStatement] > ddl:statement, ddl:alterable, ddl:domainOperand mixin - - ddl:alterDomainAction (STRING) // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN - -// ============================================================================= -// DROP STATEMENTS -// ============================================================================= -[ddl:dropSchemaStatement] > ddl:statement, ddl:droppable, ddl:schemaOperand mixin -[ddl:dropTableStatement] > ddl:statement, ddl:droppable, ddl:tableOperand mixin -[ddl:dropViewStatement] > ddl:statement, ddl:droppable, ddl:viewOperand mixin -[ddl:dropDomainStatement] > ddl:statement, ddl:droppable, ddl:domainOperand mixin -[ddl:dropCharacterSetStatement] > ddl:statement, ddl:droppable, ddl:characterSetOperand mixin -[ddl:dropCollationStatement] > ddl:statement, ddl:droppable, ddl:collationOperand mixin -[ddl:dropTranslationStatement] > ddl:statement, ddl:droppable, ddl:translationOperand mixin -[ddl:dropAssertionStatement] > ddl:statement, ddl:droppable, ddl:assertionOperand mixin - -[ddl:alterColumnDefinition] > ddl:columnDefinition, ddl:alterable mixin -[ddl:addColumnDefinition] > ddl:columnDefinition, ddl:creatable mixin -[ddl:dropColumnDefinition] > ddl:columnDefinition, ddl:droppable mixin -[ddl:addTableConstraintDefinition] > ddl:tableConstraint, ddl:creatable mixin -[ddl:dropTableConstraintDefinition] > ddl:tableConstraint, ddl:droppable mixin - -// ============================================================================= -// MISC STATEMENTS -// ============================================================================= -[ddl:setStatement] > ddl:statement, ddl:settable mixin - // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN - -[ddl:insertStatement] > ddl:statement, ddl:insertable mixin - // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN - -// ============================================================================= -// GRANT STATEMENTS -// ============================================================================= - -[ddl:grantPrivilege] mixin - - ddl:type (STRING) mandatory - + * (ddl:columnReference) = ddl:columnReference multiple - -[ddl:grantStatement] > ddl:statement, ddl:grantable mixin - - ddl:allPrivileges (boolean) - + * (ddl:grantPrivilege) = ddl:grantPrivilege multiple - + * (ddl:grantee) = ddl:grantee multiple - -[ddl:grantOnTableStatement] > ddl:grantStatement, ddl:tableOperand mixin -[ddl:grantOnDomainStatement] > ddl:grantStatement, ddl:domainOperand mixin -[ddl:grantOnCollationStatement] > ddl:grantStatement, ddl:collationOperand mixin -[ddl:grantOnCharacterSetStatement] > ddl:grantStatement, ddl:characterSetOperand mixin -[ddl:grantOnTranslationStatement] > ddl:grantStatement, ddl:translationOperand mixin - -// ============================================================================= -// REVOKE STATEMENTS -// ============================================================================= - -[ddl:revokeStatement] > ddl:statement, ddl:revokable, ddl:droppable mixin - - ddl:allPrivileges (boolean) - + * (ddl:grantPrivilege) = ddl:grantPrivilege multiple - + * (ddl:grantee) = ddl:grantee multiple - -[ddl:revokeOnTableStatement] > ddl:revokeStatement, ddl:tableOperand mixin -[ddl:revokeOnDomainStatement] > ddl:revokeStatement, ddl:domainOperand mixin -[ddl:revokeOnCollationStatement] > ddl:revokeStatement, ddl:collationOperand mixin -[ddl:revokeOnCharacterSetStatement] > ddl:revokeStatement, ddl:characterSetOperand mixin -[ddl:revokeOnTranslationStatement] > ddl:revokeStatement, ddl:translationOperand mixin Index: modeshape-integration-tests/src/test/resources/sequencers/cnd/javaSource.cnd new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/resources/sequencers/cnd/javaSource.cnd (working copy) @@ -0,0 +1,257 @@ +/* + * ModeShape (http://www.modeshape.org) + * 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. + * + * ModeShape is free software. Unless otherwise indicated, all code in ModeShape + * 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. + * + * ModeShape 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. + */ + +/** + * @author Serge Pagop (serge.pagop@innoq.com) + */ + +//------------------------------------------------------------------------------ +// N A M E S P A C E S +//------------------------------------------------------------------------------ + + + + +//------------------------------------------------------------------------------ +// B A S E T Y P E S +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// V E R S I O N I N G +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// N O D E T Y P E S +//------------------------------------------------------------------------------ + +/** + * Element-value + */ +[java:elementValue] > nt:unstructured + + java:kindOfvalues (java:conditionalExpression, java:annotationDeclaration, java:elementValueArrayInitializer) mandatory + +/** + * Modifiers + */ +[java:modifierDeclaration] > nt:unstructured + - java:modifierName (string) mandatory + +/** + * Expression element-value type + */ +[java:conditionalExpression] > nt:unstructured + - java:expression (string) + +/** + * Array initializer element-value type + */ +[java:elementValueArrayInitializer] > nt:unstructured + + java:elementValue (java:elementValue) = java:elementValue multiple + +/** + * Identifier + */ +[java:identifier] > nt:unstructured + - java:identifierName (String) mandatory + + java:value (java:elementValue) = java:elementValue mandatory + +/** + * Element-value pair + */ +[java:elementValuePair] > nt:unstructured + + java:identifier (java:identifier) mandatory + +/** + * Annotation type + */ +[java:annotationDeclaration] > nt:unstructured + + java:annotationType (java:normalAnnotation, java:markerAnnotation, java:singleElementAnnotation) mandatory + +/** + * Normal annotation e.g. @Entity(name="Customer") + */ +[java:normalAnnotation] > nt:unstructured + - java:normalAnnotationName (string) mandatory + + java:elementValuePair (java:elementValuePair) + +/** + * Marker annotation e.g. @GET + */ +[java:markerAnnotation] > nt:unstructured + - java:markerAnnotationName (string) mandatory + +/** + * Single element annotation e.g. @Path("/book") + */ +[java:singleElementAnnotation] > nt:unstructured + - java:singleElementAnnotationName (string) mandatory + + java:value (java:elementValue) = java:elementValue mandatory + +/** + * Formal parameter + */ +[java:formalParameter] > nt:unstructured + + java:type (java:primitiveType, java:arrayType, java:simpleType, java:qualifiedType, java:wildcardType, java:parameterizedType) + +/** + * Primitive type: + * - Integral type ('byte', 'short', 'int', 'long', 'char') + * - Floating point type ('float', 'double') + * - Boolean type ('boolean') + * - No return type ('void') + */ +[java:primitiveType] > nt:unstructured + - java:primitiveTypeDescription (string) + + java:modifier (java:modifierDeclaration) = java:modifierDeclaration + - java:primitiveTypeName (string) mandatory + + java:primitiveVariable (java:variable) = java:variable + + [java:variable] > nt:unstructured + - java:variableName (string) mandatory + +/** + * java:arrayType + */ +[java:arrayType] > nt:unstructured + - java:arrayTypeDescription (string) + + java:arrayTypeModifier (java:modifierDeclaration) = java:modifierDeclaration + - java:arrayTypeName (string) mandatory + + java:arrayTypeVariable (java:variable) = java:variable + +[java:simpleType] > nt:unstructured + - java:simpleTypeDescription (string) + + java:simpleTypeModifier (java:modifierDeclaration) = java:modifierDeclaration + - java:simpleTypeName (string) mandatory + + java:simpleTypeVariable (java:variable) = java:variable + +[java:qualifiedType] > nt:unstructured + - java:qualifiedTypeDescription (string) + + java:qualifiedTypeModifier (java:modifierDeclaration) = java:modifierDeclaration + - java:qualifiedTypeName (string) mandatory + + java:qualifiedTypeVariable (java:variable) = java:variable + +[java:wildcardType] > nt:unstructured + - java:wildcardTypeDescription (string) + + java:wildcardTypeModifier (java:modifierDeclaration) = java:modifierDeclaration + - java:wildcardTypeName (string) mandatory + + java:wildcardTypeVariable (java:variable) = java:variable + +[java:parameterizedType] > nt:unstructured + - java:parameterizedTypeDescription (string) + + java:parameterizedTypeModifier (java:modifierDeclaration) = java:modifierDeclaration + - java:parameterizedTypeName (string) mandatory + + java:parameterizedTypeVariable (java:variable) = java:variable + +/** + * Field type + */ +[java:fieldType] > nt:unstructured + + java:type (java:primitiveType, java:arrayType, java:simpleType, java:qualifiedType, java:wildcardType, java:parameterizedType) mandatory multiple + + /** + * Method declaration + */ +[java:methodDeclaration] > nt:unstructured + - java:methodDescription (string) + + java:modifier (java:modifierDeclaration) = java:modifierDeclaration + + java:resultType (java:primitiveType, java:arrayType, java:simpleType, java:qualifiedType, java:wildcardType, java:parameterizedType) mandatory + - java:methodName (string) mandatory + + java:parameter (java:formalParameter) multiple + +/** + * Constructor declarations + */ +[java:constructorDeclaration] > nt:unstructured + - java:constructorDescription (string) + + java:modifier (java:modifierDeclaration) = java:modifierDeclaration + - java:constructorName (string) mandatory + + java:parameter (java:formalParameter) + + +/** + * Package declarations + */ +[java:packageDeclaration] > nt:unstructured + + java:annotation (java:annotationDeclaration) = java:annotationDeclaration + - java:packageKeyword (string) + < 'package' + - java:packageName (string) mandatory + +/** + * Import declarations + */ +[java:singleTypeImportDeclaration] > nt:unstructured + - java:singleTypeImportkeyword (string) mandatory + < 'import' + - java:singleImportName (string) mandatory + +[java:typeImportOnDemandDeclaration] > nt:unstructured + - java:onDemandImportKeyword (string) mandatory + < 'import' + - java:onDemandImportName (string) mandatory + + [java:importDeclaration] > nt:unstructured + + java:singleImport (java:singleTypeImportDeclaration) = java:singleTypeImportDeclaration + + java:importOnDemand (java:typeImportOnDemandDeclaration) = java:typeImportOnDemandDeclaration + + +/** + * Class declaration + * + * The body of class declares members (fields and methods and nested classes and interfaces), + * instance and static initializers, and constructors + */ +[java:normalClassDeclaration] > nt:unstructured + - java:description (string) + + java:modifier (java:modifierDeclaration) = java:modifierDeclaration + - java:normalClassName (string) mandatory + + java:field (java:fieldType) = java:fieldType multiple + + java:method (java:methodDeclaration) = java:methodDeclaration multiple + + java:constructor (java:constructorDeclaration) = java:constructorDeclaration multiple + +[java:enumDeclaration] > nt:unstructured // TODO + +[java:classDeclaration] > nt:unstructured + + java:normalClass (java:normalClassDeclaration) = java:normalClassDeclaration + + java:enum (java:enumDeclaration) = java:enumDeclaration + +/** + * Interface declaration + * + * The body of class declares members (fields and methods and nested classes and interfaces), + * instance and static initializers, and constructors + */ + //TODO +[java:interfaceDeclaration] > nt:unstructured + + +/** + * Compilation unit + */ +[java:compilationUnit] > nt:unstructured + + java:package (java:packageDeclaration) = java:packageDeclaration + + java:import (java:importDeclaration) = java:importDeclaration + + java:unitType (java:classDeclaration, java:interfaceDeclaration) Index: modeshape-integration-tests/src/test/resources/sequencers/cnd/jsr_283_builtins.cnd new file mode 100644 =================================================================== --- /dev/null (revision 2433) +++ modeshape-integration-tests/src/test/resources/sequencers/cnd/jsr_283_builtins.cnd (working copy) @@ -0,0 +1,189 @@ + + + + + + +// ------------------------------------------------------------------------ +// Pre-defined Node Types +// ------------------------------------------------------------------------ + +[mode:defined] mixin +- modeint:nodeDefinition (string) protected ignore +- modeint:multiValuedProperties (string) multiple protected ignore + +[nt:base] > mode:defined abstract + - jcr:primaryType (name) mandatory autocreated + protected compute + - jcr:mixinTypes (name) protected multiple compute + +[nt:unstructured] + orderable + - * (undefined) multiple + - * (undefined) + + * (nt:base) = nt:unstructured sns version + +[mix:created] mixin + - jcr:created (date) protected + - jcr:createdBy (string) protected + +[nt:hierarchyNode] > mix:created abstract + +[nt:file] > nt:hierarchyNode + + jcr:content (nt:base) primary mandatory + +[nt:linkedFile] > nt:hierarchyNode + - jcr:content (reference) primary mandatory + +[nt:folder] > nt:hierarchyNode + + * (nt:hierarchyNode) version + +[mix:referenceable] mixin + - jcr:uuid (string) mandatory autocreated protected initialize + +[mix:mimeType] mixin + - jcr:mimeType (string) + - jcr:encoding (string) + +[mix:lastModified] mixin + - jcr:lastModified (date) + - jcr:lastModifiedBy (string) + +[nt:resource] > mix:mimeType, mix:lastModified + - jcr:data (binary) primary mandatory + +[nt:nodeType] + - jcr:nodeTypeName (name) mandatory protected copy + - jcr:supertypes (name) multiple protected copy + - jcr:isAbstract (boolean) mandatory protected copy + - jcr:isMixin (boolean) mandatory protected copy + - jcr:isQueryable (boolean) mandatory protected copy + - jcr:hasOrderableChildNodes (boolean) mandatory protected copy + - jcr:primaryItemName (name) protected copy + + jcr:propertyDefinition (nt:propertyDefinition) = nt:propertyDefinition sns protected copy + + jcr:childNodeDefinition (nt:childNodeDefinition) = nt:childNodeDefinition sns protected copy + +[nt:propertyDefinition] + - jcr:name (name) protected + - jcr:autoCreated (boolean) mandatory protected + - jcr:mandatory (boolean) mandatory protected + - jcr:isFullTextSearchable (boolean) mandatory protected + - jcr:isQueryOrderable (boolean) mandatory protected + - jcr:onParentVersion (string) mandatory protected + < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE', + 'IGNORE', 'ABORT' + - jcr:protected (boolean) mandatory protected + - jcr:requiredType (string) mandatory protected + < 'STRING', 'BINARY', 'LONG', 'DOUBLE', 'BOOLEAN', + 'DATE', 'NAME', 'PATH', 'REFERENCE', 'UNDEFINED' + - jcr:valueConstraints (string) multiple protected + - jcr:availableQueryOperators (name) mandatory multiple protected + - jcr:defaultValues (undefined) multiple protected + - jcr:multiple (boolean) mandatory protected + +[nt:childNodeDefinition] + - jcr:name (name) protected + - jcr:autoCreated (boolean) mandatory protected + - jcr:mandatory (boolean) mandatory protected + - jcr:onParentVersion (string) mandatory protected + < 'COPY', 'VERSION', 'INITIALIZE', 'COMPUTE', + 'IGNORE', 'ABORT' + - jcr:protected (boolean) mandatory protected + - jcr:requiredPrimaryTypes (name) = 'nt:base' mandatory protected multiple + - jcr:defaultPrimaryType (name) protected + - jcr:sameNameSiblings (boolean) mandatory protected + +[nt:versionHistory] > mix:referenceable + - jcr:versionableUuid (string) mandatory autocreated protected abort + - jcr:copiedFrom (weakreference) protected abort < 'nt:version' + + jcr:rootVersion (nt:version) = nt:version mandatory autocreated protected abort + + jcr:versionLabels (nt:versionLabels) = nt:versionLabels mandatory autocreated protected abort + + * (nt:version) = nt:version protected abort + + +[nt:versionLabels] + - * (reference) protected abort < 'nt:version' + +[nt:version] > mix:referenceable + - jcr:created (date) mandatory autocreated protected abort + - jcr:predecessors (reference) protected multiple abort < 'nt:version' + - jcr:successors (reference) protected multiple abort < 'nt:version' + - jcr:activity (reference) protected abort < 'nt:activity' + + jcr:frozenNode (nt:frozenNode) protected abort + +[nt:frozenNode] > mix:referenceable + orderable + - jcr:frozenPrimaryType (name) mandatory autocreated protected abort + - jcr:frozenMixinTypes (name) protected multiple abort + - jcr:frozenUuid (string) mandatory autocreated protected abort + - * (undefined) protected abort + - * (undefined) protected multiple abort + + * (nt:base) protected sns abort + +[nt:versionedChild] + - jcr:childVersionHistory (reference) mandatory autocreated protected abort < 'nt:versionHistory' + +[nt:query] + - jcr:statement (string) + - jcr:language (string) + +[nt:activity] > mix:referenceable + - jcr:activityTitle (string) mandatory autocreated protected + + +[mix:simpleVersionable] mixin + - jcr:isCheckedOut (boolean) = 'true' mandatory autocreated protected ignore + +[mix:versionable] > mix:simpleVersionable, mix:referenceable mixin + - jcr:versionHistory (reference) mandatory protected ignore < 'nt:versionHistory' + - jcr:baseVersion (reference) mandatory protected ignore < 'nt:version' + - jcr:predecessors (reference) mandatory protected multiple ignore < 'nt:version' + - jcr:mergeFailed (reference) protected multiple abort + - jcr:activity (reference) protected < 'nt:version' + - jcr:configuration (reference) protected ignore < 'nt:configuration' + +[nt:configuration] > mix:versionable + - jcr:root (reference) mandatory autocreated protected + +[nt:address] + - jcr:protocol (string) + - jcr:host (string) + - jcr:port (string) + - jcr:repository (string) + - jcr:workspace (string) + - jcr:path (path) + - jcr:id (weakreference) + +[nt:naturalText] + - jcr:text (string) + - jcr:messageId (string) + + +// ------------------------------------------------------------------------ +// Pre-defined Mixins +// ------------------------------------------------------------------------ + +[mix:etag] mixin + - jcr:etag (string) protected autocreated + +[mix:lockable] mixin + - jcr:lockOwner (string) protected ignore + - jcr:lockIsDeep (boolean) protected ignore + +[mix:lifecycle] mixin + - jcr:lifecyclePolicy (reference) protected initialize + - jcr:currentLifecycleState (string) protected initialize + +[mix:managedRetention] > mix:referenceable mixin + - jcr:hold (string) protected multiple + - jcr:isDeep (boolean) protected multiple + - jcr:retentionPolicy (reference) protected + +[mix:shareable] > mix:referenceable mixin + +[mix:title] mixin + - jcr:title (string) + - jcr:description (string) + +[mix:language] mixin + - jcr:language (string) Index: modeshape-integration-tests/src/test/resources/sequencers/zip/test-files.zip new file mode 100644 =================================================================== Binary files /dev/null and modeshape-integration-tests/src/test/resources/sequencers/zip/test-files.zip differ Index: modeshape-repository/src/main/java/org/modeshape/repository/sequencer/SequencerOutputMap.java =================================================================== --- modeshape-repository/src/main/java/org/modeshape/repository/sequencer/SequencerOutputMap.java (revision 2433) +++ modeshape-repository/src/main/java/org/modeshape/repository/sequencer/SequencerOutputMap.java (working copy) @@ -25,9 +25,8 @@ package org.modeshape.repository.sequencer; import java.util.ArrayList; import java.util.Collections; -import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedList; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import net.jcip.annotations.Immutable; @@ -53,7 +52,7 @@ public class SequencerOutputMap implements SequencerOutput, Iterable>(); + this.data = new LinkedHashMap>(); this.factories = factories; } @@ -170,10 +169,11 @@ public class SequencerOutputMap implements SequencerOutput, Iterable iterator() { - LinkedList paths = new LinkedList(data.keySet()); - Collections.sort(paths); - sortValues(); - return new EntryIterator(paths.iterator()); + // LinkedList paths = new LinkedList(data.keySet()); + // Collections.sort(paths); + // sortValues(); + // return new EntryIterator(paths.iterator()); + return new EntryIterator(data.keySet().iterator()); } protected void sortValues() {