incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r522616 - in /incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr: persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java persistence/uuid/AllTests.java testmodel/PropertyTest.java
Date Mon, 26 Mar 2007 20:28:24 GMT
Author: clombart
Date: Mon Mar 26 13:28:23 2007
New Revision: 522616

URL: http://svn.apache.org/viewvc?view=rev&rev=522616
Log:
working on GRFT-84. add more unit test

Added:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/uuid/AllTests.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/PropertyTest.java

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java?view=auto&rev=522616
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java
(added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/jcrnodetype/PersistenceManagerJcrPropertyTest.java
Mon Mar 26 13:28:23 2007
@@ -0,0 +1,115 @@
+/*
+ * 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.portals.graffito.jcr.persistence.jcrnodetype;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.RepositoryLifecycleTestSetup;
+import org.apache.portals.graffito.jcr.TestBase;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.testmodel.PropertyTest;
+
+/**
+ * Test inheritance with node type per concrete class (without  discreminator field)
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerJcrPropertyTest extends TestBase {
+	private final static Log log = LogFactory.getLog(PersistenceManagerJcrPropertyTest.class);
+
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public PersistenceManagerJcrPropertyTest(String testName) throws Exception {
+		super(testName);
+
+	}
+
+	public static Test suite() {
+		// All methods starting with "test" will be executed in the test suite.
+		return new RepositoryLifecycleTestSetup(new TestSuite(PersistenceManagerJcrPropertyTest.class));
+	}
+
+	public void tearDown() throws Exception {
+
+		cleanUpRepisotory();
+		super.tearDown();
+		
+	}
+
+
+	public void testRequiredProperty() 
+	{
+
+		try 
+		{
+			PersistenceManager persistenceManager = this.getPersistenceManager();
+			//---------------------------------------------------------------------------------------------------------
+			// Insert 
+			//---------------------------------------------------------------------------------------------------------
		
+			
+            PropertyTest propertyTest = new PropertyTest();
+            propertyTest.setPath("/test");
+            propertyTest.setRequiredProp("requiredPropValue");
+            propertyTest.setRequiredWithConstraintsProp("abc");
+            propertyTest.setAutoCreatedProp("autoCreatePropValue");
+            
+            persistenceManager.insert(propertyTest);
+            persistenceManager.save();
+            
+			//---------------------------------------------------------------------------------------------------------
+			// Retrieve
+			//---------------------------------------------------------------------------------------------------------
		
+            propertyTest = (PropertyTest) persistenceManager.getObject("/test");
+            assertTrue("Invalid required property", propertyTest.getRequiredProp().equals("requiredPropValue"));
+            assertTrue("Invalid required property with constraints", propertyTest.getRequiredWithConstraintsProp().equals("abc"));
           
+            assertTrue("Invalid autocreated property", propertyTest.getAutoCreatedProp().equals("autoCreatePropValue"));
           
+            
+            //---------------------------------------------------------------------------------------------------------
+			// update the property requiredWithConstraintsProp with bad value
+			//---------------------------------------------------------------------------------------------------------
		
+            propertyTest.setRequiredWithConstraintsProp("invalid value");
+            try 
+            {
+            	persistenceManager.update(propertyTest);
+            	persistenceManager.save();
+            	fail("Invalid value was accepted");
+            }
+            catch(Exception e)
+            {
+                e.printStackTrace();	
+               // Do nothing - normal behaviour, the value  	
+            }
+            
+			
+			
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail();
+		}
+			
+	}
+	
+	
+	
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/uuid/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/uuid/AllTests.java?view=auto&rev=522616
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/uuid/AllTests.java
(added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/uuid/AllTests.java
Mon Mar 26 13:28:23 2007
@@ -0,0 +1,45 @@
+/*
+ * 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.portals.graffito.jcr.persistence.uuid;
+
+import org.apache.portals.graffito.jcr.RepositoryLifecycleTestSetup;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+
+/**
+ * Package level tests.
+ * 
+ * @author <a href='mailto:the_mindstorm[at]evolva[dot]ro'>Alexandru Popescu</a>
+ */
+public class AllTests {
+
+    public static Test suite() {
+        return new RepositoryLifecycleTestSetup(buildSuite());
+    }
+
+    public static Test buildSuite() {
+        TestSuite suite= new TestSuite("Test for org.apache.portals.graffito.jcr.persistence.uuid");
+        //$JUnit-BEGIN$
+        suite.addTestSuite(PersistenceManagerUuidTest.class);
+        
+        //$JUnit-END$
+
+        return suite;
+    }
+}

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/PropertyTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/PropertyTest.java?view=auto&rev=522616
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/PropertyTest.java
(added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/PropertyTest.java
Mon Mar 26 13:28:23 2007
@@ -0,0 +1,91 @@
+/*
+ * 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.portals.graffito.jcr.testmodel;
+
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
+ * 
+ */
+public class PropertyTest
+{
+	private String path;
+	private String requiredProp;
+	private String requiredWithConstraintsProp;
+	private String autoCreatedProp;
+	private String autoCreatedWithConstraintsProp;
+	private String mandatoryProp;
+	private String mandatoryWithConstaintsProp; 
+	private String protectedWithDefaultValueProp;
+	
+	
+	
+	public String getPath() {
+		return path;
+	}
+	public void setPath(String path) {
+		this.path = path;
+	}
+	public String getAutoCreatedProp() {
+		return autoCreatedProp;
+	}
+	public void setAutoCreatedProp(String autoCreadetProp) {
+		this.autoCreatedProp = autoCreadetProp;
+	}
+	public String getAutoCreatedWithConstraintsProp() {
+		return autoCreatedWithConstraintsProp;
+	}
+	public void setAutoCreatedWithConstraintsProp(
+			String autoCreatedWithConstraintsProp) {
+		this.autoCreatedWithConstraintsProp = autoCreatedWithConstraintsProp;
+	}
+	public String getMandatoryProp() {
+		return mandatoryProp;
+	}
+	public void setMandatoryProp(String mandatoryProp) {
+		this.mandatoryProp = mandatoryProp;
+	}
+	public String getMandatoryWithConstaintsProp() {
+		return mandatoryWithConstaintsProp;
+	}
+	public void setMandatoryWithConstaintsProp(String mandatoryWithConstaintsProp) {
+		this.mandatoryWithConstaintsProp = mandatoryWithConstaintsProp;
+	}
+	public String getProtectedWithDefaultValueProp() {
+		return protectedWithDefaultValueProp;
+	}
+	public void setProtectedWithDefaultValueProp(
+			String protectedWithDefaultValueProp) {
+		this.protectedWithDefaultValueProp = protectedWithDefaultValueProp;
+	}
+	public String getRequiredProp() {
+		return requiredProp;
+	}
+	public void setRequiredProp(String requiredProp) {
+		this.requiredProp = requiredProp;
+	}
+	public String getRequiredWithConstraintsProp() {
+		return requiredWithConstraintsProp;
+	}
+	public void setRequiredWithConstraintsProp(String requiredWithConstraintsProp) {
+		this.requiredWithConstraintsProp = requiredWithConstraintsProp;
+	}
+	
+	
+	
+}



Mime
View raw message