db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1841139 - in /db/torque/torque4/trunk/torque-runtime/src: main/java/org/apache/torque/TorqueInstance.java test/java/org/apache/torque/manager/AbstractBaseManagerTest.java test/java/org/apache/torque/manager/MethodResultCacheTest.java
Date Mon, 17 Sep 2018 19:50:35 GMT
Author: tv
Date: Mon Sep 17 19:50:35 2018
New Revision: 1841139

URL: http://svn.apache.org/viewvc?rev=1841139&view=rev
Log:
Add JCS shutdown

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/MethodResultCacheTest.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java?rev=1841139&r1=1841138&r2=1841139&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
Mon Sep 17 19:50:35 2018
@@ -32,6 +32,7 @@ import java.util.concurrent.ConcurrentMa
 import org.apache.commons.configuration.Configuration;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.jcs.JCS;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -856,6 +857,7 @@ public class TorqueInstance
 
         // shut down the cache managers
         managers.values().forEach(AbstractBaseManager::dispose);
+        JCS.shutdown();
 
         // shut down the data source factories
         TorqueException exception = null;

Modified: 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=1841139&r1=1841138&r2=1841139&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/AbstractBaseManagerTest.java
Mon Sep 17 19:50:35 2018
@@ -19,11 +19,17 @@ package org.apache.torque.manager;
  * under the License.
  */
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
 import java.util.ArrayList;
 import java.util.List;
 
-import junit.framework.TestCase;
-
 import org.apache.torque.BaseTestCase;
 import org.apache.torque.Column;
 import org.apache.torque.ColumnImpl;
@@ -31,9 +37,13 @@ import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
 import org.apache.torque.om.ObjectKey;
 import org.apache.torque.om.SimpleKey;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
-public class AbstractBaseManagerTest extends TestCase
-implements CacheListener<TestPersistent>
+public class AbstractBaseManagerTest implements CacheListener<TestPersistent>
 {
     private static final ObjectKey TEST_PRIMARY_KEY = SimpleKey.keyFor("testID");
     private static final String CACHE_REGION = "testCache1";
@@ -43,7 +53,8 @@ implements CacheListener<TestPersistent>
     private boolean refreshedObjectCalled;
     private boolean removedObjectCalled;
 
-    static
+    @BeforeClass
+    public static void initTorque()
     {
         try
         {
@@ -56,6 +67,19 @@ implements CacheListener<TestPersistent>
         }
     }
 
+    @AfterClass
+    public static void shutdownTorque()
+    {
+        try
+        {
+            org.apache.torque.Torque.shutdown();
+        }
+        catch (TorqueException e)
+        {
+            e.printStackTrace();
+        }
+    }
+
     /* CacheListener methods */
     @Override
     public void addedObject(TestPersistent om)
@@ -84,29 +108,21 @@ implements CacheListener<TestPersistent>
         return columnList;
     }
 
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    @Override
-    protected void setUp() throws Exception
+    @Before
+    public void setUp() throws Exception
     {
-        super.setUp();
-
         this.manager = new TestManager();
         this.manager.setOMClass(TestPersistent.class);
         this.manager.setRegion(CACHE_REGION);
     }
 
-    /**
-     * @see junit.framework.TestCase#tearDown()
-     */
-    @Override
-    protected void tearDown() throws Exception
+    @After
+    public void tearDown() throws Exception
     {
         manager.cache.clear();
-        super.tearDown();
     }
 
+    @Test
     public void testGetOMInstance() throws TorqueException
     {
         TestPersistent test = manager.getOMInstance();
@@ -114,6 +130,7 @@ implements CacheListener<TestPersistent>
         assertTrue("Instance should be a TestPersistent", test instanceof TestPersistent);
     }
 
+    @Test
     public void testGetOMInstanceObjectKey() throws TorqueException
     {
         TestPersistent test = manager.getOMInstance(TEST_PRIMARY_KEY);
@@ -122,6 +139,7 @@ implements CacheListener<TestPersistent>
         assertEquals("Instance should have id 'testID'", TEST_PRIMARY_KEY, test.getPrimaryKey());
     }
 
+    @Test
     public void testGetOMInstanceObjectKeyBoolean() throws TorqueException
     {
         TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, false);
