[infinispan-commits] Infinispan SVN: r489 - in trunk: cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje and 7 other directories.

infinispan-commits at lists.jboss.org infinispan-commits at lists.jboss.org
Fri Jun 19 14:08:18 EDT 2009


Author: galder.zamarreno at jboss.com
Date: 2009-06-19 14:08:18 -0400 (Fri, 19 Jun 2009)
New Revision: 489

Added:
   trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java
   trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java
   trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationVamTest.java
   trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java
Modified:
   trunk/cachestore/bdbje/
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java
   trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
   trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreTest.java
   trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationTest.java
   trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
Log:
[ISPN-109] (Add VAM based cache store tests) Move away from OOS and OIS based tests and instead based them on whichever marshaller has been configured. Added production level marshaller (VAM) based tests for all cache stores.


Property changes on: trunk/cachestore/bdbje
___________________________________________________________________
Name: svn:ignore
   - target
.settings
eclipse-output
test-output
output
.classpath
.project
temp-testng-customsuite.xml

   + target
.settings
eclipse-output
test-output
output
.classpath
.project
temp-testng-customsuite.xml
Infinispan-BdbjeCacheStore


Added: trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java
===================================================================
--- trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java	                        (rev 0)
+++ trunk/cachestore/bdbje/src/test/java/org/infinispan/loaders/bdbje/BdbjeCacheStoreIntegrationVamTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -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.bdbje;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * BdjeCacheStoreIntegrationTest using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "unit", enabled = true, testName = "loaders.bdbje.BdbjeCacheStoreIntegrationVamTest")
+public class BdbjeCacheStoreIntegrationVamTest extends BdbjeCacheStoreIntegrationTest {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+
+}

Modified: 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-06-19 18:04:13 UTC (rev 488)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -24,7 +24,7 @@
       TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
       JdbcBinaryCacheStoreConfig config = new JdbcBinaryCacheStoreConfig(connectionFactoryConfig, tm);
       JdbcBinaryCacheStore jdbcBucketCacheStore = new JdbcBinaryCacheStore();
-      jdbcBucketCacheStore.init(config, null, new TestObjectStreamMarshaller());
+      jdbcBucketCacheStore.init(config, null, getMarshaller());
       jdbcBucketCacheStore.start();
       assert jdbcBucketCacheStore.getConnectionFactory() != null;
       return jdbcBucketCacheStore;

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/JdbcBinaryCacheStoreVamTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}

Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java	2009-06-19 18:04:13 UTC (rev 488)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -2,6 +2,8 @@
 
 import org.infinispan.container.entries.InternalCacheEntry;
 import org.infinispan.container.entries.InternalEntryFactory;
+import org.infinispan.io.UnclosableObjectInputStream;
+import org.infinispan.io.UnclosableObjectOutputStream;
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheStore;
 import org.infinispan.loaders.jdbc.TableManipulation;
@@ -9,6 +11,7 @@
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
 import org.infinispan.loaders.jdbc.stringbased.DefaultKey2StringMapper;
 import org.infinispan.loaders.jdbc.stringbased.Person;
+import org.infinispan.marshall.Marshaller;
 import org.infinispan.marshall.TestObjectStreamMarshaller;
 import org.infinispan.test.fwk.UnitTestDatabaseManager;
 import org.testng.annotations.AfterMethod;
