Return-Path: Delivered-To: apmail-db-jdo-commits-archive@www.apache.org Received: (qmail 77492 invoked from network); 8 Mar 2006 20:03:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 8 Mar 2006 20:03:21 -0000 Received: (qmail 93594 invoked by uid 500); 8 Mar 2006 20:03:20 -0000 Mailing-List: contact jdo-commits-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-commits@db.apache.org Received: (qmail 93583 invoked by uid 99); 8 Mar 2006 20:03:20 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Mar 2006 12:03:20 -0800 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.29) with SMTP; Wed, 08 Mar 2006 12:03:20 -0800 Received: (qmail 77130 invoked by uid 65534); 8 Mar 2006 20:02:57 -0000 Message-ID: <20060308200257.77124.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r384312 - in /db/jdo/trunk/tck20/src: conf/pm.conf java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java Date: Wed, 08 Mar 2006 20:02:56 -0000 To: jdo-commits@db.apache.org From: clr@apache.org X-Mailer: svnmailer-1.0.7 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: clr Date: Wed Mar 8 12:02:55 2006 New Revision: 384312 URL: http://svn.apache.org/viewcvs?rev=384312&view=rev Log: JDO-190 Added test for DataStoreCache Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java Modified: db/jdo/trunk/tck20/src/conf/pm.conf Modified: db/jdo/trunk/tck20/src/conf/pm.conf URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/conf/pm.conf?rev=384312&r1=384311&r2=384312&view=diff ============================================================================== --- db/jdo/trunk/tck20/src/conf/pm.conf (original) +++ db/jdo/trunk/tck20/src/conf/pm.conf Wed Mar 8 12:02:55 2006 @@ -8,6 +8,7 @@ org.apache.jdo.tck.api.persistencemanager.ConcurrentPersistenceManagers \ org.apache.jdo.tck.api.persistencemanager.ConcurrentPersistenceManagersSameClasses \ org.apache.jdo.tck.api.persistencemanager.CurrentTransaction \ +org.apache.jdo.tck.api.persistencemanager.DataStoreCacheTest \ org.apache.jdo.tck.api.persistencemanager.DeletePersistent \ org.apache.jdo.tck.api.persistencemanager.DeletePersistentAllFails \ org.apache.jdo.tck.api.persistencemanager.DeletePersistentFailsIfInstanceIsTransient \ Added: db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java URL: http://svn.apache.org/viewcvs/db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java?rev=384312&view=auto ============================================================================== --- db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java (added) +++ db/jdo/trunk/tck20/src/java/org/apache/jdo/tck/api/persistencemanager/DataStoreCacheTest.java Wed Mar 8 12:02:55 2006 @@ -0,0 +1,103 @@ +/* + * Copyright 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.jdo.tck.api.persistencemanager; + +import java.util.Collection; +import java.util.HashSet; + +import javax.jdo.datastore.DataStoreCache; + +import org.apache.jdo.tck.pc.mylib.PCPoint; + +import org.apache.jdo.tck.util.BatchTestRunner; + +/** + * Title: DataStoreCacheTest + *
+ * Keywords: DataStoreCache cache pin unpin evict + *
+ * Assertion ID: A11.8 + *
+ * Assertion Description: +Most JDO implementations allow instances +to be cached in a second-level cache, and allow +direct management of the cache by knowledgeable +applications. The second-level cache is +typically a single VM cache and is used for +persistent instances associated with a single +PersistenceManagerFactory. For the purpose +of standardizing this behavior, the +DataStoreCache interface is used. + */ + +public class DataStoreCacheTest extends PersistenceManagerTest { + + Object pointoid; + Collection pointoidCollection; + Object[] pointoidArray; + + /** */ + private static final String ASSERTION_FAILED = + "Assertion A11.8 (DataStoreCacheTest) failed: "; + + /** + * The main is called when the class + * is directly executed from the command line. + * @param args The arguments passed to the program. + */ + public static void main(String[] args) { + BatchTestRunner.run(DataStoreCacheTest.class); + } + + /** + * In setup, create a persistent instance and get its oid. + * The oid is a valid parameter to the cache APIs. + */ + protected void localSetUp() { + addTearDownClass(PCPoint.class); + PCPoint point = new PCPoint(50, 100); + getPM().currentTransaction().begin(); + pm.makePersistent(point); + pointoid = pm.getObjectId(point); + pointoidCollection = new HashSet(); + pointoidCollection.add(pointoid); + pointoidArray = new Object[] {pointoid}; + pm.currentTransaction().commit(); + } + + /** + * There is no mandated behavior of the DataStoreCache + * methods. This test makes sure that the instance + * returned does not throw exceptions on any method. + */ + public void testDataStoreCache() { + DataStoreCache ds = getPMF().getDataStoreCache(); + ds.evict(pointoid); + ds.evictAll(); + ds.evictAll(pointoidCollection); + ds.evictAll(pointoidArray); + ds.evictAll(PCPoint.class, true); + ds.pin(pointoid); + ds.unpin(pointoid); + ds.pinAll(pointoidCollection); + ds.unpinAll(pointoidCollection); + ds.pinAll(pointoidArray); + ds.unpinAll(pointoidArray); + ds.pinAll(PCPoint.class, true); + ds.unpinAll(PCPoint.class, true); + } +}