@@ -133,6 +151,7 @@ implements CacheListener<TestPersistent>
         assertSame("Should be same instances", test3, test4);
     }
 
+    @Test
     public void testCacheGet() throws TorqueException
     {
         TestPersistent test1 = manager.cacheGet(TEST_PRIMARY_KEY);
@@ -142,6 +161,7 @@ implements CacheListener<TestPersistent>
         assertSame("Should be same instances", test1, test2);
     }
 
+    @Test
     public void testClearImpl() throws TorqueException
     {
         TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
@@ -153,6 +173,7 @@ implements CacheListener<TestPersistent>
         assertNull("Should not be in cache", test3);
     }
 
+    @Test
     public void testRemoveInstanceImpl() throws TorqueException
     {
         TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
@@ -162,6 +183,7 @@ implements CacheListener<TestPersistent>
         assertNull("Should not be in cache", test3);
     }
 
+    @Test
     public void testPutInstanceImplSerializableT() throws TorqueException
     {
         TestPersistent test1 = manager.getOMInstance(TEST_PRIMARY_KEY, true);
@@ -172,12 +194,14 @@ implements CacheListener<TestPersistent>
         assertSame("Should be same instances", test2, test4);
     }
 
+    @Test
     public void testGetMethodResultCache()
     {
         MethodResultCache mrc = manager.getMethodResultCache();
         assertNotNull("Should have MethodResultCache", mrc);
     }
 
+    @Test
     public void testListeners()
     {
         manager.addValidField(new ColumnImpl("test1"), new ColumnImpl("test2"));

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/MethodResultCacheTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/MethodResultCacheTest.java?rev=1841139&r1=1841138&r2=1841139&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/MethodResultCacheTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/manager/MethodResultCacheTest.java
Mon Sep 17 19:50:35 2018
@@ -19,13 +19,20 @@ package org.apache.torque.manager;
  * under the License.
  */
 
-import junit.framework.TestCase;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
 
 import org.apache.torque.BaseTestCase;
 import org.apache.torque.Torque;
 import org.apache.torque.TorqueException;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
-public class MethodResultCacheTest extends TestCase
+public class MethodResultCacheTest
 {
     private static final String CACHE_REGION = "testCache1";
     private static final String TEST_METHOD1 = "testMethod1";
@@ -37,7 +44,8 @@ public class MethodResultCacheTest exten
     private TestManager manager;
     private MethodResultCache mrc;
 
-    static
+    @BeforeClass
+    public static void initTorque()
     {
         try
         {
@@ -50,30 +58,35 @@ public class MethodResultCacheTest exten
         }
     }
 
-    /**
-     * @see junit.framework.TestCase#setUp()
-     */
-    @Override
-    protected void setUp() throws Exception
+    @AfterClass
+    public static void shutdownTorque()
     {
-        super.setUp();
+        try
+        {
+            org.apache.torque.Torque.shutdown();
+        }
+        catch (TorqueException e)
+        {
+            e.printStackTrace();
+        }
+    }
 
+    @Before
+    public void setUp() throws Exception
+    {
         this.manager = new TestManager();
         this.manager.setOMClass(TestPersistent.class);
         this.manager.setRegion(CACHE_REGION);
         this.mrc = this.manager.getMethodResultCache();
     }
 
-    /**
-     * @see junit.framework.TestCase#tearDown()
-     */
-    @Override
-    protected void tearDown() throws Exception
+    @After
+    public void tearDown() throws Exception
     {
         mrc.clear();
-        super.tearDown();
     }
 
+    @Test
     public void testGetAndPut()
     {
         TestPersistent test1 = new TestPersistent();
@@ -83,6 +96,7 @@ public class MethodResultCacheTest exten
         assertSame("Should be same instance", test1, test2);
     }
 
+    @Test
     public void testRemoveAll()
     {
         TestPersistent test1 = new TestPersistent();
@@ -108,6 +122,7 @@ public class MethodResultCacheTest exten
         assertNotNull("Should still be in cache", mrc.get(TestPersistent.class, TEST_METHOD2,
TEST_ARG_ONE, TEST_ARG_THREE));
     }
 
+    @Test
     public void testRemove()
     {
         TestPersistent test1 = new TestPersistent();



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message