jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r632863 - in /jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm: ./ manager/version/ testmodel/unstructured/
Date Sun, 02 Mar 2008 22:54:17 GMT
Author: clombart
Date: Sun Mar  2 14:54:16 2008
New Revision: 632863

URL: http://svn.apache.org/viewvc?rev=632863&view=rev
Log:
Review some unit tests. excluse the jcr:rootVersion otherwise it will causes exceptions. 

Added:
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredPage.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredParagraph.java
Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/AnnotationBasicVersionningTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/DigesterBasicVersionningTest.java

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java?rev=632863&r1=632862&r2=632863&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/AnnotationTestBase.java
Sun Mar  2 14:54:16 2008
@@ -153,6 +153,8 @@
 		classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.B2.class);
 		classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.Ancestor.class);
 		classes.add(org.apache.jackrabbit.ocm.testmodel.uuid.Descendant.class);
+		classes.add(org.apache.jackrabbit.ocm.testmodel.unstructured.UnstructuredParagraph.class);
+		classes.add(org.apache.jackrabbit.ocm.testmodel.unstructured.UnstructuredPage.class);
 		Mapper mapper = new AnnotationMapperImpl(classes);
 		ocm = new ObjectContentManagerImpl(session, mapper);
 		

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/AnnotationBasicVersionningTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/AnnotationBasicVersionningTest.java?rev=632863&r1=632862&r2=632863&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/AnnotationBasicVersionningTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/AnnotationBasicVersionningTest.java
Sun Mar  2 14:54:16 2008
@@ -29,6 +29,8 @@
 import org.apache.jackrabbit.ocm.manager.ObjectContentManager;
 import org.apache.jackrabbit.ocm.testmodel.Page;
 import org.apache.jackrabbit.ocm.testmodel.Paragraph;
+import org.apache.jackrabbit.ocm.testmodel.unstructured.UnstructuredPage;
+import org.apache.jackrabbit.ocm.testmodel.unstructured.UnstructuredParagraph;
 import org.apache.jackrabbit.ocm.version.Version;
 import org.apache.jackrabbit.ocm.version.VersionIterator;
 
@@ -59,7 +61,7 @@
 	}
 	
 
