[dna-commits] DNA SVN: r1421 - in trunk/dna-integration-tests: src/test/java/org/jboss/dna/test/integration and 12 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Thu Dec 10 13:14:51 EST 2009


Author: blafond
Date: 2009-12-10 13:14:51 -0500 (Thu, 10 Dec 2009)
New Revision: 1421

Added:
   trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/sequencer/
   trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/sequencer/ddl/
   trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java
   trunk/dna-integration-tests/src/test/resources/org/
   trunk/dna-integration-tests/src/test/resources/org/jboss/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/extensions/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/extensions/sequencer/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/extensions/sequencer/ddl/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/StandardDdl.cnd
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/create_schema.ddl
   trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/derby_test_statements.ddl
Modified:
   trunk/dna-integration-tests/pom.xml
Log:
DNA-49 Adding DDL Integration test

Modified: trunk/dna-integration-tests/pom.xml
===================================================================
--- trunk/dna-integration-tests/pom.xml	2009-12-10 18:14:00 UTC (rev 1420)
+++ trunk/dna-integration-tests/pom.xml	2009-12-10 18:14:51 UTC (rev 1421)
@@ -33,6 +33,11 @@
 			<groupId>org.jboss.dna</groupId>
 			<artifactId>dna-jcr</artifactId>
 		</dependency>
+		<dependency>
+            <groupId>org.jboss.dna</groupId>
+            <artifactId>dna-sequencer-ddl</artifactId>
+            <version>${project.version}</version>
+        </dependency>
 
 		<!-- 
       Testing (note the scope)

