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 [1/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
Author: clombart
Date: Mon Dec  5 12:37:06 2005
New Revision: 354168

URL: http://svn.apache.org/viewcvs?rev=354168&view=rev
Log:
Move jcr-mapping project

Added:
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/log4j.properties
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/AtomicTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/NullAtomicTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImplTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerBasicVersionningTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerIteratorQueryTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerMultiValueQueryTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerRemoveTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSameNameSiblingTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerScopeQueryTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerSimpleQueryTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/query/impl/QueryManagerTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/repository/RepositoryUtilTest.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/A.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Atomic.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/B.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/C.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/CmsObject.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Content.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Document.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/File.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Folder.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/MultiValue.java
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Page.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Paragraph.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Element.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/HashMapElement.java   (with props)
    incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Main.java   (with props)

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/log4j.properties
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/log4j.properties?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/log4j.properties (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/log4j.properties Mon Dec  5 12:37:06 2005
@@ -0,0 +1,38 @@
+/* ========================================================================
+ * 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.
+ * ========================================================================
+ */
+
+# ------------------------------------------------------------------------
+#
+# Logging Configuration
+#
+# $Id: Log4j.properties,v 1.3 2004/12/22 20:37:04 christophe Exp $
+#
+# ------------------------------------------------------------------------
+
+log4j.rootLogger = WARN, console
+
+log4j.category.org.apache.portals.graffito.jcr= DEBUG, console
+log4j.additivity.org.apache.portals.graffito.jcr=false
+
+#
+# Console
+#
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.console.layout.ConversionPattern=%5p: %m%n
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/TestBase.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,227 @@
+/* ========================================================================
+ * 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;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+
+import javax.jcr.ImportUUIDBehavior;
+import javax.jcr.Repository;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import junit.framework.TestCase;
+
+import org.apache.portals.graffito.jcr.exception.RepositoryException;
+import org.apache.portals.graffito.jcr.mapper.impl.DigesterMapperImpl;
+import org.apache.portals.graffito.jcr.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.BinaryTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.BooleanTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.ByteArrayTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.CalendarTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.DoubleTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.IntTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.LongTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.StringTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.TimestampTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.UtilDateTypeConverterImpl;
+import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl;
+import org.apache.portals.graffito.jcr.query.QueryManager;
+import org.apache.portals.graffito.jcr.query.impl.QueryManagerImpl;
+import org.apache.portals.graffito.jcr.repository.RepositoryUtil;
+import org.xml.sax.ContentHandler;
+
+/**
+ * Base class for testcases. Provides priviledged access to the jcr test
+ * repository.
+ * 
+ * @author <a href="mailto:okiessler@apache.org">Oliver Kiessler</a>
+ * @version $Id: Exp $
+ */
+public abstract class TestBase extends TestCase
+{
+
+	protected Session session;
+
+	private PersistenceManager persistenceManager;
+
+	private QueryManager queryManager;
+
+	DigesterMapperImpl mapper;
+
+	private static boolean isInit = false;
+
+	/**
+	 * <p>
+	 * Defines the test case name for junit.
+	 * </p>
+	 * 
+	 * @param testName
+	 *            The test case name.
+	 */
+	public TestBase(String testName)
+	{
+		super(testName);
+
+		try
+		{
+			if (!isInit)
+			{
+				RepositoryUtil.registerRepository("repositoryTest", "./src/test-config/repository.xml", "./target/repository");
+				isInit = true;
+			}
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail("Impossible to init the repository");
+		}
+	}
+
+	/**
+	 * Setting up the testcase.
+	 * 
+	 * @see junit.framework.TestCase#setUp()
+	 */
+	protected void setUp() throws Exception
+	{
+		super.setUp();
+	}
+
+	/**
+	 * @see junit.framework.TestCase#tearDown()
+	 */
+	public void tearDown() throws Exception
+	{
+		super.tearDown();
+	}
+
+	/**
+	 * Getter for property persistenceManager.
+	 * 
+	 * @return jcrSession
+	 */
+	public PersistenceManager getPersistenceManager()
+	{
+		try
+		{
+			if (persistenceManager == null)
+			{
+				initPersistenceManager();
+			}
+			return persistenceManager;
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			return null;
+		}
+	}
+
+	protected void initPersistenceManager() throws UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
+	{
+		Repository repository = RepositoryUtil.getRepository("repositoryTest");
+		String[] files = { "./src/test-config/jcrmapping.xml", "./src/test-config/jcrmapping-atomic.xml" };
+		session = RepositoryUtil.login(repository, "superuser", "superuser");		
+		HashMap atomicTypeConverters = new HashMap();
+		atomicTypeConverters.put(String.class, new StringTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(InputStream.class, new BinaryTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(long.class, new LongTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(Long.class, new LongTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(int.class, new IntTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(Integer.class, new IntTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(double.class, new DoubleTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(Double.class, new DoubleTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(boolean.class, new BooleanTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(Boolean.class, new BooleanTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(Calendar.class, new CalendarTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(GregorianCalendar.class, new CalendarTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(Date.class, new UtilDateTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(byte[].class, new ByteArrayTypeConverterImpl(session.getValueFactory()));
+		atomicTypeConverters.put(Timestamp.class, new TimestampTypeConverterImpl(session.getValueFactory()));
+		
+		mapper = new DigesterMapperImpl(files);						
+		queryManager = new QueryManagerImpl(mapper, atomicTypeConverters);
+		persistenceManager = new PersistenceManagerImpl(mapper, atomicTypeConverters, queryManager, session);
+		
+	}
+
+	/**
+	 * Setter for property jcrSession.
+	 * 
+	 * @param persistenceManager
+	 *            The persistence manager
+	 */
+	public void setPersistenceManager(PersistenceManager persistenceManager)
+	{
+		this.persistenceManager = persistenceManager;
+	}
+
+	public void exportDocument(String filePath, String nodePath, boolean skipBinary, boolean noRecurse)
+	{
+		try
+		{
+			BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(filePath));
+			ContentHandler handler = new org.apache.xml.serialize.XMLSerializer(os, null).asContentHandler();
+			session.exportDocumentView(nodePath, handler, skipBinary, noRecurse);
+			os.flush();
+			os.close();
+		}
+		catch (Exception e)
+		{
+			System.out.println("Impossible to export the content from : " + nodePath);
+			e.printStackTrace();
+		}
+	}
+
+	public void importDocument(String filePath, String nodePath)
+	{
+		try
+		{
+			BufferedInputStream is = new BufferedInputStream(new FileInputStream(filePath));
+			session.importXML(nodePath, is, ImportUUIDBehavior.IMPORT_UUID_CREATE_NEW);
+			session.save();
+			is.close();
+		}
+		catch (Exception e)
+		{
+			System.out.println("Impossible to import the content from : " + nodePath);
+			e.printStackTrace();
+		}
+
+	}
+
+	protected Session getSession()
+	{
+		return this.session;
+	}
+
+	public QueryManager getQueryManager()
+	{
+		return this.queryManager;
+	}
+
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/mapper/DigesterMapperImplTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,172 @@
+/* ========================================================================
+ * 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.mapper;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.portals.graffito.jcr.exception.JcrMappingException;
+import org.apache.portals.graffito.jcr.mapper.impl.DigesterMapperImpl;
+import org.apache.portals.graffito.jcr.mapper.model.BeanDescriptor;
+import org.apache.portals.graffito.jcr.mapper.model.ClassDescriptor;
+import org.apache.portals.graffito.jcr.mapper.model.CollectionDescriptor;
+import org.apache.portals.graffito.jcr.mapper.model.FieldDescriptor;
+import org.apache.portals.graffito.jcr.testmodel.A;
+import org.apache.portals.graffito.jcr.testmodel.B;
+
+/**
+ * Test Mapper
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class DigesterMapperImplTest extends TestCase
+{
+
+    
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public DigesterMapperImplTest(String testName)
+    {
+        super(testName);
+    }
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+    }
+
+    /**
+     * @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(DigesterMapperImplTest.class);
+    }
+
+    /**
+     * Test for getConverter
+     *
+     */
+    public void testMapper()    
+    {
+        try
+        {
+            DigesterMapperImpl mapper = new DigesterMapperImpl("./src/test-config/jcrmapping.xml");
+            assertNotNull("Mapper is null", mapper);
+            
+            ClassDescriptor classDescriptor = mapper.getClassDescriptor(A.class);
+            assertNotNull("ClassDescriptor is null", classDescriptor);
+            assertTrue("Invalid classname", classDescriptor.getClassName().equals(A.class.getName()));
+            assertTrue("Invalid path field", classDescriptor.getPathFieldDescriptor().getFieldName().equals("path"));
+            
+            FieldDescriptor fieldDescriptor = classDescriptor.getFieldDescriptor("a1");
+            assertNotNull("FieldDescriptor is null", fieldDescriptor);
+            assertTrue("Invalid jcrName for field a1", fieldDescriptor.getJcrName().equals("a1"));
+            
+            BeanDescriptor beanDescriptor = classDescriptor.getBeanDescriptor("b");
+            assertNotNull("BeanDescriptor is null", beanDescriptor);
+            assertTrue("Invalid jcrName for field b", beanDescriptor.getJcrName().equals("b"));
+            
+            CollectionDescriptor collectionDescriptor = classDescriptor.getCollectionDescriptor("collection");
+            assertNotNull("CollectionDescriptor is null", collectionDescriptor);
+            assertTrue("Invalid jcrName for field collection", collectionDescriptor.getJcrName().equals("collection"));
+        }
+        catch (JcrMappingException e)
+        {
+              e.printStackTrace();
+              fail("Impossible to retrieve the converter " + e);
+        }
+    }
+    
+    /**
+     * Test for getConverter
+     *
+     */
+    public void testMapperOptionalProperties()    
+    {
+        try
+        {
+            DigesterMapperImpl mapper = new DigesterMapperImpl("./src/test-config/jcrmapping.xml");
+            assertNotNull("Mapper is null", mapper);
+            
+            ClassDescriptor classDescriptor = mapper.getClassDescriptor(B.class);
+            assertNotNull("ClassDescriptor is null", classDescriptor);
+            assertTrue("Invalid classname", classDescriptor.getClassName().equals(B.class.getName()));
+            assertEquals(classDescriptor.getJcrSuperTypes(), "nt:base");
+            
+            FieldDescriptor b1Field = classDescriptor.getFieldDescriptor("b1");
+            assertNotNull("FieldDescriptor is null", b1Field);
+            assertEquals(b1Field.getFieldName(), "b1");
+            assertEquals(b1Field.getJcrType(), "String");
+            assertFalse(b1Field.isJcrAutoCreated());
+            assertFalse(b1Field.isJcrMandatory());
+            assertFalse(b1Field.isJcrProtected());
+            assertFalse(b1Field.isJcrMultiple());
+            assertEquals(b1Field.getJcrOnParentVersion(), "IGNORE");
+            
+            FieldDescriptor b2Field = classDescriptor.getFieldDescriptor("b2");
+            assertNotNull("FieldDescriptor is null", b2Field);
+            assertEquals(b2Field.getFieldName(), "b2");
+            assertEquals(b2Field.getJcrType(), "String");
+            assertTrue(b2Field.isJcrAutoCreated());
+            assertTrue(b2Field.isJcrMandatory());
+            assertTrue(b2Field.isJcrProtected());
+            assertTrue(b2Field.isJcrMultiple());
+            assertEquals(b2Field.getJcrOnParentVersion(), "COPY");
+            
+            ClassDescriptor classDescriptor2 = mapper.getClassDescriptor(A.class);
+            assertNotNull("ClassDescriptor is null", classDescriptor2);
+            assertTrue("Invalid classname", classDescriptor2.getClassName().equals(A.class.getName()));
+            
+            BeanDescriptor beanDescriptor = classDescriptor2.getBeanDescriptor("b");
+            assertNotNull(beanDescriptor);
+            assertEquals(beanDescriptor.getFieldName(), "b");
+            assertEquals(beanDescriptor.getJcrNodeType(), "nt:unstructured");
+            assertFalse(beanDescriptor.isJcrAutoCreated());
+            assertFalse(beanDescriptor.isJcrMandatory());
+            assertFalse(beanDescriptor.isJcrProtected());
+            assertFalse(beanDescriptor.isJcrSameNameSiblings());
+            assertEquals(beanDescriptor.getJcrOnParentVersion(), "IGNORE");
+            
+            CollectionDescriptor collectionDescriptor = classDescriptor2.getCollectionDescriptor("collection");
+            assertNotNull(collectionDescriptor);
+            assertEquals(collectionDescriptor.getJcrNodeType(), "graffito:C");
+            assertFalse(collectionDescriptor.isJcrAutoCreated());
+            assertFalse(collectionDescriptor.isJcrMandatory());
+            assertFalse(collectionDescriptor.isJcrProtected());
+            assertFalse(collectionDescriptor.isJcrSameNameSiblings());
+            assertEquals(collectionDescriptor.getJcrOnParentVersion(), "IGNORE");
+        }
+        catch (JcrMappingException e)
+        {
+              e.printStackTrace();
+              fail("Impossible to retrieve the converter " + e);
+        }
+    }
+}
\ No newline at end of file

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/AtomicTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/AtomicTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/AtomicTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/AtomicTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,147 @@
+/* ========================================================================
+ * 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.atomicconverter;
+
+import java.io.ByteArrayInputStream;
+import java.sql.Timestamp;
+import java.util.Calendar;
+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.testmodel.Atomic;
+
+/**
+ * Test Atomic perisstence fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class AtomicTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(AtomicTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public AtomicTest(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(AtomicTest.class);
+    }
+
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            getPersistenceManager().save();
+        }        
+    	
+        super.tearDown();
+    }
+    
+    public void testAtomicFields()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+        	Date date = new Date();
+        	Calendar calendar = Calendar.getInstance();
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+            Atomic a = new Atomic();
+            a.setPath("/test");
+            a.setBooleanObject(new Boolean(true));
+            a.setBooleanPrimitive(true);
+            a.setIntegerObject(new Integer(100));
+            a.setIntPrimitive(200);
+            a.setString("Test String");
+            a.setDate(date);
+            
+            byte[] content = "Test Byte".getBytes();
+            a.setByteArray(content);
+            a.setCalendar(calendar);
+            a.setDoubleObject(new Double(2.12));
+            a.setDoublePrimitive(1.23);
+            long now = System.currentTimeMillis();
+            a.setTimestamp(new Timestamp(now));
+            
+            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("Test Stream".getBytes());
+            a.setInputStream(byteArrayInputStream);
+            
+            persistenceManager.insert(a);
+            persistenceManager.save();
+
+             
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
+            a = null;
+            a = (Atomic) persistenceManager.getObject(Atomic.class, "/test");
+            assertNotNull("a is null", a);
+            assertNotNull("Boolean object is null", a.getBooleanObject());
+            assertTrue("Incorrect boolean object", a.getBooleanObject().booleanValue());
+            assertTrue("Incorrect boolean primitive", a.isBooleanPrimitive());
+            assertNotNull("Integer Object is null", a.getIntegerObject());
+            assertTrue("Incorrect Integer object", a.getIntegerObject().intValue() == 100);
+            assertTrue("Incorrect int primitive", a.getIntPrimitive() == 200);
+            assertNotNull("String object is null", a.getString());
+            assertTrue("Incorrect boolean object", a.getString().equals("Test String"));
+            assertNotNull("Byte array object is null", a.getByteArray());
+            assertTrue("Incorrect byte object", new String(a.getByteArray()).equals("Test Byte"));
+            
+            assertNotNull("date object is null", a.getDate());
+            assertTrue("Invalid date", a.getDate().equals(date));            
+            assertNotNull("calendar object is null", a.getCalendar());
+            
+            log.debug("Calendar : " + a.getCalendar().get(Calendar.YEAR) + "-" + a.getCalendar().get(Calendar.MONTH) + "-" + a.getCalendar().get(Calendar.DAY_OF_MONTH));
+            assertTrue("Invalid calendar object", a.getCalendar().equals(calendar));
+            
+            assertNotNull("Double object is null", a.getDoubleObject());
+            assertTrue("Incorrect double object", a.getDoubleObject().doubleValue() == 2.12);
+            assertTrue("Incorrect double primitive", a.getDoublePrimitive() == 1.23);
+            
+            assertNotNull("Incorrect input stream primitive", a.getInputStream());
+            assertNotNull("Incorrect timestamp", a.getTimestamp());
+            assertTrue("Invalid timestamp value ", a.getTimestamp().getTime() == now);            
+            
+        }
+        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/atomicconverter/NullAtomicTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/NullAtomicTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/NullAtomicTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/atomicconverter/NullAtomicTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,132 @@
+/* ========================================================================
+ * 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.atomicconverter;
+
+import java.io.ByteArrayInputStream;
+import java.util.Calendar;
+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.testmodel.Atomic;
+
+/**
+ * Test Atomic perisstence fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class NullAtomicTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(NullAtomicTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public NullAtomicTest(String testName)
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new TestSuite(NullAtomicTest.class);
+    }
+    
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            getPersistenceManager().save();
+        }        
+    	
+        super.tearDown();
+    }    
+
+    public void testNullValueAtomicFields()
+    {
+        try
+        {
+
+        	PersistenceManager persistenceManager = getPersistenceManager();
+     
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+            Atomic a = new Atomic();
+            a.setPath("/test");
+            a.setIntegerObject(new Integer(100));            
+            a.setDate(new Date());
+            byte[] content = "Test Byte".getBytes();
+            a.setByteArray(content);
+            a.setCalendar(Calendar.getInstance());
+            a.setDoubleObject(new Double(2.12));
+            a.setDoublePrimitive(1.23);
+            
+            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream("Test Stream".getBytes());
+            a.setInputStream(byteArrayInputStream);
+            
+            persistenceManager.insert(a);
+            persistenceManager.save();
+             
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------
+            a = null;
+            a = (Atomic) persistenceManager.getObject(Atomic.class, "/test");
+            assertNotNull("a is null", a);
+            assertNull("Boolean object is not null", a.getBooleanObject());
+            
+            assertFalse("Incorrect boolean primitive", a.isBooleanPrimitive());
+            assertNotNull("Integer Object is null", a.getIntegerObject());
+            assertTrue("Incorrect Integer object", a.getIntegerObject().intValue() == 100);
+            assertTrue("Incorrect int primitive", a.getIntPrimitive() == 0);
+            assertNull("String object is not null", a.getString());            
+            assertNotNull("Byte array object is null", a.getByteArray());
+            assertTrue("Incorrect byte object", new String(a.getByteArray()).equals("Test Byte"));
+            
+            assertNotNull("date object is null", a.getDate());
+            assertNotNull("calendar object is null", a.getCalendar());
+            
+            assertNotNull("Double object is null", a.getDoubleObject());
+            assertTrue("Incorrect double object", a.getDoubleObject().doubleValue() == 2.12);
+            assertTrue("Incorrect double primitive", a.getDoublePrimitive() == 1.23);
+            
+            assertNotNull("Incorrect input stream primitive", a.getInputStream());
+            
+            
+        }
+        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/collectionconverter/impl/DefaultCollectionConverterImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,242 @@
+/* ========================================================================
+ * 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.collectionconverter.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.C;
+
+/**
+ * Test DefaultCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class DefaultCollectionConverterImplTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(DefaultCollectionConverterImplTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public DefaultCollectionConverterImplTest(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(DefaultCollectionConverterImplTest.class);
+    }
+
+    
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            getPersistenceManager().save();
+        }        
+    	
+        super.tearDown();
+    }
+    
+    public void testDropElement()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+            A a = new A();
+            a.setPath("/test");
+            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.collection is null", a.getCollection());
+            assertTrue("Incorrect a.collection size", a.getCollection().size() == 3);
+            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            c1 = new C();
+            c1.setId("new first");
+            c1.setName("First Element");
+            
+            c2 = new C();
+            c2.setId("new second");
+            c2.setName("Second Element");
+            
+            collection = new ArrayList();
+            collection.add(c1);
+            collection.add(c2);
+            a.setCollection(collection);
+            
+            persistenceManager.update(a);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) persistenceManager.getObject(A.class, "/test");
+            assertNotNull("a is null", a);
+            assertNotNull("a.collection is null", a.getCollection());
+            assertTrue("Incorrect collection size", a.getCollection().size() == 2);
+            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("new first"));
+            
+            // --------------------------------------------------------------------------------
+            // Export to check the content
+            // --------------------------------------------------------------------------------           
+            this.exportDocument("target/DefaultCollectionConverterExport.xml", "/test", true, false);         
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+    public void testAddElement()
+    {
+        try
+        {
+
+        	PersistenceManager persistenceManager = getPersistenceManager();
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+            A a = new A();
+            a.setPath("/test");
+            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.collection is null", a.getCollection());
+            assertTrue("Incorrect a.collection size", a.getCollection().size() == 3);
+            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            c1 = new C();
+            c1.setId("first");
+            c1.setName("First Element");
+            c2 = new C();
+            c2.setId("second");
+            c2.setName("Second Element");
+            
+            c3 = new C();
+            c3.setId("third");
+            c3.setName("Third Element");
+            
+            C c4 = new C();
+            c4.setId("Fourth");
+            c4.setName("Fourth Element");
+                
+            collection = new ArrayList();
+            collection.add(c1);
+            collection.add(c2);
+            collection.add(c3);
+            collection.add(c4);
+            a.setCollection(collection);
+            
+            persistenceManager.update(a);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) persistenceManager.getObject(A.class, "/test");
+            assertNotNull("a is null", a);
+            assertNotNull("a.collection is null", a.getCollection());
+            assertTrue("Incorrect collection size", a.getCollection().size() == 4);
+            assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }    
+   
+}
\ No newline at end of file

Propchange: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,149 @@
+/* ========================================================================
+ * 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.collectionconverter.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.persistence.PersistenceManager;
+import org.apache.portals.graffito.jcr.testmodel.hashmap.Element;
+import org.apache.portals.graffito.jcr.testmodel.hashmap.HashMapElement;
+import org.apache.portals.graffito.jcr.testmodel.hashmap.Main;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class HashMapTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(HashMapTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public HashMapTest(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(HashMapTest.class);
+    }
+
+    
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            getPersistenceManager().save();
+        }        
+    	
+        super.tearDown();
+    }    
+    
+    public void testHashMap()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+        	
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+
+            Main main = new Main();
+            main.setPath("/test");
+            main.setText("Main text");
+            
+            HashMapElement hashMapElement = new HashMapElement();
+            Element e1 = new Element();
+            e1.setId("e1");
+            e1.setText("Element 1");
+            hashMapElement.addObject(e1);
+            
+            Element e2 = new Element();
+            e2.setId("e2");
+            e2.setText("Element 2");
+            hashMapElement.addObject(e2);
+            
+            main.setElements(hashMapElement);
+            
+            persistenceManager.insert(main);
+            persistenceManager.save();
+            
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            main = (Main) persistenceManager.getObject(Main.class, "/test");
+            assertNotNull("main.getElements() is null", main.getElements());
+            assertTrue("Incorrect text", main.getText().equals("Main text"));           
+            assertTrue("Incorrect para element", ((Element) main.getElements().get("e1")).getText().equals("Element 1"));
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            hashMapElement = new HashMapElement();
+            e1 = new Element();
+            e1.setId("e1");
+            e1.setText("Element 1");
+            hashMapElement.addObject(e1);
+            
+            e2 = new Element();
+            e2.setId("e3");
+            e2.setText("Element 3");
+            hashMapElement.addObject(e2);
+
+            Element e3 = new Element();
+            e3.setId("e4");
+            e3.setText("Element 4");
+            hashMapElement.addObject(e3);
+            main.setElements(hashMapElement);
+            
+            persistenceManager.update(main);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            assertNotNull("main.getElements() is null", main.getElements());
+            assertTrue("Incorrect text", main.getText().equals("Main text"));           
+            assertTrue("Incorrect para element", ((Element) main.getElements().get("e4")).getText().equals("Element 4"));
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+
+   
+}
\ No newline at end of file

Propchange: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImplTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImplTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/MultiValueCollectionConverterImplTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,141 @@
+/* ========================================================================
+ * 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.collectionconverter.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.C;
+import org.apache.portals.graffito.jcr.testmodel.MultiValue;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class MultiValueCollectionConverterImplTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(MultiValueCollectionConverterImplTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public MultiValueCollectionConverterImplTest(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(MultiValueCollectionConverterImplTest.class);
+    }
+
+    
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            getPersistenceManager().save();
+        }        
+    	
+        super.tearDown();
+    }    
+
+    public void testMultiValue()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+
+            MultiValue multiValue = new MultiValue();
+            multiValue.setPath("/test");
+            
+            ArrayList values = new ArrayList();
+            values.add("Value1");
+            values.add("Value2");
+            values.add("Value3");
+            values.add("Value4");
+            multiValue.setMultiValues(values);
+            
+            persistenceManager.insert(multiValue);
+            persistenceManager.save();
+            
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            multiValue = (MultiValue) persistenceManager.getObject(MultiValue.class, "/test");
+            assertNotNull("Object is null", multiValue);
+            assertNull("nullMultiValues field is not null", multiValue.getNullMultiValues());
+            assertTrue("Incorrect number of values", multiValue.getMultiValues().size() == 4);            
+            assertTrue("Incorrect collection element", ((String) multiValue.getMultiValues().iterator().next()).equals("Value1"));
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            values = new ArrayList();
+            values.add("Value1");
+            values.add("Value2");
+            values.add("Value3");
+            values.add("Value4");
+            values.add("Value5");
+            multiValue.setMultiValues(values);
+            
+            persistenceManager.update(multiValue);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+
+            multiValue = (MultiValue) persistenceManager.getObject(MultiValue.class, "/test");
+            assertNotNull("Object is null", multiValue);
+            assertNull("nullMultiValues field is not null", multiValue.getNullMultiValues());
+            assertTrue("Incorrect number of values", multiValue.getMultiValues().size() == 5);            
+            assertTrue("Incorrect collection element", ((String) multiValue.getMultiValues().iterator().next()).equals("Value1"));
+            
+            
+        }
+        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/collectionconverter/impl/NTCollectionConverterImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,145 @@
+/* ========================================================================
+ * 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.collectionconverter.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.C;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class NTCollectionConverterImplTest extends TestBase
+{
+    private final static Log log = LogFactory.getLog(NTCollectionConverterImplTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public NTCollectionConverterImplTest(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(NTCollectionConverterImplTest.class);
+    }
+    
+    
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+        if (getPersistenceManager().objectExists("/test"))
+        {
+            getPersistenceManager().remove("/test");
+            getPersistenceManager().save();
+        }        
+    	
+        super.tearDown();
+    }       
+
+    public void testCollection()
+    {
+        try
+        {
+        	PersistenceManager persistenceManager = getPersistenceManager();
+
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+
+            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"));
+            page.setParagraphs(paragraphs);
+            
+            persistenceManager.insert(page);
+            persistenceManager.save();
+            
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            page = (Page) persistenceManager.getObject(Page.class, "/test");
+            assertNotNull("page.getParagraphs is null", page.getParagraphs());
+            assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
+            assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() == 3);
+            assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para 1"));
+            
+            // --------------------------------------------------------------------------------
+            // Update the object
+            // --------------------------------------------------------------------------------
+            paragraphs = new ArrayList();
+            
+            paragraphs.add(new Paragraph("Para 1"));
+            paragraphs.add(new Paragraph("Para 2"));
+            paragraphs.add(new Paragraph("Para 4"));
+            paragraphs.add(new Paragraph("Para 5"));
+            page.setParagraphs(paragraphs);
+            
+            persistenceManager.update(page);
+            persistenceManager.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+
+            page = (Page) persistenceManager.getObject(Page.class, "/test");
+            assertNotNull("page.getParagraphs is null", page.getParagraphs());
+            assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
+            assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() == 4);
+            assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para 1"));
+            
+            // --------------------------------------------------------------------------------
+            // Export to check the content
+            // --------------------------------------------------------------------------------           
+            this.exportDocument("target/NTCollectionExport.xml", "/test", true, false);
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+   
+}
\ No newline at end of file

Propchange: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerAtomicQueryTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,242 @@
+/* ========================================================================
+ * 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;
+
+/**
+ * Test Query on atomic fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerAtomicQueryTest extends TestBase
+{
+	private final static Log log = LogFactory.getLog(PersistenceManagerAtomicQueryTest.class);
+	private Date date = new Date();
+	
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public PersistenceManagerAtomicQueryTest(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(PersistenceManagerAtomicQueryTest.class);
+	}
+	
+    
+    public void tearDown() throws Exception
+    {
+
+		for (int i = 1; i <= 100; i++)
+		{
+			if (getPersistenceManager().objectExists("/test" + i))
+			{
+				getPersistenceManager().remove("/test" + i);
+			}
+
+		}
+        getPersistenceManager().save();
+        super.tearDown();
+    }	
+	
+
+	public void testQueryAtomicFields()
+	{
+
+		try
+		{
+			
+			this.importData(date);
+			PersistenceManager persistenceManager = this.getPersistenceManager();
+			
+			// Test Boolean value 
+			QueryManager queryManager = this.getQueryManager();
+			Filter filter = queryManager.createFilter(Atomic.class);
+			filter.addEqualTo("booleanObject", new Boolean(true));
+			Query query = queryManager.createQuery(filter);
+			
+			long start = System.currentTimeMillis();
+			Collection result = persistenceManager.getObjects(query);
+			System.out.println("getObjects  : " + (System.currentTimeMillis() - start));
+			
+			assertTrue("Invalid number of objects - should be = 50", result.size() == 50);
+			
+			filter = queryManager.createFilter(Atomic.class);
+			filter.addEqualTo("booleanPrimitive", new Boolean(false));
+			query = queryManager.createQuery(filter);
+
+			start = System.currentTimeMillis();
+			result = persistenceManager.getObjects(query);
+			System.out.println("getObjects 2 : " + (System.currentTimeMillis() - start));
+			assertTrue("Invalid number of objects - should be = 0", result.size() == 0);
+			
+			
+			// Test int value
+			filter = queryManager.createFilter(Atomic.class);
+			filter.addBetween("integerObject", new Integer(0), new Integer(500));
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 5", result.size() == 5);
+			
+			filter = queryManager.createFilter(Atomic.class);
+			filter.addLessOrEqualThan("intPrimitive", new Integer(236));
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 36", result.size() == 36);
+
+			
+			//Test Date & Calendar
+			filter = queryManager.createFilter(Atomic.class);
+			Calendar calendar = Calendar.getInstance();
+			calendar.set(2012, 12, 01);
+			filter.addLessThan("calendar", calendar);
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 100 ", result.size() == 100);
+
+			filter = queryManager.createFilter(Atomic.class);
+			calendar = Calendar.getInstance();
+			calendar.set(1975, 12, 01);
+			filter.addLessThan("calendar", calendar);
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 0 ", result.size() == 0);
+			
+			filter = queryManager.createFilter(Atomic.class);			
+			filter.addEqualTo("date", date);
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 100 ", result.size() == 100);
+
+			filter = queryManager.createFilter(Atomic.class);			
+			filter.addBetween("date", date, new Date());
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 100 ", result.size() == 100);
+			
+			// Test contains method
+			filter = queryManager.createFilter(Atomic.class);			
+			filter.addContains(".", "JCR");
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 50 ", result.size() == 50);
+			
+			filter = queryManager.createFilter(Atomic.class);			
+			filter.addContains("byteArray", "Graffito");
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 50 ", result.size() == 50);
+			
+			filter = queryManager.createFilter(Atomic.class);			
+			filter.addContains("byteArray", "String");
+			query = queryManager.createQuery(filter);
+			
+			result = persistenceManager.getObjects(query);			
+			assertTrue("Invalid number of objects - should be = 0 ", result.size() == 0);
+
+
+			
+		}
+		catch (Exception e)
+		{
+			 e.printStackTrace();
+             fail();
+		}
+
+	}
+
+	private void importData(Date date)
+	{
+		try
+		{
+
+			PersistenceManager persistenceManager = getPersistenceManager();
+			
+			for (int i = 1; i <= 100; 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/PersistenceManagerBasicVersionningTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerBasicVersionningTest.java?rev=354168&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerBasicVersionningTest.java (added)
+++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/impl/PersistenceManagerBasicVersionningTest.java Mon Dec  5 12:37:06 2005
@@ -0,0 +1,157 @@
+package org.apache.portals.graffito.jcr.persistence.impl;
+
+
+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.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+import org.apache.portals.graffito.jcr.version.Version;
+import org.apache.portals.graffito.jcr.version.VersionIterator;
+
+/**
+ * Test Query on atomic fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class PersistenceManagerBasicVersionningTest extends TestBase
+{
+	private final static Log log = LogFactory.getLog(PersistenceManagerBasicVersionningTest.class);
+	private Date date = new Date();
+	
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public PersistenceManagerBasicVersionningTest(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(PersistenceManagerBasicVersionningTest.class);
+	}
+
+    public void tearDown() throws Exception
+    {
+    	PersistenceManager persistenceManager = getPersistenceManager();
+	    persistenceManager.remove("/page");
+    	persistenceManager.save();
+       
+        super.tearDown();
+    }	
+
+	public void testSimpleVersion()
+	{
+		     PersistenceManager persistenceManager = getPersistenceManager();
+             try
+             {
+            	 
+            	 Page page = new Page();
+            	 page.setPath("/page");
+            	 page.setTitle("Page Title");            	 
+            	 page.addParagraph(new Paragraph("para1"));
+            	 page.addParagraph(new Paragraph("para2"));
+            	 persistenceManager.insert(page);
+            	 persistenceManager.save();
+            	 
+                 
+            	 page.addParagraph(new Paragraph("para3"));
+            	 persistenceManager.checkout("/page");
+            	 persistenceManager.update(page);
+            	 persistenceManager.save();
+            	 persistenceManager.checkin("/page");
+            	 
+            	 page.addParagraph(new Paragraph("para4"));
+            	 persistenceManager.checkout("/page");
+            	 persistenceManager.update(page);
+            	 persistenceManager.save();
+            	 persistenceManager.checkin("/page");            	 
+
+            	 VersionIterator versionIterator = persistenceManager.getAllVersions("/page");
+            	 assertNotNull("VersionIterator is null", versionIterator);
+            	 assertTrue("Invalid number of versions found", versionIterator.getSize() == 3);
+            	 
+            	 while (versionIterator.hasNext())
+            	 {
+            		 Version version = (Version) versionIterator.next();
+            		 log.info("version found : " + version.getPath() + " - " +  version.getCreated().getTime());
+            		 
+            	 }
+            	 
+            	 Version baseVersion = persistenceManager.getBaseVersion("/page");
+            	 System.out.println("Base version : " + baseVersion.getName());
+
+            	 Version rootVersion = persistenceManager.getRootVersion("/page");
+            	 System.out.println("Root version : " + rootVersion.getName());
+            	 //this.exportDocument("/home/christophe/export.xml", "/jcr:system/jcr:versionStorage", true, false);
+            	             	
+            	 //Get the object matching to the first version 
+            	 Page page1 = (Page) persistenceManager.getObject(Page.class, "/page", "1.0");
+            	 assertNotNull("version 1.0 object is null", page1);
+            	 assertTrue("Invalid number of paragraph found in the root version", page1.getParagraphs().size() == 3);
+
+             }
+             catch(Exception e)
+             {
+            	 e.printStackTrace();
+            	 fail();
+            	 
+             }
+	}
+
+	
+	public void testVersionLabels()
+	{
+		     PersistenceManager persistenceManager = getPersistenceManager();
+             try
+             {
+            	 
+            	 Page page = new Page();
+            	 page.setPath("/page");
+            	 page.setTitle("Page Title");            	 
+            	 page.addParagraph(new Paragraph("para1"));
+            	 page.addParagraph(new Paragraph("para2"));
+            	 persistenceManager.insert(page);
+            	 persistenceManager.save();
+            	 
+                 
+            	 page.addParagraph(new Paragraph("para3"));
+            	 persistenceManager.checkout("/page");
+            	 persistenceManager.update(page);
+            	 persistenceManager.save();
+            	 persistenceManager.checkin("/page", new String[] {"A", "B"});
+            	 
+            	 page.addParagraph(new Paragraph("para4"));
+            	 persistenceManager.checkout("/page");
+            	 persistenceManager.update(page);
+            	 persistenceManager.save();
+            	 persistenceManager.checkin("/page", new String[] {"C", "D"});         	 
+
+            	 String[] allLabels = persistenceManager.getAllVersionLabels("/page");
+            	 assertTrue("Incorrect number of labels", allLabels.length == 4);
+
+            	 String[] versionLabels = persistenceManager.getVersionLabels("/page", "1.1");
+            	 assertTrue("Incorrect number of labels", versionLabels.length == 2);
+            	 assertTrue("Incorrect label", versionLabels[0].equals("C") || versionLabels[0].equals("D"));
+            	 assertTrue("Incorrect label", versionLabels[1].equals("C") || versionLabels[0].equals("D"));
+            	
+
+             }
+             catch(Exception e)
+             {
+            	 e.printStackTrace();
+            	 fail(); 
+             }
+	}
+	
+}
\ No newline at end of file



Mime
View raw message