[infinispan-commits] Infinispan SVN: r945 - in trunk: cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory and 12 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Wed Oct 14 12:47:44 EDT 2009


Author: mircea.markus
Date: 2009-10-14 12:47:43 -0400 (Wed, 14 Oct 2009)
New Revision: 945

Added:
   trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ManagedConnectionFactory.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/ManagedConnectionFactoryTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreFunctionalTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java
   trunk/cachestore/jdbc/src/test/resources/configs/binary-managed-connection-factory.xml
   trunk/cachestore/jdbc/src/test/resources/configs/mixed-managed-connection-factory.xml
   trunk/cachestore/jdbc/src/test/resources/configs/str-managed-connection-factory.xml
   trunk/core/src/test/java/org/infinispan/test/jndi/
   trunk/core/src/test/java/org/infinispan/test/jndi/DummyContext.java
   trunk/core/src/test/java/org/infinispan/test/jndi/DummyContextFactory.java
Removed:
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java
Modified:
   trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreConfig.java
   trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactoryConfig.java
   trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreConfig.java
   trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java
   trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java
   trunk/core/src/main/java/org/infinispan/config/TypedPropertiesAdapter.java
   trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java
   trunk/core/src/test/resources/configs/named-cache-test.xml
Log:
[ISPN-105] - (managed connection pool) - implemented

Modified: trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreConfig.java
===================================================================
--- trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreConfig.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreConfig.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -114,6 +114,12 @@
       this.connectionFactoryConfig.setPassword(password);
    }
 
+
+   public void setDatasourceJndiLocation(String location) {
+      testImmutability("datasourceJndiLocation");
+      this.connectionFactoryConfig.setDatasourceJndiLocation(location);
+   }
+
    /**
     * Driver class, will be loaded before initializing the {@link org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory}
     */

Modified: trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactoryConfig.java
===================================================================
--- trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactoryConfig.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ConnectionFactoryConfig.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -12,6 +12,7 @@
    private String connectionUrl;
    private String userName;
    private String password;
+   private String datasourceJndiLocation;
 
    public ConnectionFactoryConfig(String connectionFactoryClass, String driverClass, String connectionUrl,
                                   String userName, String password) {
@@ -65,6 +66,14 @@
       return connectionFactoryClass;
    }
 
+   public void setDatasourceJndiLocation(String location) {
+      datasourceJndiLocation = location;
+   }
+
+   public String getDatasourceJndiLocation() {
+      return datasourceJndiLocation;
+   }
+
    @Override
    public ConnectionFactoryConfig clone() {
       try {

Added: trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ManagedConnectionFactory.java
===================================================================
--- trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ManagedConnectionFactory.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/connectionfactory/ManagedConnectionFactory.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,88 @@
+package org.infinispan.loaders.jdbc.connectionfactory;
+
+import org.infinispan.loaders.CacheLoaderException;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
+
+import javax.sql.DataSource;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * Connection factory that can be used when on managed environments, like applicatons servers. It knows how to look into
+ * the JNDI tree at a certain location (configurable) and delegate connection management to the DataSource. In order to
+ * enable ti one should set the following two properties in any Jdbc cache store:
+ * <pre>
+ *   <property name="connectionFactoryClass"
+ *                        value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory"/>
+ *    <property name="datasourceJndiLocation" value="java:/ManagedConnectionFactoryTest/DS"/>
+ * </pre>
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+public class ManagedConnectionFactory extends ConnectionFactory {
+
+   private static final Log log = LogFactory.getLog(ManagedConnectionFactory.class);
+   private static final boolean trace = log.isTraceEnabled();
+
+   private DataSource dataSource;
+
+   public void start(ConnectionFactoryConfig config) throws CacheLoaderException {
+      InitialContext ctx = null;
+      String datasourceName = config.getDatasourceJndiLocation();
+      try {
+         ctx = new InitialContext();
+         dataSource = (DataSource) ctx.lookup(datasourceName);
+         if (trace) {
+            log.trace("Datasource lookup for " + datasourceName + " succeded: " + dataSource);
+         }
+         if (dataSource == null) {
+            String msg = "Could not find a connection in jndi under the name '" + datasourceName + "'";
+            log.error(msg);
+            throw new CacheLoaderException(msg);
+         }
+      }
+      catch (NamingException e) {
+         log.error("Could not lookup connection with datasource " + datasourceName, e);
+         throw new CacheLoaderException(e);
+      }
+      finally {
+         if (ctx != null) {
+            try {
+               ctx.close();
+            }
+            catch (NamingException e) {
+               log.warn("Failed to close naming context.", e);
+            }
+         }
+      }
+   }
+
+   public void stop() {
+   }
+
+   public Connection getConnection() throws CacheLoaderException {
+      Connection connection;
+      try {
+         connection = dataSource.getConnection();
+      } catch (SQLException e) {
+         log.error(e);
+         throw new CacheLoaderException(e);
+      }
+      if (trace) {
+         log.trace("Connection checked out: " + connection);
+      }
+      return connection;
+
+   }
+
+   public void releaseConnection(Connection conn) {
+      try {
+         conn.close();
+      } catch (SQLException e) {
+         log.warn("Issues while closing connection " + conn, e);
+      }
+   }
+}

Modified: trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreConfig.java
===================================================================
--- trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreConfig.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreConfig.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -193,6 +193,12 @@
       this.connectionFactoryConfig.setConnectionFactoryClass(connectionFactoryClass);
    }
 
+   public void setDatasourceJndiLocation(String location) {
+      testImmutability("datasourceJndiLocation");
+      this.connectionFactoryConfig.setDatasourceJndiLocation(location);
+   }
+
+
    public ConnectionFactoryConfig getConnectionFactoryConfig() {
       return connectionFactoryConfig;
    }

Modified: trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java
===================================================================
--- trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/main/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreConfig.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -142,6 +142,11 @@
       this.connectionFactoryConfig.setUserName(userName);
    }
 
+   public void setDatasourceJndiLocation(String location) {
+      testImmutability("datasourceJndiLocation");
+      this.connectionFactoryConfig.setDatasourceJndiLocation(location);
+   }
+
    /**
     * Database username's password.
     */

Deleted: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -1,55 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.infinispan.loaders.jdbc;
-
-import org.infinispan.CacheDelegate;
-import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
-import org.infinispan.loaders.CacheStore;
-import org.infinispan.loaders.CacheStoreConfig;
-import org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStore;
-import org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStoreConfig;
-import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
-import org.infinispan.test.fwk.UnitTestDatabaseManager;
-import org.testng.annotations.Test;
-
-/**
- * JdbcBinaryCacheStoreFunctionalTest.
- * 
- * @author Galder Zamarreño
- * @since 4.0
- */
- at Test(groups = "functional", testName = "loaders.jdbc.JdbcBinaryCacheStoreFunctionalTest")
-public class JdbcBinaryCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
-
-   @Override
-   protected CacheStoreConfig createCacheStoreConfig() throws Exception {
-      ConnectionFactoryConfig connectionFactoryConfig = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
-      TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
-      JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(connectionFactoryConfig, tm);
-      return config;
-//      JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
-//      jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
-//      jdbcBucketCacheStore.start();
-//      assert jdbcBucketCacheStore.getConnectionFactory() != null;
-//      return jdbcBucketCacheStore;
-   }
-}