-	public void testSimpleVersion()
+	public void testSimpleVersionWithNodeType()
 	{
 		     ObjectContentManager ocm = getObjectContentManager();
              try
@@ -73,14 +75,15 @@
             	 ocm.insert(page);
             	 ocm.save();
             	
-
             	 page.addParagraph(new Paragraph("para3"));
+            	 page.setTitle("Page Title 2");
             	 ocm.checkout("/page");
             	 ocm.update(page);
             	 ocm.save();
             	 ocm.checkin("/page");
             	
             	 page.addParagraph(new Paragraph("para4"));
+            	 page.setTitle("Page Title 3");
             	 ocm.checkout("/page");
             	 ocm.update(page);
             	 ocm.save();
@@ -93,8 +96,25 @@
             	 while (versionIterator.hasNext())
             	 {
             		 Version version = (Version) versionIterator.next();
-            		 log.info("version found : "+ version.getName() + " - " + version.getPath()
+ " - " +  version.getCreated().getTime());
-            		
+            		 log.info("version found : "+ version.getName() + " - " + version.getPath()
+ " - " +  version.getCreated().getTime());            		 
+            		 if (version.getName().equals("jcr:rootVersion"))
+            		 {
+            			 continue; 
+            		 }
+            		 
+            		 page = (Page) ocm.getObject("/page", version.getName());
+            		 assertNotNull("Page is null for version " + version.getName(), page);
+            		 
+            		 if (version.getName().equals("1.0"))
+            		 {
+            			assertEquals("Invalid title for version " + version.getName(),page.getTitle(),
"Page Title 2");
+            		 }
+            		 
+            		 if (version.getName().equals("1.1"))
+            		 {
+            			assertEquals("Invalid title for version " + version.getName(),page.getTitle(),
"Page Title 3"); 
+            		 } 
+            		 
             	 }
             	
             	 Version baseVersion = ocm.getBaseVersion("/page");
@@ -110,11 +130,6 @@
             	 assertTrue("Invalid number of paragraph found in the last  version", page.getParagraphs().size()
== 4);
 
             	
-            	 //Get the object matching to the first version
-                 Page  page1 = (Page) ocm.getObject( "/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)
              {
@@ -166,6 +181,86 @@
              {
             	 e.printStackTrace();
             	 fail();
+             }
+	}
+
+	public void testSimpleVersionWithoutNodeType()
+	{
+		     ObjectContentManager ocm = getObjectContentManager();
+             try
+             {
+            	
+            	 UnstructuredPage page = new UnstructuredPage();
+            	 page.setPath("/page");
+            	 page.setTitle("Page Title");            	
+            	 page.addParagraph(new UnstructuredParagraph("para1"));
+            	 page.addParagraph(new UnstructuredParagraph("para2"));
+            	 ocm.insert(page);
+            	 ocm.save();
+            	
+
+            	 page.addParagraph(new UnstructuredParagraph("para3"));
+            	 page.setTitle("Page Title 2");
+            	 ocm.checkout("/page");
+            	 ocm.update(page);
+            	 ocm.save();
+            	 ocm.checkin("/page");
+            	
+            	 page.addParagraph(new UnstructuredParagraph("para4"));
+            	 page.setTitle("Page Title 3");
+            	 ocm.checkout("/page");
+            	 ocm.update(page);
+            	 ocm.save();
+            	 ocm.checkin("/page");            	
+
+            	 VersionIterator versionIterator = ocm.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.getName() + " - " + version.getPath()
+ " - " +  version.getCreated().getTime());
+            		 if (version.getName().equals("jcr:rootVersion"))
+            		 {
+            			 continue; 
+            		 }
+            		 
+            		 page = (UnstructuredPage) ocm.getObject("/page", version.getName());
+            		 
+            		 assertNotNull("Page is null for version " + version.getName(), page);
+            		 
+            		 if (version.getName().equals("1.0"))
+            		 {
+            			assertEquals("Invalid title for version " + version.getName(),page.getTitle(),
"Page Title 2");
+            		 }
+            		 
+            		 if (version.getName().equals("1.1"))
+            		 {
+            			assertEquals("Invalid title for version " + version.getName(),page.getTitle(),
"Page Title 3"); 
+            		 } 
+
+            	 }
+            	
+            	 Version baseVersion = ocm.getBaseVersion("/page");
+            	 System.out.println("Base version : " + baseVersion.getName());
+
+            	 Version rootVersion = ocm.getRootVersion("/page");
+            	 System.out.println("Root version : " + rootVersion.getName());
+            	 //this.exportDocument("/home/christophe/export.xml", "/jcr:system/jcr:versionStorage",
true, false);
+            	             	
+                 //Get the latest version
+            	 page = (UnstructuredPage) ocm.getObject( "/page");
+            	 assertNotNull("Last version is nulll", page);
+            	 assertTrue("Invalid number of paragraph found in the last  version", page.getParagraphs().size()
== 4);
+
+            	
+             }
+             catch(Exception e)
+             {
+            	 e.printStackTrace();
+            	 fail(e.getMessage());
+            	
              }
 	}
 	

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/DigesterBasicVersionningTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/DigesterBasicVersionningTest.java?rev=632863&r1=632862&r2=632863&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/DigesterBasicVersionningTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/version/DigesterBasicVersionningTest.java
Sun Mar  2 14:54:16 2008
@@ -61,67 +61,79 @@
 
 	public void testSimpleVersion()
 	{
-		     ObjectContentManager ocm = getObjectContentManager();
-             try
-             {
-            	
-            	 Page page = new Page();
-            	 page.setPath("/page");
-            	 page.setTitle("Page Title");            	
-            	 page.addParagraph(new Paragraph("para1"));
-            	 page.addParagraph(new Paragraph("para2"));
-            	 ocm.insert(page);
-            	 ocm.save();
-            	
+	     ObjectContentManager ocm = getObjectContentManager();
+         try
+         {
+        	
+        	 Page page = new Page();
+        	 page.setPath("/page");
+        	 page.setTitle("Page Title");            	
+        	 page.addParagraph(new Paragraph("para1"));
+        	 page.addParagraph(new Paragraph("para2"));
+        	 ocm.insert(page);
+        	 ocm.save();
+        	
+        	 page.addParagraph(new Paragraph("para3"));
+        	 page.setTitle("Page Title 2");
+        	 ocm.checkout("/page");
+        	 ocm.update(page);
+        	 ocm.save();
+        	 ocm.checkin("/page");
+        	
+        	 page.addParagraph(new Paragraph("para4"));
+        	 page.setTitle("Page Title 3");
+        	 ocm.checkout("/page");
+        	 ocm.update(page);
+        	 ocm.save();
+        	 ocm.checkin("/page");            	
 
-            	 page.addParagraph(new Paragraph("para3"));
-            	 ocm.checkout("/page");
-            	 ocm.update(page);
-            	 ocm.save();
-            	 ocm.checkin("/page");
-            	
-            	 page.addParagraph(new Paragraph("para4"));
-            	 ocm.checkout("/page");
-            	 ocm.update(page);
-            	 ocm.save();
-            	 ocm.checkin("/page");            	
+        	 VersionIterator versionIterator = ocm.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.getName() + " - " + version.getPath() + "
- " +  version.getCreated().getTime());            		 
+        		 if (version.getName().equals("jcr:rootVersion"))
+        		 {
+        			 continue; 
+        		 }
+        		 
+        		 page = (Page) ocm.getObject("/page", version.getName());
+        		 assertNotNull("Page is null for version " + version.getName(), page);
+        		 
+        		 if (version.getName().equals("1.0"))
+        		 {
+        			assertEquals("Invalid title for version " + version.getName(),page.getTitle(),
"Page Title 2");
+        		 }
+        		 
+        		 if (version.getName().equals("1.1"))
+        		 {
+        			assertEquals("Invalid title for version " + version.getName(),page.getTitle(),
"Page Title 3"); 
+        		 } 
+        		 
+        	 }
+        	
+        	 Version baseVersion = ocm.getBaseVersion("/page");
+        	 System.out.println("Base version : " + baseVersion.getName());
 
-            	 VersionIterator versionIterator = ocm.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.getName() + " - " + version.getPath()
+ " - " +  version.getCreated().getTime());
-            		
-            	 }
-            	
-            	 Version baseVersion = ocm.getBaseVersion("/page");
-            	 System.out.println("Base version : " + baseVersion.getName());
+        	 Version rootVersion = ocm.getRootVersion("/page");
+        	 System.out.println("Root version : " + rootVersion.getName());
+        	             	
+             //Get the latest version
+        	 page = (Page) ocm.getObject( "/page");
+        	 assertNotNull("Last version is nulll", page);
+        	 assertTrue("Invalid number of paragraph found in the last  version", page.getParagraphs().size()
== 4);
 
