jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r582680 [1/3] - in /jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src: main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ main/java/org/apache/jackrabbit/ocm/mapper/impl/ main/java/org/apache/jackrabbit/ocm/mapp...
Date Sun, 07 Oct 2007 20:54:58 GMT
Author: clombart
Date: Sun Oct  7 13:54:52 2007
New Revision: 582680

URL: http://svn.apache.org/viewvc?rev=582680&view=rev
Log:
Add more unit tests for the annotation support. 

Added:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationAvoidRecursiveLoopTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationCopyMoveTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationRemoveTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterAvoidRecursiveLoopTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerAvoidRecursiveLoopTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterCopyMoveTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerCopyMoveTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterRemoveTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerSameNameSiblingTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/AnnotationBeanDescriptorTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/DigesterBeanDescriptorTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/BeanDescriptorTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationArrayListTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationDefaultCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationHashMapTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationMultiValueCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationNTCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualNodesCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationResidualPropertiesCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterArrayListTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ArrayListTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterDefaultCollectionConverterImplTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DefaultCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterHashMapTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/HashMapTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterMultiValueCollectionConverterImplTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/MultiValueCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterNTCollectionConverterImplTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/NTCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualNodesCollectionConverterImplTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ResidualNodesCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterResidualPropertiesCollectionConverterImplTest.java
      - copied, changed from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ResidualPropertiesCollectionConverterImplTest.java
Removed:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerAvoidRecursiveLoopTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerCopyMoveTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerRemoveTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerSameNameSiblingTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/BeanDescriptorTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ArrayListTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DefaultCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/HashMapTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/MultiValueCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/NTCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ResidualNodesCollectionConverterImplTest.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/ResidualPropertiesCollectionConverterImplTest.java
Modified:
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/Collection.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AllTests.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/AllTests.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/FakeBeanConverter.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AllTests.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/A.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/B.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/C.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/D.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/DFull.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/E.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/MultiValue.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Page.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Paragraph.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/Residual.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/Element.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/collection/Main.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/crossreference/A.java
    jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/testmodel/crossreference/B.java

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java?rev=582680&r1=582679&r2=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/ObjectConverterImpl.java Sun Oct  7 13:54:52 2007
@@ -586,7 +586,8 @@
 			throw new JcrMappingException(
 					"Class of type: "
 							+ object.getClass().getName()
-							+ " has no path mapping. Maybe attribute path=\"true\" for a field element of this class in jcrmapping.xml is missing?");
+							+ " has no path mapping. Maybe attribute path=\"true\" for a field element of this class in mapping descriptor is missing " +
+							  " or maybe it is defined in an ancestor class which has no mapping descriptor.");
 		}
 		String pathField = pathFieldDescriptor.getFieldName();
 

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java?rev=582680&r1=582679&r2=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/AbstractMapperImpl.java Sun Oct  7 13:54:52 2007
@@ -38,8 +38,10 @@
  *
  * Abstract class for {@link org.apache.jackrabbit.ocm.mapper.Mapper}
  *
- * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @author <a href="mailto:christophe.lombart@gmail.com">Lombart Christophe </a>
  * 
