From graffito-commits-return-703-apmail-incubator-graffito-commits-archive=www.apache.org@incubator.apache.org Mon May 22 23:34:47 2006 Return-Path: Delivered-To: apmail-incubator-graffito-commits-archive@www.apache.org Received: (qmail 20456 invoked from network); 22 May 2006 23:34:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 22 May 2006 23:34:45 -0000 Received: (qmail 72849 invoked by uid 500); 22 May 2006 23:34:44 -0000 Mailing-List: contact graffito-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: graffito-dev@incubator.apache.org Delivered-To: mailing list graffito-commits@incubator.apache.org Received: (qmail 72654 invoked by uid 99); 22 May 2006 23:34:43 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2006 16:34:43 -0700 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [140.211.166.113] (HELO eris.apache.org) (140.211.166.113) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 22 May 2006 16:34:37 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 2CFDE1A9884; Mon, 22 May 2006 13:46:58 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r408761 - in /incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic: ./ AllTests.java PersistenceManagerRemoveTest.java PersistenceManagerSameNameSiblingTest.java PersistenceManagerTest.java Date: Mon, 22 May 2006 20:46:57 -0000 To: graffito-commits@incubator.apache.org From: clombart@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20060522204658.2CFDE1A9884@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: clombart Date: Mon May 22 13:46:56 2006 New Revision: 408761 URL: http://svn.apache.org/viewvc?rev=408761&view=rev Log: Reorganise the unit tests Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/AllTests.java incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerRemoveTest.java incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerTest.java Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/AllTests.java URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/AllTests.java?rev=408761&view=auto ============================================================================== --- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/AllTests.java (added) +++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/AllTests.java Mon May 22 13:46:56 2006 @@ -0,0 +1,46 @@ +/* ======================================================================== + * 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.basic; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.apache.portals.graffito.jcr.RepositoryLifecycleTestSetup; + + +/** + * Package level tests. + * + * @author Alexandru Popescu + */ +public class AllTests { + + public static Test suite() { + return new RepositoryLifecycleTestSetup(buildSuite()); + } + + public static Test buildSuite() { + TestSuite suite= new TestSuite("Test for org.apache.portals.graffito.jcr.persistence.basic"); + //$JUnit-BEGIN$ + suite.addTestSuite(PersistenceManagerRemoveTest.class); + suite.addTestSuite(PersistenceManagerSameNameSiblingTest.class); + suite.addTestSuite(PersistenceManagerTest.class); + //$JUnit-END$ + + return suite; + } +} Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerRemoveTest.java URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerRemoveTest.java?rev=408761&view=auto ============================================================================== --- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerRemoveTest.java (added) +++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerRemoveTest.java Mon May 22 13:46:56 2006 @@ -0,0 +1,173 @@ +/* ======================================================================== + * 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.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.portals.graffito.jcr.RepositoryLifecycleTestSetup; +import org.apache.portals.graffito.jcr.TestBase; +import org.apache.portals.graffito.jcr.persistence.PersistenceManager; +import org.apache.portals.graffito.jcr.query.Filter; +import org.apache.portals.graffito.jcr.query.Query; +import org.apache.portals.graffito.jcr.query.QueryManager; +import org.apache.portals.graffito.jcr.testmodel.Atomic; +import org.apache.portals.graffito.jcr.testmodel.MultiValue; + +/** + * Test Query on atomic fields + * + * @author Christophe Lombart + */ +public class PersistenceManagerRemoveTest extends TestBase +{ + private final static Log log = LogFactory.getLog(PersistenceManagerRemoveTest.class); + private Date date = new Date(); + /** + *

Defines the test case name for junit.