-            	 Version rootVersion = ocm.getRootVersion("/page");
-            	 System.out.println("Root version : " + rootVersion.getName());
-            	 //this.exportDocument("/home/christophe/export.xml", "/jcr:system/jcr:versionStorage",
true, false);
-            	             	
-                 //Get the latest version
-            	 page = (Page) ocm.getObject( "/page");
-            	 assertNotNull("Last version is nulll", page);
-            	 assertTrue("Invalid number of paragraph found in the last  version", page.getParagraphs().size()
== 4);
-
-            	
-            	 //Get the object matching to the first version
-                 Page  page1 = (Page) ocm.getObject( "/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(e.getMessage());
-            	
-             }
+        	
+         }
+         catch(Exception e)
+         {
+        	 e.printStackTrace();
+        	 fail(e.getMessage());
+        	
+         }
 	}
 
 	

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredPage.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredPage.java?rev=632863&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredPage.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredPage.java
Sun Mar  2 14:54:16 2008
@@ -0,0 +1,90 @@
+/*
+ * 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.testmodel.unstructured;
+
+import java.util.ArrayList;
+
+
+import org.apache.jackrabbit.ocm.manager.collectionconverter.impl.NTCollectionConverterImpl;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Collection;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+/**
+ * This pojo is mapped into node type "nt:unstructured" and the mixin node type "mix:versionable"
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+@Node(jcrMixinTypes = "mix:versionable")
+public class UnstructuredPage
+{
+	@Field(path=true) String path;
+    @Field String title;
+
+    @Collection(elementClassName=UnstructuredParagraph.class)
+    java.util.Collection paragraphs;
+
+    public String getPath()
+    {
+		return path;
+	}
+	public void setPath(String path)
+	{
+		this.path = path;
+	}
+	/**
+     * @return Returns the paragraphs.
+     */
+    public java.util.Collection getParagraphs()
+    {
+        return paragraphs;
+    }
+    /**
+     * @param paragraphs The paragraphs to set.
+     */
+    public void setParagraphs(java.util.Collection paragraphs)
+    {
+        this.paragraphs = paragraphs;
+    }
+    /**
+     * @return Returns the title.
+     */
+    public String getTitle()
+    {
+        return title;
+    }
+    /**
+     * @param title The title to set.
+     */
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    public void addParagraph(UnstructuredParagraph paragraph)
+    {
+    	if (paragraphs == null)
+    	{
+    		paragraphs = new ArrayList();
+    	}
+    	
+    	paragraphs.add(paragraph);
+    }
+
+
+
+}