Deleted: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreTest.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -1,60 +0,0 @@
-package org.infinispan.loaders.jdbc;
-
-import static org.easymock.classextension.EasyMock.*;
-import org.infinispan.loaders.BaseCacheStoreTest;
-import org.infinispan.loaders.CacheStore;
-import org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStore;
-import org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStoreConfig;
-import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
-import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
-import org.infinispan.marshall.TestObjectStreamMarshaller;
-import org.infinispan.test.fwk.UnitTestDatabaseManager;
-import org.infinispan.CacheDelegate;
-import org.testng.annotations.Test;
-
-/**
- * Tester class for {@link JdbcBinaryCacheStore}
- *
- * @author Mircea.Markus at jboss.com
- */
- at Test(groups = "functional", testName = "loaders.jdbc.JdbcBinaryCacheStoreTest")
-public class JdbcBinaryCacheStoreTest extends BaseCacheStoreTest {
-
-   protected CacheStore createCacheStore() throws Exception {
-      ConnectionFactoryConfig connectionFactoryConfig = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
-      TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
-      JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(connectionFactoryConfig, tm);
-      JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
-      jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
-      jdbcBucketCacheStore.start();
-      assert jdbcBucketCacheStore.getConnectionFactory() != null;
-      return jdbcBucketCacheStore;
-   }
-
-   public void testNotCreateConnectionFactory() throws Exception {
-      JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
-      JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(false);
-      config.setCreateTableOnStart(false);
-      jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), new TestObjectStreamMarshaller());
-      jdbcBucketCacheStore.start();
-      assert jdbcBucketCacheStore.getConnectionFactory() == null;
-
-      /* this will make sure that if a method like stop is called on the connection then it will barf an exception */
-      ConnectionFactory connectionFactory = createMock(ConnectionFactory.class);
-      TableManipulation tableManipulation = createMock(TableManipulation.class);
-      config.setTableManipulation(tableManipulation);
-
-      tableManipulation.start(connectionFactory);
-      tableManipulation.setCacheName("aName");
-      replay(tableManipulation);
-      jdbcBucketCacheStore.doConnectionFactoryInitialization(connectionFactory);
-      verify(tableManipulation);
-
-      //stop should be called even if this is an externally managed connection   
-      reset(tableManipulation, connectionFactory);
-      tableManipulation.stop();
-      replay(tableManipulation, connectionFactory);
-      jdbcBucketCacheStore.stop();
-      verify(tableManipulation, connectionFactory);
-   }
-}

Deleted: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2009, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.infinispan.loaders.jdbc;
-
-import org.infinispan.commands.RemoteCommandFactory;
-import org.infinispan.marshall.Marshaller;
-import org.infinispan.marshall.VersionAwareMarshaller;
-import org.testng.annotations.Test;
-
-/**
- * JdbcBinaryCacheStoreTest using production level marshaller.
- * 
- * @author Galder Zamarreño
- * @since 4.0
- */
- at Test(groups = "functional", testName = "loaders.jdbc.JdbcBinaryCacheStoreVamTest")
-public class JdbcBinaryCacheStoreVamTest extends JdbcBinaryCacheStoreTest {   
-   @Override
-   protected Marshaller getMarshaller() {
-      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
-      marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
-      marshaller.start();
-      return marshaller;
-   }
-}

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/ManagedConnectionFactoryTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/ManagedConnectionFactoryTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/ManagedConnectionFactoryTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,104 @@
+package org.infinispan.loaders.jdbc;
+
+import org.infinispan.loaders.BaseCacheStoreTest;
+import org.infinispan.loaders.CacheLoaderException;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.loaders.jdbc.connectionfactory.SimpleConnectionFactory;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.infinispan.test.jndi.DummyContextFactory;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.sql.DataSource;
+import java.io.PrintWriter;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.ManagedConnectionFactoryTest")
+public abstract class ManagedConnectionFactoryTest extends BaseCacheStoreTest {
+
+   public static final String DATASOURCE_LOCATION = "java:/ManagedConnectionFactoryTest/DS";
+   private DummyDataSource ds;
+
+   @BeforeClass
+   public void bindDatasourceInJndi() throws Exception {
+      System.setProperty(Context.INITIAL_CONTEXT_FACTORY, DummyContextFactory.class.getName());
+      ds = new DummyDataSource();
+      ds.start();
+      InitialContext ic = new InitialContext();
+      ic.bind(DATASOURCE_LOCATION, ds);
+      assert ic.lookup(DATASOURCE_LOCATION) instanceof DummyDataSource;
+   }
+
+   @AfterClass
+   public void destroyDatasourceAndUnbind() throws NamingException {
+      InitialContext ic = new InitialContext();
+      ic.unbind(DATASOURCE_LOCATION);
+      assert ic.lookup(DATASOURCE_LOCATION) == null;
+      ds.stop();
+   }
+
+
+   @Override
+   public void testConcurrency() throws Exception {
+      //this is a long lasting method and this test is only to make sure the connection is properly fetched
+   }
+
+   public static class DummyDataSource implements DataSource {
+
+      private SimpleConnectionFactory simpleFactory;
+
+      public void start() throws CacheLoaderException {
+         ConnectionFactoryConfig config = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+         simpleFactory = new SimpleConnectionFactory();
+         simpleFactory.start(config);
+      }
+
+      public void stop() {
+         simpleFactory.stop();
+      }
+
+      public Connection getConnection() throws SQLException {
+         try {
+            return simpleFactory.getConnection();
+         } catch (CacheLoaderException e) {
+            throw new SQLException(e);
+         }
+      }
+
+      public Connection getConnection(String username, String password) throws SQLException {
+         return getConnection();
+      }
+
+      public PrintWriter getLogWriter() throws SQLException {
+         throw new IllegalStateException("This should not be called!");
+      }
+
+      public void setLogWriter(PrintWriter out) throws SQLException {
+         throw new IllegalStateException("This should not be called!");
+      }
+
+      public void setLoginTimeout(int seconds) throws SQLException {
+         throw new IllegalStateException("This should not be called!");
+      }
+
+      public int getLoginTimeout() throws SQLException {
+         throw new IllegalStateException("This should not be called!");
+      }
+
+      public <T> T unwrap(Class<T> iface) throws SQLException {
+         throw new IllegalStateException("This should not be called!");
+      }
+
+      public boolean isWrapperFor(Class<?> iface) throws SQLException {
+         throw new IllegalStateException("This should not be called!");
+      }
+   }
+}

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/BinaryStoreWithManagedConnectionTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,58 @@
+package org.infinispan.loaders.jdbc.binary;
+
+import org.infinispan.Cache;
+import org.infinispan.CacheDelegate;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.CacheLoaderManager;
+import org.infinispan.loaders.CacheStore;
+import org.infinispan.loaders.jdbc.ManagedConnectionFactoryTest;
+import org.infinispan.loaders.jdbc.TableManipulation;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test (groups = "functional", testName = "loaders.jdbc.stringbased.BinaryStoreWithManagedConnectionTest")
+public class BinaryStoreWithManagedConnectionTest extends ManagedConnectionFactoryTest {
+   protected CacheStore createCacheStore() throws Exception {
+      ConnectionFactoryConfig connectionFactoryConfig = new ConnectionFactoryConfig();
+      connectionFactoryConfig.setConnectionFactoryClass(ManagedConnectionFactory.class.getName());
+      connectionFactoryConfig.setDatasourceJndiLocation(DATASOURCE_LOCATION);
+      TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+      JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(connectionFactoryConfig, tm);
+      JdbcBinaryCacheStore jdbcBinaryCacheStore = new JdbcBinaryCacheStore();
+      jdbcBinaryCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
+      jdbcBinaryCacheStore.start();
+      assert jdbcBinaryCacheStore.getConnectionFactory() instanceof ManagedConnectionFactory;
+      return jdbcBinaryCacheStore;
+   }
+
+
+   public void testLoadFromFile() throws Exception {
+      CacheManager cm = null;
+      try {
+         cm = new DefaultCacheManager("configs/binary-managed-connection-factory.xml");
+         Cache<String, String> first = cm.getCache("first");
+         Cache<String, String> second = cm.getCache("second");
+
+         CacheLoaderConfig firstCacheLoaderConfig = first.getConfiguration().getCacheLoaderManagerConfig().getFirstCacheLoaderConfig();
+         assert firstCacheLoaderConfig != null;
+         CacheLoaderConfig secondCacheLoaderConfig = second.getConfiguration().getCacheLoaderManagerConfig().getFirstCacheLoaderConfig();
+         assert secondCacheLoaderConfig != null;
+         assert firstCacheLoaderConfig instanceof JdbcBinaryCacheStoreConfig;
+         assert secondCacheLoaderConfig instanceof JdbcBinaryCacheStoreConfig;
+         CacheLoaderManager cacheLoaderManager = first.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
+         JdbcBinaryCacheStore loader = (JdbcBinaryCacheStore) cacheLoaderManager.getCacheLoader();
+         assert loader.getConnectionFactory() instanceof ManagedConnectionFactory;
+      } finally {
+         TestingUtil.killCacheManagers(cm);
+      }
+   }
+
+}
\ No newline at end of file

