Package org.jboss.cache.passivation

Source Code of org.jboss.cache.passivation.PassivationToJDBCCacheLoaderTest

/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package org.jboss.cache.passivation;

import java.util.Properties;
import org.jboss.cache.CacheSPI;
import static org.jboss.cache.factories.UnitTestCacheConfigurationFactory.*;
import org.jboss.cache.config.CacheLoaderConfig;
import org.jboss.cache.util.TestingUtil;
import org.testng.annotations.Test;

/**
* Tests passivation using JDBC Cache Loader.
* This test has MySQL hard-coded. To run it, run MySQL first: mysqld -u=root
*
* @author <a href="mailto:{hmesha@novell.com}">{Hany Mesha}</a>
* @version $Id: PassivationToJDBCCacheLoaderTest.java 6905 2008-10-13 09:35:27Z dpospisi@redhat.com $         
*/
@Test(groups = "functional")
public class PassivationToJDBCCacheLoaderTest extends PassivationTestsBase
{
   protected String getJDBCProps()
   {
      Properties prop = new Properties();
      try
      {
         prop.load(this.getClass().getClassLoader().getResourceAsStream("cache-jdbc.properties"));
      }
      catch (Exception e)
      {
         System.out.println("Error loading jdbc properties ");
      }
      return "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") + "\n" +
            "cache.jdbc.sql-concat=" + prop.getProperty("cache.jdbc.sql-concat") + "\n" +
            "cache.jdbc.table.name=passivationtojdbc" + TestingUtil.getThreadId() + "\n" +
            "cache.jdbc.table.primarykey=passivationtojdbc_pk" +  TestingUtil.getThreadId();
     
   }

   protected void configureCache() throws Exception
   {
      CacheLoaderConfig loaderConfig = buildSingleCacheLoaderConfig(true, null, "org.jboss.cache.loader.JDBCCacheLoader",
            getJDBCProps(), false, false, false, false, false);
      CacheSPI<Object, Object> cache = cacheTL.get();
      cache.getConfiguration().setCacheLoaderConfig(loaderConfig);
   }
}
TOP

Related Classes of org.jboss.cache.passivation.PassivationToJDBCCacheLoaderTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.