Return-Path: X-Original-To: apmail-db-torque-dev-archive@www.apache.org Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id AD4C817C4D for ; Tue, 8 Sep 2015 15:01:40 +0000 (UTC) Received: (qmail 86435 invoked by uid 500); 8 Sep 2015 15:01:06 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 86399 invoked by uid 500); 8 Sep 2015 15:01:06 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 86387 invoked by uid 500); 8 Sep 2015 15:01:06 -0000 Received: (qmail 86384 invoked by uid 99); 8 Sep 2015 15:01:06 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Sep 2015 15:01:06 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 148DFAC0154 for ; Tue, 8 Sep 2015 15:01:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1701815 - in /db/torque/torque4/trunk/torque-runtime/src/test: java/org/apache/torque/manager/ resources/ Date: Tue, 08 Sep 2015 15:01:05 -0000 To: torque-commits@db.apache.org From: tv@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150908150106.148DFAC0154@hades.apache.org> Author: tv Date: Tue Sep 8 15:01:05 2015 New Revision: 1701815 URL: http://svn.apache.org/r1701815 Log: Added preliminary manager test Added: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java (with props) db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestManager.java (with props) db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestPersistent.java (with props) db/torque/torque4/trunk/torque-runtime/src/test/resources/cache.ccf Added: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java?rev=1701815&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java (added) +++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java Tue Sep 8 15:01:05 2015 @@ -0,0 +1,175 @@ +package org.apache.torque.manager; + +/* + * 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. + */ + +import junit.framework.TestCase; + +import org.apache.torque.BaseTestCase; +import org.apache.torque.Torque; +import org.apache.torque.TorqueException; +import org.apache.torque.om.SimpleKey; + +public class AbstractBaseManagerTest extends TestCase +{ + private static final String TEST_PRIMARY_KEY = "testID"; + private static final String CACHE_REGION = "testCache1"; + private TestManager manager; + + static + { + try + { + org.apache.torque.Torque.init(BaseTestCase.CONFIG_FILE); + org.apache.torque.Torque.getConfiguration().setProperty(Torque.CACHE_KEY, Boolean.TRUE); + } + catch (TorqueException e) + { + e.printStackTrace(); + } + } + + /** + * @see junit.framework.TestCase#setUp() + */ + @Override + protected void setUp() throws Exception + { + super.setUp(); + + this.manager = new TestManager(); + this.manager.setOMClass(TestPersistent.class); + this.manager.setRegion(CACHE_REGION); + } + + public void testGetOMInstance() throws TorqueException + { + TestPersistent test = manager.getOMInstance(); + assertNotNull("Instance should not be null", test); + assertTrue("Instance should be a TestPersistent", test instanceof TestPersistent); + } + + public void testGetOMInstanceObjectKey() throws TorqueException + { + TestPersistent test = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY)); + assertNotNull("Instance should not be null", test); + assertTrue("Instance should be a TestPersistent", test instanceof TestPersistent); + assertEquals("Instance should have id 'testID'", TEST_PRIMARY_KEY, test.getPrimaryKey().getValue()); + } + + public void testGetOMInstanceObjectKeyBoolean() throws TorqueException + { + TestPersistent test1 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), false); + TestPersistent test2 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), false); + assertNotSame("Should be different instances", test1, test2); + + TestPersistent test3 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), true); + TestPersistent test4 = manager.getOMInstance(SimpleKey.keyFor(TEST_PRIMARY_KEY), true); + assertSame("Should be same instances", test3, test4); + } + +/* + public void testCacheGet() + { + fail("Not yet implemented"); + } + + public void testClearImpl() + { + fail("Not yet implemented"); + } + + public void testDispose() + { + fail("Not yet implemented"); + } + + public void testRemoveInstanceImpl() + { + fail("Not yet implemented"); + } + + public void testPutInstanceImplT() + { + fail("Not yet implemented"); + } + + public void testPutInstanceImplSerializableT() + { + fail("Not yet implemented"); + + } + + public void testRetrieveStoredOM() + { + fail("Not yet implemented"); + } + + public void testGetOMsObjectKeyArray() + { + fail("Not yet implemented"); + } + + public void testGetOMsListOfQextendsObjectKey() + { + fail("Not yet implemented"); + } + + public void testGetOMsListOfQextendsObjectKeyBoolean() + { + + fail("Not yet implemented"); + } + + public void testRetrieveStoredOMs() + { + fail("Not yet implemented"); + } + + public void testGetRegion() + { + fail("Not yet implemented"); + } + + public void testSetRegion() + { + fail("Not yet implemented"); + } + + public void testGetMethodResultCache() + { + fail("Not yet implemented"); + } + + public void testRegisterAsListener() + { + fail("Not yet implemented"); + } + + public void testAddCacheListenerImpl() + { + fail("Not yet implemented"); + } + + public void testNotifyListeners() + { + fail("Not yet implemented"); + } +*/ +} Propchange: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestManager.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestManager.java?rev=1701815&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestManager.java (added) +++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestManager.java Tue Sep 8 15:01:05 2015 @@ -0,0 +1,59 @@ +package org.apache.torque.manager; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.torque.TorqueException; +import org.apache.torque.om.ObjectKey; + +/* + * 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. + */ + +/** + * Test the manager implementation + * + */ +public class TestManager extends AbstractBaseManager +{ + /** Serial number */ + private static final long serialVersionUID = 1021912588603493352L; + + @Override + protected TestPersistent retrieveStoredOM(ObjectKey id) + throws TorqueException + { + TestPersistent test = new TestPersistent(); + test.setPrimaryKey(id); + return test; + } + + @Override + protected List retrieveStoredOMs( + List ids) throws TorqueException + { + List testList = new ArrayList(ids.size()); + + for (ObjectKey id : ids) + { + testList.add(retrieveStoredOM(id)); + } + + return testList; + } +} Propchange: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestManager.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestPersistent.java URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestPersistent.java?rev=1701815&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestPersistent.java (added) +++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestPersistent.java Tue Sep 8 15:01:05 2015 @@ -0,0 +1,128 @@ +package org.apache.torque.manager; + +/* + * 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. + */ + +import java.io.Serializable; +import java.sql.Connection; + +import org.apache.torque.TorqueException; +import org.apache.torque.om.ObjectKey; +import org.apache.torque.om.Persistent; +import org.apache.torque.om.SimpleKey; + +/** + * Dummy Persistent implementation + * + */ +public class TestPersistent implements Persistent, Serializable +{ + /** Serial ID */ + private static final long serialVersionUID = 738162496580951932L; + + private ObjectKey primaryKey; + private boolean isNew = true; + private boolean modified; + + /** + * @see org.apache.torque.om.Persistent#getPrimaryKey() + */ + public ObjectKey getPrimaryKey() + { + return primaryKey; + } + + /** + * @see org.apache.torque.om.Persistent#setPrimaryKey(org.apache.torque.om.ObjectKey) + */ + public void setPrimaryKey(ObjectKey primaryKey) throws TorqueException + { + this.primaryKey = primaryKey; + } + + /** + * @see org.apache.torque.om.Persistent#setPrimaryKey(java.lang.String) + */ + public void setPrimaryKey(String primaryKey) throws TorqueException + { + setPrimaryKey(SimpleKey.keyFor(primaryKey)); + } + + /** + * @see org.apache.torque.om.Persistent#isModified() + */ + public boolean isModified() + { + return modified; + } + + /** + * @see org.apache.torque.om.Persistent#isNew() + */ + public boolean isNew() + { + return isNew; + } + + /** + * @see org.apache.torque.om.Persistent#setNew(boolean) + */ + public void setNew(boolean b) + { + this.isNew = b; + } + + /** + * @see org.apache.torque.om.Persistent#setModified(boolean) + */ + public void setModified(boolean m) + { + this.modified = m; + } + + /** + * @see org.apache.torque.om.Persistent#save() + */ + public void save() throws Exception + { + // do nothing + setModified(false); + setNew(false); + } + + /** + * @see org.apache.torque.om.Persistent#save(java.lang.String) + */ + public void save(String dbName) throws Exception + { + // do nothing + setModified(false); + setNew(false); + } + + /** + * @see org.apache.torque.om.Persistent#save(java.sql.Connection) + */ + public void save(Connection con) throws Exception + { + // do nothing + setModified(false); + setNew(false); + } +} Propchange: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/TestPersistent.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Added: db/torque/torque4/trunk/torque-runtime/src/test/resources/cache.ccf URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/resources/cache.ccf?rev=1701815&view=auto ============================================================================== --- db/torque/torque4/trunk/torque-runtime/src/test/resources/cache.ccf (added) +++ db/torque/torque4/trunk/torque-runtime/src/test/resources/cache.ccf Tue Sep 8 15:01:05 2015 @@ -0,0 +1,28 @@ +# 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. + +# JCS Config for unit testing, just a simple memory only cache + +jcs.default= +jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes +jcs.default.cacheattributes.MaxObjects=1000 +jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache + +jcs.region.testCache1= +jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes +jcs.region.testCache1.cacheattributes.MaxObjects=1000 +jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache --------------------------------------------------------------------- To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org For additional commands, e-mail: torque-dev-help@db.apache.org