Copied: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreFunctionalTest.java (from rev 940, trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreFunctionalTest.java)
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreFunctionalTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreFunctionalTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.jdbc.binary;
+
+import org.infinispan.loaders.BaseCacheStoreFunctionalTest;
+import org.infinispan.loaders.CacheStoreConfig;
+import org.infinispan.loaders.jdbc.TableManipulation;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+/**
+ * JdbcBinaryCacheStoreFunctionalTest.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.binary.JdbcBinaryCacheStoreFunctionalTest")
+public class JdbcBinaryCacheStoreFunctionalTest extends BaseCacheStoreFunctionalTest {
+
+   @Override
+   protected CacheStoreConfig createCacheStoreConfig() throws Exception {
+      ConnectionFactoryConfig connectionFactoryConfig = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+      TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+      JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(connectionFactoryConfig, tm);
+      return config;
+//      JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
+//      jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
+//      jdbcBucketCacheStore.start();
+//      assert jdbcBucketCacheStore.getConnectionFactory() != null;
+//      return jdbcBucketCacheStore;
+   }
+}

Copied: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreTest.java (from rev 940, trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreTest.java)
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,59 @@
+package org.infinispan.loaders.jdbc.binary;
+
+import static org.easymock.classextension.EasyMock.*;
+import org.infinispan.CacheDelegate;
+import org.infinispan.loaders.BaseCacheStoreTest;
+import org.infinispan.loaders.CacheStore;
+import org.infinispan.loaders.jdbc.TableManipulation;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.marshall.TestObjectStreamMarshaller;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+/**
+ * Tester class for {@link JdbcBinaryCacheStore}
+ *
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.binary.JdbcBinaryCacheStoreTest")
+public class JdbcBinaryCacheStoreTest extends BaseCacheStoreTest {
+
+   protected CacheStore createCacheStore() throws Exception {
+      ConnectionFactoryConfig connectionFactoryConfig = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+      TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+      JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(connectionFactoryConfig, tm);
+      JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
+      jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
+      jdbcBucketCacheStore.start();
+      assert jdbcBucketCacheStore.getConnectionFactory() != null;
+      return jdbcBucketCacheStore;
+   }
+
+   public void testNotCreateConnectionFactory() throws Exception {
+      JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
+      JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(false);
+      config.setCreateTableOnStart(false);
+      jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), new TestObjectStreamMarshaller());
+      jdbcBucketCacheStore.start();
+      assert jdbcBucketCacheStore.getConnectionFactory() == null;
+
+      /* this will make sure that if a method like stop is called on the connection then it will barf an exception */
+      ConnectionFactory connectionFactory = createMock(ConnectionFactory.class);
+      TableManipulation tableManipulation = createMock(TableManipulation.class);
+      config.setTableManipulation(tableManipulation);
+
+      tableManipulation.start(connectionFactory);
+      tableManipulation.setCacheName("aName");
+      replay(tableManipulation);
+      jdbcBucketCacheStore.doConnectionFactoryInitialization(connectionFactory);
+      verify(tableManipulation);
+
+      //stop should be called even if this is an externally managed connection   
+      reset(tableManipulation, connectionFactory);
+      tableManipulation.stop();
+      replay(tableManipulation, connectionFactory);
+      jdbcBucketCacheStore.stop();
+      verify(tableManipulation, connectionFactory);
+   }
+}


Property changes on: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreTest.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Copied: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java (from rev 940, trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java)
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/binary/JdbcBinaryCacheStoreVamTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.loaders.jdbc.binary;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * JdbcBinaryCacheStoreTest using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.binary.JdbcBinaryCacheStoreVamTest")
+public class JdbcBinaryCacheStoreVamTest extends JdbcBinaryCacheStoreTest {   
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.inject(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      marshaller.start();
+      return marshaller;
+   }
+}

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/MixedStoreWithManagedConnectionTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,61 @@
+package org.infinispan.loaders.jdbc.mixed;
+
+import org.infinispan.Cache;
+import org.infinispan.CacheDelegate;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.CacheLoaderManager;
+import org.infinispan.loaders.CacheStore;
+import org.infinispan.loaders.jdbc.ManagedConnectionFactoryTest;
+import org.infinispan.loaders.jdbc.TableManipulation;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.mixed.MixedStoreWithManagedConnectionTest")
+public class MixedStoreWithManagedConnectionTest extends ManagedConnectionFactoryTest {
+
+   protected CacheStore createCacheStore() throws Exception {
+      ConnectionFactoryConfig connectionFactoryConfig = new ConnectionFactoryConfig();
+      connectionFactoryConfig.setConnectionFactoryClass(ManagedConnectionFactory.class.getName());
+      connectionFactoryConfig.setDatasourceJndiLocation(DATASOURCE_LOCATION);
+      TableManipulation stringsTm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+      stringsTm.setTableNamePrefix("STRINGS_TABLE");
+      TableManipulation binaryTm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+      binaryTm.setTableNamePrefix("BINARY_TABLE");
+      JdbcMixedCacheStoreConfig cacheStoreConfig = new JdbcMixedCacheStoreConfig(connectionFactoryConfig, binaryTm, stringsTm);
+      JdbcMixedCacheStore store = new JdbcMixedCacheStore();
+      store.init(cacheStoreConfig, new CacheDelegate("aName"), getMarshaller());
+      store.start();
+      assert store.getConnectionFactory() instanceof ManagedConnectionFactory;
+      return store;
+   }
+
+
+   public void testLoadFromFile() throws Exception {
+      CacheManager cm = null;
+      try {
+         cm = new DefaultCacheManager("configs/mixed-managed-connection-factory.xml");
+         Cache<String, String> first = cm.getCache("first");
+         Cache<String, String> second = cm.getCache("second");
+
+         CacheLoaderConfig firstCacheLoaderConfig = first.getConfiguration().getCacheLoaderManagerConfig().getFirstCacheLoaderConfig();
+         assert firstCacheLoaderConfig != null;
+         CacheLoaderConfig secondCacheLoaderConfig = second.getConfiguration().getCacheLoaderManagerConfig().getFirstCacheLoaderConfig();
+         assert secondCacheLoaderConfig != null;
+         assert firstCacheLoaderConfig instanceof JdbcMixedCacheStoreConfig;
+         assert secondCacheLoaderConfig instanceof JdbcMixedCacheStoreConfig;
+         CacheLoaderManager cacheLoaderManager = first.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
+         JdbcMixedCacheStore loader = (JdbcMixedCacheStore) cacheLoaderManager.getCacheLoader();
+         assert loader.getConnectionFactory() instanceof ManagedConnectionFactory;
+      } finally {
+         TestingUtil.killCacheManagers(cm);
+      }
+   }
+}

Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -22,10 +22,10 @@
       ConnectionFactoryConfig connectionFactoryConfig = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
       TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
       JdbcStringBasedCacheStoreConfig config = new JdbcStringBasedCacheStoreConfig(connectionFactoryConfig, tm);