Added: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java
===================================================================
--- trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java	                        (rev 0)
+++ trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java	2009-12-10 18:14:51 UTC (rev 1421)
@@ -0,0 +1,314 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors.
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ * 
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.test.integration.sequencer.ddl;
+
+import static org.junit.Assert.assertEquals;
+import static org.hamcrest.core.Is.is;
+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.Node;
+import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.Property;
+import javax.jcr.PropertyIterator;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
+import org.jboss.dna.graph.SecurityContext;
+import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
+import org.jboss.dna.jcr.JcrConfiguration;
+import org.jboss.dna.jcr.JcrEngine;
+import org.jboss.dna.jcr.JcrTools;
+import org.jboss.dna.jcr.SecurityContextCredentials;
+import org.jboss.dna.repository.sequencer.SequencingService;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class DdlSequencerIntegrationTest {
+    private JcrEngine engine;
+    private Session session;
+    private URL cndUrl;
+    private JcrTools tools;
+    
+    @Before
+    public void beforeEach() throws Exception {
+        // Configure the DNA 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();
+        
+        String repositoryName = "ddlRepository";
+        String workspaceName = "default";
+        String repositorySource = "ddlRepositorySource";
+        
+        cndUrl = this.getClass().getClassLoader().getResource("org/jboss/dna/test/integration/sequencer/ddl/StandardDdl.cnd");
+        
+        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);
+        // Set up the JCR repository to use the source ...
+        config.repository(repositoryName).addNodeTypes(cndUrl).setSource(repositorySource);
+        // Set up the DDL sequencer ...
+        config.sequencer("DDL Sequencer")
+            .usingClass("org.jboss.dna.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 SecurityContextCredentials(new MyCustomSecurityContext()), workspaceName);
+
+    }
+
+    @After
+    public void afterEach() throws Exception {
+        if (this.session != null) {
+            this.session.logout();
+        }
+        if (this.engine != null) {
+            this.engine.shutdown();
+        }
+    }
+    
+    private void uploadFile(URL url) throws RepositoryException, IOException {
+        // 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";
+
+        // 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");
+
+        // 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());
+        contentNode.setProperty("jcr:data", url.openStream());
+
+        // Save the session ...
+        session.save();
+
+    }
+    
+    /**
+     * Get the sequencing statistics.
+     * 
+     * @return the statistics; never null
+     */
+    public SequencingService.Statistics getStatistics() {
+        return this.engine.getSequencingService().getStatistics();
+    }
+    
+    protected void waitUntilSequencedNodesIs( int totalNumberOfNodesSequenced ) throws InterruptedException {
+        // check 50 times, waiting 0.1 seconds between (for a total of 5 seconds max) ...
+        long numFound = 0;
+        for (int i = 0; i != 50; i++) {
+            numFound = getStatistics().getNumberOfNodesSequenced();
+            if (numFound >= totalNumberOfNodesSequenced) {
+                return;
+            }
+            Thread.sleep(1000);
+        }
+        fail("Expected to find " + totalNumberOfNodesSequenced + " nodes sequenced, but found " + numFound);
+    }
+
+    @Test
+    public void shouldSequenceCreateSchemaDdlFile() throws Exception {
+        System.out.println("STARTED:  shouldSequenceCreateSchemaDdlFile(create_schema.ddl)");
+        URL url = this.getClass().getClassLoader().getResource("org/jboss/dna/test/integration/sequencer/ddl/create_schema.ddl");
+        uploadFile(url);
+        
+        waitUntilSequencedNodesIs(1);
+        
+        // Find the node ...
+        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);
+                    
+                    verifyNode(ddlNode, "hollywood", "ns001:startLineNumber");
+                    verifyNode(ddlNode, "winners", "ns001:expression");
+                    verifyNode(ddlNode, "title", "ns001:datatypeLength");
+                }
+            }
+        }
+        
+        System.out.println("FINISHED:  shouldSequenceCreateSchemaDdlFile(create_schema.ddl)");
+    }
+    
+    @Test
+    public void shouldSequenceDerbyDdlFile() throws Exception {
+        System.out.println("STARTED:  shouldSequenceDerbyDdlFile(derby_test_statements.ddl)");
+        URL url = this.getClass().getClassLoader().getResource("org/jboss/dna/test/integration/sequencer/ddl/derby_test_statements.ddl");
+        uploadFile(url);
+        
+        waitUntilSequencedNodesIs(1);
+        
+        // Find the node ...
+        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, 64);
+                    
+                    printNodeProperties(ddlNode);
+                    
+                    verifyNode(ddlNode, "HOTELAVAILABILITY", "ns001:startLineNumber");
+                    verifyNode(ddlNode, "SAMP.DEPARTMENT", "ns001:expression");
+                    verifyNode(ddlNode, "HOTEL_ID", "ns001:datatypeName");
+                    verifyNode(ddlNode, "CITIES", "ns001:startLineNumber");
+                }
+            }
+        }
+        
+        System.out.println("FINISHED:  shouldSequenceDerbyDdlFile(derby_test_statements.ddl)");
+    }
+    
+    protected class MyCustomSecurityContext implements SecurityContext {
+        /**
+         * {@inheritDoc}
+         * 
+         * @see org.jboss.dna.graph.SecurityContext#getUserName()
+         */
+        public String getUserName() {
+            return "Fred";
+        }
+
+        /**
+         * {@inheritDoc}
+         * 
+         * @see org.jboss.dna.graph.SecurityContext#hasRole(java.lang.String)
+         */
+        public boolean hasRole( String roleName ) {
+            return true;
+        }
+
+        /**
+         * {@inheritDoc}
+         * 
+         * @see org.jboss.dna.graph.SecurityContext#logout()
+         */
+        public void logout() {
+            // do something
+        }
+    }
+    
+    private void printNodeProperties(Node node) throws Exception {
+        printProperties(node);
+        for (NodeIterator iter = node.getNodes(); iter.hasNext();) { 
+            printNodeProperties(iter.nextNode());
+        }
+        
+    }
+    
+    private void verifyNode(Node topNode, String name, String propName) throws Exception {
+        Node node = findNode(topNode, name);
+        
+        if( node != null ) {
+            assertThat( node.hasProperty(propName), is(true));
+        } else {
+            fail("NODE: " + name + " not found");
+        }
+        
+    }
+    
+    private Node findNode(Node node, String name) throws Exception  {
+        if( node.getName().equals(name)) {
+            return node;
+        }
+        for (NodeIterator iter = node.getNodes(); iter.hasNext();) {
+            Node nextNode = iter.nextNode();
+            if( nextNode.getName().equals(name)) {
+                return nextNode;
+            }
+            Node someNode = findNode(nextNode, name);
+            if( someNode != null ) {
+                return someNode;
+            }
+        }
+        
+        return null;
+    }
+    
+    private void printProperties( Node node ) throws RepositoryException, PathNotFoundException, ValueFormatException {
+        
+        System.out.println("\n >>>  NODE PATH: " + node.getPath() );
+        System.out.println("\n           NAME: " + node.getName() );
+
+        // Create a Properties object containing the properties for this node; ignore any children ...
+        //Properties props = new Properties();
+        for (PropertyIterator propertyIter = node.getProperties(); propertyIter.hasNext();) {
+            Property property = propertyIter.nextProperty();
+            String name = property.getName();
+            String stringValue = null;
+            if (property.getDefinition().isMultiple()) {
+                StringBuilder sb = new StringBuilder();
+                boolean first = true;
+                for (Value value : property.getValues()) {
+                    if (!first) {
+                        sb.append(", ");
+                        first = false;
+                    }
+                    sb.append(value.getString());
+                }
+                stringValue = sb.toString();
+            } else {
+                stringValue = property.getValue().getString();
+            }
+            System.out.println("   | PROP: " + name + "  VALUE: " + stringValue);
+            //props.put(name, stringValue);
+        }
+    }
+}