Added: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredParagraph.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredParagraph.java?rev=632863&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredParagraph.java
(added)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/testmodel/unstructured/UnstructuredParagraph.java
Sun Mar  2 14:54:16 2008
@@ -0,0 +1,88 @@
+/*
+ * 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.testmodel.unstructured;
+
+import org.apache.jackrabbit.ocm.manager.beanconverter.impl.ParentBeanConverterImpl;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Bean;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Field;
+import org.apache.jackrabbit.ocm.mapper.impl.annotation.Node;
+
+/**
+ * This pojo is mapped into node type "nt:unstructured" and the mixin node type "mix:versionable"
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+@Node(jcrMixinTypes = "mix:versionable")
+public class UnstructuredParagraph
+{
+    @Field(path=true) private String path;
+	@Field private String text;
+	
+    // The converter ParentBeanConverterImpl can be used to have a simple reference
+	// to the page containing this pararaph (parent node) - cannot be updated
+	@Bean(proxy=true, converter=ParentBeanConverterImpl.class) private UnstructuredPage page;
+	
+    public String getPath()
+    {
+		return path;
+	}
+
+	public void setPath(String path)
+	{
+		this.path = path;
+	}
+
+	public UnstructuredParagraph()
+    {
+        this.text = "Default text";
+    }
+
+    public UnstructuredParagraph(String text)
+    {
+        this.text = text;
+    }
+
+    /**
+     * @return Returns the text.
+     */
+    public String getText()
+    {
+        return text;
+    }
+
+    /**
+     * @param text The text to set.
+     */
+    public void setText(String text)
+    {
+        this.text = text;
+    }
+
+	public UnstructuredPage getPage()
+	{
+		return page;
+	}
+
+	public void setPage(UnstructuredPage page) {
+		this.page = page;
+	}
+
+	
+
+
+}



Mime
View raw message