incubator-graffito-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r354168 [2/3] - in /incubator/graffito/trunk/jcr/jcr-mapping/src/test: ./ org/ org/apache/ org/apache/portals/ org/apache/portals/graffito/ org/apache/portals/graffito/jcr/ org/apache/portals/graffito/jcr/mapper/ org/apache/portals/graffito...
Date Mon, 05 Dec 2005 20:37:32 GMT
Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerIteratorQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerIteratorQueryTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerIteratorQueryTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerIteratorQueryTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,218 @@
+/* ========================================================================
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+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.TestBase;
+import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+
+
+/**
+ * Test Object Iterator
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerIteratorQueryTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(PersistenceManagerIteratorQueryTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public PersistenceManagerIteratorQueryTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(PersistenceManagerIteratorQueryTest.class);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+		this.importData();
+        
+    }
+    
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            
+        }    
+        getPersistenceManager().save();
+        super.tearDown();
+    }	
+    
+    /**
+     * Test equalTo
+     *
+     */
+    public void testsetScope()
+    {
+
+    	try
+    	{
+    		
+    		  // No scope    		  
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(Page.class);        	      
+    	      Query query = queryManager.createQuery(filter);    	      
+    	      PersistenceManager persistenceManager = this.getPersistenceManager();
+    	      
+    	      long  start = System.currentTimeMillis();
+    	      Iterator iterator = persistenceManager.getObjectIterator(query);
+    	      System.out.println("getObject takes : " + (System.currentTimeMillis() - start));
+    	          	      
+    	      start = System.currentTimeMillis();
+    	      Collection result = persistenceManager.getObjects(query);
+    	      System.out.println("getObject takes : " + (System.currentTimeMillis() - start));   
+    	      
+    	      start = System.currentTimeMillis();
+    	      iterator = persistenceManager.getObjectIterator(query);
+    	      System.out.println("getObject takes : " + (System.currentTimeMillis() - start));       	      
+
+    	      
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+    
+    private void importData() throws JcrMappingException 
+    {
+        
+    	try
+		{
+    		PersistenceManager persistenceManager = getPersistenceManager();
+    		
+        	if (persistenceManager.objectExists("/test"))
+            {
+                persistenceManager.remove("/test");
+            }
+        	
+			PersistenceManagerImpl persistenceManagerImpl = (PersistenceManagerImpl) persistenceManager;
+			
+			Session session = persistenceManagerImpl.getSession();
+			Node root = session.getRootNode();
+			root.addNode("test");
+			root.addNode("test/node1");
+			root.addNode("test/node2");
+			
+			root.save();
+			
+			Page page = new Page();
+			page.setPath("/test/node1/page1");
+			page.setTitle("Page 1 Title");
+			
+			ArrayList paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 1"));
+			paragraphs.add(new Paragraph("Para 2"));
+			paragraphs.add(new Paragraph("Para 3"));
+			paragraphs.add(new Paragraph("Another Para "));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert(page);
+						
+			
+			page = new Page();
+			page.setPath("/test/node1/page2");
+			page.setTitle("Page 2 Title");
+			
+			paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 1"));
+			paragraphs.add(new Paragraph("Para 2"));
+			paragraphs.add(new Paragraph("Para 5"));
+			paragraphs.add(new Paragraph("Another Para"));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert(page);
+			
+			page = new Page();
+			page.setPath("/test/node2/page1");
+			page.setTitle("Page 3 Title");
+			
+			paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 1"));
+			paragraphs.add(new Paragraph("Para 4"));
+			paragraphs.add(new Paragraph("Para 5"));
+			paragraphs.add(new Paragraph("Another Para"));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert(page);
+
+			page = new Page();
+			page.setPath("/test/node2/page2");
+			page.setTitle("Page 4 Title");
+			
+			paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 6"));
+			paragraphs.add(new Paragraph("Para 7"));
+			paragraphs.add(new Paragraph("Para 8"));
+			paragraphs.add(new Paragraph("Another Para"));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert(page);
+			
+			persistenceManager.save();
+			
+
+			
+		}
+		catch (RepositoryException e)
+		{
+			
+			e.printStackTrace();
+		}            
+                
+
+    }
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerMultiValueQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerMultiValueQueryTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerMultiValueQueryTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerMultiValueQueryTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,171 @@
+/* ========================================================================
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+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.TestBase;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.MultiValue;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerMultiValueQueryTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(PersistenceManagerMultiValueQueryTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public PersistenceManagerMultiValueQueryTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(PersistenceManagerMultiValueQueryTest.class);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+		this.importData();
+        
+    }
+    
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            
+        }    
+        getPersistenceManager().save();
+        super.tearDown();
+    }	
+    
+    public void testMultiValueSearch()
+    {
+        try
+        {
+        	
+  	      QueryManager queryManager = this.getQueryManager();
+	      Filter filter = queryManager.createFilter(MultiValue.class);    
+	      filter.addEqualTo("multiValues", "Value1");
+	      Query query = queryManager.createQuery(filter);    	      
+	      PersistenceManager persistenceManager = this.getPersistenceManager();
+	      Collection result = persistenceManager.getObjects(query);
+	      assertTrue("Invalid number of objects - should be = 3", result.size() == 3);            
+          
+  	      queryManager = this.getQueryManager();
+	      filter = queryManager.createFilter(MultiValue.class);    
+	      filter.addEqualTo("multiValues", "Value9");
+	      query = queryManager.createQuery(filter);    	      
+	      persistenceManager = this.getPersistenceManager();
+	      result = persistenceManager.getObjects(query);
+	      assertTrue("Invalid number of objects - should be = 1", result.size() == 1);
+	      MultiValue multiValue = (MultiValue)result.iterator().next();
+	      assertTrue("Incorrect MultiValue found ", multiValue.getName().equals("m3"));
+	      
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+
+    public void importData()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+
+			PersistenceManagerImpl persistenceManagerImpl = (PersistenceManagerImpl) persistenceManager;
+			
+			Session session = persistenceManagerImpl.getSession();
+			Node root = session.getRootNode();
+			root.addNode("test");
+
+            MultiValue multiValue = new MultiValue();
+            multiValue.setPath("/test/m1");
+            multiValue.setName("m1");
+            ArrayList values = new ArrayList();
+            values.add("Value1");
+            values.add("Value2");
+            values.add("Value3");
+            values.add("Value4");
+            multiValue.setMultiValues(values);
+            persistenceManager.insert(multiValue);
+            
+            multiValue = new MultiValue();
+            multiValue.setPath("/test/m2");
+            multiValue.setName("m2");
+            values = new ArrayList();
+            values.add("Value1");
+            values.add("Value5");
+            values.add("Value6");
+            values.add("Value7");            
+            multiValue.setMultiValues(values);
+            persistenceManager.insert(multiValue);
+            
+            multiValue = new MultiValue();
+            multiValue.setPath("/test/m3");
+            multiValue.setName("m3");
+            values = new ArrayList();
+            values.add("Value1");
+            values.add("Value2");
+            values.add("Value8");
+            values.add("Value9");
+            
+            multiValue.setMultiValues(values);
+            persistenceManager.insert(multiValue);
+                                   
+            persistenceManager.save();
+            
+        }
+        catch(Exception e)
+        {
+        	e.printStackTrace();
+        	fail("Impossible to insert objects");
+        }
+    	
+    }
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerRemoveTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerRemoveTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerRemoveTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerRemoveTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,171 @@
+/* ========================================================================
+ * 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 java.io.ByteArrayInputStream;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+
+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.TestBase;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.Atomic;
+import org.apache.portals.graffito.jcr.testmodel.MultiValue;
+
+/**
+ * Test Query on atomic fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerRemoveTest extends TestBase
+{
+	private final static Log log = LogFactory.getLog(PersistenceManagerRemoveTest.class);
+	private Date date = new Date();
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public PersistenceManagerRemoveTest(String testName) throws Exception
+	{
+		super(testName);
+
+	}
+
+	public static Test suite()
+	{
+		// All methods starting with "test" will be executed in the test suite.
+		return new TestSuite(PersistenceManagerRemoveTest.class);
+	}
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+		this.importData(date);
+        
+    }
+	
+	public void tearDown() throws Exception
+	{
+
+		for (int i = 1; i <= 10; i++)
+		{
+			if (getPersistenceManager().objectExists("/test" + i))
+			{
+				getPersistenceManager().remove("/test" + i);
+			}
+
+		}
+		getPersistenceManager().save();
+
+		super.tearDown();
+	}
+
+	public void testRemove()
+	{
+
+		try
+		{
+			
+			PersistenceManager persistenceManager = this.getPersistenceManager();
+			persistenceManager.remove("/test5");
+			persistenceManager.save();
+
+			assertFalse("Test5 has not been removed", persistenceManager.objectExists("/test5"));
+
+			QueryManager queryManager = this.getQueryManager();
+			Filter filter = queryManager.createFilter(Atomic.class);
+			filter.addEqualTo("booleanObject" , new Boolean(false));
+			Query query = queryManager.createQuery(filter);
+			persistenceManager.remove(query);
+			persistenceManager.save();
+
+			filter = queryManager.createFilter(Atomic.class);
+			filter.setScope("//");
+			query = queryManager.createQuery(filter);			
+			Collection result = persistenceManager.getObjects(query);
+			assertTrue("Invalid number of objects", result.size() == 5);
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail();
+		}
+
+	}
+
+	private void importData(Date date)
+	{
+		try
+		{
+
+			PersistenceManager persistenceManager = getPersistenceManager();
+
+			for (int i = 1; i <= 10; i++)
+			{
+				Atomic a = new Atomic();
+				a.setPath("/test" + i);
+				a.setBooleanObject(new Boolean(i % 2 == 0));
+				a.setBooleanPrimitive(true);
+				a.setIntegerObject(new Integer(100 * i));
+				a.setIntPrimitive(200 + i);
+				a.setString("Test String " + i);
+				a.setDate(date);
+				Calendar calendar = Calendar.getInstance();
+				calendar.set(1976, 4, 20, 15, 40);
+				a.setCalendar(calendar);
+				a.setDoubleObject(new Double(2.12 + i));
+				a.setDoublePrimitive(1.23 + i);
+				long now = System.currentTimeMillis();
+				a.setTimestamp(new Timestamp(now));
+				if ((i % 2) == 0)
+				{
+					a.setByteArray("This is small object stored in a JCR repository".getBytes());
+					a.setInputStream(new ByteArrayInputStream("Test inputstream".getBytes()));
+				}
+				else
+				{
+					a.setByteArray("This is small object stored in a Graffito repository".getBytes());
+					a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
+				}
+				persistenceManager.insert(a);
+
+			}
+			persistenceManager.save();
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail("Exception occurs during the unit test : " + e);
+		}
+
+	}
+
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,208 @@
+/* ========================================================================
+ * 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 java.io.ByteArrayInputStream;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+
+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.TestBase;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.AtomicTypeConverter;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.Atomic;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+
+/**
+ * Test Query on atomic fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerSameNameSiblingTest extends TestBase
+{
+	private final static Log log = LogFactory.getLog(PersistenceManagerSameNameSiblingTest.class);
+	private Date date = new Date();
+	
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public PersistenceManagerSameNameSiblingTest(String testName) throws Exception
+	{
+		super(testName);
+		
+	}
+
+	public static Test suite()
+	{
+		// All methods starting with "test" will be executed in the test suite.
+		return new TestSuite(PersistenceManagerSameNameSiblingTest.class);
+	}
+
+
+	public void testSameNameSiblings()
+	{
+
+		try
+		{
+			this.importData(date);
+			PersistenceManager persistenceManager = this.getPersistenceManager();
+				
+			// Query all objects 
+			QueryManager queryManager = this.getQueryManager();
+			Filter filter = queryManager.createFilter(Atomic.class);	
+			filter.setScope("/");
+			Query query = queryManager.createQuery(filter);
+			Collection result = persistenceManager.getObjects(query);
+            assertTrue("Incorrect number of objects found", result.size() == 10);
+                         
+            // Get objects
+            Atomic atomic = (Atomic) persistenceManager.getObject(Atomic.class, "/test[2]");
+            assertNotNull("Object /test[2] not found", atomic);
+            
+            atomic = (Atomic) persistenceManager.getObject(Atomic.class, "/test[10]");
+            assertNotNull("Object /test[2] not found", atomic);            
+            
+            // Update the object 
+            atomic.setString("Modified Test String 10");
+            persistenceManager.update(atomic);
+            persistenceManager.save();
+
+            // Query on the attribute "string"
+            queryManager = this.getQueryManager();
+			filter = queryManager.createFilter(Atomic.class);	
+			filter.addLike("string", "Modified%");			
+			query = queryManager.createQuery(filter);
+			result = persistenceManager.getObjects(query);
+			assertTrue("Incorrect number of objects found", result.size() == 1);
+            
+			atomic = (Atomic) persistenceManager.getObject(query);
+			assertNotNull("Object not found", atomic);
+			assertTrue("Incorrect Object", atomic.getString().equals("Modified Test String 10"));   
+			
+            // Delete all objects
+            queryManager = this.getQueryManager();
+			filter = queryManager.createFilter(Atomic.class);	
+			filter.setScope("/");
+			query = queryManager.createQuery(filter) ;           
+            persistenceManager.remove(query);
+            persistenceManager.save();
+
+			result = persistenceManager.getObjects(query);
+            assertTrue("Incorrect number of objects found", result.size() == 0);
+            
+            
+		}
+		catch (Exception e)
+		{
+			 e.printStackTrace();
+             fail();
+		}
+
+	}
+
+	public void testUnsupportedSameNameSiblings()
+	{
+		     PersistenceManager persistenceManager = getPersistenceManager();
+             try
+             {
+            	 
+            	 Page page = new Page();
+            	 page.setPath("/page");
+            	 page.setTitle("Page Title");            	 
+            	 persistenceManager.insert(page);
+            	 persistenceManager.save();
+            	 
+            	 Paragraph p1 = new Paragraph("para1");
+            	 p1.setPath("/page/paragraph");
+            	 persistenceManager.insert(p1);
+            	 
+            	 Paragraph p2 = new Paragraph("para1");
+            	 p2.setPath("/page/paragraph");
+            	 persistenceManager.insert(p2);
+                 fail();            	 
+            	 
+             }
+             catch(Exception e)
+             {
+    		            	 persistenceManager.remove("/page");
+            	 persistenceManager.save();
+             }
+	}
+	
+	
+	private void importData(Date date)
+	{
+		try
+		{
+
+			PersistenceManager persistenceManager = getPersistenceManager();
+			
+			
+			for (int i = 1; i <= 10; i++)
+			{
+				Atomic a = new Atomic();
+				a.setPath("/test");
+				a.setBooleanObject(new Boolean(i%2==0));
+				a.setBooleanPrimitive(true);
+				a.setIntegerObject(new Integer(100 * i));
+				a.setIntPrimitive(200 + i);
+				a.setString("Test String " + i);
+				a.setDate(date);
+				Calendar calendar = Calendar.getInstance();
+				calendar.set(1976, 4, 20, 15, 40);
+				a.setCalendar(calendar);
+				a.setDoubleObject(new Double(2.12 + i));
+				a.setDoublePrimitive(1.23 + i);
+				long now = System.currentTimeMillis();
+				a.setTimestamp(new Timestamp(now));
+				if ((i % 2) == 0)
+				{
+				     a.setByteArray("This is small object stored in a JCR repository".getBytes());
+				     a.setInputStream(new ByteArrayInputStream("Test inputstream".getBytes()));
+				}
+				else
+				{
+					 a.setByteArray("This is small object stored in a Graffito repository".getBytes());
+					 a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
+				}
+				persistenceManager.insert(a);
+				
+				
+			}
+			persistenceManager.save();
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail("Exception occurs during the unit test : " + e);
+		}
+
+	}
+	
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerScopeQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerScopeQueryTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerScopeQueryTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerScopeQueryTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,239 @@
+/* ========================================================================
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+
+import javax.jcr.Node;
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+
+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.TestBase;
+import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+
+
+/**
+ * Test QueryManagerImpl Query methods
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerScopeQueryTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(PersistenceManagerScopeQueryTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public PersistenceManagerScopeQueryTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(PersistenceManagerScopeQueryTest.class);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+		this.importData();
+        
+    }
+    
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");            
+        }    
+        getPersistenceManager().save();
+        super.tearDown();
+    }	
+    
+    /**
+     * Test equalTo
+     *
+     */
+    public void testsetScope()
+    {
+
+    	try
+    	{
+    		
+              	      
+    	      PersistenceManager persistenceManager = this.getPersistenceManager();
+    	      // Search on subtree (test/node1)
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(Paragraph.class);    
+    	      filter.setScope("/test/node1//");
+    	      Query query = queryManager.createQuery(filter);    	      
+    	      persistenceManager = this.getPersistenceManager();
+    	      Collection result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 8", result.size() == 8);
+    	      
+    	      
+    	      queryManager = this.getQueryManager();
+    	      filter = queryManager.createFilter(Paragraph.class);    
+    	      filter.setScope("/test//");
+    	      query = queryManager.createQuery(filter);    	      
+    	      persistenceManager = this.getPersistenceManager();
+    	      result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 16", result.size() == 16);
+    	      
+    	      // Test on children 
+    	      queryManager = this.getQueryManager();
+    	      filter = queryManager.createFilter(Paragraph.class);    
+    	      filter.setScope("/test/");
+    	      query = queryManager.createQuery(filter);    	      
+    	      persistenceManager = this.getPersistenceManager();
+    	      result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 0", result.size() == 0);
+    	      
+              // Search on scope and properties
+    	      queryManager = this.getQueryManager();
+    	      filter = queryManager.createFilter(Paragraph.class);    
+    	      filter.setScope("/test//");
+    	      filter.addEqualTo("text", "Para 1");
+    	      query = queryManager.createQuery(filter);    	      
+    	      persistenceManager = this.getPersistenceManager();
+    	      result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 3", result.size() == 3);
+
+    	      
+    	      queryManager = this.getQueryManager();
+    	      filter = queryManager.createFilter(Paragraph.class);    
+    	      filter.setScope("/test//");
+    	      filter.addContains("text", "another");
+    	      query = queryManager.createQuery(filter);    	      
+    	      persistenceManager = this.getPersistenceManager();
+    	      result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 4", result.size() == 4);
+    	      
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+    
+    private void importData() throws JcrMappingException 
+    {
+        
+    	try
+		{
+    		PersistenceManager persistenceManager = getPersistenceManager();
+        	
+			PersistenceManagerImpl persistenceManagerImpl = (PersistenceManagerImpl) persistenceManager;
+			
+			Session session = persistenceManagerImpl.getSession();
+			Node root = session.getRootNode();
+			root.addNode("test");
+			root.addNode("test/node1");
+			root.addNode("test/node2");
+			
+			root.save();
+			
+			Page page = new Page();
+			page.setPath("/test/node1/page1");
+			page.setTitle("Page 1 Title");
+			
+			ArrayList paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 1"));
+			paragraphs.add(new Paragraph("Para 2"));
+			paragraphs.add(new Paragraph("Para 3"));
+			paragraphs.add(new Paragraph("Another Para "));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert(page);
+						
+			
+			page = new Page();
+			page.setPath("/test/node1/page2");
+			page.setTitle("Page 2 Title");
+			
+			paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 1"));
+			paragraphs.add(new Paragraph("Para 2"));
+			paragraphs.add(new Paragraph("Para 5"));
+			paragraphs.add(new Paragraph("Another Para"));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert(page);
+			
+			page = new Page();
+			page.setPath("/test/node2/page1");
+			page.setTitle("Page 3 Title");
+			
+			paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 1"));
+			paragraphs.add(new Paragraph("Para 4"));
+			paragraphs.add(new Paragraph("Para 5"));
+			paragraphs.add(new Paragraph("Another Para"));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert( page);
+
+			page = new Page();
+			page.setPath("/test/node2/page2");
+			page.setTitle("Page 4 Title");
+			
+			paragraphs = new ArrayList();
+			
+			paragraphs.add(new Paragraph("Para 6"));
+			paragraphs.add(new Paragraph("Para 7"));
+			paragraphs.add(new Paragraph("Para 8"));
+			paragraphs.add(new Paragraph("Another Para"));
+			page.setParagraphs(paragraphs);
+			
+			persistenceManager.insert(page);
+			persistenceManager.save();
+
+			
+		}
+		catch (RepositoryException e)
+		{
+			
+			e.printStackTrace();
+		}            
+                
+
+    }
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSimpleQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSimpleQueryTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSimpleQueryTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSimpleQueryTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,278 @@
+/* ========================================================================
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+
+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.TestBase;
+import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+
+
+/**
+ * Test QueryManagerImpl Query methods
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerSimpleQueryTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(PersistenceManagerSimpleQueryTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public PersistenceManagerSimpleQueryTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(PersistenceManagerSimpleQueryTest.class);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        importData();
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+    	getPersistenceManager().remove("/test");
+    	getPersistenceManager().save();
+    	
+        super.tearDown();
+    }
+    
+    /**
+     * Test equalTo
+     *
+     */
+    public void testGetObjectEqualsTo()
+    {
+
+    	try
+    	{
+    		    		      		 
+    		  // Build the Query Object
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(Paragraph.class);
+    	      filter.addEqualTo("text", "Para 1");    	          	     
+    	      
+    	      
+    	      Query query = queryManager.createQuery(filter);
+    	      
+    	      PersistenceManager persistenceManager = this.getPersistenceManager();
+    	      Paragraph paragraph = (Paragraph) persistenceManager.getObject(query);
+    	      assertNotNull("Object is null", paragraph);    	      
+    	      assertTrue("Invalid paragraph found" , paragraph.getText().equals("Para 1"));
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }    
+    
+    /**
+     * Test equalTo
+     *
+     */
+    public void testGetObjectsEqualsTo()
+    {
+
+    	try
+    	{
+    		    		      		 
+    		  // Build the Query Object
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(Paragraph.class);
+    	      filter.addEqualTo("text", "Para 1");    	          	     
+    	      filter.setScope("/test/");
+    	      
+    	      Query query = queryManager.createQuery(filter);
+    	      
+    	      PersistenceManager persistenceManager = this.getPersistenceManager();
+    	      Collection result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 1", result.size() == 1);
+    	      Paragraph paragraph = (Paragraph) result.iterator().next();
+    	      assertTrue("Invalid paragraph found" , paragraph.getText().equals("Para 1"));
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+    /**
+     * Test the like "like" expression
+     */
+    public void testGetObjectsLike()
+    {
+
+    	try
+    	{
+    		
+    		  // Build the Query Object
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(Paragraph.class);
+    	      filter.addLike("text", "Para%");    	          	     
+    	      filter.setScope("/test/");
+    	      
+    	      Query query = queryManager.createQuery(filter);
+    	      
+    	      PersistenceManager persistenceManager = this.getPersistenceManager();
+    	      Collection result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 3", result.size() == 3);
+
+    	      Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
+    	      assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 1"));
+    	      assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
+    	      assertTrue("Invalid paragraph found", paragraphs[2].getText().equals("Para 3"));
+    	      
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+    
+    
+    /**
+     * Build an or expression between 2 filters
+     *
+     */
+    public void testGetObjectsOr()
+    {
+
+    	try
+    	{
+    		
+    		  // Build the Query Object
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter1 = queryManager.createFilter(Paragraph.class);
+    	      filter1.addEqualTo("text", "Para 1");    	     
+    	      filter1.setScope("/test/");
+
+    	      Filter filter2 = queryManager.createFilter(Paragraph.class);
+    	      filter2.addEqualTo("text", "Para 2");    	     
+    	      
+              filter1.addOrFilter(filter2);
+    	      
+    	      Query query = queryManager.createQuery(filter1);
+    	      
+    	      PersistenceManager persistenceManager = this.getPersistenceManager();
+    	      Collection result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 2", result.size() == 2);
+    	      
+    	      Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
+    	      assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 1"));
+    	      assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+    
+    public void testGetObjectOrderBy()
+    {
+
+    	try
+    	{
+    		
+    		  // Build the Query Object
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(Paragraph.class);
+    	      filter.addLike("text", "Para%");    	          	     
+    	      filter.setScope("/test/");
+    	      
+    	      Query query = queryManager.createQuery(filter);
+    	      query.addOrderByDescending("text");
+    	      
+    	      PersistenceManager persistenceManager = this.getPersistenceManager();
+    	      Collection result = persistenceManager.getObjects(query);
+    	      assertTrue("Invalid number of objects - should be = 3", result.size() == 3);
+
+    	      Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
+    	      assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 3"));
+    	      assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
+    	      assertTrue("Invalid paragraph found", paragraphs[2].getText().equals("Para 1"));
+    	      
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+    
+    private void importData() throws JcrMappingException 
+    {
+    	PersistenceManager persistenceManager = getPersistenceManager();
+
+        Page page = new Page();
+        page.setPath("/test");
+        page.setTitle("Page Title");
+        
+        ArrayList paragraphs = new ArrayList();
+        
+        paragraphs.add(new Paragraph("Para 1"));
+        paragraphs.add(new Paragraph("Para 2"));
+        paragraphs.add(new Paragraph("Para 3"));
+        paragraphs.add(new Paragraph("Another Para "));
+        page.setParagraphs(paragraphs);
+        
+        persistenceManager.insert(page);  
+        persistenceManager.save();
+                
+
+    }
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,165 @@
+/* ========================================================================
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+
+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.TestBase;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.testmodel.A;
+import org.apache.portals.graffito.jcr.testmodel.B;
+import org.apache.portals.graffito.jcr.testmodel.C;
+
+/**
+ * Test JcrSession
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(PersistenceManagerTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public PersistenceManagerTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(PersistenceManagerTest.class);
+    }
+
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+    	if (getPersistenceManager().objectExists("/test"))
+    	{
+    	   getPersistenceManager().remove("/test");
+    	   getPersistenceManager().save();
+    	}
+        super.tearDown();
+    }
+    
+    public void testClassA()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+            A a = new A();
+            a.setPath("/test");
+            a.setA1("a1");
+            a.setA2("a2");
+            B b = new B();
+            b.setB1("b1");
+            b.setB2("b2");
+            a.setB(b);
+            
+            C c1 = new C();
+            c1.setId("first");
+            c1.setName("First Element");
+            C c2 = new C();
+            c2.setId("second");
+            c2.setName("Second Element");
+            
+            C c3 = new C();
+            c3.setId("third");
+            c3.setName("Third Element");
+            
+            
+            Collection collection = new ArrayList();
+            collection.add(c1);
+            collection.add(c2);
+            collection.add(c3);
+            
+            a.setCollection(collection);
+            
+            persistenceManager.insert(a);
+            persistenceManager.save();
+            
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) persistenceManager.getObject(A.class, "/test");
+            assertNotNull("a is null", a);
+            assertTrue("Incorrect a1", a.getA1().equals("a1"));
+            assertNotNull("a.b is null", a.getB());
+            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("b1"));
+            assertNotNull("a.collection is null", a.getCollection());
+            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            a.setA1("new value");
+            B newB = new B();
+            newB.setB1("new B1");
+            newB.setB2("new B2");
+            a.setB(newB);
+            
+            
+            persistenceManager.update(a);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) persistenceManager.getObject(A.class, "/test");
+            assertNotNull("a is null", a);
+            assertTrue("Incorrect a1", a.getA1().equals("new value"));
+            assertNotNull("a.b is null", a.getB());
+            assertTrue("Incorrect a.b.b1", a.getB().getB1().equals("new B1"));
+            
+
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+    
+    public void testIsPersistent()
+    {    
+    	PersistenceManager persistenceManager = getPersistenceManager();
+    	assertTrue("Class A is not persistent ", persistenceManager.isPersistent(A.class));
+    	assertFalse("Class String is  persistent - hum ? ", persistenceManager.isPersistent(String.class));
+    }
+    
+
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,110 @@
+/* ========================================================================
+ * 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.query.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.TestBase;
+import org.apache.portals.graffito.jcr.query.Filter;
+import org.apache.portals.graffito.jcr.query.Query;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.testmodel.C;
+
+
+/**
+ * Test QueryManagerImpl methods
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class QueryManagerTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(QueryManagerTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public QueryManagerTest(String testName)  throws Exception
+    {
+        super(testName);
+        initPersistenceManager();
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(QueryManagerTest.class);
+    }
+
+    public void testBuildExpression1()
+    {
+
+    	try
+    	{
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(C.class);
+    	      filter.addEqualTo("name", "a test value");
+    	      filter.addEqualTo("id", new Integer(1));
+    	      filter.setScope("/test//");
+    	      
+    	      Query query = queryManager.createQuery(filter);
+    	      String jcrExpression = queryManager.buildJCRExpression(query);
+    	      assertNotNull("jcrExpression is null", jcrExpression);
+    	      assertTrue("Invalid JcrExpression", jcrExpression.equals("/jcr:root/test//element(*, graffito:C) [@graffito:name = 'a test value' and @graffito:id = 1]"));
+    	      
+    	      
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+    public void testBuildExpression2()
+    {
+
+    	try
+    	{
+    	      QueryManager queryManager = this.getQueryManager();
+    	      Filter filter = queryManager.createFilter(C.class);
+    	      filter.addEqualTo("name", "a test value");
+    	      filter.addEqualTo("id", new Integer(1));    	      
+    	      
+    	      Query query = queryManager.createQuery(filter);
+    	      String jcrExpression = queryManager.buildJCRExpression(query);
+    	      assertNotNull("jcrExpression is null", jcrExpression);
+    	      assertTrue("Invalid JcrExpression", jcrExpression.equals("//element(*, graffito:C) [@graffito:name = 'a test value' and @graffito:id = 1]"));
+    	      
+    	      
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+    
+
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,232 @@
+/* ========================================================================
+ * 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.repository;
+
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.Node;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.nodetype.NodeTypeManager;
+import javax.transaction.UserTransaction;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.transaction.jackrabbit.UserTransactionImpl;
+
+/** Testcase for RepositoryUtil.
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class RepositoryUtilTest extends TestCase
+{
+    private final static Log log = LogFactory.getLog(RepositoryUtilTest.class);
+    private static boolean isInit = false;
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public RepositoryUtilTest(String testName)
+    {
+        super(testName);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        if (! isInit)
+        {
+            RepositoryUtil.registerRepository("repositoryTest", "src/test-config/repository.xml", "target/repository");
+            isInit = true;
+        }
+    }
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(RepositoryUtilTest.class);
+    }
+
+    /**
+     * Test for getRepository() and login
+     *
+     */
+    public void testgetRegistryAndLogin()
+    {
+        try
+        {
+            Repository repository = RepositoryUtil.getRepository("repositoryTest");
+            assertNotNull("The repository is null", repository);
+            Session session = RepositoryUtil.login(repository, "superuser", "superuser");
+            Node root = session.getRootNode();
+            assertNotNull("Root node is null", root);
+            session.logout();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Unable to find the repository : " + e);
+        }
+
+    }
+    
+    /**
+     * Simple unit test to check if custome node types are well defined
+     *
+     */
+    public void testgetCustomNodeType()
+    {
+        try
+        {
+            Repository repository = RepositoryUtil.getRepository("repositoryTest");           
+            Session session = RepositoryUtil.login(repository, "superuser", "superuser");
+            NodeTypeManager nodeTypeManager = session.getWorkspace().getNodeTypeManager();
+            
+            // TODO custom node types not implemented yet
+            
+            //NodeType nodeType = nodeTypeManager.getNodeType("graffito:folder");
+            //assertNotNull("Root node is null", nodeType);
+            
+            session.logout();
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Unable to find the repository : " + e);
+        }
+    }
+
+    /**
+     * Test for getParentPath() 
+     *
+     */
+    public void testgetParentPath()
+    {
+        try
+        {
+            String parentPath = RepositoryUtil.getParentPath("/test");
+            assertNotNull("parent path is null for /test", parentPath);
+            assertTrue("parent path is incorrect for /test", parentPath.equals("/"));
+
+            parentPath = RepositoryUtil.getParentPath("/test/test2");
+            assertNotNull("parent path is null for /test/test2", parentPath);
+            assertTrue("parent path is incorrect for /test/test2", parentPath.equals("/test"));
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Unable to find the repository : " + e);
+        }
+    }
+    
+    /**
+     * Test for getNodeName() 
+     *
+     */
+    public void testgetNodeName()
+    {
+        try
+        {
+            String nodeName = RepositoryUtil.getNodeName("/test");
+            assertNotNull("node name is null for /test", nodeName);
+            assertTrue("node name is incorrect for /test", nodeName.equals("test"));
+            
+            nodeName = RepositoryUtil.getNodeName("/test/test2");
+            assertNotNull("node name is null for /test/test2", nodeName);
+            assertTrue("node name is incorrect for /test/test2", nodeName.equals("test2"));
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Unable to find the repository : " + e);
+        }
+    }   
+    
+    public void testEncodePath()
+    {
+         String encodedPath = RepositoryUtil.encodePath("/files/test/1.0");
+         assertTrue("Incorrect encoded path", encodedPath.equals("/files/test/_x0031_.0"));
+
+         encodedPath = RepositoryUtil.encodePath("/files/test/12aa/b/34/rrr/1.0");
+         assertTrue("Incorrect encoded path", encodedPath.equals("/files/test/_x0031_2aa/b/_x0033_4/rrr/_x0031_.0"));
+
+    }
+    
+    public void testUserTransaction()
+    {
+    	try
+		{
+			Repository repository = RepositoryUtil.getRepository("repositoryTest");
+			assertNotNull("The repository is null", repository);
+			Session session = RepositoryUtil.login(repository, "superuser",
+					"superuser");
+
+			UserTransaction utx = new UserTransactionImpl(session);
+
+			// start transaction
+			utx.begin();
+
+			// add node and save
+			Node root = session.getRootNode();
+			Node n = root.addNode("test");
+			root.save();
+			utx.commit();
+			
+			assertTrue("test node doesn't exist", session.itemExists("/test"));
+			
+			utx = new UserTransactionImpl(session);
+			utx.begin();
+			Node test = (Node) session.getItem("/test");
+			test.remove();
+			session.save();
+			utx.rollback();
+			
+			assertTrue("test node doesn't exist", session.itemExists("/test"));			
+
+			utx = new UserTransactionImpl(session);
+			utx.begin();
+			test = (Node) session.getItem("/test");
+			test.remove();
+			session.save();
+			utx.commit();
+			
+			assertFalse("test node exists", session.itemExists("/test"));			
+			
+		}
+		catch (Exception e)
+		{
+
+		}
+    }
+    
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,131 @@
+/*
+ * Copyright 2000-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.testmodel;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class A
+{
+	private String path; 
+    private String a1;
+    private String a2;
+    private B b;
+    private B emptyB;
+    private Collection collection;
+    private Collection emptyCollection; 
+    
+    
+    
+    public String getPath() {
+		return path;
+	}
+	public void setPath(String path) {
+		this.path = path;
+	}
+	/**
+     * @return Returns the a1.
+     */
+    public String getA1()
+    {
+        return a1;
+    }
+    /**
+     * @param a1 The a1 to set.
+     */
+    public void setA1(String a1)
+    {
+        this.a1 = a1;
+    }
+    /**
+     * @return Returns the a2.
+     */
+    public String getA2()
+    {
+        return a2;
+    }
+    /**
+     * @param a2 The a2 to set.
+     */
+    public void setA2(String a2)
+    {
+        this.a2 = a2;
+    }
+    /**
+     * @return Returns the b.
+     */
+    public B getB()
+    {
+        return b;
+    }
+    /**
+     * @param b The b to set.
+     */
+    public void setB(B b)
+    {
+        this.b = b;
+    }
+    
+        
+    /**
+     * @return Returns the collection.
+     */
+    public Collection getCollection()
+    {
+        return collection;
+    }
+    
+    /**
+     * @param collection The collection to set.
+     */
+    public void setCollection(Collection collection)
+    {
+        this.collection = collection;
+    }
+    
+    public void addC(C c)
+    {
+       if (collection == null )
+       {
+           collection = new ArrayList();
+       }
+       
+       collection.add(c);   
+    }
+    public Collection getEmptyCollection()
+    {
+        return emptyCollection;
+    }
+    public void setEmptyCollection(Collection emptyCollection)
+    {
+        this.emptyCollection = emptyCollection;
+    }
+    public B getEmptyB()
+    {
+        return emptyB;
+    }
+    public void setEmptyB(B emptyB)
+    {
+        this.emptyB = emptyB;
+    }
+    
+    
+}

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Atomic.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Atomic.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Atomic.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Atomic.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2000-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.testmodel;
+
+import java.io.InputStream;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+
+/**
+ *
+ * Simple object used to test atomic type
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class Atomic
+{
+	private String path;
+    private String string;
+    private Boolean booleanObject;
+    private boolean booleanPrimitive;
+    private Integer integerObject;
+    private int intPrimitive;
+    private byte[] byteArray;
+    private Calendar calendar;
+    private Date date;
+    private Double doubleObject;
+    private double doublePrimitive;
+    private InputStream inputStream;
+    private Timestamp timestamp;
+    private Collection multiValue;
+    
+    
+    
+    public String getPath() {
+		return path;
+	}
+	public void setPath(String path) {
+		this.path = path;
+	}
+	public Boolean getBooleanObject()
+    {
+        return booleanObject;
+    }
+    public void setBooleanObject(Boolean booleanObject)
+    {
+        this.booleanObject = booleanObject;
+    }
+    public boolean isBooleanPrimitive()
+    {
+        return booleanPrimitive;
+    }
+    public void setBooleanPrimitive(boolean booleanPrimitive)
+    {
+        this.booleanPrimitive = booleanPrimitive;
+    }
+    public Integer getIntegerObject()
+    {
+        return integerObject;
+    }
+    public void setIntegerObject(Integer integerObject)
+    {
+        this.integerObject = integerObject;
+    }
+    public int getIntPrimitive()
+    {
+        return intPrimitive;
+    }
+    public void setIntPrimitive(int intPrimitive)
+    {
+        this.intPrimitive = intPrimitive;
+    }
+    public String getString()
+    {
+        return string;
+    }
+    public void setString(String string)
+    {
+        this.string = string;
+    }
+    public byte[] getByteArray()
+    {
+        return byteArray;
+    }
+    public void setByteArray(byte[] byteArray)
+    {
+        this.byteArray = byteArray;
+    }
+    public Calendar getCalendar()
+    {
+        return calendar;
+    }
+    public void setCalendar(Calendar calandar)
+    {
+        this.calendar = calandar;
+    }
+    public Date getDate()
+    {
+        return date;
+    }
+    public void setDate(Date date)
+    {
+        this.date = date;
+    }
+    public Double getDoubleObject()
+    {
+        return doubleObject;
+    }
+    public void setDoubleObject(Double doubleObject)
+    {
+        this.doubleObject = doubleObject;
+    }
+    public double getDoublePrimitive()
+    {
+        return doublePrimitive;
+    }
+    public void setDoublePrimitive(double doublePrimitive)
+    {
+        this.doublePrimitive = doublePrimitive;
+    }
+    public InputStream getInputStream()
+    {
+        return inputStream;
+    }
+    public void setInputStream(InputStream inputStream)
+    {
+        this.inputStream = inputStream;
+    }
+    public Timestamp getTimestamp()
+    {
+        return timestamp;
+    }
+    public void setTimestamp(Timestamp timestamp)
+    {
+        this.timestamp = timestamp;
+    }
+    
+	public Collection getMultiValue()
+	{
+		return multiValue;
+	}
+	public void setMultiValue(Collection multiValue)
+	{
+		this.multiValue = multiValue;
+	}
+    
+    
+}

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2000-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.testmodel;
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class B
+{
+     private String b1;
+     private String b2;
+     
+     
+    /**
+     * @return Returns the b1.
+     */
+    public String getB1()
+    {
+        return b1;
+    }
+    /**
+     * @param b1 The b1 to set.
+     */
+    public void setB1(String b1)
+    {
+        this.b1 = b1;
+    }
+    /**
+     * @return Returns the b2.
+     */
+    public String getB2()
+    {
+        return b2;
+    }
+    /**
+     * @param b2 The b2 to set.
+     */
+    public void setB2(String b2)
+    {
+        this.b2 = b2;
+    }
+}

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/C.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/C.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/C.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/C.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2000-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.testmodel;
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class C
+{
+     private String id;
+     private String name;
+     
+    /**
+     * @return Returns the id.
+     */
+    public String getId()
+    {
+        return id;
+    }
+    /**
+     * @param id The id to set.
+     */
+    public void setId(String id)
+    {
+        this.id = id;
+    }
+    /**
+     * @return Returns the name.
+     */
+    public String getName()
+    {
+        return name;
+    }
+    /**
+     * @param name The name to set.
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+}

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/CmsObject.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/CmsObject.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/CmsObject.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/CmsObject.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,197 @@
+/*
+ * Copyright 2000-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.testmodel;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/**
+ * CmsObject test
+ * 
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ * 
+ */
+public class CmsObject
+{
+    public static final long serialVersionUID = 1;
+    
+    protected Long objectId;
+        
+    protected Long parentId;  //parent folder id
+    protected Folder parentFolder;
+    
+    protected String name;
+    
+    protected String description;
+    protected String title;
+    protected Date creationDate;
+    protected Date lastModified;
+    
+    /** 
+     * Special attribute telling OJB the object's concrete type.
+     *  
+     */    
+    protected String ojbConcreteClass; 
+       
+    /**
+     * Constructor
+     */
+    public CmsObject()
+    {
+        ojbConcreteClass = this.getClass().getName();       
+    }
+    
+    
+        
+    /**
+     * @return Returns the parentFolder.
+     */
+    public Folder getParentFolder()
+    {
+        return parentFolder;
+    }
+
+    /**
+     * @param parentFolder The parentFolder to set.
+     */
+    public void setParentFolder(Folder parentFolder)
+    {
+        this.parentFolder = parentFolder;
+    }
+
+    /**
+     * @param parentId The parentId to set.
+     */
+    public void setParentId(Long parentId)
+    {
+        this.parentId = parentId;
+    }
+
+    /**
+     * @return Returns the parentId.
+     */
+    public Long getParentId()
+    {
+        return parentId;
+    }
+       
+    
+    /**
+     * @return Returns the objectId.
+     */
+    public Long getObjectId()
+    {
+        return objectId;
+    }
+
+    /**
+     * @param objectId The objectId to set.
+     */
+    public void setObjectId(Long objectId)
+    {
+        this.objectId = objectId;
+    }
+    
+
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#getName()
+     */
+    public String getName()
+    {
+        return this.name;
+    }
+
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#getCreationDate()
+     */
+    public Date getCreationDate()
+    {
+        return this.creationDate;
+    }
+
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#setCreationDate(java.util.Date)
+     */
+    public void setCreationDate(Date creationDate)
+    {
+        this.creationDate = creationDate;
+    }
+
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#getLastModified()
+     */
+    public Date getLastModified()
+    {
+        return this.lastModified;
+    }
+
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#setLastModified(java.util.Date)
+     */
+    public void setLastModified(Date lastModified)
+    {
+        this.lastModified = lastModified;
+    }
+
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#getDescription()
+     */
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    /* 
+     * @see org.apache.portals.graffito.model.CmsObject#setDescription(java.lang.String)
+     */
+    public void setDescription(String v)
+    {
+        this.description = v;
+    }
+
+    /** 
+     * @see org.apache.portals.graffito.model.CmsObject#getTitle()
+     */
+    public String getTitle()
+    {
+        return this.title;
+    }
+
+    /** 
+     * @see org.apache.portals.graffito.model.CmsObject#setTitle(java.lang.String)
+     */    
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+    
+    
+ 
+    
+    
+}

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Content.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Content.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Content.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Content.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2000-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.testmodel;
+
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+
+
+/**
+ * Content object
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ */
+public class Content 
+{
+    protected final static Log log = LogFactory.getLog(Content.class);
+  
+    protected Long contentId;    
+   
+    protected byte[] content;
+    
+    protected String encoding;
+
+
+    /**
+     * @return Returns the content.
+     */
+    public InputStream getContentStream()
+    {
+        return new ByteArrayInputStream(content);        
+    }
+
+    /**
+     * @return Returns the content.
+     */
+    public byte[] getContentByte()
+    {
+        
+        return content;
+    }
+
+
+    /**
+     * @param stream The content to set.
+     */
+    public void setContent(byte[] stream)
+    {
+        
+        content = stream;
+
+    }
+        
+    /**
+     * @return Returns the encoding.
+     */
+    public String getEncoding()
+    {
+        return encoding;
+    }
+    
+    /**
+     * @param encoding The encoding to set.
+     */
+    public void setEncoding(String encoding)
+    {
+        this.encoding = encoding;
+    }
+}
+
+

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Document.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Document.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Document.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Document.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2000-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.testmodel;
+
+
+import java.util.*;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * CMS VersionnedDocument implementation.
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ * 
+ */
+public class Document extends CmsObject
+{
+    protected final static Log log =  LogFactory.getLog(Document.class);
+    
+    protected long size;
+    protected String contentType;   
+        
+    protected Content content;
+
+
+    /** 
+     * @see org.apache.portals.graffito.model.Document#getContentType()
+     */
+    public String getContentType()
+    {
+        return this.contentType;
+    }
+
+    /**
+     * @see org.apache.portals.graffito.model.Document#setContentType(java.lang.String)
+     */
+    public void setContentType(String contentType)
+    {
+        this.contentType = contentType;
+    }
+
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.model.Document#getSize()
+     */
+    public long getSize()
+    {
+        return size;
+    }
+
+    /**
+     * 
+     * @see org.apache.portals.graffito.model.Document#setSize(long)
+     */
+    public void setSize(long size)
+    {
+        this.size = size;
+    }
+
+    
+    public Content getContent()
+    {
+        return content;
+    }
+    public void setContent(Content content)
+    {
+        this.content = content;
+    }
+}
+



Mime
View raw message