+ * TODO : Add more reference tests. For exemple, the mapper has to check if the class used for the elements
+ *        of a collectiondescriptor exists. For performance reasone, we can defined some optional validations.
  */
 public abstract class AbstractMapperImpl implements Mapper {
     protected static final Log log = LogFactory.getLog(AbstractMapperImpl.class);

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java?rev=582680&r1=582679&r2=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/AnnotationDescriptorReader.java Sun Oct  7 13:54:52 2007
@@ -32,7 +32,6 @@
 import org.apache.jackrabbit.ocm.mapper.model.FieldDescriptor;
 import org.apache.jackrabbit.ocm.mapper.model.ImplementDescriptor;
 import org.apache.jackrabbit.ocm.mapper.model.MappingDescriptor;
-import org.apache.jackrabbit.ocm.reflection.ReflectionUtils;
 
 /**
  * Helper class that reads the xml mapping file and load all class descriptors into memory (object graph)
@@ -77,7 +76,7 @@
 		}
 		else
 		{
-			throw  new InitMapperException("The persistent class " + clazz.getName() + " has not @Node annotation");
+			throw  new InitMapperException("The annotation @Node is not defined for the persistent class " + clazz.getName());
 		}
 	
 		
@@ -199,15 +198,7 @@
 			                             String fieldName, String collectionClassName, Collection collectionAnnotation) {
 		
 		Class targetClass = collectionAnnotation.elementClassName();
-		CollectionDescriptor collectionDescriptor = new CollectionDescriptor();
-		ClassDescriptor classDescriptor = mappingDescriptor.getClassDescriptorByName(targetClass.getName());
-
-		//TODO : This check can be done later by AbstractMapperImpl
-		if (classDescriptor == null)
-			throw new InitMapperException(
-					"Unable to reference class "
-							+ targetClass.getName()
-							+ " as a child node since it has not been registered, ordering perhaps?");
+		CollectionDescriptor collectionDescriptor = new CollectionDescriptor();	
 		
 		collectionDescriptor.setFieldName(fieldName);
 		
@@ -235,10 +226,17 @@
 		{
 		    collectionDescriptor.setElementClassName(targetClass.getName());
 		}
+
+		if (! collectionAnnotation.collectionClassName().equals(Object.class))
+		{
+			collectionDescriptor.setCollectionClassName(collectionAnnotation.collectionClassName().getName());
+		}
 		
 		collectionDescriptor.setCollectionConverter(collectionAnnotation.collectionConverter().getName());
-		
-		collectionDescriptor.setJcrType(annotationNode.jcrType());
+		if (annotationNode != null)
+		{
+		    collectionDescriptor.setJcrType(annotationNode.jcrType());
+		}
 		collectionDescriptor.setJcrSameNameSiblings(collectionAnnotation.jcrSameNameSiblings());
 		collectionDescriptor.setJcrAutoCreated(collectionAnnotation.jcrAutoCreated());
 		collectionDescriptor.setJcrProtected(collectionAnnotation.jcrProtected());

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/Collection.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/Collection.java?rev=582680&r1=582679&r2=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/Collection.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/main/java/org/apache/jackrabbit/ocm/mapper/impl/annotation/Collection.java Sun Oct  7 13:54:52 2007
@@ -49,6 +49,10 @@
     
 	Class collectionConverter() default DefaultCollectionConverterImpl.class;
 
+	// Use Object.class as default value 
+    // because it is not possible to have a default null value in annotation field	
+	Class collectionClassName() default Object.class; 
+
     String jcrType() default "";
     
     boolean jcrAutoCreated() default false; 

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java?rev=582680&r1=582679&r2=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java Sun Oct  7 13:54:52 2007
@@ -26,8 +26,20 @@
 import org.apache.jackrabbit.ocm.mapper.Mapper;
 import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
 import org.apache.jackrabbit.ocm.repository.RepositoryUtil;
+import org.apache.jackrabbit.ocm.testmodel.A;
 import org.apache.jackrabbit.ocm.testmodel.Atomic;
+import org.apache.jackrabbit.ocm.testmodel.B;
+import org.apache.jackrabbit.ocm.testmodel.C;
+import org.apache.jackrabbit.ocm.testmodel.D;
+import org.apache.jackrabbit.ocm.testmodel.DFull;
 import org.apache.jackrabbit.ocm.testmodel.Default;
+import org.apache.jackrabbit.ocm.testmodel.E;
+import org.apache.jackrabbit.ocm.testmodel.MultiValue;
+import org.apache.jackrabbit.ocm.testmodel.Page;
+import org.apache.jackrabbit.ocm.testmodel.Paragraph;
+import org.apache.jackrabbit.ocm.testmodel.Residual;
+import org.apache.jackrabbit.ocm.testmodel.Residual.ResidualNodes;
+import org.apache.jackrabbit.ocm.testmodel.Residual.ResidualProperties;
 import org.apache.jackrabbit.ocm.testmodel.auto.CmsObject;
 import org.apache.jackrabbit.ocm.testmodel.auto.Content;
 import org.apache.jackrabbit.ocm.testmodel.auto.Document;
@@ -36,6 +48,8 @@
 import org.apache.jackrabbit.ocm.testmodel.auto.impl.ContentImpl;
 import org.apache.jackrabbit.ocm.testmodel.auto.impl.DocumentImpl;
 import org.apache.jackrabbit.ocm.testmodel.auto.impl.FolderImpl;
+import org.apache.jackrabbit.ocm.testmodel.collection.Element;
+import org.apache.jackrabbit.ocm.testmodel.collection.Main;
 
 /**
  * Base class for testcases. Provides priviledged access to the jcr test
@@ -68,9 +82,26 @@
 		Repository repository = RepositoryUtil.getRepository("repositoryTest");	
 		session = RepositoryUtil.login(repository, "superuser", "superuser");
 		List<Class> classes = new ArrayList<Class>();
+		
+		// Register content classes used by the unit tests
 		classes.add(Atomic.class);
 		classes.add(Default.class);
+		classes.add(A.class);
+		classes.add(B.class);
+		classes.add(C.class);
+		classes.add(D.class);
+		classes.add(DFull.class);
+		classes.add(E.class);
+		classes.add(Page.class);
+		classes.add(Paragraph.class);
+		classes.add(Main.class);
+		classes.add(Element.class);
+		classes.add(MultiValue.class);
 		
+
+		classes.add(Residual.class); 
+		classes.add(ResidualProperties.class);
+		classes.add(ResidualNodes.class);
 		Mapper mapper = new AnnotationMapperImpl(classes);
 		ocm = new ObjectContentManagerImpl(session, mapper);
 		

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AllTests.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AllTests.java?rev=582680&r1=582679&r2=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AllTests.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AllTests.java Sun Oct  7 13:54:52 2007
@@ -36,11 +36,18 @@
     public static Test buildSuite() {
         TestSuite suite= new TestSuite("Test for org.apache.jackrabbit.ocm.manager.basic");
         //$JUnit-BEGIN$
-        suite.addTestSuite(ObjectContentManagerAvoidRecursiveLoopTest.class);
-        suite.addTestSuite(ObjectContentManagerCopyMoveTest.class);
-        suite.addTestSuite(ObjectContentManagerRemoveTest.class);
-        suite.addTestSuite(ObjectContentManagerSameNameSiblingTest.class);
-        suite.addTestSuite(ObjectContentManagerTest.class);        
+        suite.addTestSuite(DigesterAvoidRecursiveLoopTest.class);
+        suite.addTestSuite(DigesterCopyMoveTest.class);
+        suite.addTestSuite(DigesterRemoveTest.class);
+        suite.addTestSuite(DigesterSameNameSiblingTest.class);
+        suite.addTestSuite(DigesterSimpleTest.class);
+        
+        suite.addTestSuite(AnnotationAvoidRecursiveLoopTest.class);
+        suite.addTestSuite(AnnotationCopyMoveTest.class);
+        suite.addTestSuite(AnnotationRemoveTest.class);
+        suite.addTestSuite(AnnotationSameNameSiblingTest.class);
+        suite.addTestSuite(AnnotationSimpleTest.class);        
+
         //$JUnit-END$
 
         return suite;

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationAvoidRecursiveLoopTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationAvoidRecursiveLoopTest.java?rev=582680&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationAvoidRecursiveLoopTest.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationAvoidRecursiveLoopTest.java Sun Oct  7 13:54:52 2007
@@ -0,0 +1,176 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.basic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.jcr.Repository;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.AnnotationTestBase;
+import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
+import org.apache.jackrabbit.ocm.mapper.Mapper;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.AnnotationMapperImpl;
+import org.apache.jackrabbit.ocm.repository.RepositoryUtil;
+import org.apache.jackrabbit.ocm.testmodel.auto.CmsObject;
+import org.apache.jackrabbit.ocm.testmodel.auto.Content;
+import org.apache.jackrabbit.ocm.testmodel.auto.Document;
+import org.apache.jackrabbit.ocm.testmodel.auto.Folder;
+import org.apache.jackrabbit.ocm.testmodel.auto.impl.CmsObjectImpl;
+import org.apache.jackrabbit.ocm.testmodel.auto.impl.ContentImpl;
+import org.apache.jackrabbit.ocm.testmodel.auto.impl.DocumentImpl;
+import org.apache.jackrabbit.ocm.testmodel.auto.impl.FolderImpl;
+import org.apache.jackrabbit.ocm.testmodel.crossreference.A;
+import org.apache.jackrabbit.ocm.testmodel.crossreference.B;
+
+
+/**
+ * Basic test for ObjectContentManager
+ * Test when objects are cross referenced 
+ * eg. object 'a' contains a reference to an object 'b' and object 'b' contains a reference to 'a'.
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com>Christophe Lombart</a>
+ */
+public class AnnotationAvoidRecursiveLoopTest extends AnnotationTestBase
+{
+    private final static Log log = LogFactory.getLog(AnnotationAvoidRecursiveLoopTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public AnnotationAvoidRecursiveLoopTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new RepositoryLifecycleTestSetup(
+                new TestSuite(AnnotationAvoidRecursiveLoopTest.class));
+    }
+
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+    	if (getObjectContentManager().objectExists("/test"))
+    	{
+    	   getObjectContentManager().remove("/test");
+    	   getObjectContentManager().save();
+    	}
+        super.tearDown();
+    }
+    
+    public void testCrossReferences()
+    {
+        try
+        {
+        	ObjectContentManager ocm = getObjectContentManager();
+            // --------------------------------------------------------------------------------
+            // Create and store an object graph in the repository
+            // --------------------------------------------------------------------------------
+            A a = new A();
+            a.setPath("/test");
+            a.setA1("a1");
+            a.setA2("a2");
+            
+            ocm.insert(a);
+            ocm.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) ocm.getObject( "/test");
+            assertNotNull("a is null", a);
+            
+            B b = new B();
+            b.setB1("b1");
+            b.setB2("b2");
+            // Add crossreference between b and a 
+            a.setB(b);
+            b.setA(a); 
+
+            B b1 = new B();
+            b1.setB1("b1.1");
+            b1.setB2("b1.2");            
+            b1.setA(a);
+            a.addB(b1);
+
+            B b2 = new B();
+            b2.setB1("b2.1");
+            b2.setB2("b2.2");            
+            b2.setA(a);
+            a.addB(b2);
+
+            ocm.update(a);
+            ocm.save();
+            
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) ocm.getObject( "/test");
+            assertNotNull("a is null", a);
+            assertTrue("Duplicate instance a", a == a.getB().getA());
+            
+            Collection collection = a.getCollection();
+            assertTrue("Invalid number of items in the collection", collection.size() == 2);
+            B[] bs = (B[]) collection.toArray(new B[2]);
+            assertTrue("Duplicate instance a", a == bs[0].getA());
+            assertTrue("Duplicate instance a", a == bs[1].getA());
+            
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            fail("Exception occurs during the unit test : " + e);
+        }
+        
+    }
+
+	
+	protected void initObjectContentManager() throws UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
+	{
+		Repository repository = RepositoryUtil.getRepository("repositoryTest");	
+		session = RepositoryUtil.login(repository, "superuser", "superuser");
+		List<Class> classes = new ArrayList<Class>();
+		
+		classes.add(B.class);
+		classes.add(A.class);		
+		Mapper mapper = new AnnotationMapperImpl(classes);
+		ocm = new ObjectContentManagerImpl(session, mapper);
+
+		
+	}	
+
+    
+
+}
\ No newline at end of file

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationCopyMoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationCopyMoveTest.java?rev=582680&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationCopyMoveTest.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationCopyMoveTest.java Sun Oct  7 13:54:52 2007
@@ -0,0 +1,295 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.basic;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import javax.jcr.Node;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.exception.ObjectContentManagerException;
+import org.apache.jackrabbit.ocm.testmodel.A;
+import org.apache.jackrabbit.ocm.testmodel.Atomic;
+import org.apache.jackrabbit.ocm.testmodel.B;
+import org.apache.jackrabbit.ocm.testmodel.C;
+
+
+/**
+ * Test Copy & move objects
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ */
+public class AnnotationCopyMoveTest extends DigesterTestBase
+{
+	private final static Log log = LogFactory.getLog(AnnotationCopyMoveTest.class);
+	
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public AnnotationCopyMoveTest(String testName) throws Exception
+	{
+		super(testName);
+
+	}
+
+	public static Test suite()
+	{
+		// All methods starting with "test" will be executed in the test suite.
+		return new RepositoryLifecycleTestSetup(
+                new TestSuite(AnnotationCopyMoveTest.class));
+	}
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+
+        
+    }
+	
+	public void tearDown() throws Exception {
+
+		cleanUpRepisotory();
+		super.tearDown();
+		
+	}
+
+	public void testCopy()
+	{
+
+        // --------------------------------------------------------------------------------
+        // 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);
+        
+        ocm.insert(a);
+        ocm.save();
+		
+        // --------------------------------------------------------------------------------
+        // Copy the object 
+        // --------------------------------------------------------------------------------
+        ocm.copy("/test", "/test2");      
+        
+        // --------------------------------------------------------------------------------
+        // Get the object 
+        // --------------------------------------------------------------------------------
+        a = (A) ocm.getObject("/test2");
+        assertNotNull("a is null", a);
+        assertTrue("Invalid field a1", a.getA1().equals("a1"));
+        assertTrue("Invalid field b.b1", a.getB().getB1().equals("b1"));
+        assertTrue("Invalid number of items in field collection", a.getCollection().size() == 3);
+
+        
+        // --------------------------------------------------------------------------------
+        // Check exceptions 
+        // --------------------------------------------------------------------------------
+       
+        try 
+        {
+			ocm.copy("/incorrectpath", "/test2");			
+			fail("the copy method accepts an incorrect source path");
+		} catch (ObjectContentManagerException e) 
+		{
+			// Nothing to do  - Expected behaviour
+		}       
+
+        try 
+        {
+			ocm.copy("/test", "incorrectpath");			
+			fail("the copy method accepts an incorrect destination path");
+		} catch (ObjectContentManagerException e) 
+		{
+			// Nothing to do  - Expected behaviour
+		}
+		
+        // --------------------------------------------------------------------------------
+        // Remove objects 
+        // --------------------------------------------------------------------------------
+        ocm.remove("/test");
+        ocm.remove("/test2");
+        ocm.save();
+        
+	}
+
+	public void testSimpleMove()
+	{
+
+        try {
+			// --------------------------------------------------------------------------------
+			// Create and store an object graph in the repository
+			// --------------------------------------------------------------------------------
+
+        	Atomic atomic =  new Atomic();
+        	atomic.setPath("/source");
+        	atomic.setString("test atomic");
+        	ocm.insert(atomic);
+        	ocm.save();
+			
+			// --------------------------------------------------------------------------------
+			// Copy the object 
+			// --------------------------------------------------------------------------------
+        	ocm.move("/source", "/result");
+
+			// --------------------------------------------------------------------------------
+			// Get the object 
+			// --------------------------------------------------------------------------------
+			atomic = (Atomic) ocm.getObject("/result");
+			assertNotNull("atomic is null", atomic);
+			assertTrue("Invalid field a1", atomic.getString().equals("test atomic"));			        
+
+			assertFalse("Object with path /source still exists", ocm.objectExists("/source"));
+
+			// --------------------------------------------------------------------------------
+			// Check exceptions 
+			// --------------------------------------------------------------------------------      
+			try 
+			{
+				ocm.move("/incorrectpath", "/test2");			
+				fail("the copy method accepts an incorrect source path");
+			} catch (ObjectContentManagerException e) 
+			{
+				// Nothing to do  - Expected behaviour
+			}       
+
+			try 
+			{
+				ocm.move("/test", "incorrectpath");			
+				fail("the copy method accepts an incorrect destination path");
+			} catch (ObjectContentManagerException e) 
+			{
+				// Nothing to do  - Expected behaviour
+			}
+			
+			// --------------------------------------------------------------------------------
+			// Remove objects 
+			// --------------------------------------------------------------------------------
+			ocm.remove("/result");
+			ocm.save();
+		} 
+        catch (Exception e) 
+		{
+        	e.printStackTrace();
+        	fail();
+		}
+		
+        
+	}
+	
+	public void testObjectGraphMove()
+	{
+
+        try {
+			// --------------------------------------------------------------------------------
+			// Create and store an object graph in the repository
+			// --------------------------------------------------------------------------------
+			A a = new A();
+			a.setPath("/source");
+			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);
+			
+			ocm.insert(a);
+        	ocm.save();
+			
+			// --------------------------------------------------------------------------------
+			// Copy the object 
+			// --------------------------------------------------------------------------------			
+        	ocm.move("/source", "/result");            
+        	// --------------------------------------------------------------------------------
+			// Get the object 
+			// --------------------------------------------------------------------------------
+			a = (A) ocm.getObject("/result");
+			assertNotNull("a is null", a);
+			assertTrue("Invalid field a1", a.getA1().equals("a1"));
+			assertTrue("Invalid field b.b1", a.getB().getB1().equals("b1"));
+			assertTrue("Invalid number of items in field collection", a.getCollection().size() == 3);
+			        
+			assertFalse("Object with path /source still exists", ocm.objectExists("/source"));
+			
+			// --------------------------------------------------------------------------------
+			// Remove objects 
+			// --------------------------------------------------------------------------------
+			ocm.remove("/result");
+			ocm.save();
+		} 
+        catch (Exception e) 
+		{
+        	e.printStackTrace();
+        	fail();
+		}
+	}
+	
+	
+}
\ No newline at end of file

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationRemoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationRemoveTest.java?rev=582680&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationRemoveTest.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationRemoveTest.java Sun Oct  7 13:54:52 2007
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.basic;
+
+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.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.query.Filter;
+import org.apache.jackrabbit.ocm.query.Query;
+import org.apache.jackrabbit.ocm.query.QueryManager;
+import org.apache.jackrabbit.ocm.testmodel.Atomic;
+
+
+/**
+ * Test Query on atomic fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class AnnotationRemoveTest extends DigesterTestBase
+{
+	private final static Log log = LogFactory.getLog(AnnotationRemoveTest.class);
+	private Date date = new Date();
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public AnnotationRemoveTest(String testName) throws Exception
+	{
+		super(testName);
+
+	}
+
+	public static Test suite()
+	{
+		// All methods starting with "test" will be executed in the test suite.
+		return new RepositoryLifecycleTestSetup(
+                new TestSuite(AnnotationRemoveTest.class));
+	}
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+		this.importData(date);
+        
+    }
+	
+	public void tearDown() throws Exception {
+
+		cleanUpRepisotory();
+		super.tearDown();
+		
+	}
+
+	public void testRemove()
+	{
+
+		try
+		{
+			
+			ObjectContentManager ocm = this.getObjectContentManager();
+			ocm.remove("/test5");
+			ocm.save();
+
+			assertFalse("Test5 has not been removed", ocm.objectExists("/test5"));
+
+			QueryManager queryManager = this.getQueryManager();
+			Filter filter = queryManager.createFilter(Atomic.class);
+			filter.addEqualTo("booleanObject" , new Boolean(false));
+			Query query = queryManager.createQuery(filter);
+			ocm.remove(query);
+			ocm.save();
+
+			filter = queryManager.createFilter(Atomic.class);
+			filter.setScope("//");
+			query = queryManager.createQuery(filter);			
+			Collection result = ocm.getObjects(query);
+			assertEquals("Invalid number of objects", 5, result.size());
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail();
+		}
+
+	}
+
+	private void importData(Date date)
+	{
+		try
+		{
+
+			ObjectContentManager ocm = getObjectContentManager();
+
+			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 the repository".getBytes());
+					a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
+				}
+				ocm.insert(a);
+
+			}
+			ocm.save();
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail("Exception occurs during the unit test : " + e);
+		}
+
+	}
+
+}
\ No newline at end of file

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java?rev=582680&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSameNameSiblingTest.java Sun Oct  7 13:54:52 2007
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.basic;
+
+import java.io.ByteArrayInputStream;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+
+import javax.jcr.Repository;
+import javax.jcr.UnsupportedRepositoryOperationException;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
+import org.apache.jackrabbit.ocm.query.Filter;
+import org.apache.jackrabbit.ocm.query.Query;
+import org.apache.jackrabbit.ocm.query.QueryManager;
+import org.apache.jackrabbit.ocm.repository.RepositoryUtil;
+import org.apache.jackrabbit.ocm.testmodel.Atomic;
+import org.apache.jackrabbit.ocm.testmodel.Page;
+import org.apache.jackrabbit.ocm.testmodel.Paragraph;
+
+/**
+ * Test Query on atomic fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class AnnotationSameNameSiblingTest extends DigesterTestBase
+{
+	private final static Log log = LogFactory.getLog(AnnotationSameNameSiblingTest.class);
+	private Date date = new Date();
+	
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public AnnotationSameNameSiblingTest(String testName) throws Exception
+	{
+		super(testName);
+		
+	}
+
+	public static Test suite()
+	{
+		// All methods starting with "test" will be executed in the test suite.
+		return new RepositoryLifecycleTestSetup(
+                new TestSuite(AnnotationSameNameSiblingTest.class));
+	}
+
+	public void tearDown() throws Exception 
+	{
+
+		cleanUpRepisotory();
+		super.tearDown();
+		
+	}
+	public void testSameNameSiblings()
+	{
+
+		try
+		{
+			this.importData(date);
+			ObjectContentManager ocm = this.getObjectContentManager();
+				
+			// Query all objects 
+			QueryManager queryManager = this.getQueryManager();
+			Filter filter = queryManager.createFilter(Atomic.class);	
+			filter.setScope("/");
+			Query query = queryManager.createQuery(filter);
+			Collection result = ocm.getObjects(query);
+            assertEquals("Incorrect number of objects found", 10, result.size());
+                         
+            // Get objects
+            Atomic atomic = (Atomic) ocm.getObject( "/test[2]");
+            assertNotNull("Object /test[2] not found", atomic);
+            
+            atomic = (Atomic) ocm.getObject( "/test[10]");
+            assertNotNull("Object /test[2] not found", atomic);            
+            
+            // Update the object 
+            atomic.setString("Modified Test String 10");
+            ocm.update(atomic);
+            ocm.save();
+
+            // Query on the attribute "string"
+            queryManager = this.getQueryManager();
+			filter = queryManager.createFilter(Atomic.class);	
+			filter.addLike("string", "Modified%");			
+			query = queryManager.createQuery(filter);
+			result = ocm.getObjects(query);
+			assertTrue("Incorrect number of objects found", result.size() == 1);
+            
+			atomic = (Atomic) ocm.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) ;           
+            ocm.remove(query);
+            ocm.save();
+
+			result = ocm.getObjects(query);
+            assertTrue("Incorrect number of objects found", result.size() == 0);
+            
+            
+		}
+		catch (Exception e)
+		{
+			 e.printStackTrace();
+             fail();
+		}
+
+	}
+
+	public void testUnsupportedSameNameSiblings()
+	{
+		     ObjectContentManager ocm = getObjectContentManager();
+             try
+             {
+            	 
+            	 Page page = new Page();
+            	 page.setPath("/page");
+            	 page.setTitle("Page Title");            	 
+            	 ocm.insert(page);
+            	 ocm.save();
+            	 
+            	 Paragraph p1 = new Paragraph("para1");
+            	 p1.setPath("/page/paragraph");
+            	 ocm.insert(p1);
+            	 
+            	 Paragraph p2 = new Paragraph("para1");
+            	 p2.setPath("/page/paragraph");
+            	 ocm.insert(p2);
+             fail();            	 
+            	 
+             }
+             catch(Exception e)
+             {
+    		            	 ocm.remove("/page");
+            	        ocm.save();
+             }
+	}
+	
+	
+	private void importData(Date date)
+	{
+		try
+		{
+
+			ObjectContentManager ocm = getObjectContentManager();
+			
+			
+			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 the repository".getBytes());
+					 a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
+				}
+				ocm.insert(a);
+				
+				
+			}
+			ocm.save();
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail("Exception occurs during the unit test : " + e);
+		}
+
+	}
+	
+	protected void initObjectContentManager() throws UnsupportedRepositoryOperationException, javax.jcr.RepositoryException
+	{
+		Repository repository = RepositoryUtil.getRepository("repositoryTest");
+		String[] files = { "./src/test/test-config/jcrmapping-sibling.xml" };
+		session = RepositoryUtil.login(repository, "superuser", "superuser");
+
+		
+		ocm = new ObjectContentManagerImpl(session, files);
+		
+	}	
+	
+}
\ No newline at end of file

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java?rev=582680&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/AnnotationSimpleTest.java Sun Oct  7 13:54:52 2007
@@ -0,0 +1,221 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.basic;
+
+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.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.testmodel.A;
+import org.apache.jackrabbit.ocm.testmodel.B;
+import org.apache.jackrabbit.ocm.testmodel.C;
+import org.apache.jackrabbit.ocm.testmodel.Discriminator;
+
+/**
+ * Test JcrSession
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class AnnotationSimpleTest extends DigesterTestBase
+{
+    private final static Log log = LogFactory.getLog(AnnotationSimpleTest.class);
+
+    /**
+     * <p>Defines the test case name for junit.</p>
+     * @param testName The test case name.
+     */
+    public AnnotationSimpleTest(String testName)  throws Exception
+    {
+        super(testName);
+    }
+
+    public static Test suite()
+    {
+        // All methods starting with "test" will be executed in the test suite.
+        return new RepositoryLifecycleTestSetup(
+                new TestSuite(AnnotationSimpleTest.class));
+    }
+
+
+    /**
+     * @see junit.framework.TestCase#tearDown()
+     */
+    public void tearDown() throws Exception
+    {
+    	if (getObjectContentManager().objectExists("/test"))
+    	{
+    	   getObjectContentManager().remove("/test");
+    	   getObjectContentManager().save();
+    	}
+        super.tearDown();
+    }
+    
+    public void testClassA()
+    {
+        try
+        {
+        	ObjectContentManager ocm = getObjectContentManager();
+
+
+            // --------------------------------------------------------------------------------
+            // 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);
+            
+            ocm.insert(a);
+            ocm.save();
+            
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) ocm.getObject( "/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);
+            
+            
+            ocm.update(a);
+            ocm.save();
+
+            // --------------------------------------------------------------------------------
+            // Get the object
+            // --------------------------------------------------------------------------------           
+            a = (A) ocm.getObject("/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);
+        }
+        
+    }
+    
+    /**
+     * Test an persistent object mapped with a discriminator and with a nodetype
+     *
+     */
+    public void testDiscriminatorAndNodeType()
+    {
+    	 try
+         {
+         	ObjectContentManager ocm = getObjectContentManager();
+
+
+             // --------------------------------------------------------------------------------         	
+             // Create and store the object in the repository
+            // --------------------------------------------------------------------------------
+         	Discriminator discriminatorObject = new Discriminator();
+         	discriminatorObject.setPath("/test");
+         	discriminatorObject.setContent("This is my content");
+             ocm.insert(discriminatorObject);             
+             ocm.save();
+             
+
+             // --------------------------------------------------------------------------------
+             // Get the object
+             // --------------------------------------------------------------------------------           
+             discriminatorObject = (Discriminator) ocm.getObject( "/test");
+             assertNotNull("discriminator object  is null", discriminatorObject );
+             assertTrue("Incorrect content", discriminatorObject.getContent().equals("This is my content"));
+             
+             // --------------------------------------------------------------------------------
+             // Update the object
+             // --------------------------------------------------------------------------------
+             discriminatorObject.setContent("new content");             
+             
+             ocm.update(discriminatorObject);
+             ocm.save();
+
+             // --------------------------------------------------------------------------------
+             // Get the object
+             // --------------------------------------------------------------------------------           
+             discriminatorObject = (Discriminator) ocm.getObject( "/test");
+             assertNotNull("discriminator object  is null", discriminatorObject );
+             assertTrue("Incorrect content", discriminatorObject.getContent().equals("new content"));
+             
+
+             
+         }
+         catch (Exception e)
+         {
+             e.printStackTrace();
+             fail("Exception occurs during the unit test : " + e);
+         }	
+    }
+    
+    public void testIsPersistent()
+    {    
+    	ObjectContentManager ocm = getObjectContentManager();
+    	assertTrue("Class A is not persistent ", ocm.isPersistent(A.class));
+    	assertFalse("Class String is  persistent - hum ? ", ocm.isPersistent(String.class));
+    }
+    
+
+}
\ No newline at end of file

