jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From resc...@apache.org
Subject svn commit: r791884 - in /jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype: NodeTypeCreationTest.java TestAll.java
Date Tue, 07 Jul 2009 15:58:20 GMT
Author: reschke
Date: Tue Jul  7 15:58:20 2009
New Revision: 791884

URL: http://svn.apache.org/viewvc?rev=791884&view=rev
Log:
JCR-2085: start work on node type management tests

Added:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java
  (with props)
Modified:
    jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/TestAll.java

Added: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java?rev=791884&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java
(added)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java
Tue Jul  7 15:58:20 2009
@@ -0,0 +1,121 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.test.api.nodetype;
+
+import java.util.List;
+import java.util.UUID;
+
+import javax.jcr.PropertyType;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.jcr.nodetype.NodeTypeTemplate;
+import javax.jcr.nodetype.PropertyDefinition;
+import javax.jcr.nodetype.PropertyDefinitionTemplate;
+import javax.jcr.query.qom.QueryObjectModelConstants;
+import javax.jcr.version.OnParentVersionAction;
+
+import org.apache.jackrabbit.test.AbstractJCRTest;
+
+/**
+ * Tests the node type creation functionality of the {@link NodeTypeManager}.
+ *
+ * @test
+ * @sources NodeTypeCreationTest.java
+ * @executeClass org.apache.jackrabbit.test.api.nodetype.NodeTypeCreationTest
+ * @keywords level2
+ */
+public class NodeTypeCreationTest extends AbstractJCRTest {
+
+    private static String ns = "urn:uuid:" + UUID.randomUUID();
+
+    private NodeTypeManager ntm;
+    
+    /**
+     * Sets up the fixture for the test cases.
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        ntm = superuser.getWorkspace().getNodeTypeManager();
+        super.checkSupportedOption(Repository.OPTION_NODE_TYPE_MANAGEMENT_SUPPORTED);
+    }
+
+    /**
+     * Releases the session aquired in {@link #setUp()}.
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testNodeTypeTemplate() throws Exception {
+        
+        String ntname = "{" + ns + "}" + "littlemixin";
+        
+        NodeTypeTemplate ntt = ntm.createNodeTypeTemplate();
+        
+        ntt.setName(ntname);
+        ntt.setAbstract(false);
+        ntt.setDeclaredSuperTypeNames(null);
+        ntt.setMixin(true);
+        ntt.setOrderableChildNodes(false);
+        ntt.setQueryable(false);
+        
+        List pdefs = ntt.getPropertyDefinitionTemplates();
+        pdefs.add(createBooleanPropTemplate());
+    }
+
+    public void testPropertyDefinitionTemplate() throws Exception {
+        PropertyDefinitionTemplate pdt = createBooleanPropTemplate();
+        
+        assertEquals("{" + ns + "}" + "boolean", pdt.getName()); // TODO - this should return
a JCR name, not an expanded name, right? See JCR-2192.
+        assertEquals(false, pdt.isAutoCreated());
+        assertEquals(false, pdt.isMandatory());
+        assertEquals(OnParentVersionAction.IGNORE, pdt.getOnParentVersion());
+        assertEquals(false, pdt.isProtected());
+        assertEquals(PropertyType.BOOLEAN, pdt.getRequiredType());
+        assertEquals(null, pdt.getValueConstraints());
+        assertEquals(null, pdt.getDefaultValues());
+        assertEquals(false, pdt.isMultiple());
+        String[] qo = pdt.getAvailableQueryOperators();
+        assertEquals(1, qo.length);
+        assertEquals(QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO, qo[0]);
+        assertEquals(false, pdt.isFullTextSearchable());
+        assertEquals(false, pdt.isQueryOrderable());
+    }
+    
+    
+    private PropertyDefinitionTemplate createBooleanPropTemplate() throws RepositoryException
{
+        String propname = "{" + ns + "}" + "boolean";
+        
+        PropertyDefinitionTemplate pdt = ntm.createPropertyDefinitionTemplate();
+        pdt.setName(propname);
+        pdt.setAutoCreated(false);
+        pdt.setMandatory(false);
+        pdt.setOnParentVersion(OnParentVersionAction.IGNORE);
+        pdt.setProtected(false);
+        pdt.setRequiredType(PropertyType.BOOLEAN);
+        pdt.setValueConstraints(null);
+        pdt.setDefaultValues(null);
+        pdt.setMultiple(false);
+        pdt.setAvailableQueryOperators(new String[] { QueryObjectModelConstants.JCR_OPERATOR_EQUAL_TO
});
+        pdt.setFullTextSearchable(false);
+        pdt.setQueryOrderable(false);
+
+        return pdt;
+    }
+    
+}
\ No newline at end of file

Propchange: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/NodeTypeCreationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/TestAll.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/TestAll.java?rev=791884&r1=791883&r2=791884&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/TestAll.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-tests/src/main/java/org/apache/jackrabbit/test/api/nodetype/TestAll.java
Tue Jul  7 15:58:20 2009
@@ -59,6 +59,10 @@
         suite.addTestSuite(CanAddChildNodeCallWithoutNodeTypeTest.class);
 
         suite.addTestSuite(CanRemoveItemTest.class);
+        
+        // JCR 2.0
+
+        suite.addTestSuite(NodeTypeCreationTest.class);
 
         return suite;
     }



Mime
View raw message