[jboss-cvs] JBossCache/tests/functional/org/jboss/cache/loader ...
Galder Zamarreno
galder.zamarreno at jboss.com
Wed Jan 17 13:53:28 EST 2007
User: gzamarreno
Date: 07/01/17 13:53:28
Modified: tests/functional/org/jboss/cache/loader
JDBCCacheLoaderTest.java
Log:
[JBCACHE-802] SQLExceptions generated in JDBCCacheLoader hides the original Exception which is wrong! Changed so that the original exceptions are thrown back. JDBCCacheLoaderTest improved so that with reasonable little effort, you can run the tests getting DataSource from AS. Added jndi.properties to help here, but commented out for general purpouse. Added table properties for Hypersonic to cache-jdbc.properties. Client AS library missing as I'm temporarily using jbossall-client.jar. This should be sorted soon.
Revision Changes Path
1.8 +73 -44 JBossCache/tests/functional/org/jboss/cache/loader/JDBCCacheLoaderTest.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JDBCCacheLoaderTest.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/tests/functional/org/jboss/cache/loader/JDBCCacheLoaderTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- JDBCCacheLoaderTest.java 25 Oct 2006 04:50:19 -0000 1.7
+++ JDBCCacheLoaderTest.java 17 Jan 2007 18:53:28 -0000 1.8
@@ -17,40 +17,55 @@
* The default test is configured using Derby embedded framework.
* The server and database configuration is read from a properties file located at
* /etc/cache-jdbc.properties.
- *
+ * <p/>
* To run this test with any other RDBMS, The appropriate JDBC driver
* (i.e mysql-connector-java-3.0.10-stable-bin.jar)
* must be in the lib directory.
*
* @author <a href="hmesha at novell.com">Hany Mesha</a>
- * @version <tt>$Revision: 1.7 $</tt>
+ * @author <a href="mailto:galder.zamarreno at jboss.com">Galder Zamarreno</a>
+ * @version <tt>$Revision: 1.8 $</tt>
*/
-public class JDBCCacheLoaderTest
- extends CacheLoaderTestsBase
+public class JDBCCacheLoaderTest extends CacheLoaderTestsBase
{
+ private static final boolean MANAGED = true;
+
protected void configureCache() throws Exception
{
- Properties prop = new Properties();
- try{
- prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
- }catch(Exception e){
- System.out.println("Error loading jdbc properties ");
+ Properties prop = getProperties();
+
+ String props;
+ if (MANAGED)
+ {
+ props = "cache.jdbc.datasource=" + prop.getProperty("cache.jdbc.datasource") + "\n" +
+ "cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type") + "\n" +
+ "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" +
+ "cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
+ "cache.jdbc.password=" + prop.getProperty("cache.jdbc.password");
+ //cache.getConfiguration().setTransactionManagerLookupClass("org.jboss.cache.JBossTransactionManagerLookup");
}
- String props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
- "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") +"\n" +
+ else
+ {
+ props = "cache.jdbc.driver =" + prop.getProperty("cache.jdbc.driver") + "\n" +
+ "cache.jdbc.url=" + prop.getProperty("cache.jdbc.url") + "\n" +
"cache.jdbc.user=" + prop.getProperty("cache.jdbc.user") + "\n" +
"cache.jdbc.password=" + prop.getProperty("cache.jdbc.password") + "\n" +
"cache.jdbc.node.type=" + prop.getProperty("cache.jdbc.node.type");
- cache.getConfiguration().setCacheLoaderConfig( getSingleCacheLoaderConfig("", "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false) );
+ }
+
+ cache.getConfiguration().setCacheLoaderConfig(getSingleCacheLoaderConfig("",
+ "org.jboss.cache.loader.JDBCCacheLoader", props, false, true, false));
}
public void testLargeObject()
{
- try {
+ try
+ {
String key = "LargeObj";
// create an object with size bigger than 4k (k=1024 bytes)
StringBuffer text = new StringBuffer("LargeObject");
- while (text.toString().getBytes().length < (1024*100)) {
+ while (text.toString().getBytes().length < (1024 * 100))
+ {
text.append(text);
}
String initialValue = text.toString();
@@ -67,11 +82,25 @@
retVal = loader.put(FQN, key, updatedValue);
assertEquals(initialValue, (String) retVal);
assertEquals(updatedValue, (String) loader.get(FQN).get(key));
- } catch(Exception e) {
+ } catch (Exception e)
+ {
fail(e.toString());
}
}
+ private Properties getProperties() throws Exception
+ {
+ Properties properties = new Properties();
+ try
+ {
+ properties.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
+ return properties;
+ }
+ catch (Exception e)
+ {
+ throw new Exception("Error loading jdbc properties ", e);
+ }
+ }
public static Test suite()
{
More information about the jboss-cvs-commits
mailing list