incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r407632 - in /incubator/graffito/trunk/jcr/jcr-mapping/src: test-config/ test/org/apache/portals/graffito/jcr/persistence/impl/ test/org/apache/portals/graffito/jcr/testmodel/interfaces/
Date Thu, 18 May 2006 21:05:20 GMT
Author: clombart
Date: Thu May 18 14:05:19 2006
New Revision: 407632

URL: http://svn.apache.org/viewvc?rev=407632&view=rev
Log:
Starting unit test for auto* setting

Added:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAutoUpdateTest.java
Modified:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/CmsObject.java

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml?rev=407632&r1=407631&r2=407632&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml (original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test-config/jcrmapping-inheritance.xml Thu
May 18 14:05:19 2006
@@ -9,7 +9,9 @@
 	
 	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.AnotherInterface"
 interface="true" />
 
+     
      <!--MAPPING USED TO TEST INTERFACES WITH NODE TYPE   -->	
+     
 	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.interfaces.CmsObject"
 interface="true" discriminator="false"
 	                                   jcrNodeType="graffito:cmsobject" />
 
@@ -57,7 +59,7 @@
 		
 		<field-descriptor fieldName="path" path="true" />
 		<field-descriptor fieldName="name" jcrName="graffito:name"  id="true" />
-		<bean-descriptor  fieldName="parentFolder" 						 
+		<bean-descriptor  fieldName="parentFolder"  					 
 						  converter="org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ParentBeanConverterImpl"
/>
 
 	</class-descriptor>     
@@ -65,7 +67,7 @@
 	<class-descriptor className="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.FolderImpl"
jcrNodeType="graffito:folderimpl" 
 	                                    extend="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.CmsObjectImpl"
discriminator="false"  >
 		<implement-descriptor interfaceName="org.apache.portals.graffito.jcr.testmodel.interfaces.Folder"
/>	  		                                    
-		<collection-descriptor fieldName="children" proxy="true" 
+		<collection-descriptor fieldName="children" proxy="true" autoUpdate="false" 
 		                       elementClassName="org.apache.portals.graffito.jcr.testmodel.inheritance.impl.CmsObjectImpl"

 		                       collectionConverter="org.apache.portals.graffito.jcr.persistence.collectionconverter.impl.NTCollectionConverterImpl"
/>
 	</class-descriptor >	

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java?rev=407632&r1=407631&r2=407632&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/AllTests.java
Thu May 18 14:05:19 2006
@@ -37,6 +37,7 @@
         TestSuite suite= new TestSuite("Test for org.apache.portals.graffito.jcr.persistence.impl");
         //$JUnit-BEGIN$
         suite.addTestSuite(PersistenceManagerAtomicQueryTest.class);
+        suite.addTestSuite(PersistenceManagerAutoUpdateTest.class);
         suite.addTestSuite(PersistenceManagerBasicVersionningTest.class);
         suite.addTestSuite(PersistenceManagerInheritanceConcreteClassTest.class);
         suite.addTestSuite(PersistenceManagerInheritanceHierarchyTest.class);

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAutoUpdateTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAutoUpdateTest.java?rev=407632&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAutoUpdateTest.java
(added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAutoUpdateTest.java
Thu May 18 14:05:19 2006
@@ -0,0 +1,124 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed 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.impl;
+
+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.Atomic;
+import org.apache.portals.graffito.jcr.testmodel.inheritance.impl.DocumentImpl;
+import org.apache.portals.graffito.jcr.testmodel.inheritance.impl.DocumentStream;
+import org.apache.portals.graffito.jcr.testmodel.inheritance.impl.FolderImpl;
+import org.apache.portals.graffito.jcr.testmodel.interfaces.Document;
+import org.apache.portals.graffito.jcr.testmodel.interfaces.Folder;
+
+/**
+ * Test autoupdate setting
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerAutoUpdateTest extends TestBase {
+	private final static Log log = LogFactory.getLog(PersistenceManagerAutoUpdateTest.class);
+
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public PersistenceManagerAutoUpdateTest(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(
+				PersistenceManagerAutoUpdateTest.class));
+	}
+
+	public void tearDown() throws Exception {
+
+		cleanUpRepisotory();
+		super.tearDown();
+		
+	}
+
+	
+	public void testAutoUpdate() {
+		PersistenceManager persistenceManager = this.getPersistenceManager();
+
+		//---------------------------------------------------------------------------------------------------------
+		// Insert cmsobjects
+		//---------------------------------------------------------------------------------------------------------
		
+	    Document document = new DocumentImpl();        
+	    document.setName("document4");
+	    document.setContentType("plain/text"); 
+	    DocumentStream documentStream = new DocumentStream();
+	    documentStream.setEncoding("utf-8");
+	    documentStream.setContent("Test Content 4".getBytes());
+	    document.setDocumentStream(documentStream);       
+
+	    Folder subFolder = new FolderImpl();
+	    subFolder.setName("subfolder");
+	    
+	    Folder  folder = new FolderImpl();
+	    folder.setPath("/folder2");
+	    folder.setName("folder2");        
+	    folder.addChild(document);
+	    folder.addChild(subFolder);
+	    persistenceManager.insert(folder);               		
+		persistenceManager.save();
+		
+		//---------------------------------------------------------------------------------------------------------

+		// Retrieve folder2 
+		//---------------------------------------------------------------------------------------------------------

+		Folder folder2 = (Folder) persistenceManager.getObject( "/folder2");
+		assertNotNull("folder 2 is null", folder2);
+		assertEquals("Invalid number of cms object  found in folder2 children", folder2.getChildren().size()
,2);
+		assertTrue("Invalid item in the collection", this.contains(folder2.getChildren(), "/folder2/document4",
DocumentImpl.class));
+		assertTrue("Invalid item in the collection", this.contains(folder2.getChildren(), "/folder2/subfolder",
FolderImpl.class));		
+		
+		//---------------------------------------------------------------------------------------------------------

+		// Update  folder2 
+		//---------------------------------------------------------------------------------------------------------

+		folder2.setChildren(null);  // This  modification should be ignored because the field children
has autoUpdate = false
+		persistenceManager.update(folder2);
+		persistenceManager.save();
+
+		
+		//---------------------------------------------------------------------------------------------------------

+		// Retrieve folder2 
+		//---------------------------------------------------------------------------------------------------------

+		 folder2 = (Folder) persistenceManager.getObject( "/folder2");
+		assertNotNull("folder 2 is null", folder2);
+		assertEquals("Invalid number of cms object  found in folder2 children", folder2.getChildren().size()
,2);
+		assertTrue("Invalid item in the collection", this.contains(folder2.getChildren(), "/folder2/document4",
DocumentImpl.class));
+		assertTrue("Invalid item in the collection", this.contains(folder2.getChildren(), "/folder2/subfolder",
FolderImpl.class));		
+		
+		//---------------------------------------------------------------------------------------------------------

+		// Update  folder2 
+		//---------------------------------------------------------------------------------------------------------

+		folder2.setChildren(null);  // This  modification should be ignored because the field children
has autoUpdate = false
+		persistenceManager.save();
+		
+	}
+	
+}
\ No newline at end of file

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java?rev=407632&r1=407631&r2=407632&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerInterfaceConcreteClassTest.java
Thu May 18 14:05:19 2006
@@ -350,96 +350,6 @@
      }
 }
 
-public void testAdvancedQuery() {
-
-	try {
-		PersistenceManager persistenceManager = this.getPersistenceManager();
-
-		//---------------------------------------------------------------------------------------------------------
-		// Insert cmsobjects
-		//---------------------------------------------------------------------------------------------------------
		
-	    DocumentImpl document = new DocumentImpl();
-	    document.setPath("/document1");
-	    document.setName("document name 1");
-	    document.setContentType("plain/text"); 
-	    DocumentStream documentStream = new DocumentStream();
-	    documentStream.setEncoding("utf-8");
-	    documentStream.setContent("Test Content".getBytes());
-	    document.setDocumentStream(documentStream);        
-	    persistenceManager.insert(document);
-	    
-	    document = new DocumentImpl();
-	    document.setPath("/document2");        
-	    document.setName("document name 2");
-	    document.setContentType("plain/text"); 
-	    documentStream = new DocumentStream();
-	    documentStream.setEncoding("utf-8");
-	    documentStream.setContent("Test Content".getBytes());
-	    document.setDocumentStream(documentStream);       
-	    persistenceManager.insert(document);
-
-	    document = new DocumentImpl();
-	    document.setPath("/document3");        
-	    document.setName("document 3");
-	    document.setContentType("plain/text"); 
-	    documentStream = new DocumentStream();
-	    documentStream.setEncoding("utf-8");
-	    documentStream.setContent("Test Content 3".getBytes());
-	    document.setDocumentStream(documentStream);       
-	    persistenceManager.insert(document);
-	    
-	    FolderImpl folder = new FolderImpl();
-	    folder.setPath("/folder1");
-	    folder.setName("folder1");
-	    persistenceManager.insert(folder);
-
-
-	    document = new DocumentImpl();        
-	    document.setName("document4");
-	    document.setContentType("plain/text"); 
-	    documentStream = new DocumentStream();
-	    documentStream.setEncoding("utf-8");
-	    documentStream.setContent("Test Content 4".getBytes());
-	    document.setDocumentStream(documentStream);       
-
-	    FolderImpl subFolder = new FolderImpl();
-	    subFolder.setName("subfolder");
-	    
-	    folder = new FolderImpl();
-	    folder.setPath("/folder2");
-	    folder.setName("folder2");        
-	    folder.addChild(document);
-	    folder.addChild(subFolder);
-	    persistenceManager.insert(folder);               		
-
-	    
-		Atomic a = new Atomic();
-		a.setPath("/atomic");
-		a.setBooleanPrimitive(true);
-		persistenceManager.insert(a);
-
-		persistenceManager.save();
-
-		//---------------------------------------------------------------------------------------------------------

-		// Retrieve Folders found on the root level
-		//---------------------------------------------------------------------------------------------------------
		
-		QueryManager queryManager = persistenceManager.getQueryManager();
-		Filter filter = queryManager.createFilter(Folder.class);
-		//filter.addJCRExpression("")
-		Query query = queryManager.createQuery(filter);
-		filter.setScope("/");
-		Collection result = persistenceManager.getObjects(query);
-		assertEquals("Invalid number of folders found", result.size(), 2);
-		assertTrue("Invalid item in the collection", this.contains(result, "/folder1",FolderImpl.class));
-		assertTrue("Invalid item in the collection", this.contains(result, "/folder2", FolderImpl.class));
	
-		
-		
-	} catch (Exception e) {
-		e.printStackTrace();
-		fail();
-	}
-
-}
 
 	
 }

Modified: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/CmsObject.java
URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/CmsObject.java?rev=407632&r1=407631&r2=407632&view=diff
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/CmsObject.java
(original)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/interfaces/CmsObject.java
Thu May 18 14:05:19 2006
@@ -15,10 +15,6 @@
  */
 package org.apache.portals.graffito.jcr.testmodel.interfaces;
 
-import org.apache.portals.graffito.jcr.testmodel.inheritance.impl.FolderImpl;
-
-
-
 public interface CmsObject {
 
 	public String getName();



Mime
View raw message