Property changes on: trunk/dna-integration-tests/src/test/java/org/jboss/dna/test/integration/sequencer/ddl/DdlSequencerIntegrationTest.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Added: trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/StandardDdl.cnd
===================================================================
--- trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/StandardDdl.cnd	                        (rev 0)
+++ trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/StandardDdl.cnd	2009-12-10 18:14:51 UTC (rev 1421)
@@ -0,0 +1,266 @@
+/*
+ * JBoss DNA (http://www.jboss.org/dna)
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * See the AUTHORS.txt file in the distribution for a full listing of 
+ * individual contributors. 
+ *
+ * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
+ * is licensed to you under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * JBoss DNA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ 
+ //------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<ddl='http://jboss.org/dna/ddl/1.0'>
+
+
+//------------------------------------------------------------------------------
+// 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) < '(0,]' mandatory           // The starting line number for the statement
+  - ddl:startColumnNumber (LONG) < '(0,]' mandatory         // The starting column number for the statement
+  - ddl:startCharIndex (LONG) < '(0,]' mandatory            // The starting content character index for the statement
+  - ddl:length (LONG) < '(0,]' 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: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, ddl:operand 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
+
+// =============================================================================
+// CREATE SCHEMA
+// =============================================================================
+[ddl:schemaDefinition] > ddl:statement, ddl:creatable, ddl:schemaStatement  mixin
+  - ddl:defaultCharacterSetName (STRING)
+  + * (ddl:ddlStatement) = ddl:ddlStatement (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:tableConstraintDefinition) = ddl:tableConstraintDefinition 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:tableConstraintDefinition) = ddl:tableConstraintDefinition multiple
+
+// =============================================================================
+// CREATE ASSERTION
+// =============================================================================
+[ddl:createAssertionStatement] > ddl:statement, ddl:creatable, ddl:assertionOperand mixin
+  - ddl:constraintName (STRING) mandatory
+  - ddl:searchCondition (STRING) mandatory
+  + ddl:constraintAttribute (ddl:simpleProperty) = ddl:simpleProperty 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:alterStatement, 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:alterStatement, ddl:domainOperand mixin
+  - ddl:alterDomainAction (STRING)                  // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN
+
+// =============================================================================
+// DROP STATEMENTS
+// =============================================================================
+[ddl:dropSchemaStatement]           > ddl:droppable, ddl:schemaOperand mixin
+[ddl:dropTableStatement]            > ddl:droppable, ddl:tableOperand mixin
+[ddl:dropViewStatement]             > ddl:droppable, ddl:viewOperand mixin
+[ddl:dropDomainStatement]           > ddl:droppable, ddl:domainOperand mixin
+[ddl:dropCharacterSetStatement]     > ddl:droppable, ddl:characterSetOperand mixin
+[ddl:dropCollationStatement]        > ddl:droppable, ddl:collationOperand mixin
+[ddl:dropTranslationStatement]      > ddl:droppable, ddl:translationOperand mixin
+[ddl:dropAssertionStatement]        > 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:tableConstraintDefinition, ddl:creatable, mixin
+[ddl:dropTableConstraintDefinition] > ddl:tableConstraintDefinition, 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
+   
+[ddl:grantStatement] > ddl:statement, ddl:grantable mixin
+   // TODO: THIS IS COMPLEX, NEED TO BREAK DOWN
+
+// =============================================================================
+// 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 multiple
+  + ddl:columnAttribute (ddl:simpleProperty) = ddl:simpleProperty multiple
+
+// =============================================================================
+// TABLE CONSTRAINT
+// =============================================================================
+[ddl:tableConstraintDefinition] > 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:constraintAttribute (ddl:simpleProperty) = ddl:simpleProperty multiple
+  
+// =============================================================================
+// REFERENCE
+// =============================================================================
+[ddl:columnReference] > ddl:referenceOperand mixin
+[ddl:tableReference] > ddl:referenceOperand mixin
+[ddl:fkColumnReference] > ddl:referenceOperand mixin
+
+// =============================================================================
+// SIMPLE STRING PROPERTY
+// =============================================================================
+[ddl:simpleProperty] mixin
+  - ddl:propValue (STRING) mandatory
+  
+// =============================================================================
+// DDL PROBLEM
+// =============================================================================
+[ddl:ddlProblem] mixin
+  - ddl:problemLevel (LONG) mandatory
+  - ddl:message (STRING) mandatory
+
+// =============================================================================
+// STATEMENT OPTION
+// =============================================================================
+[ddl:statementOption] mixin
+  - ddl:value (STRING) mandatory
+


Property changes on: trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/StandardDdl.cnd
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/create_schema.ddl
===================================================================
--- trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/create_schema.ddl	                        (rev 0)
+++ trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/create_schema.ddl	2009-12-10 18:14:51 UTC (rev 1421)
@@ -0,0 +1,3 @@
+CREATE SCHEMA hollywood
+    CREATE TABLE films (title varchar(255), release date, producerName varchar(255))
+    CREATE VIEW winners AS SELECT title, release FROM films WHERE producerName IS NOT NULL;
\ No newline at end of file


Property changes on: trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/create_schema.ddl
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/derby_test_statements.ddl
===================================================================
--- trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/derby_test_statements.ddl	                        (rev 0)
+++ trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/derby_test_statements.ddl	2009-12-10 18:14:51 UTC (rev 1421)
@@ -0,0 +1,218 @@
+--
+-- SAMPLE DERBY STATEMENTS
+--
+
+-- Add a new column with a column-level constraint
+-- to an existing table
+-- An exception will be thrown if the table
+-- contains any rows
+-- since the newcol will be initialized to NULL
+-- in all existing rows in the table
+ALTER TABLE CITIES ADD COLUMN REGION VARCHAR(26)
+    CONSTRAINT NEW_CONSTRAINT CHECK (REGION IS NOT NULL);
+
+-- Add a new unique constraint to an existing table
+-- An exception will be thrown if duplicate keys are found
+ALTER TABLE SAMP.DEPARTMENT
+    ADD CONSTRAINT NEW_UNIQUE UNIQUE (DEPTNO);
+
+-- add a new foreign key constraint to the
+-- Cities table. Each row in Cities is checked
+-- to make sure it satisfied the constraints.
+-- if any rows don't satisfy the constraint, the
+-- constraint is not added
+ALTER TABLE CITIES ADD CONSTRAINT COUNTRY_FK
+    Foreign Key (COUNTRY) REFERENCES COUNTRIES (COUNTRY);
+
+-- Add a primary key constraint to a table
+-- First, create a new table
+CREATE TABLE ACTIVITIES (CITY_ID INT NOT NULL,
+    SEASON CHAR(2), ACTIVITY VARCHAR(32) NOT NULL);
+-- You will not be able to add this constraint if the
+-- columns you are including in the primary key have
+-- null data or duplicate values.
+ALTER TABLE Activities ADD PRIMARY KEY (city_id, activity);
+
+-- Drop the city_id column if there are no dependent objects:
+ALTER TABLE Cities DROP COLUMN city_id RESTRICT;
+-- Drop the city_id column, also dropping all dependent objects:
+ALTER TABLE Cities DROP COLUMN city_id CASCADE;
+
+-- Drop a primary key constraint from the CITIES table
+
+ALTER TABLE Cities DROP CONSTRAINT Cities_PK;
+-- Drop a foreign key constraint from the CITIES table
+ALTER TABLE Cities DROP CONSTRAINT COUNTRIES_FK;
+-- add a DEPTNO column with a default value of 1
+ALTER TABLE SAMP.EMP_ACT ADD COLUMN DEPTNO INT DEFAULT 1;
+-- increase the width of a VARCHAR column
+ALTER TABLE SAMP.EMP_PHOTO ALTER PHOTO_FORMAT SET DATA TYPE VARCHAR(30);
+-- change the lock granularity of a table
+ALTER TABLE SAMP.SALES LOCKSIZE TABLE;
+
+-- Remove the NOT NULL constraint from the MANAGER column
+ALTER TABLE Employees ALTER COLUMN Manager NULL;
+-- Add the NOT NULL constraint to the SSN column
+ALTER TABLE Employees ALTER COLUMN ssn NOT NULL;
+
+-- Change the default value for the SALARY column
+ALTER TABLE Employees ALTER COLUMN Salary DEFAULT 1000.0;
+ALTER TABLE Employees ALTER COLUMN Salary DROP DEFAULT;
+
+
+CREATE FUNCTION TO_DEGREES
+	( RADIANS DOUBLE )
+	RETURNS DOUBLE
+	PARAMETER STYLE JAVA
+	NO SQL LANGUAGE JAVA
+	EXTERNAL NAME 'java.lang.Math.toDegrees';
+
+
+CREATE FUNCTION PROPERTY_FILE_READER
+	( FILENAME VARCHAR( 32672 ) )
+	RETURNS TABLE
+	  (
+	     KEY_COL     VARCHAR( 10 ),
+	     VALUE_COL VARCHAR( 1000 )
+	  )
+	LANGUAGE JAVA
+	PARAMETER STYLE DERBY_JDBC_RESULT_SET
+	NO SQL
+	EXTERNAL NAME 'vtis.example.PropertyFileVTI.propertyFileVTI';
+
+CREATE INDEX OrigIndex ON Flights(orig_airport);
+
+CREATE INDEX PAY_DESC ON SAMP.EMPLOYEE (SALARY);
+
+CREATE INDEX IXSALE ON SAMP.SALES (SALES);
+
+CREATE PROCEDURE SALES.TOTAL_REVENUE(IN S_MONTH INTEGER,
+    IN S_YEAR INTEGER, OUT TOTAL DECIMAL(10,2))
+    PARAMETER STYLE JAVA READS SQL DATA LANGUAGE JAVA EXTERNAL NAME 
+    'com.acme.sales.calculateRevenueByMonth';
+
+CREATE ROLE purchases_reader;
+
+CREATE ROLE purchases_reader_role;
+
+CREATE SCHEMA FLIGHTS AUTHORIZATION anita;
+
+CREATE SCHEMA EMP;
+
+CREATE SCHEMA AUTHORIZATION takumi; 
+
+CREATE SYNONYM SAMP.T1 FOR SAMP.TABLEWITHLONGNAME;
+
+CREATE TABLE HOTELAVAILABILITY
+     (HOTEL_ID INT NOT NULL, BOOKING_DATE DATE NOT NULL,
+    ROOMS_TAKEN INT DEFAULT 0, PRIMARY KEY (HOTEL_ID, BOOKING_DATE));
+
+CREATE TABLE PEOPLE
+    (PERSON_ID INT NOT NULL GENERATED ALWAYS AS IDENTITY
+    CONSTRAINT PEOPLE_PK PRIMARY KEY, PERSON VARCHAR(26));
+    
+CREATE TABLE greetings
+  (i int generated by default as identity (START WITH 2, INCREMENT BY 1), ch char(50));
+
+CREATE TABLE GROUPS
+    (GROUP_ID SMALLINT NOT NULL GENERATED ALWAYS AS IDENTITY 
+    (START WITH 5, INCREMENT BY 5), ADDRESS VARCHAR(100), PHONE VARCHAR(15));
+
+CREATE TRIGGER t1 NO CASCADE BEFORE UPDATE ON x
+  FOR EACH ROW MODE DB2SQL
+  values app.notifyEmail('Jerry', 'Table x is about to be updated'); 
+
+
+CREATE TRIGGER FLIGHTSDELETE
+  AFTER DELETE ON FLIGHTS
+  REFERENCING OLD_TABLE AS DELETEDFLIGHTS
+  FOR EACH STATEMENT 
+  DELETE FROM FLIGHTAVAILABILITY WHERE FLIGHT_ID IN
+  (SELECT FLIGHT_ID FROM DELETEDFLIGHTS);
+
+CREATE TRIGGER FLIGHTSDELETE3
+  AFTER DELETE ON FLIGHTS
+  REFERENCING OLD AS OLD
+  FOR EACH ROW 
+  DELETE FROM FLIGHTAVAILABILITY WHERE FLIGHT_ID = OLD.FLIGHT_ID;
+
+
+
+CREATE VIEW SAMP.V1 (COL_SUM, COL_DIFF)
+    AS SELECT COMM + BONUS, COMM - BONUS
+    FROM SAMP.EMPLOYEE;
+
+CREATE VIEW SAMP.VEMP_RES (RESUME)
+    AS VALUES 'Delores M. Quintana', 'Heather A. Nicholls', 'Bruce Adamson';
+
+CREATE VIEW SAMP.PROJ_COMBO 
+    (PROJNO, PRENDATE, PRSTAFF, MAJPROJ) 
+		    AS SELECT PROJNO, PRENDATE, PRSTAFF, MAJPROJ
+		    FROM SAMP.PROJECT UNION ALL 
+		SELECT PROJNO, EMSTDATE, EMPTIME, EMPNO 
+		    FROM SAMP.EMP_ACT 
+		    WHERE EMPNO IS NOT NULL;
+
+CREATE VIEW V1 (C1) AS SELECT SIN(C1) FROM T1;
+
+declare global temporary table SESSION.t1(c11 int) not logged;
+-- The SESSION qualification is redundant here because temporary 
+-- tables can only exist in the SESSION schema. 
+
+declare global temporary table t2(c21 int) not logged; 
+-- The temporary table is not qualified here with SESSION because temporary 
+-- tables can only exist in the SESSION schema.
+
+DROP FUNCTION some_function_name;
+
+DROP INDEX OrigIndex;
+
+DROP INDEX DestIndex;
+
+DROP PROCEDURE some_procedure_name;
+
+DROP ROLE reader;
+
+-- The RESTRICT keyword is required
+DROP SCHEMA SAMP RESTRICT;
+
+DROP SYNONYM some_synonym_name;
+
+DROP TABLE some_table_name;
+
+DROP TRIGGER TRIG1;
+
+DROP VIEW AnIdentifier;
+
+GRANT SELECT ON TABLE t TO maria,harry; 
+
+GRANT UPDATE, TRIGGER ON TABLE t TO anita,zhi;
+
+GRANT SELECT ON TABLE s.v to PUBLIC;
+
+GRANT EXECUTE ON PROCEDURE p TO george;
+
+GRANT purchases_reader_role TO george,maria;
+
+GRANT SELECT ON TABLE t TO purchases_reader_role;
+
+INSERT INTO COUNTRIES
+      VALUES ('Taiwan', 'TW', 'Asia');
+
+INSERT INTO MA_EMP_ACT
+    SELECT * FROM EMP_ACT
+    WHERE SUBSTR(PROJNO, 1, 2) = 'MA';
+    
+-- Insert the DEFAULT value for the LOCATION column
+INSERT INTO DEPARTMENT
+      VALUES ('E31', 'ARCHITECTURE', '00390', 'E01', DEFAULT);
+    
+LOCK TABLE FlightAvailability IN EXCLUSIVE MODE;
+
+LOCK TABLE Maps IN EXCLUSIVE MODE;
+
+RENAME INDEX DESTINDEX TO ARRIVALINDEX;
+
+RENAME TABLE SAMP.EMP_ACT TO EMPLOYEE_ACT;
+
+


Property changes on: trunk/dna-integration-tests/src/test/resources/org/jboss/dna/test/integration/sequencer/ddl/derby_test_statements.ddl
___________________________________________________________________
Name: svn:executable
   + *



More information about the dna-commits mailing list