@@ -18,8 +21,8 @@
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.Set;
 
 /**
@@ -38,7 +41,6 @@
    private static final Person MIRCEA = new Person("Mircea", "Markus", 28);
    private static final Person MANIK = new Person("Manik", "Surtani", 18);
 
-
    @BeforeTest
    public void createCacheStore() throws CacheLoaderException {
       stringsTm = UnitTestDatabaseManager.buildDefaultTableManipulation();
@@ -51,7 +53,7 @@
 
       cacheStoreConfig.setKey2StringMapperClass(DefaultKey2StringMapper.class.getName());
       cacheStore = new JdbcMixedCacheStore();
-      cacheStore.init(cacheStoreConfig, null, new TestObjectStreamMarshaller(true));
+      cacheStore.init(cacheStoreConfig, null, getMarshaller());
       cacheStore.start();
    }
 
@@ -109,12 +111,26 @@
       cacheStore.store(InternalEntryFactory.create(MIRCEA, "value1"));
       cacheStore.store(InternalEntryFactory.create(MANIK, "value2"));
       assertRowCounts(2, 2);
-      ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-      ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
-      cacheStore.toStream(objectOutputStream);
-      cacheStore.clear();
+      Marshaller marshaller = getMarshaller();
+      ByteArrayOutputStream out = new ByteArrayOutputStream();
+      ObjectOutput oo = marshaller.startObjectOutput(out, false);
+      try {
+         cacheStore.toStream(new UnclosableObjectOutputStream(oo));
+      } finally {
+         marshaller.finishObjectOutput(oo);
+         out.close();
+         cacheStore.clear();         
+      }
       assertRowCounts(0, 0);
-      cacheStore.fromStream(new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray())));
+      
+      ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+      ObjectInput oi = marshaller.startObjectInput(in, false);
+      try {
+         cacheStore.fromStream(new UnclosableObjectInputStream(oi));         
+      } finally {
+         marshaller.finishObjectInput(oi);
+         in.close();
+      }
       assertRowCounts(2, 2);
       assert cacheStore.load("String").getValue().equals("someValue");
       assert cacheStore.load("String2").getValue().equals("someValue");
@@ -167,7 +183,6 @@
    }
 
    public void testTableConflict() {
-
    }
 
    private void assertRowCounts(int binary, int strings) {
@@ -176,24 +191,22 @@
    }
 
    private void assertStringsRowCount(int rowCount) {
-
       JdbcMixedCacheStore store = (JdbcMixedCacheStore) cacheStore;
       ConnectionFactory connectionFactory = store.getConnectionFactory();
       String tableName = stringsTm.getTableName();
       int value = UnitTestDatabaseManager.rowCount(connectionFactory, tableName);
       assert value == rowCount : "Expected " + rowCount + " rows, actual value is " + value;
-
    }
 
    private void assertBinaryRowCount(int rowCount) {
-
       JdbcMixedCacheStore store = (JdbcMixedCacheStore) cacheStore;
       ConnectionFactory connectionFactory = store.getConnectionFactory();
       String tableName = binaryTm.getTableName();
       int value = UnitTestDatabaseManager.rowCount(connectionFactory, tableName);
       assert value == rowCount : "Expected " + rowCount + " rows, actual value is " + value;
+   }
 
+   protected Marshaller getMarshaller() {
+      return new TestObjectStreamMarshaller(false);
    }
-
-
 }

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.mixed;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * JdbcMixedCacheStoreTest using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.mixed.JdbcMixedCacheStoreVamTest")
+public class JdbcMixedCacheStoreVamTest extends JdbcMixedCacheStoreTest {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/mixed/JdbcMixedCacheStoreVamTest2.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.mixed;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * JdbcMixedCacheStoreTest2 using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.mixed.JdbcMixedCacheStoreVamTest2")
+public class JdbcMixedCacheStoreVamTest2 extends JdbcMixedCacheStoreTest2 {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}

Modified: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java	2009-06-19 18:04:13 UTC (rev 488)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -7,6 +7,7 @@
 import org.infinispan.loaders.jdbc.TableManipulation;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactory;
 import org.infinispan.loaders.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.infinispan.marshall.Marshaller;
 import org.infinispan.marshall.TestObjectStreamMarshaller;
 import org.infinispan.test.fwk.UnitTestDatabaseManager;
 import org.testng.annotations.AfterMethod;
@@ -40,7 +41,7 @@
       config.setKey2StringMapperClass(PersonKey2StringMapper.class.getName());
       config.setPurgeSynchronously(true);
       cacheStore = new JdbcStringBasedCacheStore();
-      cacheStore.init(config, null, new TestObjectStreamMarshaller());
+      cacheStore.init(config, null, getMarshaller());
       cacheStore.start();
    }
 
@@ -135,4 +136,8 @@
       JdbcStringBasedCacheStore store = (JdbcStringBasedCacheStore) cacheStore;
       return store.getConnectionFactory();
    }
+   
+   protected Marshaller getMarshaller() {
+      return new TestObjectStreamMarshaller(false);
+   }
 }

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.stringbased;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * JdbcStringBasedCacheStoreTest using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.stringbased.JdbcStringBasedCacheStoreVamTest")
+public class JdbcStringBasedCacheStoreVamTest extends JdbcStringBasedCacheStoreTest {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}

Added: trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java
===================================================================
--- trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java	                        (rev 0)
+++ trunk/cachestore/jdbc/src/test/java/org/infinispan/loaders/jdbc/stringbased/JdbcStringBasedCacheStoreVamTest2.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.stringbased;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * JdbcStringBasedCacheStoreTest2 using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "loaders.jdbc.stringbased.JdbcStringBasedCacheStoreVamTest2")
+public class JdbcStringBasedCacheStoreVamTest2 extends JdbcStringBasedCacheStoreTest2 {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}

Modified: trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreTest.java
===================================================================
--- trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreTest.java	2009-06-19 18:04:13 UTC (rev 488)
+++ trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -1,17 +1,12 @@
 package org.infinispan.loaders.jdbm;
 
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
 import java.io.File;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
 import java.util.Set;
 
 import org.infinispan.container.entries.InternalCacheEntry;
 import org.infinispan.container.entries.InternalEntryFactory;
-import org.infinispan.io.UnclosableObjectOutputStream;
 import org.infinispan.loaders.BaseCacheStoreTest;
 import org.infinispan.loaders.CacheLoaderException;
 import org.infinispan.loaders.CacheStore;

Added: trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java
===================================================================
--- trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java	                        (rev 0)
+++ trunk/cachestore/jdbm/src/test/java/org/infinispan/loaders/jdbm/JdbmCacheStoreVamTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.jdbm;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * JdbmCacheStoreTest using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "unit", testName = "loaders.jdbm.JdbmCacheStoreVamTest")
+public class JdbmCacheStoreVamTest extends JdbmCacheStoreTest {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}

Modified: trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationTest.java
===================================================================
--- trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationTest.java	2009-06-19 18:04:13 UTC (rev 488)
+++ trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -5,8 +5,8 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.HashSet;
 import java.util.Set;
 
@@ -19,6 +19,7 @@
 import org.infinispan.loaders.CacheStore;
 import org.infinispan.loaders.s3.jclouds.JCloudsBucket;
 import org.infinispan.loaders.s3.jclouds.JCloudsConnection;
+import org.infinispan.marshall.Marshaller;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.BeforeTest;
@@ -145,17 +146,26 @@
       cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
       cs.store(InternalEntryFactory.create("k3", "v3", -1, -1));
 
+      Marshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
-      ObjectOutputStream oos = new ObjectOutputStream(out);
-      cs.toStream(new UnclosableObjectOutputStream(oos));
-      oos.flush();
-      oos.close();
-      out.close();
-      ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
-      cs2.fromStream(new UnclosableObjectInputStream(ois));
+      ObjectOutput oo = marshaller.startObjectOutput(out, false);
+      try {
+         cs.toStream(new UnclosableObjectOutputStream(oo));
+      } finally {
+         marshaller.finishObjectOutput(oo);
+         out.close();
+      }
 
+      ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+      ObjectInput oi = marshaller.startObjectInput(in, false);
+      try {
+         cs2.fromStream(new UnclosableObjectInputStream(oi));         
+      } finally {
+         marshaller.finishObjectInput(oi);
+         in.close();
+      }
+      
       Set<InternalCacheEntry> set = cs2.loadAll();
-
       assertEquals(set.size(), 3);
       Set expected = new HashSet();
       expected.add("k1");
@@ -173,30 +183,39 @@
       cs.store(InternalEntryFactory.create("k2", "v2", -1, -1));
       cs.store(InternalEntryFactory.create("k3", "v3", -1, -1));
 
+      Marshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       byte[] dummyStartBytes = {1, 2, 3, 4, 5, 6, 7, 8};
-      byte[] dummyEndBytes = {8, 7, 6, 5, 4, 3, 2, 1};
-      out.write(dummyStartBytes);
-      ObjectOutputStream oos = new ObjectOutputStream(out);
-      cs.toStream(new UnclosableObjectOutputStream(oos));
-      oos.flush();
-      oos.close();
-      out.write(dummyEndBytes);
-      out.close();
+      byte[] dummyEndBytes = {8, 7, 6, 5, 4, 3, 2, 1};      
+      ObjectOutput oo = marshaller.startObjectOutput(out, false);
+      try {
+         oo.write(dummyStartBytes);
+         cs.toStream(new UnclosableObjectOutputStream(oo));
+         oo.flush();
+         oo.write(dummyEndBytes);
+      } finally {
+         marshaller.finishObjectOutput(oo);
+         out.close();         
+      }
 
       // first pop the start bytes
       byte[] dummy = new byte[8];
       ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-      int bytesRead = in.read(dummy, 0, 8);
-      assertEquals(bytesRead, 8);
-      for (int i = 1; i < 9; i++) assert dummy[i - 1] == i : "Start byte stream corrupted!";
-      cs2.fromStream(new UnclosableObjectInputStream(new ObjectInputStream(in)));
-      bytesRead = in.read(dummy, 0, 8);
-      assertEquals(bytesRead, 8);
-      for (int i = 8; i > 0; i--) assert dummy[8 - i] == i : "Start byte stream corrupted!";
+      ObjectInput oi = marshaller.startObjectInput(in, false);
+      try {
+         int bytesRead = oi.read(dummy, 0, 8);
+         assert bytesRead == 8;
+         for (int i = 1; i < 9; i++) assert dummy[i - 1] == i : "Start byte stream corrupted!";      
+         cs2.fromStream(new UnclosableObjectInputStream(oi));
+         bytesRead = oi.read(dummy, 0, 8);
+         assert bytesRead == 8;
+         for (int i = 8; i > 0; i--) assert dummy[8 - i] == i : "Start byte stream corrupted!";                  
+      } finally {
+         marshaller.finishObjectInput(oi);
+         in.close();
+      }
 
       Set<InternalCacheEntry> set = cs2.loadAll();
-
       assertEquals(set.size(), 3);
       Set expected = new HashSet();
       expected.add("k1");

Added: trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationVamTest.java
===================================================================
--- trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationVamTest.java	                        (rev 0)
+++ trunk/cachestore/s3/src/test/java/org/infinispan/loaders/s3/S3CacheStoreIntegrationVamTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.s3;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * S3CacheStoreIntegrationTest using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "unit", sequential = true, testName = "loaders.s3.S3CacheStoreIntegrationVamTest")
+public class S3CacheStoreIntegrationVamTest extends S3CacheStoreIntegrationTest {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}

Modified: trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java	2009-06-19 18:04:13 UTC (rev 488)
+++ trunk/core/src/test/java/org/infinispan/loaders/BaseCacheStoreTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -21,8 +21,8 @@
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedList;
@@ -429,20 +429,27 @@
       cs.store(InternalEntryFactory.create("k2", "v2"));
       cs.store(InternalEntryFactory.create("k3", "v3"));
 
+      Marshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
-      ObjectOutputStream oos = new ObjectOutputStream(out);
+      ObjectOutput oo = marshaller.startObjectOutput(out, false);
+      try {
+         cs.toStream(new UnclosableObjectOutputStream(oo));
+      } finally {
+         marshaller.finishObjectOutput(oo);
+         out.close();
+         cs.clear();         
+      }
 
-      cs.toStream(new UnclosableObjectOutputStream(oos));
-      oos.flush();
-      oos.close();
-      out.close();
-      cs.clear();
+      ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
+      ObjectInput oi = marshaller.startObjectInput(in, false);
+      try {
+         cs.fromStream(new UnclosableObjectInputStream(oi));         
+      } finally {
+         marshaller.finishObjectInput(oi);
+         in.close();
+      }
 
-      ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(out.toByteArray()));
-      cs.fromStream(new UnclosableObjectInputStream(ois));
-
       Set<InternalCacheEntry> set = cs.loadAll();
-
       assert set.size() == 3;
       Set expected = new HashSet();
       expected.add("k1");
@@ -457,31 +464,40 @@
       cs.store(InternalEntryFactory.create("k2", "v2"));
       cs.store(InternalEntryFactory.create("k3", "v3"));
 
+      Marshaller marshaller = getMarshaller();
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       byte[] dummyStartBytes = {1, 2, 3, 4, 5, 6, 7, 8};
       byte[] dummyEndBytes = {8, 7, 6, 5, 4, 3, 2, 1};
-      out.write(dummyStartBytes);
-      ObjectOutputStream oos = new ObjectOutputStream(out);
-      cs.toStream(new UnclosableObjectOutputStream(oos));
-      oos.flush();
-      oos.close();
-      out.write(dummyEndBytes);
-      out.close();
-      cs.clear();
+      ObjectOutput oo = marshaller.startObjectOutput(out, false);
+      try {
+         oo.write(dummyStartBytes);
+         cs.toStream(new UnclosableObjectOutputStream(oo));
+         oo.flush();
+         oo.write(dummyEndBytes);
+      } finally {
+         marshaller.finishObjectOutput(oo);
+         out.close();
+         cs.clear();         
+      }
 
       // first pop the start bytes
       byte[] dummy = new byte[8];
       ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
-      int bytesRead = in.read(dummy, 0, 8);
-      assert bytesRead == 8;
-      for (int i = 1; i < 9; i++) assert dummy[i - 1] == i : "Start byte stream corrupted!";
-      cs.fromStream(new UnclosableObjectInputStream(new ObjectInputStream(in)));
-      bytesRead = in.read(dummy, 0, 8);
-      assert bytesRead == 8;
-      for (int i = 8; i > 0; i--) assert dummy[8 - i] == i : "Start byte stream corrupted!";
-
-      Set<InternalCacheEntry> set = cs.loadAll();
-
+      ObjectInput oi = marshaller.startObjectInput(in, false);
+      try {
+         int bytesRead = oi.read(dummy, 0, 8);
+         assert bytesRead == 8;
+         for (int i = 1; i < 9; i++) assert dummy[i - 1] == i : "Start byte stream corrupted!";      
+         cs.fromStream(new UnclosableObjectInputStream(oi));
+         bytesRead = oi.read(dummy, 0, 8);
+         assert bytesRead == 8;
+         for (int i = 8; i > 0; i--) assert dummy[8 - i] == i : "Start byte stream corrupted!";                  
+      } finally {
+         marshaller.finishObjectInput(oi);
+         in.close();
+      }
+      
+      Set<InternalCacheEntry> set = cs.loadAll(); 
       assert set.size() == 3;
       Set expected = new HashSet();
       expected.add("k1");
@@ -490,7 +506,7 @@
       for (InternalCacheEntry se : set) assert expected.remove(se.getKey());
       assert expected.isEmpty();
    }
-
+   
    public void testConfigFile() throws Exception {
       Class<? extends CacheLoaderConfig> cfgClass = cs.getConfigurationClass();
       CacheLoaderConfig clc = Util.getInstance(cfgClass);

Added: trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java	                        (rev 0)
+++ trunk/core/src/test/java/org/infinispan/loaders/file/FileCacheStoreVamTest.java	2009-06-19 18:08:18 UTC (rev 489)
@@ -0,0 +1,43 @@
+/*
+ * 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.file;
+
+import org.infinispan.commands.RemoteCommandFactory;
+import org.infinispan.marshall.Marshaller;
+import org.infinispan.marshall.VersionAwareMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * FileCacheStoreTest using production level marshaller.
+ * 
+ * @author Galder Zamarreño
+ * @since 4.0
+ */
+ at Test(groups = "unit", testName = "loaders.file.FileCacheStoreVamTest")
+public class FileCacheStoreVamTest extends FileCacheStoreTest {
+   @Override
+   protected Marshaller getMarshaller() {
+      VersionAwareMarshaller marshaller = new VersionAwareMarshaller();
+      marshaller.init(Thread.currentThread().getContextClassLoader(), new RemoteCommandFactory());
+      return marshaller;
+   }
+}




More information about the infinispan-commits mailing list