Author: mircea.markus
Date: 2008-12-04 11:20:46 -0500 (Thu, 04 Dec 2008)
New Revision: 7253
Modified:
core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
Log:
shutdown derby database
Modified: core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-12-04
15:36:15 UTC (rev 7252)
+++ core/trunk/src/test/java/org/jboss/cache/loader/JDBCCacheLoaderTest.java 2008-12-04
16:20:46 UTC (rev 7253)
@@ -11,6 +11,7 @@
import org.testng.annotations.Test;
import java.util.Properties;
+import java.sql.DriverManager;
import org.jboss.cache.CacheSPI;
import org.jboss.cache.util.TestDbPropertiesFactory;
@@ -54,6 +55,24 @@
return p.toString();
}
+ protected void cleanup()
+ {
+ Properties props =
cacheTL.get().getConfiguration().getCacheLoaderConfig().getIndividualCacheLoaderConfigs().get(0).getProperties();
+ try
+ {
+ String shutDownConnection = TestDbPropertiesFactory.getShutdownUrl(props);
+ System.out.println("shutDownConnection = " + shutDownConnection);
+ DriverManager.getConnection(shutDownConnection);
+ fail("Exception should be raised to confirm the DB is closed");
+ //here is why: Important: The XJ015 error (successful shutdown of the Derby
engine) and the 08006 error
+ //(successful shutdown of a single database) are the *only exceptions thrown by
Derby that might indicate that an operation succeeded*.
+ }
+ catch (Throwable e)
+ {
+ //expected
+ }
+ }
+
private void append(String propertyName, Properties prop, StringBuilder builder)
{
if (prop.containsKey(propertyName))
Modified: core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-12-04
15:36:15 UTC (rev 7252)
+++ core/trunk/src/test/java/org/jboss/cache/util/TestDbPropertiesFactory.java 2008-12-04
16:20:46 UTC (rev 7253)
@@ -1,6 +1,7 @@
package org.jboss.cache.util;
import java.util.Properties;
+import java.util.StringTokenizer;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
@@ -36,6 +37,17 @@
}
}
+ public static String getShutdownUrl(Properties props)
+ {
+ String url = props.getProperty("cache.jdbc.url");
+ assert url != null;
+ //jdbc:derby:jbossdb;create=true
+ StringTokenizer tokenizer = new StringTokenizer(url,";");
+ String result = tokenizer.nextToken() + ";" + "shutdown=true";
+ System.out.println("result = " + result);
+ return result;
+ }
+
private static Properties returnBasedOnDifferentInstance()
{
Properties toReturn = (Properties) realProps.clone();
Show replies by date