Copied: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterAvoidRecursiveLoopTest.java (from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerAvoidRecursiveLoopTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterAvoidRecursiveLoopTest.java?p2=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterAvoidRecursiveLoopTest.java&p1=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerAvoidRecursiveLoopTest.java&r1=580157&r2=582680&rev=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerAvoidRecursiveLoopTest.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterAvoidRecursiveLoopTest.java Sun Oct  7 13:54:52 2007
@@ -26,8 +26,8 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.RepositoryLifecycleTestSetup;
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
 import org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl;
 import org.apache.jackrabbit.ocm.repository.RepositoryUtil;
@@ -42,15 +42,15 @@
  *
  * @author <a href="mailto:christophe.lombart@gmail.com>Christophe Lombart</a>
  */
-public class ObjectContentManagerAvoidRecursiveLoopTest extends DigesterTestBase
+public class DigesterAvoidRecursiveLoopTest extends DigesterTestBase
 {
-    private final static Log log = LogFactory.getLog(ObjectContentManagerAvoidRecursiveLoopTest.class);
+    private final static Log log = LogFactory.getLog(DigesterAvoidRecursiveLoopTest.class);
 
     /**
      * <p>Defines the test case name for junit.</p>
      * @param testName The test case name.
      */
-    public ObjectContentManagerAvoidRecursiveLoopTest(String testName)  throws Exception
+    public DigesterAvoidRecursiveLoopTest(String testName)  throws Exception
     {
         super(testName);
     }
@@ -59,7 +59,7 @@
     {
         // All methods starting with "test" will be executed in the test suite.
         return new RepositoryLifecycleTestSetup(
-                new TestSuite(ObjectContentManagerAvoidRecursiveLoopTest.class));
+                new TestSuite(DigesterAvoidRecursiveLoopTest.class));
     }
 
 

Copied: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterCopyMoveTest.java (from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerCopyMoveTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterCopyMoveTest.java?p2=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterCopyMoveTest.java&p1=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerCopyMoveTest.java&r1=580157&r2=582680&rev=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerCopyMoveTest.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterCopyMoveTest.java Sun Oct  7 13:54:52 2007
@@ -40,15 +40,15 @@
  *
  * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
  */
-public class ObjectContentManagerCopyMoveTest extends DigesterTestBase
+public class DigesterCopyMoveTest extends DigesterTestBase
 {
-	private final static Log log = LogFactory.getLog(ObjectContentManagerCopyMoveTest.class);
+	private final static Log log = LogFactory.getLog(DigesterCopyMoveTest.class);
 	
 	/**
 	 * <p>Defines the test case name for junit.</p>
 	 * @param testName The test case name.
 	 */
-	public ObjectContentManagerCopyMoveTest(String testName) throws Exception
+	public DigesterCopyMoveTest(String testName) throws Exception
 	{
 		super(testName);
 
@@ -58,7 +58,7 @@
 	{
 		// All methods starting with "test" will be executed in the test suite.
 		return new RepositoryLifecycleTestSetup(
-                new TestSuite(ObjectContentManagerCopyMoveTest.class));
+                new TestSuite(DigesterCopyMoveTest.class));
 	}
 
     /**

Added: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterRemoveTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterRemoveTest.java?rev=582680&view=auto
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterRemoveTest.java (added)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterRemoveTest.java Sun Oct  7 13:54:52 2007
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jackrabbit.ocm.manager.basic;
+
+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.jackrabbit.ocm.RepositoryLifecycleTestSetup;
+import org.apache.jackrabbit.ocm.DigesterTestBase;
+import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
+import org.apache.jackrabbit.ocm.query.Filter;
+import org.apache.jackrabbit.ocm.query.Query;
+import org.apache.jackrabbit.ocm.query.QueryManager;
+import org.apache.jackrabbit.ocm.testmodel.Atomic;
+
+
+/**
+ * Test Query on atomic fields
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class DigesterRemoveTest extends DigesterTestBase
+{
+	private final static Log log = LogFactory.getLog(DigesterRemoveTest.class);
+	private Date date = new Date();
+	/**
+	 * <p>Defines the test case name for junit.</p>
+	 * @param testName The test case name.
+	 */
+	public DigesterRemoveTest(String testName) throws Exception
+	{
+		super(testName);
+
+	}
+
+	public static Test suite()
+	{
+		// All methods starting with "test" will be executed in the test suite.
+		return new RepositoryLifecycleTestSetup(
+                new TestSuite(DigesterRemoveTest.class));
+	}
+
+    /**
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+		this.importData(date);
+        
+    }
+	
+	public void tearDown() throws Exception {
+
+		cleanUpRepisotory();
+		super.tearDown();
+		
+	}
+
+	public void testRemove()
+	{
+
+		try
+		{
+			
+			ObjectContentManager ocm = this.getObjectContentManager();
+			ocm.remove("/test5");
+			ocm.save();
+
+			assertFalse("Test5 has not been removed", ocm.objectExists("/test5"));
+
+			QueryManager queryManager = this.getQueryManager();
+			Filter filter = queryManager.createFilter(Atomic.class);
+			filter.addEqualTo("booleanObject" , new Boolean(false));
+			Query query = queryManager.createQuery(filter);
+			ocm.remove(query);
+			ocm.save();
+
+			filter = queryManager.createFilter(Atomic.class);
+			filter.setScope("//");
+			query = queryManager.createQuery(filter);			
+			Collection result = ocm.getObjects(query);
+			assertEquals("Invalid number of objects", 5, result.size());
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail();
+		}
+
+	}
+
+	private void importData(Date date)
+	{
+		try
+		{
+
+			ObjectContentManager ocm = getObjectContentManager();
+
+			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 the repository".getBytes());
+					a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes()));
+				}
+				ocm.insert(a);
+
+			}
+			ocm.save();
+
+		}
+		catch (Exception e)
+		{
+			e.printStackTrace();
+			fail("Exception occurs during the unit test : " + e);
+		}
+
+	}
+
+}
\ No newline at end of file

Copied: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java (from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerSameNameSiblingTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java?p2=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java&p1=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerSameNameSiblingTest.java&r1=580157&r2=582680&rev=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerSameNameSiblingTest.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSameNameSiblingTest.java Sun Oct  7 13:54:52 2007
@@ -47,16 +47,16 @@
  *
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
  */
-public class ObjectContentManagerSameNameSiblingTest extends DigesterTestBase
+public class DigesterSameNameSiblingTest extends DigesterTestBase
 {
-	private final static Log log = LogFactory.getLog(ObjectContentManagerSameNameSiblingTest.class);
+	private final static Log log = LogFactory.getLog(DigesterSameNameSiblingTest.class);
 	private Date date = new Date();
 	
 	/**
 	 * <p>Defines the test case name for junit.</p>
 	 * @param testName The test case name.
 	 */
-	public ObjectContentManagerSameNameSiblingTest(String testName) throws Exception
+	public DigesterSameNameSiblingTest(String testName) throws Exception
 	{
 		super(testName);
 		
@@ -66,7 +66,7 @@
 	{
 		// All methods starting with "test" will be executed in the test suite.
 		return new RepositoryLifecycleTestSetup(
-                new TestSuite(ObjectContentManagerSameNameSiblingTest.class));
+                new TestSuite(DigesterSameNameSiblingTest.class));
 	}
 
 	public void tearDown() throws Exception 

Copied: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java (from r580157, jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerTest.java)
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java?p2=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java&p1=jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerTest.java&r1=580157&r2=582680&rev=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/ObjectContentManagerTest.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/basic/DigesterSimpleTest.java Sun Oct  7 13:54:52 2007
@@ -37,15 +37,15 @@
  *
  * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
  */
-public class ObjectContentManagerTest extends DigesterTestBase
+public class DigesterSimpleTest extends DigesterTestBase
 {
-    private final static Log log = LogFactory.getLog(ObjectContentManagerTest.class);
+    private final static Log log = LogFactory.getLog(DigesterSimpleTest.class);
 
     /**
      * <p>Defines the test case name for junit.</p>
      * @param testName The test case name.
      */
-    public ObjectContentManagerTest(String testName)  throws Exception
+    public DigesterSimpleTest(String testName)  throws Exception
     {
         super(testName);
     }
@@ -54,7 +54,7 @@
     {
         // All methods starting with "test" will be executed in the test suite.
         return new RepositoryLifecycleTestSetup(
-                new TestSuite(ObjectContentManagerTest.class));
+                new TestSuite(DigesterSimpleTest.class));
     }
 
 

Modified: jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/AllTests.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/AllTests.java?rev=582680&r1=582679&r2=582680&view=diff
==============================================================================
--- jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/AllTests.java (original)
+++ jackrabbit/trunk/contrib/jackrabbit-jcr-mapping/jcr-mapping/src/test/java/org/apache/jackrabbit/ocm/manager/beanconverter/AllTests.java Sun Oct  7 13:54:52 2007
@@ -36,7 +36,8 @@
     public static Test buildSuite() {
         TestSuite suite= new TestSuite("Test for org.apache.jackrabbit.ocm.manager.beanconverter");
         //$JUnit-BEGIN$
-        suite.addTestSuite(BeanDescriptorTest.class);
+        suite.addTestSuite(DigesterBeanDescriptorTest.class);        
+        suite.addTestSuite(AnnotationBeanDescriptorTest.class);
         //$JUnit-END$
 
         return suite;



Mime
View raw message