+ * @param testName The test case name. + */ + public PersistenceManagerRemoveTest(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(PersistenceManagerRemoveTest.class)); + } + + /** + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception + { + super.setUp(); + this.importData(date); + + } + + public void tearDown() throws Exception + { + + for (int i = 1; i <= 10; i++) + { + if (getPersistenceManager().objectExists("/test" + i)) + { + getPersistenceManager().remove("/test" + i); + } + + } + getPersistenceManager().save(); + + super.tearDown(); + } + + public void testRemove() + { + + try + { + + PersistenceManager persistenceManager = this.getPersistenceManager(); + persistenceManager.remove("/test5"); + persistenceManager.save(); + + assertFalse("Test5 has not been removed", persistenceManager.objectExists("/test5")); + + QueryManager queryManager = this.getQueryManager(); + Filter filter = queryManager.createFilter(Atomic.class); + filter.addEqualTo("booleanObject" , new Boolean(false)); + Query query = queryManager.createQuery(filter); + persistenceManager.remove(query); + persistenceManager.save(); + + filter = queryManager.createFilter(Atomic.class); + filter.setScope("//"); + query = queryManager.createQuery(filter); + Collection result = persistenceManager.getObjects(query); + assertEquals("Invalid number of objects", 5, result.size()); + + } + catch (Exception e) + { + e.printStackTrace(); + fail(); + } + + } + + private void importData(Date date) + { + try + { + + PersistenceManager persistenceManager = getPersistenceManager(); + + 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 a Graffito repository".getBytes()); + a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes())); + } + persistenceManager.insert(a); + + } + persistenceManager.save(); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("Exception occurs during the unit test : " + e); + } + + } + +} \ No newline at end of file Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java?rev=408761&view=auto ============================================================================== --- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java (added) +++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerSameNameSiblingTest.java Mon May 22 13:46:56 2006 @@ -0,0 +1,236 @@ +/* ======================================================================== + * 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.basic; + +import java.io.ByteArrayInputStream; +import java.sql.Timestamp; +import java.util.Calendar; +import java.util.Collection; +import java.util.Date; +import java.util.Map; + +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.portals.graffito.jcr.RepositoryLifecycleTestSetup; +import org.apache.portals.graffito.jcr.TestBase; +import org.apache.portals.graffito.jcr.mapper.impl.DigesterMapperImpl; +import org.apache.portals.graffito.jcr.persistence.PersistenceManager; +import org.apache.portals.graffito.jcr.persistence.atomictypeconverter.impl.DefaultAtomicTypeConverterProvider; +import org.apache.portals.graffito.jcr.persistence.impl.PersistenceManagerImpl; +import org.apache.portals.graffito.jcr.persistence.objectconverter.ObjectConverter; +import org.apache.portals.graffito.jcr.persistence.objectconverter.impl.ObjectConverterImpl; +import org.apache.portals.graffito.jcr.query.Filter; +import org.apache.portals.graffito.jcr.query.Query; +import org.apache.portals.graffito.jcr.query.QueryManager; +import org.apache.portals.graffito.jcr.query.impl.QueryManagerImpl; +import org.apache.portals.graffito.jcr.repository.RepositoryUtil; +import org.apache.portals.graffito.jcr.testmodel.Atomic; +import org.apache.portals.graffito.jcr.testmodel.Page; +import org.apache.portals.graffito.jcr.testmodel.Paragraph; + +/** + * Test Query on atomic fields + * + * @author Christophe Lombart + */ +public class PersistenceManagerSameNameSiblingTest extends TestBase +{ + private final static Log log = LogFactory.getLog(PersistenceManagerSameNameSiblingTest.class); + private Date date = new Date(); + + /** + *

Defines the test case name for junit.

+ * @param testName The test case name. + */ + public PersistenceManagerSameNameSiblingTest(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(PersistenceManagerSameNameSiblingTest.class)); + } + + + public void testSameNameSiblings() + { + + try + { + this.importData(date); + PersistenceManager persistenceManager = this.getPersistenceManager(); + + // Query all objects + QueryManager queryManager = this.getQueryManager(); + Filter filter = queryManager.createFilter(Atomic.class); + filter.setScope("/"); + Query query = queryManager.createQuery(filter); + Collection result = persistenceManager.getObjects(query); + assertEquals("Incorrect number of objects found", 10, result.size()); + + // Get objects + Atomic atomic = (Atomic) persistenceManager.getObject( "/test[2]"); + assertNotNull("Object /test[2] not found", atomic); + + atomic = (Atomic) persistenceManager.getObject( "/test[10]"); + assertNotNull("Object /test[2] not found", atomic); + + // Update the object + atomic.setString("Modified Test String 10"); + persistenceManager.update(atomic); + persistenceManager.save(); + + // Query on the attribute "string" + queryManager = this.getQueryManager(); + filter = queryManager.createFilter(Atomic.class); + filter.addLike("string", "Modified%"); + query = queryManager.createQuery(filter); + result = persistenceManager.getObjects(query); + assertTrue("Incorrect number of objects found", result.size() == 1); + + atomic = (Atomic) persistenceManager.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) ; + persistenceManager.remove(query); + persistenceManager.save(); + + result = persistenceManager.getObjects(query); + assertTrue("Incorrect number of objects found", result.size() == 0); + + + } + catch (Exception e) + { + e.printStackTrace(); + fail(); + } + + } + + public void testUnsupportedSameNameSiblings() + { + PersistenceManager persistenceManager = getPersistenceManager(); + try + { + + Page page = new Page(); + page.setPath("/page"); + page.setTitle("Page Title"); + persistenceManager.insert(page); + persistenceManager.save(); + + Paragraph p1 = new Paragraph("para1"); + p1.setPath("/page/paragraph"); + persistenceManager.insert(p1); + + Paragraph p2 = new Paragraph("para1"); + p2.setPath("/page/paragraph"); + persistenceManager.insert(p2); + fail(); + + } + catch(Exception e) + { + persistenceManager.remove("/page"); + persistenceManager.save(); + } + } + + + private void importData(Date date) + { + try + { + + PersistenceManager persistenceManager = getPersistenceManager(); + + + 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 a Graffito repository".getBytes()); + a.setInputStream(new ByteArrayInputStream("Another Stream".getBytes())); + } + persistenceManager.insert(a); + + + } + persistenceManager.save(); + + } + catch (Exception e) + { + e.printStackTrace(); + fail("Exception occurs during the unit test : " + e); + } + + } + + protected void initPersistenceManager() throws UnsupportedRepositoryOperationException, javax.jcr.RepositoryException + { + Repository repository = RepositoryUtil.getRepository("repositoryTest"); + String[] files = { "./src/test-config/jcrmapping-sibling.xml" }; + session = RepositoryUtil.login(repository, "superuser", "superuser"); + + + mapper = new DigesterMapperImpl(files).buildMapper(); + converterProvider = new DefaultAtomicTypeConverterProvider(); + Map atomicTypeConverters = converterProvider.getAtomicTypeConverters(); + queryManager = new QueryManagerImpl(mapper, atomicTypeConverters); + ObjectConverter objectConverter = new ObjectConverterImpl(mapper, converterProvider); + persistenceManager = new PersistenceManagerImpl(mapper, objectConverter, queryManager, session); + + } + +} \ No newline at end of file Added: incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerTest.java URL: http://svn.apache.org/viewvc/incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerTest.java?rev=408761&view=auto ============================================================================== --- incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerTest.java (added) +++ incubator/graffito/trunk/jcr/jcr-mapping/src/test/org/apache/portals/graffito/jcr/persistence/basic/PersistenceManagerTest.java Mon May 22 13:46:56 2006 @@ -0,0 +1,221 @@ +/* ======================================================================== + * 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.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.portals.graffito.jcr.RepositoryLifecycleTestSetup; +import org.apache.portals.graffito.jcr.TestBase; +import org.apache.portals.graffito.jcr.persistence.PersistenceManager; +import org.apache.portals.graffito.jcr.testmodel.A; +import org.apache.portals.graffito.jcr.testmodel.B; +import org.apache.portals.graffito.jcr.testmodel.C; +import org.apache.portals.graffito.jcr.testmodel.Discriminator; + +/** + * Test JcrSession + * + * @author Christophe Lombart + */ +public class PersistenceManagerTest extends TestBase +{ + private final static Log log = LogFactory.getLog(PersistenceManagerTest.class); + + /** + *

Defines the test case name for junit.

+ * @param testName The test case name. + */ + public PersistenceManagerTest(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(PersistenceManagerTest.class)); + } + + + /** + * @see junit.framework.TestCase#tearDown() + */ + public void tearDown() throws Exception + { + if (getPersistenceManager().objectExists("/test")) + { + getPersistenceManager().remove("/test"); + getPersistenceManager().save(); + } + super.tearDown(); + } + + public void testClassA() + { + try + { + PersistenceManager persistenceManager = getPersistenceManager(); + + + // -------------------------------------------------------------------------------- + // 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); + + persistenceManager.insert(a); + persistenceManager.save(); + + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + a = (A) persistenceManager.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); + + + persistenceManager.update(a); + persistenceManager.save(); + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + a = (A) persistenceManager.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 + { + PersistenceManager persistenceManager = getPersistenceManager(); + + + // -------------------------------------------------------------------------------- + // Create and store the object in the repository + // -------------------------------------------------------------------------------- + Discriminator discriminatorObject = new Discriminator(); + discriminatorObject.setPath("/test"); + discriminatorObject.setContent("This is my content"); + persistenceManager.insert(discriminatorObject); + persistenceManager.save(); + + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + discriminatorObject = (Discriminator) persistenceManager.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"); + + persistenceManager.update(discriminatorObject); + persistenceManager.save(); + + // -------------------------------------------------------------------------------- + // Get the object + // -------------------------------------------------------------------------------- + discriminatorObject = (Discriminator) persistenceManager.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() + { + PersistenceManager persistenceManager = getPersistenceManager(); + assertTrue("Class A is not persistent ", persistenceManager.isPersistent(A.class)); + assertFalse("Class String is persistent - hum ? ", persistenceManager.isPersistent(String.class)); + } + + +} \ No newline at end of file