You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tv...@apache.org on 2015/09/08 17:01:05 UTC
svn commit: r1701815 - in /db/torque/torque4/trunk/torque-runtime/src/test:
java/org/apache/torque/manager/ resources/
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<TestPersistent>
+{
+ /** 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<TestPersistent> retrieveStoredOMs(
+ List<? extends ObjectKey> ids) throws TorqueException
+ {
+ List<TestPersistent> testList = new ArrayList<TestPersistent>(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