jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clomb...@apache.org
Subject svn commit: r618092 - in /jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager: collectionconverter/ query/
Date Sun, 03 Feb 2008 21:24:07 GMT
Author: clombart
Date: Sun Feb  3 13:24:06 2008
New Revision: 618092

URL: http://svn.apache.org/viewvc?rev=618092&view=rev
Log:
Some unit tests failed because some checks on collections were invalid
It seems that some changes occured recently in Jacrabbit core because those unit tests worked
with Jackrabbit 1.4.
So, I added new methods to check if a collection contains an element in the unit tests. 
Now the unit tests work fine. 

Modified:
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationNTCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterNTCollectionConverterImplTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/AnnotationSimpleQueryTest.java
    jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationNTCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationNTCollectionConverterImplTest.java?rev=618092&r1=618091&r2=618092&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationNTCollectionConverterImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/AnnotationNTCollectionConverterImplTest.java
Sun Feb  3 13:24:06 2008
@@ -17,6 +17,8 @@
 package org.apache.jackrabbit.ocm.manager.collectionconverter;
 
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -99,7 +101,8 @@
             assertNotNull("page.getParagraphs is null", page.getParagraphs());
             assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
             assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() ==
3);
-            assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para
1"));
+            assertTrue("Incorrect para element", this.containsText(page.getParagraphs(),
"Para 1"));
+            
 
             // --------------------------------------------------------------------------------
             // Update the object
@@ -123,7 +126,7 @@
             assertNotNull("page.getParagraphs is null", page.getParagraphs());
             assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
             assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() ==
4);
-            assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para
1"));
+            assertTrue("Incorrect para element", this.containsText(page.getParagraphs(),
"Para 1"));
 
             // --------------------------------------------------------------------------------
             // Export to check the content
@@ -137,6 +140,21 @@
             fail("Exception occurs during the unit test : " + e);
         }
 
+    }
+    
+    private boolean containsText(Collection paragraphs, String text)
+    {
+    	Iterator iterator = paragraphs.iterator();
+    	while (iterator.hasNext()) {
+			Paragraph paragraph = (Paragraph) iterator.next();
+			if (paragraph.getText().equals(text))
+			{
+				return true;
+			}
+			
+		}
+    	return false; 
+    	
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterNTCollectionConverterImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterNTCollectionConverterImplTest.java?rev=618092&r1=618091&r2=618092&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterNTCollectionConverterImplTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/collectionconverter/DigesterNTCollectionConverterImplTest.java
Sun Feb  3 13:24:06 2008
@@ -18,6 +18,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Iterator;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
@@ -102,7 +103,7 @@
             assertNotNull("page.getParagraphs is null", page.getParagraphs());
             assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
             assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() ==
3);
-            assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para
1"));
+            assertTrue("Incorrect para element", this.containsText(page.getParagraphs(),"Para
1"));
 
             // --------------------------------------------------------------------------------
             // Update the object
@@ -126,7 +127,7 @@
             assertNotNull("page.getParagraphs is null", page.getParagraphs());
             assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
             assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() ==
4);
-            assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para
1"));
+            assertTrue("Incorrect para element", this.containsText(page.getParagraphs(),"Para
1"));
 
             // --------------------------------------------------------------------------------
             // Export to check the content
@@ -140,6 +141,21 @@
             fail("Exception occurs during the unit test : " + e);
         }
 
+    }
+    
+    private boolean containsText(Collection paragraphs, String text)
+    {
+    	Iterator iterator = paragraphs.iterator();
+    	while (iterator.hasNext()) {
+			Paragraph paragraph = (Paragraph) iterator.next();
+			if (paragraph.getText().equals(text))
+			{
+				return true;
+			}
+			
+		}
+    	return false; 
+    	
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/AnnotationSimpleQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/AnnotationSimpleQueryTest.java?rev=618092&r1=618091&r2=618092&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/AnnotationSimpleQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/AnnotationSimpleQueryTest.java
Sun Feb  3 13:24:06 2008
@@ -158,9 +158,9 @@
     	      assertEquals("Invalid number of objects - should be = 3", 3, result.size());
 
     	      Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
-    	      assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 1"));
-    	      assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
-    	      assertTrue("Invalid paragraph found", paragraphs[2].getText().equals("Para 3"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 3"));
     	
 
         }
@@ -201,8 +201,8 @@
     	      assertEquals("Invalid number of objects - should be = 2", 2, result.size());
     	
     	      Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
-    	      assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 1"));
-    	      assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
 
         }
         catch (Exception e)
@@ -233,9 +233,9 @@
     	      assertEquals("Invalid number of objects - should be = 3", 3, result.size());
 
     	      Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
-    	      assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 3"));
-    	      assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
-    	      assertTrue("Invalid paragraph found", paragraphs[2].getText().equals("Para 1"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
+    	      assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 3"));
     	
 
         }
@@ -268,4 +268,18 @@
 
 
     }
+    
+    private boolean containsText(Paragraph[] paragraphs, String text)
+    {
+    	
+    	for (int i = 0; i < paragraphs.length; i++) 
+    	{
+    		if (paragraphs[i].getText().equals(text))
+			{
+				return true;
+			}	
+		}
+    	return false; 
+    	
+    }       
 }

Modified: jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java?rev=618092&r1=618091&r2=618092&view=diff
==============================================================================
--- jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java
(original)
+++ jackrabbit/trunk/jackrabbit-ocm/src/test/java/org/apache/jackrabbit/ocm/manager/query/DigesterSimpleQueryTest.java
Sun Feb  3 13:24:06 2008
@@ -148,9 +148,9 @@
             assertEquals("Invalid number of objects - should be = 3", 3, result.size());
 
             Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
-            assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 1"));
-            assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
-            assertTrue("Invalid paragraph found", paragraphs[2].getText().equals("Para 3"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 3"));
 
         } catch (Exception e) {
             e.printStackTrace();
@@ -185,8 +185,8 @@
             assertEquals("Invalid number of objects - should be = 2", 2, result.size());
 
             Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
-            assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 1"));
-            assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
 
         } catch (Exception e) {
             e.printStackTrace();
@@ -213,9 +213,9 @@
             assertEquals("Invalid number of objects - should be = 3", 3, result.size());
 
             Paragraph[] paragraphs = (Paragraph[]) result.toArray(new Paragraph[result.size()]);
-            assertTrue("Invalid paragraph found", paragraphs[0].getText().equals("Para 3"));
-            assertTrue("Invalid paragraph found", paragraphs[1].getText().equals("Para 2"));
-            assertTrue("Invalid paragraph found", paragraphs[2].getText().equals("Para 1"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 1"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 2"));
+            assertTrue("Invalid paragraph found", this.containsText(paragraphs,"Para 3"));
 
         } catch (Exception e) {
             e.printStackTrace();
@@ -329,8 +329,19 @@
         {
         	fail("Impossible to create the data " + e);
         }
-		
-
-
     }
+    
+    private boolean containsText(Paragraph[] paragraphs, String text)
+    {
+    	
+    	for (int i = 0; i < paragraphs.length; i++) 
+    	{
+    		if (paragraphs[i].getText().equals(text))
+			{
+				return true;
+			}	
+		}
+    	return false; 
+    	
+    }    
 }



Mime
View raw message