You are viewing a plain text version of this content. The canonical link for it is here.
Posted to graffito-commits@incubator.apache.org by cl...@apache.org on 2005/09/21 18:52:07 UTC
svn commit: r290790 - in
/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr:
persistence/collectionconverter/ persistence/collectionconverter/impl/
testmodel/ testmodel/hashmap/
Author: clombart
Date: Wed Sep 21 11:51:56 2005
New Revision: 290790
URL: http://svn.apache.org/viewcvs?rev=290790&view=rev
Log:
Review unit tests
Added:
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/File.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Page.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Paragraph.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Element.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/HashMapElement.java (with props)
incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Main.java (with props)
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,224 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================================
+ */
+package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.TestBase;
+import org.apache.portals.graffito.jcr.testmodel.A;
+import org.apache.portals.graffito.jcr.testmodel.C;
+
+/**
+ * Test DefaultCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class DefaultCollectionConverterImplTest extends TestBase
+{
+ private final static Log log = LogFactory.getLog(DefaultCollectionConverterImplTest.class);
+
+ /**
+ * <p>Defines the test case name for junit.</p>
+ * @param testName The test case name.
+ */
+ public DefaultCollectionConverterImplTest(String testName) throws Exception
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(DefaultCollectionConverterImplTest.class);
+ }
+
+ public void testDropElement()
+ {
+ try
+ {
+
+ if (getPersistenceManager().itemExists("/test"))
+ {
+ getPersistenceManager().remove("/test");
+ }
+
+ // --------------------------------------------------------------------------------
+ // Create and store an object graph in the repository
+ // --------------------------------------------------------------------------------
+ A a = new A();
+
+ 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);
+
+ getPersistenceManager().insert("/test", a);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+ a = (A) getPersistenceManager().getObject(A.class, "/test");
+ assertNotNull("a.collection is null", a.getCollection());
+ assertTrue("Incorrect a.collection size", a.getCollection().size() == 3);
+ assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+
+ // --------------------------------------------------------------------------------
+ // Update the object
+ // --------------------------------------------------------------------------------
+ c1 = new C();
+ c1.setId("new first");
+ c1.setName("First Element");
+
+ c2 = new C();
+ c2.setId("new second");
+ c2.setName("Second Element");
+
+ collection = new ArrayList();
+ collection.add(c1);
+ collection.add(c2);
+ a.setCollection(collection);
+
+ getPersistenceManager().update("/test", a);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+ a = (A) getPersistenceManager().getObject(A.class, "/test");
+ assertNotNull("a is null", a);
+ assertNotNull("a.collection is null", a.getCollection());
+ assertTrue("Incorrect collection size", a.getCollection().size() == 2);
+ assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("new first"));
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Exception occurs during the unit test : " + e);
+ }
+
+ }
+
+ public void testAddElement()
+ {
+ try
+ {
+
+ if (getPersistenceManager().itemExists("/test"))
+ {
+ getPersistenceManager().remove("/test");
+ }
+
+ // --------------------------------------------------------------------------------
+ // Create and store an object graph in the repository
+ // --------------------------------------------------------------------------------
+ A a = new A();
+
+ 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);
+
+ getPersistenceManager().insert("/test", a);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+ a = (A) getPersistenceManager().getObject(A.class, "/test");
+ assertNotNull("a.collection is null", a.getCollection());
+ assertTrue("Incorrect a.collection size", a.getCollection().size() == 3);
+ assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+
+ // --------------------------------------------------------------------------------
+ // Update the object
+ // --------------------------------------------------------------------------------
+ c1 = new C();
+ c1.setId("first");
+ c1.setName("First Element");
+ c2 = new C();
+ c2.setId("second");
+ c2.setName("Second Element");
+
+ c3 = new C();
+ c3.setId("third");
+ c3.setName("Third Element");
+
+ C c4 = new C();
+ c4.setId("Fourth");
+ c4.setName("Fourth Element");
+
+ collection = new ArrayList();
+ collection.add(c1);
+ collection.add(c2);
+ collection.add(c3);
+ collection.add(c4);
+ a.setCollection(collection);
+
+ getPersistenceManager().update("/test", a);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+ a = (A) getPersistenceManager().getObject(A.class, "/test");
+ assertNotNull("a is null", a);
+ assertNotNull("a.collection is null", a.getCollection());
+ assertTrue("Incorrect collection size", a.getCollection().size() == 4);
+ assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Exception occurs during the unit test : " + e);
+ }
+
+ }
+
+}
\ No newline at end of file
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/DefaultCollectionConverterImplTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,224 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================================
+ */
+package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
+
+import java.util.ArrayList;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.TestBase;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+import org.apache.portals.graffito.jcr.testmodel.hashmap.Element;
+import org.apache.portals.graffito.jcr.testmodel.hashmap.HashMapElement;
+import org.apache.portals.graffito.jcr.testmodel.hashmap.Main;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class HashMapTest extends TestBase
+{
+ private final static Log log = LogFactory.getLog(HashMapTest.class);
+
+ /**
+ * <p>Defines the test case name for junit.</p>
+ * @param testName The test case name.
+ */
+ public HashMapTest(String testName) throws Exception
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(HashMapTest.class);
+ }
+
+ public void testHashMap()
+ {
+ try
+ {
+
+ if (getPersistenceManager().itemExists("/test"))
+ {
+ getPersistenceManager().remove("/test");
+ }
+
+ // --------------------------------------------------------------------------------
+ // Create and store an object graph in the repository
+ // --------------------------------------------------------------------------------
+
+ Main main = new Main();
+ main.setText("Main text");
+
+ HashMapElement hashMapElement = new HashMapElement();
+ Element e1 = new Element();
+ e1.setId("e1");
+ e1.setText("Element 1");
+ hashMapElement.addObject(e1);
+
+ Element e2 = new Element();
+ e2.setId("e2");
+ e2.setText("Element 2");
+ hashMapElement.addObject(e2);
+
+ main.setElements(hashMapElement);
+
+ getPersistenceManager().insert("/test", main);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+ main = (Main) getPersistenceManager().getObject(Main.class, "/test");
+ assertNotNull("main.getElements() is null", main.getElements());
+ assertTrue("Incorrect text", main.getText().equals("Main text"));
+ assertTrue("Incorrect para element", ((Element) main.getElements().get("e1")).getText().equals("Element 1"));
+
+ // --------------------------------------------------------------------------------
+ // Update the object
+ // --------------------------------------------------------------------------------
+ hashMapElement = new HashMapElement();
+ e1 = new Element();
+ e1.setId("e1");
+ e1.setText("Element 1");
+ hashMapElement.addObject(e1);
+
+ e2 = new Element();
+ e2.setId("e3");
+ e2.setText("Element 3");
+ hashMapElement.addObject(e2);
+
+ Element e3 = new Element();
+ e3.setId("e4");
+ e3.setText("Element 4");
+ hashMapElement.addObject(e3);
+ main.setElements(hashMapElement);
+
+ getPersistenceManager().update("/test", main);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+ assertNotNull("main.getElements() is null", main.getElements());
+ assertTrue("Incorrect text", main.getText().equals("Main text"));
+ assertTrue("Incorrect para element", ((Element) main.getElements().get("e4")).getText().equals("Element 4"));
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Exception occurs during the unit test : " + e);
+ }
+
+ }
+
+// public void testAddElement()
+// {
+// try
+// {
+//
+// if (getPersistenceManager().itemExists("/test"))
+// {
+// getPersistenceManager().remove("/test");
+// }
+//
+// // --------------------------------------------------------------------------------
+// // Create and store an object graph in the repository
+// // --------------------------------------------------------------------------------
+// A a = new A();
+//
+// 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);
+//
+// getPersistenceManager().insert("/test", a);
+//
+// // --------------------------------------------------------------------------------
+// // Get the object
+// // --------------------------------------------------------------------------------
+// a = (A) getPersistenceManager().getObject(A.class, "/test");
+// assertNotNull("a.collection is null", a.getCollection());
+// assertTrue("Incorrect a.collection size", a.getCollection().size() == 3);
+// assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+//
+// // --------------------------------------------------------------------------------
+// // Update the object
+// // --------------------------------------------------------------------------------
+// c1 = new C();
+// c1.setId("first");
+// c1.setName("First Element");
+// c2 = new C();
+// c2.setId("second");
+// c2.setName("Second Element");
+//
+// c3 = new C();
+// c3.setId("third");
+// c3.setName("Third Element");
+//
+// C c4 = new C();
+// c4.setId("Fourth");
+// c4.setName("Fourth Element");
+//
+// collection = new ArrayList();
+// collection.add(c1);
+// collection.add(c2);
+// collection.add(c3);
+// collection.add(c4);
+// a.setCollection(collection);
+//
+// getPersistenceManager().update("/test", a);
+//
+// // --------------------------------------------------------------------------------
+// // Get the object
+// // --------------------------------------------------------------------------------
+// a = (A) getPersistenceManager().getObject(A.class, "/test");
+// assertNotNull("a is null", a);
+// assertNotNull("a.collection is null", a.getCollection());
+// assertTrue("Incorrect collection size", a.getCollection().size() == 4);
+// assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+//
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace();
+// fail("Exception occurs during the unit test : " + e);
+// }
+//
+// }
+
+}
\ No newline at end of file
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/HashMapTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,218 @@
+/* ========================================================================
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ========================================================================
+ */
+package org.apache.portals.graffito.jcr.persistence.collectionconverter.impl;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.portals.graffito.jcr.TestBase;
+import org.apache.portals.graffito.jcr.testmodel.A;
+import org.apache.portals.graffito.jcr.testmodel.C;
+import org.apache.portals.graffito.jcr.testmodel.Page;
+import org.apache.portals.graffito.jcr.testmodel.Paragraph;
+
+/**
+ * Test NTCollectionConverterImpl
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Christophe Lombart</a>
+ */
+public class NTCollectionConverterImplTest extends TestBase
+{
+ private final static Log log = LogFactory.getLog(NTCollectionConverterImplTest.class);
+
+ /**
+ * <p>Defines the test case name for junit.</p>
+ * @param testName The test case name.
+ */
+ public NTCollectionConverterImplTest(String testName) throws Exception
+ {
+ super(testName);
+ }
+
+ public static Test suite()
+ {
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(NTCollectionConverterImplTest.class);
+ }
+
+ public void testCollection()
+ {
+ try
+ {
+
+ if (getPersistenceManager().itemExists("/test"))
+ {
+ getPersistenceManager().remove("/test");
+ }
+
+ // --------------------------------------------------------------------------------
+ // Create and store an object graph in the repository
+ // --------------------------------------------------------------------------------
+
+ Page page = new Page();
+ page.setTitle("Page Title");
+
+ ArrayList paragraphs = new ArrayList();
+
+ paragraphs.add(new Paragraph("Para 1"));
+ paragraphs.add(new Paragraph("Para 2"));
+ paragraphs.add(new Paragraph("Para 3"));
+ page.setParagraphs(paragraphs);
+
+ getPersistenceManager().insert("/test", page);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+ page = (Page) getPersistenceManager().getObject(Page.class, "/test");
+ assertNotNull("page.getParagraphs is null", page.getParagraphs());
+ assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
+ assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() == 3);
+ assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para 1"));
+
+ // --------------------------------------------------------------------------------
+ // Update the object
+ // --------------------------------------------------------------------------------
+ paragraphs = new ArrayList();
+
+ paragraphs.add(new Paragraph("Para 1"));
+ paragraphs.add(new Paragraph("Para 2"));
+ paragraphs.add(new Paragraph("Para 4"));
+ paragraphs.add(new Paragraph("Para 5"));
+ page.setParagraphs(paragraphs);
+
+ getPersistenceManager().update("/test", page);
+
+ // --------------------------------------------------------------------------------
+ // Get the object
+ // --------------------------------------------------------------------------------
+
+ page = (Page) getPersistenceManager().getObject(Page.class, "/test");
+ assertNotNull("page.getParagraphs is null", page.getParagraphs());
+ assertTrue("Incorrect page title", page.getTitle().equals("Page Title"));
+ assertTrue("Incorrect page.getParagraphs size", page.getParagraphs().size() == 4);
+ assertTrue("Incorrect para element", ((Paragraph) page.getParagraphs().iterator().next()).getText().equals("Para 1"));
+
+ // --------------------------------------------------------------------------------
+ // Export to check the content
+ // --------------------------------------------------------------------------------
+ this.exportDocument("target/NTCollectionExport.xml", "/test", true, false);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ fail("Exception occurs during the unit test : " + e);
+ }
+
+ }
+
+// public void testAddElement()
+// {
+// try
+// {
+//
+// if (getPersistenceManager().itemExists("/test"))
+// {
+// getPersistenceManager().remove("/test");
+// }
+//
+// // --------------------------------------------------------------------------------
+// // Create and store an object graph in the repository
+// // --------------------------------------------------------------------------------
+// A a = new A();
+//
+// 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);
+//
+// getPersistenceManager().insert("/test", a);
+//
+// // --------------------------------------------------------------------------------
+// // Get the object
+// // --------------------------------------------------------------------------------
+// a = (A) getPersistenceManager().getObject(A.class, "/test");
+// assertNotNull("a.collection is null", a.getCollection());
+// assertTrue("Incorrect a.collection size", a.getCollection().size() == 3);
+// assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+//
+// // --------------------------------------------------------------------------------
+// // Update the object
+// // --------------------------------------------------------------------------------
+// c1 = new C();
+// c1.setId("first");
+// c1.setName("First Element");
+// c2 = new C();
+// c2.setId("second");
+// c2.setName("Second Element");
+//
+// c3 = new C();
+// c3.setId("third");
+// c3.setName("Third Element");
+//
+// C c4 = new C();
+// c4.setId("Fourth");
+// c4.setName("Fourth Element");
+//
+// collection = new ArrayList();
+// collection.add(c1);
+// collection.add(c2);
+// collection.add(c3);
+// collection.add(c4);
+// a.setCollection(collection);
+//
+// getPersistenceManager().update("/test", a);
+//
+// // --------------------------------------------------------------------------------
+// // Get the object
+// // --------------------------------------------------------------------------------
+// a = (A) getPersistenceManager().getObject(A.class, "/test");
+// assertNotNull("a is null", a);
+// assertNotNull("a.collection is null", a.getCollection());
+// assertTrue("Incorrect collection size", a.getCollection().size() == 4);
+// assertTrue("Incorrect a.collection", ((C) a.getCollection().iterator().next()).getId().equals("first"));
+//
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace();
+// fail("Exception occurs during the unit test : " + e);
+// }
+//
+// }
+
+}
\ No newline at end of file
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/collectionconverter/impl/NTCollectionConverterImplTest.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/File.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/File.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/File.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/File.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,48 @@
+package org.apache.portals.graffito.jcr.testmodel;
+
+import java.io.InputStream;
+import java.util.Calendar;
+
+public class File
+{
+
+ private String mimeType;
+ private String encoding;
+ private InputStream data;
+ private Calendar lastModified;
+
+ public InputStream getData()
+ {
+ return data;
+ }
+ public void setData(InputStream data)
+ {
+ this.data = data;
+ }
+ public String getEncoding()
+ {
+ return encoding;
+ }
+ public void setEncoding(String encoding)
+ {
+ this.encoding = encoding;
+ }
+ public Calendar getLastModified()
+ {
+ return lastModified;
+ }
+ public void setLastModified(Calendar lastModified)
+ {
+ this.lastModified = lastModified;
+ }
+ public String getMimeType()
+ {
+ return mimeType;
+ }
+ public void setMimeType(String mimeType)
+ {
+ this.mimeType = mimeType;
+ }
+
+
+}
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/File.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Page.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Page.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Page.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Page.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.portals.graffito.jcr.testmodel;
+
+import java.util.Collection;
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class Page
+{
+ String title;
+ Collection paragraphs;
+
+ /**
+ * @return Returns the paragraphs.
+ */
+ public Collection getParagraphs()
+ {
+ return paragraphs;
+ }
+ /**
+ * @param paragraphs The paragraphs to set.
+ */
+ public void setParagraphs(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;
+ }
+
+
+}
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Page.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Paragraph.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Paragraph.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Paragraph.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Paragraph.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2000-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.portals.graffito.jcr.testmodel;
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class Paragraph
+{
+ private String text;
+
+
+ public Paragraph()
+ {
+ this.text = "Default text";
+ }
+
+ public Paragraph(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;
+ }
+
+}
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/Paragraph.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Element.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Element.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Element.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Element.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.jcr.testmodel.hashmap;
+
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class Element
+{
+ private String id;
+ private String text;
+
+
+ /**
+ * @return Returns the id.
+ */
+ public String getId()
+ {
+ return id;
+ }
+ /**
+ * @param id The id to set.
+ */
+ public void setId(String id)
+ {
+ this.id = id;
+ }
+ /**
+ * @return Returns the text.
+ */
+ public String getText()
+ {
+ return text;
+ }
+ /**
+ * @param text The text to set.
+ */
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+
+}
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Element.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/HashMapElement.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/HashMapElement.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/HashMapElement.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/HashMapElement.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2000-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.portals.graffito.jcr.testmodel.hashmap;
+
+import java.util.HashMap;
+import java.util.Iterator;
+
+import org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection;
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@gmail.com">Christophe Lombart</a>
+ *
+ */
+public class HashMapElement extends HashMap implements ManageableCollection
+{
+
+ /**
+ * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#addObject(java.lang.Object)
+ */
+ public void addObject(Object object)
+ {
+ if (object instanceof Element)
+ {
+ this.put(((Element)object).getId(), object);
+ }
+ }
+
+ /**
+ * @see org.apache.portals.graffito.jcr.persistence.collectionconverter.ManageableCollection#getIterator()
+ */
+ public Iterator getIterator()
+ {
+ return this.values().iterator();
+ }
+
+}
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/HashMapElement.java
------------------------------------------------------------------------------
svn:executable = *
Added: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Main.java
URL: http://svn.apache.org/viewcvs/incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Main.java?rev=290790&view=auto
==============================================================================
--- incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Main.java (added)
+++ incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Main.java Wed Sep 21 11:51:56 2005
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.portals.graffito.jcr.testmodel.hashmap;
+
+import java.util.HashMap;
+
+/**
+ *
+ * @author <a href="mailto:christophe.lombart@sword-technologies.com">Lombart Christophe </a>
+ * @version $Id: Exp $
+ */
+public class Main
+{
+ private String text;
+ private HashMapElement elements;
+ /**
+ * @return Returns the elements.
+ */
+ public HashMapElement getElements()
+ {
+ return elements;
+ }
+ /**
+ * @param elements The elements to set.
+ */
+ public void setElements(HashMapElement elements)
+ {
+ this.elements = elements;
+ }
+ /**
+ * @return Returns the text.
+ */
+ public String getText()
+ {
+ return text;
+ }
+ /**
+ * @param text The text to set.
+ */
+ public void setText(String text)
+ {
+ this.text = text;
+ }
+
+
+}
Propchange: incubator/graffito/trunk/jcr-mapping/src/test/org/apache/portals/graffito/jcr/testmodel/hashmap/Main.java
------------------------------------------------------------------------------
svn:executable = *