-      JdbcStringBasedCacheStore jdbcBucketCacheStore = new JdbcStringBasedCacheStore();
-      jdbcBucketCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
-      jdbcBucketCacheStore.start();
-      return jdbcBucketCacheStore;
+      JdbcStringBasedCacheStore stringBasedCacheStore = new JdbcStringBasedCacheStore();
+      stringBasedCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
+      stringBasedCacheStore.start();
+      return stringBasedCacheStore;
    }
 
    public void testNotCreateConnectionFactory() throws Exception {

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/StringStoreWithManagedConnectionTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,56 @@
+package org.infinispan.loaders.jdbc.stringbased;
+
+import org.infinispan.Cache;
+import org.infinispan.CacheDelegate;
+import org.infinispan.loaders.CacheLoaderConfig;
+import org.infinispan.loaders.CacheLoaderManager;
+import org.infinispan.loaders.CacheStore;
+import org.infinispan.loaders.jdbc.ManagedConnectionFactoryTest;
+import org.infinispan.loaders.jdbc.TableManipulation;
+import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.TestingUtil;
+import org.infinispan.test.fwk.UnitTestDatabaseManager;
+import org.testng.annotations.Test;
+
+/**
+ * @author Mircea.Markus at jboss.com
+ */
+ at Test (groups = "functional", testName = "loaders.jdbc.stringbased.StringStoreWithManagedConnectionTest")
+public class StringStoreWithManagedConnectionTest extends ManagedConnectionFactoryTest {
+
+   protected CacheStore createCacheStore() throws Exception {
+      ConnectionFactoryConfig connectionFactoryConfig = new ConnectionFactoryConfig();
+      connectionFactoryConfig.setConnectionFactoryClass(ManagedConnectionFactory.class.getName());
+      connectionFactoryConfig.setDatasourceJndiLocation(DATASOURCE_LOCATION);
+      TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+      JdbcStringBasedCacheStoreConfig config = new JdbcStringBasedCacheStoreConfig(connectionFactoryConfig, tm);
+      JdbcStringBasedCacheStore stringBasedCacheStore = new JdbcStringBasedCacheStore();
+      stringBasedCacheStore.init(config, new CacheDelegate("aName"), getMarshaller());
+      stringBasedCacheStore.start();
+      return stringBasedCacheStore;
+   }
+
+   public void testLoadFromFile() throws Exception {
+      CacheManager cm = null;
+      try {
+         cm = new DefaultCacheManager("configs/str-managed-connection-factory.xml");
+         Cache<String, String> first = cm.getCache("first");
+         Cache<String, String> second = cm.getCache("second");
+
+         CacheLoaderConfig firstCacheLoaderConfig = first.getConfiguration().getCacheLoaderManagerConfig().getFirstCacheLoaderConfig();
+         assert firstCacheLoaderConfig != null;
+         CacheLoaderConfig secondCacheLoaderConfig = second.getConfiguration().getCacheLoaderManagerConfig().getFirstCacheLoaderConfig();
+         assert secondCacheLoaderConfig != null;
+         assert firstCacheLoaderConfig instanceof JdbcStringBasedCacheStoreConfig;
+         assert secondCacheLoaderConfig instanceof JdbcStringBasedCacheStoreConfig;
+         CacheLoaderManager cacheLoaderManager = first.getAdvancedCache().getComponentRegistry().getComponent(CacheLoaderManager.class);
+         JdbcStringBasedCacheStore loader = (JdbcStringBasedCacheStore) cacheLoaderManager.getCacheLoader();
+         assert loader.getConnectionFactory() instanceof ManagedConnectionFactory;
+      } finally {
+         TestingUtil.killCacheManagers(cm);
+      }
+   }
+}

Added: trunk/cachestore/jdbc/src/test/resources/configs/binary-managed-connection-factory.xml
===================================================================
--- trunk/cachestore/jdbc/src/test/resources/configs/binary-managed-connection-factory.xml	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/resources/configs/binary-managed-connection-factory.xml	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:4.0">
+
+   <global>
+
+      <!-- Note that if these are left blank, defaults are used.  See the user guide for what these defaults are -->
+      <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="5"/>
+            <property name="threadNamePrefix" value="AsyncListenerThread"/>
+         </properties>
+      </asyncListenerExecutor>
+
+      <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="25"/>
+            <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+         </properties>
+      </asyncTransportExecutor>
+
+      <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="EvictionThread"/>
+         </properties>
+      </evictionScheduledExecutor>
+
+      <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+         </properties>
+      </replicationQueueScheduledExecutor>
+
+      <globalJmxStatistics enabled="false" jmxDomain="infinispan"/>
+
+      <serialization marshallerClass="org.infinispan.marshall.VersionAwareMarshaller" version="1.0"/>
+
+      <shutdown hookBehavior="DEFAULT"/>
+   </global>
+
+   <default>
+      <locking
+            isolationLevel="REPEATABLE_READ"
+            lockAcquisitionTimeout="20000"
+            writeSkewCheck="false"
+            concurrencyLevel="500" useLockStriping="false"/>
+      <loaders>
+         <loader class="org.infinispan.loaders.jdbc.binary.JdbcBinaryCacheStore" fetchPersistentState="false"
+                 ignoreModifications="false" purgeOnStartup="false">
+            <properties>
+               <property name="bucketTableNamePrefix" value="ISPN_BUCKET_TABLE"/>
+               <property name="idColumnName" value="ID_COLUMN"/>
+               <property name="dataColumnName" value="DATA_COLUMN"/>
+               <property name="timestampColumnName" value="TIMESTAMP_COLUMN"/>
+               <property name="timestampColumnType" value="BIGINT"/>
+               <property name="connectionFactoryClass"
+                         value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory"/>
+               <property name="datasourceJndiLocation" value="java:/ManagedConnectionFactoryTest/DS"/>
+
+               <property name="userName" value="sa"/>
+               <property name="driverClass" value="org.h2.Driver"/>
+               <property name="idColumnType" value="VARCHAR(255)"/>
+               <property name="dataColumnType" value="BINARY"/>
+               <property name="dropTableOnExit" value="true"/>
+               <property name="createTableOnStart" value="true"/>
+            </properties>
+         </loader>
+      </loaders>
+
+   </default>
+
+
+   <namedCache name="first"/>
+
+   <namedCache name="second"/>
+
+</infinispan>

Added: trunk/cachestore/jdbc/src/test/resources/configs/mixed-managed-connection-factory.xml
===================================================================
--- trunk/cachestore/jdbc/src/test/resources/configs/mixed-managed-connection-factory.xml	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/resources/configs/mixed-managed-connection-factory.xml	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:4.0">
+
+   <global>
+
+      <!-- Note that if these are left blank, defaults are used.  See the user guide for what these defaults are -->
+      <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="5"/>
+            <property name="threadNamePrefix" value="AsyncListenerThread"/>
+         </properties>
+      </asyncListenerExecutor>
+
+      <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="25"/>
+            <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+         </properties>
+      </asyncTransportExecutor>
+
+      <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="EvictionThread"/>
+         </properties>
+      </evictionScheduledExecutor>
+
+      <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+         </properties>
+      </replicationQueueScheduledExecutor>
+
+      <globalJmxStatistics enabled="false" jmxDomain="infinispan"/>
+
+      <serialization marshallerClass="org.infinispan.marshall.VersionAwareMarshaller" version="1.0"/>
+
+      <shutdown hookBehavior="DEFAULT"/>
+   </global>
+
+   <default>
+      <locking
+            isolationLevel="REPEATABLE_READ"
+            lockAcquisitionTimeout="20000"
+            writeSkewCheck="false"
+            concurrencyLevel="500" useLockStriping="false"/>
+      <loaders>
+         <loader class="org.infinispan.loaders.jdbc.mixed.JdbcMixedCacheStore" fetchPersistentState="false"
+                 ignoreModifications="false" purgeOnStartup="false">
+            <properties>
+               <property name="tableNamePrefixForStrings" value="ISPN_MIXED_STR_TABLE"/>
+               <property name="tableNamePrefixForBinary" value="ISPN_MIXED_BINARY_TABLE"/>
+               <property name="idColumnNameForStrings" value="ID_COLUMN"/>
+               <property name="idColumnNameForBinary" value="ID_COLUMN"/>
+               <property name="dataColumnNameForStrings" value="DATA_COLUMN"/>
+               <property name="dataColumnNameForBinary" value="DATA_COLUMN"/>
+               <property name="timestampColumnNameForStrings" value="TIMESTAMP_COLUMN"/>
+               <property name="timestampColumnNameForBinary" value="TIMESTAMP_COLUMN"/>
+               <property name="timestampColumnTypeForStrings" value="BIGINT"/>
+               <property name="timestampColumnTypeForBinary" value="BIGINT"/>
+               <property name="connectionFactoryClass"
+                         value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory"/>
+               <property name="datasourceJndiLocation" value="java:/ManagedConnectionFactoryTest/DS"/>
+               <property name="userName" value="sa"/>
+               <property name="driverClass" value="org.h2.Driver"/>
+               <property name="idColumnTypeForStrings" value="VARCHAR(255)"/>
+               <property name="idColumnTypeForBinary" value="VARCHAR(255)"/>
+               <property name="dataColumnTypeForStrings" value="BINARY"/>
+               <property name="dataColumnTypeForBinary" value="BINARY"/>
+               <property name="dropTableOnExitForStrings" value="false"/>
+               <property name="dropTableOnExitForBinary" value="false"/>
+               <property name="createTableOnStartForStrings" value="true"/>
+               <property name="createTableOnStartForBinary" value="true"/>
+               <property name="createTableOnStartForStrings" value="true"/>
+               <property name="createTableOnStartForBinary" value="true"/>
+            </properties>
+
+         </loader>
+      </loaders>
+
+   </default>
+
+
+   <namedCache name="first"/>
+
+   <namedCache name="second"/>
+
+</infinispan>

Added: trunk/cachestore/jdbc/src/test/resources/configs/str-managed-connection-factory.xml
===================================================================
--- trunk/cachestore/jdbc/src/test/resources/configs/str-managed-connection-factory.xml	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/resources/configs/str-managed-connection-factory.xml	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<infinispan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:infinispan:config:4.0">
+
+   <global>
+
+      <!-- Note that if these are left blank, defaults are used.  See the user guide for what these defaults are -->
+      <asyncListenerExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="5"/>
+            <property name="threadNamePrefix" value="AsyncListenerThread"/>
+         </properties>
+      </asyncListenerExecutor>
+
+      <asyncTransportExecutor factory="org.infinispan.executors.DefaultExecutorFactory">
+         <properties>
+            <property name="maxThreads" value="25"/>
+            <property name="threadNamePrefix" value="AsyncSerializationThread"/>
+         </properties>
+      </asyncTransportExecutor>
+
+      <evictionScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="EvictionThread"/>
+         </properties>
+      </evictionScheduledExecutor>
+
+      <replicationQueueScheduledExecutor factory="org.infinispan.executors.DefaultScheduledExecutorFactory">
+         <properties>
+            <property name="threadNamePrefix" value="ReplicationQueueThread"/>
+         </properties>
+      </replicationQueueScheduledExecutor>
+
+      <globalJmxStatistics enabled="false" jmxDomain="infinispan"/>
+
+      <serialization marshallerClass="org.infinispan.marshall.VersionAwareMarshaller" version="1.0"/>
+
+      <shutdown hookBehavior="DEFAULT"/>
+   </global>
+
+   <default>
+      <locking
+            isolationLevel="REPEATABLE_READ"
+            lockAcquisitionTimeout="20000"
+            writeSkewCheck="false"
+            concurrencyLevel="500" useLockStriping="false"/>
+      <loaders>
+         <loader class="org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore" fetchPersistentState="false"
+                 ignoreModifications="false" purgeOnStartup="false">
+            <properties>
+               <property name="stringsTableNamePrefix" value="ISPN_STRING_TABLE"/>
+               <property name="idColumnName" value="ID_COLUMN"/>
+               <property name="dataColumnName" value="DATA_COLUMN"/>
+               <property name="timestampColumnName" value="TIMESTAMP_COLUMN"/>
+               <property name="timestampColumnType" value="BIGINT"/>
+               <property name="connectionFactoryClass"
+                         value="org.infinispan.loaders.jdbc.connectionfactory.ManagedConnectionFactory"/>
+               <property name="datasourceJndiLocation" value="java:/ManagedConnectionFactoryTest/DS"/>
+               <property name="idColumnType" value="VARCHAR(255)"/>
+               <property name="dataColumnType" value="BINARY"/>
+               <property name="dropTableOnExit" value="true"/>
+               <property name="createTableOnStart" value="true"/>
+            </properties>
+         </loader>
+      </loaders>
+
+   </default>
+
+
+   <namedCache name="first"/>
+
+   <namedCache name="second"/>
+
+</infinispan>

Modified: trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/core/src/main/java/org/infinispan/config/InfinispanConfiguration.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -24,9 +24,13 @@
 import org.infinispan.Version;
 import org.infinispan.config.parsing.XmlConfigurationParser;
 import org.infinispan.util.FileLookup;
+import org.infinispan.util.logging.Log;
+import org.infinispan.util.logging.LogFactory;
 
 import javax.xml.bind.JAXBContext;
 import javax.xml.bind.Unmarshaller;
+import javax.xml.bind.ValidationEvent;
+import javax.xml.bind.ValidationEventHandler;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -63,6 +67,8 @@
 @XmlAccessorType(XmlAccessType.FIELD)
 public class InfinispanConfiguration implements XmlConfigurationParser {
 
+   private static Log log = LogFactory.getLog(InfinispanConfiguration.class);
+
    public static final String VALIDATING_SYSTEM_PROPERTY = "infinispan.config.validate";
 
    public static final String SCHEMA_SYSTEM_PROPERTY = "infinispan.config.schema";
@@ -185,12 +191,17 @@
       try {
          JAXBContext jc = JAXBContext.newInstance(InfinispanConfiguration.class);
          Unmarshaller u = jc.createUnmarshaller();
+         ErrorValidationHandler handler = new ErrorValidationHandler();
+         u.setEventHandler(handler);
 
          if (schema != null) {
             SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
             u.setSchema(factory.newSchema(new StreamSource(schema)));
          }
          InfinispanConfiguration ic = (InfinispanConfiguration) u.unmarshal(config);
+         if (handler.errorsReported()) {
+            throw new ConfigurationException("Exception were reported during parsing the config file: " + handler.getReportedErrors());
+         }
          // legacy, don't ask
          ic.parseGlobalConfiguration().setDefaultConfiguration(ic.parseDefaultConfiguration());
          if (cbv != null) {
@@ -198,12 +209,44 @@
          }
          return ic;
       } catch (Exception e) {
+         log.error("Cought unexpected ex: ", e);
          IOException ioe = new IOException(e.getLocalizedMessage());
          ioe.initCause(e);
          throw ioe;
       }
    }
 
+   public static class ErrorValidationHandler implements ValidationEventHandler {
+      private boolean errorsReported = false;
+      private StringBuilder errors;
+
+      public boolean handleEvent(ValidationEvent event) {
+         if (event != null && event.getLinkedException() != null) {
+            errorsReported = true;
+            getErrors().append(event.getMessage());
+            log.error("Exception while parsing the xml file: ", event.getLinkedException());
+         }
+         return true;
+      }
+
+      private StringBuilder getErrors() {
+         if (errors == null) {
+            errors = new StringBuilder();
+         } else {
+            errors.append('\n');
+         }
+         return errors;
+      }
+
+      public boolean errorsReported() {
+         return errorsReported;
+      }
+
+      public String getReportedErrors() {
+         return errors.toString();
+      }
+   }
+
    private static boolean skipSchemaValidation() {
       String s = System.getProperty(VALIDATING_SYSTEM_PROPERTY);
       return s != null && !Boolean.parseBoolean(s);

Modified: trunk/core/src/main/java/org/infinispan/config/TypedPropertiesAdapter.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/TypedPropertiesAdapter.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/core/src/main/java/org/infinispan/config/TypedPropertiesAdapter.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -21,11 +21,11 @@
  */
 package org.infinispan.config;
 
-import java.util.Set;
-import java.util.Map.Entry;
+import org.infinispan.util.TypedProperties;
 
 import javax.xml.bind.annotation.adapters.XmlAdapter;
-import org.infinispan.util.TypedProperties;
+import java.util.Map.Entry;
+import java.util.Set;
 /**
  * TypedPropertiesAdapter is JAXB XmlAdapter for TypedProperties.
  *
@@ -53,8 +53,10 @@
    @Override
    public TypedProperties unmarshal(PropertiesType props) throws Exception {
       TypedProperties tp = new TypedProperties();
-      for (Property p : props.properties) {
-         tp.put(p.name, p.value);
+      if (props != null && props.properties != null) {
+         for (Property p : props.properties) {
+            tp.put(p.name, p.value);
+         }
       }
       return tp;
    }

Modified: trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/core/src/test/java/org/infinispan/config/parsing/EHCache2InfinispanTransformerTest.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -14,6 +14,7 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
+import java.io.FileOutputStream;
 
 /**
  * @author Mircea.Markus at jboss.com
@@ -49,13 +50,13 @@
          convertor.parse(fileName, baos, XSLT_FILE);
 
 
-//         File out = new File("zzzz2.xml");
-//         if (out.exists()) out.delete();
-//         out.createNewFile();
-//         FileOutputStream fos = new FileOutputStream(out);
-//         fos.write(baos.toByteArray());
-//         baos.close();
-//         fos.close();
+         File out = new File("zzzz3.xml");
+         if (out.exists()) out.delete();
+         out.createNewFile();
+         FileOutputStream fos = new FileOutputStream(out);
+         fos.write(baos.toByteArray());
+         baos.close();
+         fos.close();
 
          dcm = new DefaultCacheManager(new ByteArrayInputStream(baos.toByteArray()));
          Cache<Object,Object> defaultCache = dcm.getCache();

Added: trunk/core/src/test/java/org/infinispan/test/jndi/DummyContext.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/jndi/DummyContext.java	                        (rev 0)
+++ trunk/core/src/test/java/org/infinispan/test/jndi/DummyContext.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,556 @@
+package org.infinispan.test.jndi;
+
+import javax.naming.Context;
+import javax.naming.Name;
+import javax.naming.NameClassPair;
+import javax.naming.NameParser;
+import javax.naming.NamingEnumeration;
+import javax.naming.NamingException;
+import javax.naming.Binding;
+import java.util.Hashtable;
+import java.util.HashMap;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ByteArrayInputStream;
+
+public class DummyContext implements Context {
+
+
+   HashMap<String, Object> bindings = new HashMap<String, Object>();
+   boolean serializing;
+
+   public DummyContext() {
+      this.serializing = false;
+   }
+
+   public DummyContext(boolean serializing) {
+      this.serializing = serializing;
+   }
+
+   /**
+    * Retrieves the named object. If <tt>name</tt> is empty, returns a new instance of this context (which represents
+    * the same naming context as this context, but its environment may be modified independently and it may be accessed
+    * concurrently).
+    *
+    * @param name the name of the object to look up
+    * @return the object bound to <tt>name</tt>
+    * @throws NamingException if a naming exception is encountered
+    * @see #lookup(String)
+    * @see #lookupLink(Name)
+    */
+   public Object lookup(Name name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Retrieves the named object. See {@link #lookup(Name)} for details.
+    *
+    * @param name the name of the object to look up
+    * @return the object bound to <tt>name</tt>
+    * @throws NamingException if a naming exception is encountered
+    */
+   public Object lookup(String name) throws NamingException {
+      try {
+         deserialize();
+         return bindings.get(name);
+      }
+      finally {
+         serialize();
+      }
+   }
+
+   /**
+    * Binds a name to an object. All intermediate contexts and the target context (that named by all but terminal atomic
+    * component of the name) must already exist.
+    *
+    * @param name the name to bind; may not be empty
+    * @param obj  the object to bind; possibly null
+    * @throws javax.naming.NameAlreadyBoundException
+    *                         if name is already bound
+    * @throws javax.naming.directory.InvalidAttributesException
+    *                         if object did not supply all mandatory attributes
+    * @throws NamingException if a naming exception is encountered
+    * @see #bind(String,Object)
+    * @see #rebind(Name,Object)
+    * @see javax.naming.directory.DirContext#bind(Name,Object, javax.naming.directory.Attributes)
+    */
+   public void bind(Name name, Object obj) throws NamingException {
+      bind("NAME: " + name.toString(), obj);
+   }
+
+   /**
+    * Binds a name to an object. See {@link #bind(Name,Object)} for details.
+    *
+    * @param name the name to bind; may not be empty
+    * @param obj  the object to bind; possibly null
+    * @throws javax.naming.NameAlreadyBoundException
+    *                         if name is already bound
+    * @throws javax.naming.directory.InvalidAttributesException
+    *                         if object did not supply all mandatory attributes
+    * @throws NamingException if a naming exception is encountered
+    */
+   public void bind(String name, Object obj) throws NamingException {
+      try {
+         deserialize();
+         bindings.put(name, obj);
+      }
+      finally {
+         serialize();
+      }
+   }
+
+   /**
+    * Binds a name to an object, overwriting any existing binding. All intermediate contexts and the target context
+    * (that named by all but terminal atomic component of the name) must already exist.
+    * <p/>
+    * <p> If the object is a <tt>DirContext</tt>, any existing attributes associated with the name are replaced with
+    * those of the object. Otherwise, any existing attributes associated with the name remain unchanged.
+    *
+    * @param name the name to bind; may not be empty
+    * @param obj  the object to bind; possibly null
+    * @throws javax.naming.directory.InvalidAttributesException
+    *                         if object did not supply all mandatory attributes
+    * @throws NamingException if a naming exception is encountered
+    * @see #rebind(String,Object)
+    * @see #bind(Name,Object)
+    * @see javax.naming.directory.DirContext#rebind(Name,Object, javax.naming.directory.Attributes)
+    * @see javax.naming.directory.DirContext
+    */
+   public void rebind(Name name, Object obj) throws NamingException {
+      bind(name, obj);
+   }
+
+   /**
+    * Binds a name to an object, overwriting any existing binding. See {@link #rebind(Name,Object)} for details.
+    *
+    * @param name the name to bind; may not be empty
+    * @param obj  the object to bind; possibly null
+    * @throws javax.naming.directory.InvalidAttributesException
+    *                         if object did not supply all mandatory attributes
+    * @throws NamingException if a naming exception is encountered
+    */
+   public void rebind(String name, Object obj) throws NamingException {
+      bind(name, obj);
+   }
+
+   /**
+    * Unbinds the named object. Removes the terminal atomic name in <code>name</code> from the target context--that
+    * named by all but the terminal atomic part of <code>name</code>.
+    * <p/>
+    * <p> This method is idempotent. It succeeds even if the terminal atomic name is not bound in the target context,
+    * but throws <tt>NameNotFoundException</tt> if any of the intermediate contexts do not exist.
+    * <p/>
+    * <p> Any attributes associated with the name are removed. Intermediate contexts are not changed.
+    *
+    * @param name the name to unbind; may not be empty
+    * @throws javax.naming.NameNotFoundException
+    *                         if an intermediate context does not exist
+    * @throws NamingException if a naming exception is encountered
+    * @see #unbind(String)
+    */
+   public void unbind(Name name) throws NamingException {
+      unbind("NAME: " + name.toString());
+   }
+
+   /**
+    * Unbinds the named object. See {@link #unbind(Name)} for details.
+    *
+    * @param name the name to unbind; may not be empty
+    * @throws javax.naming.NameNotFoundException
+    *                         if an intermediate context does not exist
+    * @throws NamingException if a naming exception is encountered
+    */
+   public void unbind(String name) throws NamingException {
+      try {
+         deserialize();
+         bindings.remove(name);
+      }
+      finally {
+         serialize();
+      }
+   }
+
+   /**
+    * Binds a new name to the object bound to an old name, and unbinds the old name.  Both names are relative to this
+    * context. Any attributes associated with the old name become associated with the new name. Intermediate contexts of
+    * the old name are not changed.
+    *
+    * @param oldName the name of the existing binding; may not be empty
+    * @param newName the name of the new binding; may not be empty
+    * @throws javax.naming.NameAlreadyBoundException
+    *                         if <tt>newName</tt> is already bound
+    * @throws NamingException if a naming exception is encountered
+    * @see #rename(String,String)
+    * @see #bind(Name,Object)
+    * @see #rebind(Name,Object)
+    */
+   public void rename(Name oldName, Name newName) throws NamingException {
+   }
+
+   /**
+    * Binds a new name to the object bound to an old name, and unbinds the old name. See {@link #rename(Name,Name)} for
+    * details.
+    *
+    * @param oldName the name of the existing binding; may not be empty
+    * @param newName the name of the new binding; may not be empty
+    * @throws javax.naming.NameAlreadyBoundException
+    *                         if <tt>newName</tt> is already bound
+    * @throws NamingException if a naming exception is encountered
+    */
+   public void rename(String oldName, String newName) throws NamingException {
+   }
+
+   /**
+    * Enumerates the names bound in the named context, along with the class names of objects bound to them. The contents
+    * of any subcontexts are not included.
+    * <p/>
+    * <p> If a binding is added to or removed from this context, its effect on an enumeration previously returned is
+    * undefined.
+    *
+    * @param name the name of the context to list
+    * @return an enumeration of the names and class names of the bindings in this context.  Each element of the
+    *         enumeration is of type <tt>NameClassPair</tt>.
+    * @throws NamingException if a naming exception is encountered
+    * @see #list(String)
+    * @see #listBindings(Name)
+    * @see javax.naming.NameClassPair
+    */
+   public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Enumerates the names bound in the named context, along with the class names of objects bound to them. See {@link
+    * #list(Name)} for details.
+    *
+    * @param name the name of the context to list
+    * @return an enumeration of the names and class names of the bindings in this context.  Each element of the
+    *         enumeration is of type <tt>NameClassPair</tt>.
+    * @throws NamingException if a naming exception is encountered
+    */
+   public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Enumerates the names bound in the named context, along with the objects bound to them. The contents of any
+    * subcontexts are not included.
+    * <p/>
+    * <p> If a binding is added to or removed from this context, its effect on an enumeration previously returned is
+    * undefined.
+    *
+    * @param name the name of the context to list
+    * @return an enumeration of the bindings in this context. Each element of the enumeration is of type
+    *         <tt>Binding</tt>.
+    * @throws NamingException if a naming exception is encountered
+    * @see #listBindings(String)
+    * @see #list(Name)
+    * @see javax.naming.Binding
+    */
+   public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Enumerates the names bound in the named context, along with the objects bound to them. See {@link
+    * #listBindings(Name)} for details.
+    *
+    * @param name the name of the context to list
+    * @return an enumeration of the bindings in this context. Each element of the enumeration is of type
+    *         <tt>Binding</tt>.
+    * @throws NamingException if a naming exception is encountered
+    */
+   public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Destroys the named context and removes it from the namespace. Any attributes associated with the name are also
+    * removed. Intermediate contexts are not destroyed.
+    * <p/>
+    * <p> This method is idempotent. It succeeds even if the terminal atomic name is not bound in the target context,
+    * but throws <tt>NameNotFoundException</tt> if any of the intermediate contexts do not exist.
+    * <p/>
+    * <p> In a federated naming system, a context from one naming system may be bound to a name in another.  One can
+    * subsequently look up and perform operations on the foreign context using a composite name.  However, an attempt
+    * destroy the context using this composite name will fail with <tt>NotContextException</tt>, because the foreign
+    * context is not a "subcontext" of the context in which it is bound. Instead, use <tt>unbind()</tt> to remove the
+    * binding of the foreign context.  Destroying the foreign context requires that the <tt>destroySubcontext()</tt> be
+    * performed on a context from the foreign context's "native" naming system.
+    *
+    * @param name the name of the context to be destroyed; may not be empty
+    * @throws javax.naming.NameNotFoundException
+    *                         if an intermediate context does not exist
+    * @throws javax.naming.NotContextException
+    *                         if the name is bound but does not name a context, or does not name a context of the
+    *                         appropriate type
+    * @throws javax.naming.ContextNotEmptyException
+    *                         if the named context is not empty
+    * @throws NamingException if a naming exception is encountered
+    * @see #destroySubcontext(String)
+    */
+   public void destroySubcontext(Name name) throws NamingException {
+   }
+
+   /**
+    * Destroys the named context and removes it from the namespace. See {@link #destroySubcontext(Name)} for details.
+    *
+    * @param name the name of the context to be destroyed; may not be empty
+    * @throws javax.naming.NameNotFoundException
+    *                         if an intermediate context does not exist
+    * @throws javax.naming.NotContextException
+    *                         if the name is bound but does not name a context, or does not name a context of the
+    *                         appropriate type
+    * @throws javax.naming.ContextNotEmptyException
+    *                         if the named context is not empty
+    * @throws NamingException if a naming exception is encountered
+    */
+   public void destroySubcontext(String name) throws NamingException {
+   }
+
+   /**
+    * Creates and binds a new context. Creates a new context with the given name and binds it in the target context
+    * (that named by all but terminal atomic component of the name).  All intermediate contexts and the target context
+    * must already exist.
+    *
+    * @param name the name of the context to create; may not be empty
+    * @return the newly created context
+    * @throws javax.naming.NameAlreadyBoundException
+    *                         if name is already bound
+    * @throws javax.naming.directory.InvalidAttributesException
+    *                         if creation of the subcontext requires specification of mandatory attributes
+    * @throws NamingException if a naming exception is encountered
+    * @see #createSubcontext(String)
+    * @see javax.naming.directory.DirContext#createSubcontext
+    */
+   public Context createSubcontext(Name name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Creates and binds a new context. See {@link #createSubcontext(Name)} for details.
+    *
+    * @param name the name of the context to create; may not be empty
+    * @return the newly created context
+    * @throws javax.naming.NameAlreadyBoundException
+    *                         if name is already bound
+    * @throws javax.naming.directory.InvalidAttributesException
+    *                         if creation of the subcontext requires specification of mandatory attributes
+    * @throws NamingException if a naming exception is encountered
+    */
+   public Context createSubcontext(String name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Retrieves the named object, following links except for the terminal atomic component of the name. If the object
+    * bound to <tt>name</tt> is not a link, returns the object itself.
+    *
+    * @param name the name of the object to look up
+    * @return the object bound to <tt>name</tt>, not following the terminal link (if any).
+    * @throws NamingException if a naming exception is encountered
+    * @see #lookupLink(String)
+    */
+   public Object lookupLink(Name name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Retrieves the named object, following links except for the terminal atomic component of the name. See {@link
+    * #lookupLink(Name)} for details.
+    *
+    * @param name the name of the object to look up
+    * @return the object bound to <tt>name</tt>, not following the terminal link (if any)
+    * @throws NamingException if a naming exception is encountered
+    */
+   public Object lookupLink(String name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Retrieves the parser associated with the named context. In a federation of namespaces, different naming systems
+    * will parse names differently.  This method allows an application to get a parser for parsing names into their
+    * atomic components using the naming convention of a particular naming system. Within any single naming system,
+    * <tt>NameParser</tt> objects returned by this method must be equal (using the <tt>equals()</tt> test).
+    *
+    * @param name the name of the context from which to get the parser
+    * @return a name parser that can parse compound names into their atomic components
+    * @throws NamingException if a naming exception is encountered
+    * @see #getNameParser(String)
+    * @see javax.naming.CompoundName
+    */
+   public NameParser getNameParser(Name name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Retrieves the parser associated with the named context. See {@link #getNameParser(Name)} for details.
+    *
+    * @param name the name of the context from which to get the parser
+    * @return a name parser that can parse compound names into their atomic components
+    * @throws NamingException if a naming exception is encountered
+    */
+   public NameParser getNameParser(String name) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Composes the name of this context with a name relative to this context. Given a name (<code>name</code>) relative
+    * to this context, and the name (<code>prefix</code>) of this context relative to one of its ancestors, this method
+    * returns the composition of the two names using the syntax appropriate for the naming system(s) involved.  That is,
+    * if <code>name</code> names an object relative to this context, the result is the name of the same object, but
+    * relative to the ancestor context.  None of the names may be null.
+    * <p/>
+    * For example, if this context is named "wiz.com" relative to the initial context, then
+    * <pre>
+    * 	composeName("east", "wiz.com")	</pre>
+    * might return <code>"east.wiz.com"</code>. If instead this context is named "org/research", then
+    * <pre>
+    * 	composeName("user/jane", "org/research")	</pre>
+    * might return <code>"org/research/user/jane"</code> while
+    * <pre>
+    * 	composeName("user/jane", "research")	</pre>
+    * returns <code>"research/user/jane"</code>.
+    *
+    * @param name   a name relative to this context
+    * @param prefix the name of this context relative to one of its ancestors
+    * @return the composition of <code>prefix</code> and <code>name</code>
+    * @throws NamingException if a naming exception is encountered
+    * @see #composeName(String,String)
+    */
+   public Name composeName(Name name, Name prefix) throws NamingException {
+      return null;
+   }
+
+   /**
+    * Composes the name of this context with a name relative to this context. See {@link #composeName(Name,Name)} for
+    * details.
+    *
+    * @param name   a name relative to this context
+    * @param prefix the name of this context relative to one of its ancestors
+    * @return the composition of <code>prefix</code> and <code>name</code>
+    * @throws NamingException if a naming exception is encountered
+    */
+   public String composeName(String name, String prefix)
+         throws NamingException {
+      return null;
+   }
+
+   /**
+    * Adds a new environment property to the environment of this context.  If the property already exists, its value is
+    * overwritten. See class description for more details on environment properties.
+    *
+    * @param propName the name of the environment property to add; may not be null
+    * @param propVal  the value of the property to add; may not be null
+    * @return the previous value of the property, or null if the property was not in the environment before
+    * @throws NamingException if a naming exception is encountered
+    * @see #getEnvironment()
+    * @see #removeFromEnvironment(String)
+    */
+   public Object addToEnvironment(String propName, Object propVal)
+         throws NamingException {
+      return null;
+   }
+
+   /**
+    * Removes an environment property from the environment of this context.  See class description for more details on
+    * environment properties.
+    *
+    * @param propName the name of the environment property to remove; may not be null
+    * @return the previous value of the property, or null if the property was not in the environment
+    * @throws NamingException if a naming exception is encountered
+    * @see #getEnvironment()
+    * @see #addToEnvironment(String,Object)
+    */
+   public Object removeFromEnvironment(String propName)
+         throws NamingException {
+      return null;
+   }
+
+   /**
+    * Retrieves the environment in effect for this context. See class description for more details on environment
+    * properties.
+    * <p/>
+    * <p> The caller should not make any changes to the object returned: their effect on the context is undefined. The
+    * environment of this context may be changed using <tt>addToEnvironment()</tt> and
+    * <tt>removeFromEnvironment()</tt>.
+    *
+    * @return the environment of this context; never null
+    * @throws NamingException if a naming exception is encountered
+    * @see #addToEnvironment(String,Object)
+    * @see #removeFromEnvironment(String)
+    */
+   public Hashtable<?, ?> getEnvironment() throws NamingException {
+      return null;
+   }
+
+   /**
+    * Closes this context. This method releases this context's resources immediately, instead of waiting for them to be
+    * released automatically by the garbage collector.
+    * <p/>
+    * <p> This method is idempotent:  invoking it on a context that has already been closed has no effect.  Invoking any
+    * other method on a closed context is not allowed, and results in undefined behaviour.
+    *
+    * @throws NamingException if a naming exception is encountered
+    */
+   public void close() throws NamingException {
+   }
+
+   /**
+    * Retrieves the full name of this context within its own namespace.
+    * <p/>
+    * <p> Many naming services have a notion of a "full name" for objects in their respective namespaces.  For example,
+    * an LDAP entry has a distinguished name, and a DNS record has a fully qualified name. This method allows the client
+    * application to retrieve this name. The string returned by this method is not a JNDI composite name and should not
+    * be passed directly to context methods. In naming systems for which the notion of full name does not make sense,
+    * <tt>OperationNotSupportedException</tt> is thrown.
+    *
+    * @return this context's name in its own namespace; never null
+    * @throws javax.naming.OperationNotSupportedException
+    *                         if the naming system does not have the notion of a full name
+    * @throws NamingException if a naming exception is encountered
+    * @since 1.3
+    */
+   public String getNameInNamespace() throws NamingException {
+      return null;
+   }
+
+   byte[] bytes = null;
+
+   private void serialize() {
+      if (serializing) {
+         try {
+            ByteArrayOutputStream bstream = new ByteArrayOutputStream();
+            ObjectOutputStream oos = new ObjectOutputStream(bstream);
+            oos.writeObject(bindings);
+            oos.close();
+            bstream.close();
+            bytes = bstream.toByteArray();
+            bindings = null;
+         }
+         catch (Exception e) {
+            throw new RuntimeException(e);
+         }
+      }
+   }
+
+   @SuppressWarnings("unchecked")
+   private void deserialize() {
+      if (serializing) {
+         if (bytes == null)
+            bindings = new HashMap<String, Object>();
+         else {
+            try {
+               ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(bytes));
+               bindings = (HashMap<String, Object>) ois.readObject();
+               ois.close();
+               bytes = null;
+            }
+            catch (Exception e) {
+               throw new RuntimeException(e);
+            }
+         }
+      }
+   }
+}

Added: trunk/core/src/test/java/org/infinispan/test/jndi/DummyContextFactory.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/test/jndi/DummyContextFactory.java	                        (rev 0)
+++ trunk/core/src/test/java/org/infinispan/test/jndi/DummyContextFactory.java	2009-10-14 16:47:43 UTC (rev 945)
@@ -0,0 +1,28 @@
+package org.infinispan.test.jndi;
+
+import javax.naming.Context;
+import javax.naming.NamingException;
+import javax.naming.spi.InitialContextFactory;
+import java.util.Hashtable;
+
+public class DummyContextFactory implements InitialContextFactory {
+   static Context instance = null;
+
+   /**
+    * Creates an Initial Context for beginning name resolution. Special requirements of this context are supplied using
+    * <code>environment</code>.
+    * <p/>
+    * The environment parameter is owned by the caller. The implementation will not modify the object or keep a
+    * reference to it, although it may keep a reference to a clone or copy.
+    *
+    * @param environment The possibly null environment specifying information to be used in the creation of the initial
+    *                    context.
+    * @return A non-null initial context object that implements the Context interface.
+    * @throws javax.naming.NamingException If cannot create an initial context.
+    */
+   public Context getInitialContext(Hashtable environment) throws NamingException {
+      if (instance == null)
+         instance = new DummyContext();
+      return instance;
+   }
+}

Modified: trunk/core/src/test/resources/configs/named-cache-test.xml
===================================================================
--- trunk/core/src/test/resources/configs/named-cache-test.xml	2009-10-14 13:04:50 UTC (rev 944)
+++ trunk/core/src/test/resources/configs/named-cache-test.xml	2009-10-14 16:47:43 UTC (rev 945)
@@ -152,17 +152,10 @@
       <jmxStatistics enabled="false"/>
       <deadlockDetection enabled="true" spinDuration="1221"/>
       <loaders passivation="true" shared="true" preload="true"> 
-      	<loader class="org.infinispan.loaders.jdbc.stringbased.JdbcStringBasedCacheStore" fetchPersistentState="true" 
+      	<loader class="org.infinispan.loaders.file.FileCacheStore" fetchPersistentState="true"
                         ignoreModifications="true" purgeOnStartup="true"> 
            <properties> 
-             <property name="connectionFactoryClass" value="org.infinispan.loaders.jdbc.connectionfactory.PooledConnectionFactory"/> 
-             <property name="connectionUrl" value="jdbc://some-url"/> 
-             <property name="userName" value="root"/> 
-             <property name="driverClass" value="org.dbms.Driver"/> 
-             <property name="idColumnType" value="VARCHAR2(256)"/> 
-             <property name="dataColumnType" value="BLOB"/> 
-             <property name="dropTableOnExit" value="true"/> 
-             <property name="createTableOnStart" value="false"/>                     
+             <property name="location" value="${java.io.tmpdir}"/>
             </properties>
            <singletonStore enabled="true" pushStateWhenCoordinator="true" pushStateTimeout="20000"/> 
             <async enabled="true" threadPoolSize="10" mapLockTimeout="10000"/> 



More information about the infinispan-commits mailing list