Author: mircea.markus
Date: 2009-03-04 13:04:58 -0500 (Wed, 04 Mar 2009)
New Revision: 7851
Added:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapperTest.java
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/Person.java
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/PersonKey2StringMapper.java
Removed:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/DefaultKey2StringMapperTest.java
core/branches/flat/src/test/java/org/horizon/loader/jdbc/JdbcStringBasedCacheStoreTest.java
Modified:
core/branches/flat/src/main/java/org/horizon/loader/jdbc/JdbcCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapper.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/Key2StringMapper.java
core/branches/flat/src/test/java/org/horizon/loader/jdbc/UnitTestDatabaseManager.java
Log:
ongoing jdbc cache store work
Modified: core/branches/flat/src/main/java/org/horizon/loader/jdbc/JdbcCacheStore.java
===================================================================
---
core/branches/flat/src/main/java/org/horizon/loader/jdbc/JdbcCacheStore.java 2009-03-04
17:31:09 UTC (rev 7850)
+++
core/branches/flat/src/main/java/org/horizon/loader/jdbc/JdbcCacheStore.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -101,6 +101,6 @@
}
private CacheStore getCacheStore(Object key) {
- return stringBasedCacheStore.supportsKey(key) ? stringBasedCacheStore :
binaryCacheStore;
+ return stringBasedCacheStore.supportsKey(key.getClass()) ? stringBasedCacheStore :
binaryCacheStore;
}
}
Modified:
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapper.java
===================================================================
---
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapper.java 2009-03-04
17:31:09 UTC (rev 7850)
+++
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapper.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -11,8 +11,7 @@
/**
* Returns true if this is an primitive wrapper, false otherwise.
*/
- public boolean isSupportedType(Object key) {
- Class clazz = key.getClass();
+ public boolean isSupportedType(Class key) {
return key == String.class ||
key == Short.class ||
key == Byte.class ||
Modified:
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java
===================================================================
---
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java 2009-03-04
17:31:09 UTC (rev 7850)
+++
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStore.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -311,8 +311,8 @@
throw new CacheLoaderException(message, e);
}
- public boolean supportsKey(Object obj) {
- return key2StringMapper.isSupportedType(obj);
+ public boolean supportsKey(Class keyType) {
+ return key2StringMapper.isSupportedType(keyType);
}
/**
@@ -327,7 +327,7 @@
tableManipulation.start(connectionFactory);
}
- public Object getConnectionFactory() {
+ public ConnectionFactory getConnectionFactory() {
return connectionFactory;
}
}
Modified:
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/Key2StringMapper.java
===================================================================
---
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/Key2StringMapper.java 2009-03-04
17:31:09 UTC (rev 7850)
+++
core/branches/flat/src/main/java/org/horizon/loader/jdbc/stringbased/Key2StringMapper.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -13,7 +13,7 @@
/**
* Do we support this key type?
*/
- boolean isSupportedType(Object key);
+ boolean isSupportedType(Class keyType);
/**
* Must return an unique String for the supplied key.
Deleted:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/DefaultKey2StringMapperTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/jdbc/DefaultKey2StringMapperTest.java 2009-03-04
17:31:09 UTC (rev 7850)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/DefaultKey2StringMapperTest.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -1,34 +0,0 @@
-package org.horizon.loader.jdbc;
-
-import org.testng.annotations.Test;
-import org.horizon.loader.jdbc.stringbased.DefaultKey2StringMapper;
-
-/**
- * Tester for {@link org.horizon.loader.jdbc.stringbased.Key2StringMapper}.
- *
- * @author Mircea.Markus(a)jboss.com
- */
-@Test(groups = "unit", testName =
"loader.jdbc.DefaultKey2StringMapperTest")
-public class DefaultKey2StringMapperTest {
-
- DefaultKey2StringMapper mapper = new DefaultKey2StringMapper();
-
- public void testPrimitivesAreSupported() {
- assert mapper.isSupportedType(Integer.class);
- assert mapper.isSupportedType(Byte.class);
- assert mapper.isSupportedType(Short.class);
- assert mapper.isSupportedType(Long.class);
- assert mapper.isSupportedType(Double.class);
- assert mapper.isSupportedType(Float.class);
- assert mapper.isSupportedType(Boolean.class);
- assert mapper.isSupportedType(String.class);
- }
-
- @SuppressWarnings(value = "all")
- public void testGetStingMapping() {
- Object[] toTest = {new Integer(0), new Byte("1"), new
Short("2"), new Long(3), new Double("3.4"), new
Float("3.5"), Boolean.FALSE, "some string"};
- for (Object o : toTest) {
- assert mapper.getStringMapping(o).equals(o.toString());
- }
- }
-}
Deleted:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/JdbcStringBasedCacheStoreTest.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/jdbc/JdbcStringBasedCacheStoreTest.java 2009-03-04
17:31:09 UTC (rev 7850)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/JdbcStringBasedCacheStoreTest.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -1,58 +0,0 @@
-package org.horizon.loader.jdbc;
-
-import org.horizon.loader.BaseCacheStoreTest;
-import org.horizon.loader.CacheStore;
-import org.horizon.loader.jdbc.connectionfactory.ConnectionFactory;
-import org.horizon.loader.jdbc.connectionfactory.ConnectionFactoryConfig;
-import org.horizon.loader.jdbc.stringbased.JdbcStringBasedCacheStore;
-import org.horizon.loader.jdbc.stringbased.JdbcStringBasedCacheStoreConfig;
-import org.horizon.marshall.ObjectStreamMarshaller;
-import org.testng.annotations.Test;
-import static org.easymock.classextension.EasyMock.*;
-import static org.easymock.classextension.EasyMock.replay;
-import static org.easymock.classextension.EasyMock.verify;
-
-/**
- * Tester class for {@link
org.horizon.loader.jdbc.stringbased.JdbcStringBasedCacheStore}.
- *
- * @author Mircea.Markus(a)jboss.com
- */
-@Test(groups = "functional", testName =
"loader.jdbc.JdbcStringBasedCacheStoreTest")
-public class JdbcStringBasedCacheStoreTest extends BaseCacheStoreTest {
-
- protected CacheStore createCacheStore() throws Exception {
- ConnectionFactoryConfig connectionFactoryConfig =
UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
- TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
- JdbcStringBasedCacheStoreConfig config = new
JdbcStringBasedCacheStoreConfig(connectionFactoryConfig, tm);
- JdbcStringBasedCacheStore jdbcBucketCacheStore = new JdbcStringBasedCacheStore();
- jdbcBucketCacheStore.init(config, null, new ObjectStreamMarshaller());
- jdbcBucketCacheStore.start();
- return jdbcBucketCacheStore;
- }
-
- public void testNotCreateConnectionFactory() throws Exception {
- JdbcStringBasedCacheStore stringBasedCacheStore = new JdbcStringBasedCacheStore();
- JdbcStringBasedCacheStoreConfig config = new
JdbcStringBasedCacheStoreConfig(false);
- config.setCreateTableOnStart(false);
- stringBasedCacheStore.init(config, null, new ObjectStreamMarshaller());
- stringBasedCacheStore.start();
- assert stringBasedCacheStore.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);
- replay(tableManipulation);
- stringBasedCacheStore.doConnectionFactoryInitialization(connectionFactory);
- verify(tableManipulation);
-
- //stop should be called even if this is an external
- reset(tableManipulation, connectionFactory);
- tableManipulation.stop();
- replay(tableManipulation, connectionFactory);
- stringBasedCacheStore.stop();
- verify(tableManipulation, connectionFactory);
- }
-}
Modified:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/UnitTestDatabaseManager.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/jdbc/UnitTestDatabaseManager.java 2009-03-04
17:31:09 UTC (rev 7850)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/UnitTestDatabaseManager.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -75,7 +75,7 @@
TestingUtil.recursiveFileRemove(toDel);
}
- private static String getDatabaseName(Properties prop) {
+ public static String getDatabaseName(Properties prop) {
StringTokenizer tokenizer = new
StringTokenizer(prop.getProperty("cache.jdbc.url"), ":");
tokenizer.nextToken();
tokenizer.nextToken();
Copied:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapperTest.java
(from rev 7847,
core/branches/flat/src/test/java/org/horizon/loader/jdbc/DefaultKey2StringMapperTest.java)
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapperTest.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapperTest.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -0,0 +1,33 @@
+package org.horizon.loader.jdbc.stringbased;
+
+import org.testng.annotations.Test;
+
+/**
+ * Tester for {@link org.horizon.loader.jdbc.stringbased.Key2StringMapper}.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+@Test(groups = "unit", testName =
"loader.jdbc.DefaultKey2StringMapperTest")
+public class DefaultKey2StringMapperTest {
+
+ DefaultKey2StringMapper mapper = new DefaultKey2StringMapper();
+
+ public void testPrimitivesAreSupported() {
+ assert mapper.isSupportedType(Integer.class);
+ assert mapper.isSupportedType(Byte.class);
+ assert mapper.isSupportedType(Short.class);
+ assert mapper.isSupportedType(Long.class);
+ assert mapper.isSupportedType(Double.class);
+ assert mapper.isSupportedType(Float.class);
+ assert mapper.isSupportedType(Boolean.class);
+ assert mapper.isSupportedType(String.class);
+ }
+
+ @SuppressWarnings(value = "all")
+ public void testGetStingMapping() {
+ Object[] toTest = {new Integer(0), new Byte("1"), new
Short("2"), new Long(3), new Double("3.4"), new
Float("3.5"), Boolean.FALSE, "some string"};
+ for (Object o : toTest) {
+ assert mapper.getStringMapping(o).equals(o.toString());
+ }
+ }
+}
Property changes on:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/DefaultKey2StringMapperTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java
(from rev 7848,
core/branches/flat/src/test/java/org/horizon/loader/jdbc/JdbcStringBasedCacheStoreTest.java)
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -0,0 +1,56 @@
+package org.horizon.loader.jdbc.stringbased;
+
+import static org.easymock.classextension.EasyMock.*;
+import org.horizon.loader.BaseCacheStoreTest;
+import org.horizon.loader.CacheStore;
+import org.horizon.loader.jdbc.TableManipulation;
+import org.horizon.loader.jdbc.UnitTestDatabaseManager;
+import org.horizon.loader.jdbc.connectionfactory.ConnectionFactory;
+import org.horizon.loader.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.horizon.marshall.ObjectStreamMarshaller;
+import org.testng.annotations.Test;
+
+/**
+ * Tester class for {@link
org.horizon.loader.jdbc.stringbased.JdbcStringBasedCacheStore}.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+@Test(groups = "functional", testName =
"loader.jdbc.JdbcStringBasedCacheStoreTest")
+public class JdbcStringBasedCacheStoreTest extends BaseCacheStoreTest {
+
+ protected CacheStore createCacheStore() throws Exception {
+ ConnectionFactoryConfig connectionFactoryConfig =
UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+ TableManipulation tm = UnitTestDatabaseManager.buildDefaultTableManipulation();
+ JdbcStringBasedCacheStoreConfig config = new
JdbcStringBasedCacheStoreConfig(connectionFactoryConfig, tm);
+ JdbcStringBasedCacheStore jdbcBucketCacheStore = new JdbcStringBasedCacheStore();
+ jdbcBucketCacheStore.init(config, null, new ObjectStreamMarshaller());
+ jdbcBucketCacheStore.start();
+ return jdbcBucketCacheStore;
+ }
+
+ public void testNotCreateConnectionFactory() throws Exception {
+ JdbcStringBasedCacheStore stringBasedCacheStore = new JdbcStringBasedCacheStore();
+ JdbcStringBasedCacheStoreConfig config = new
JdbcStringBasedCacheStoreConfig(false);
+ config.setCreateTableOnStart(false);
+ stringBasedCacheStore.init(config, null, new ObjectStreamMarshaller());
+ stringBasedCacheStore.start();
+ assert stringBasedCacheStore.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);
+ replay(tableManipulation);
+ stringBasedCacheStore.doConnectionFactoryInitialization(connectionFactory);
+ verify(tableManipulation);
+
+ //stop should be called even if this is an external
+ reset(tableManipulation, connectionFactory);
+ tableManipulation.stop();
+ replay(tableManipulation, connectionFactory);
+ stringBasedCacheStore.stop();
+ verify(tableManipulation, connectionFactory);
+ }
+}
Property changes on:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -0,0 +1,140 @@
+package org.horizon.loader.jdbc.stringbased;
+
+import org.horizon.loader.CacheLoaderException;
+import org.horizon.loader.CacheStore;
+import org.horizon.loader.StoredEntry;
+import org.horizon.loader.jdbc.JdbcUtil;
+import org.horizon.loader.jdbc.TableManipulation;
+import org.horizon.loader.jdbc.UnitTestDatabaseManager;
+import org.horizon.loader.jdbc.connectionfactory.ConnectionFactoryConfig;
+import org.horizon.marshall.ObjectStreamMarshaller;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.Collections;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Tester for {@link JdbcStringBasedCacheStore} with an alternative {@link
org.horizon.loader.jdbc.stringbased.Key2StringMapper}.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+@Test(groups = "functional", testName =
"jdbc.stringbased.JdbcStringBasedCacheStoreTest2")
+public class JdbcStringBasedCacheStoreTest2 {
+
+ CacheStore cacheStore;
+ private ConnectionFactoryConfig cfc;
+ private TableManipulation tableManipulation;
+ 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 {
+ tableManipulation = UnitTestDatabaseManager.buildDefaultTableManipulation();
+ cfc = UnitTestDatabaseManager.getUniqueConnectionFactoryConfig();
+ JdbcStringBasedCacheStoreConfig config = new JdbcStringBasedCacheStoreConfig(cfc,
tableManipulation);
+ config.setKey2StringMapperClass(PersonKey2StringMapper.class.getName());
+ cacheStore = new JdbcStringBasedCacheStore();
+ cacheStore.init(config, null, new ObjectStreamMarshaller());
+ cacheStore.start();
+ }
+
+ @AfterMethod
+ public void clearStore() throws Exception {
+ cacheStore.clear();
+ assert rowCount() == 0;
+ }
+
+ @AfterTest
+ public void destroyStore() throws CacheLoaderException {
+ cacheStore.stop();
+ UnitTestDatabaseManager.shutdownInMemoryDatabase(cfc);
+ }
+
+ /**
+ * When trying to perists an unsupported object an exception is expected.
+ */
+ public void persistUnsupportedObject() throws Exception {
+ try {
+ cacheStore.store(newStoredEntry("key", "value"));
+ assert false : "exception is expected as PersonKey2StringMapper does not
support strings";
+ } catch (UnsupportedKeyTypeException e) {
+ assert true : "expected";
+ }
+ //just check that an person object will be persisted okay
+ cacheStore.store(newStoredEntry(MIRCEA, "Cluj Napoca"));
+ }
+
+ public void testStoreLoadRemove() throws Exception {
+ assert rowCount() == 0;
+ assert cacheStore.load(MIRCEA) == null : "should not be present in the
store";
+ String value = "adsdsadsa";
+ cacheStore.store(newStoredEntry(MIRCEA, value));
+ assert rowCount() == 1;
+ assert cacheStore.load(MIRCEA).getValue().equals(value);
+ assert !cacheStore.remove(MANIK);
+ assert cacheStore.load(MIRCEA).getValue().equals(value);
+ assert rowCount() == 1;
+ assert cacheStore.remove(MIRCEA);
+ assert rowCount() == 0;
+ }
+
+ public void testRemoveAll() throws Exception {
+ assert rowCount() == 0;
+ cacheStore.store(new StoredEntry(MIRCEA, "value"));
+ cacheStore.store(new StoredEntry(MANIK, "value"));
+ assert rowCount() == 2;
+ cacheStore.removeAll(Collections.singleton((Object)MIRCEA));
+ cacheStore.load(MANIK).getValue().equals("value");
+ assert rowCount() == 1;
+ cacheStore.store(new StoredEntry(MIRCEA,"value"));
+ assert rowCount() == 2;
+ Set toRemove = new HashSet();
+ toRemove.add(MIRCEA);
+ toRemove.add(MANIK);
+ cacheStore.removeAll(toRemove);
+ assert rowCount() == 0;
+ }
+
+ public void testClear() throws Exception {
+ assert rowCount() == 0;
+ cacheStore.store(new StoredEntry(MIRCEA, "value"));
+ cacheStore.store(new StoredEntry(MANIK, "value"));
+ assert rowCount() == 2;
+ cacheStore.clear();
+ assert rowCount() == 0;
+ }
+
+ private int rowCount() {
+ JdbcStringBasedCacheStore store = (JdbcStringBasedCacheStore) cacheStore;
+ Connection conn = null;
+ PreparedStatement statement = null;
+ ResultSet resultSet = null;
+ try {
+ conn = store.getConnectionFactory().getConnection();
+ String tableName = tableManipulation.getTableName();
+ String sql = "SELECT count(*) FROM " + tableName;
+ statement = conn.prepareStatement(sql);
+ resultSet = statement.executeQuery();
+ resultSet.next();
+ return resultSet.getInt(1);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ finally {
+ JdbcUtil.safeClose(resultSet);
+ JdbcUtil.safeClose(statement);
+ store.getConnectionFactory().releaseConnection(conn);
+ }
+ }
+
+ private StoredEntry newStoredEntry(Object key, Object value) {
+ return new StoredEntry(key, value);
+ }
+}
Property changes on:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/JdbcStringBasedCacheStoreTest2.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/Person.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/Person.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/Person.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -0,0 +1,54 @@
+package org.horizon.loader.jdbc.stringbased;
+
+import java.io.Serializable;
+
+/**
+ * Pojo used for testing jdbc caches stores.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class Person implements Serializable {
+ private String name;
+ private String surname;
+ private int age;
+
+ public Person(String name, String surname, int age) {
+ this.name = name;
+ this.surname = surname;
+ this.age = age;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getSurname() {
+ return surname;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (!(o instanceof Person)) return false;
+
+ Person person = (Person) o;
+
+ if (age != person.age) return false;
+ if (name != null ? !name.equals(person.name) : person.name != null) return false;
+ if (surname != null ? !surname.equals(person.surname) : person.surname != null)
return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = name != null ? name.hashCode() : 0;
+ result = 31 * result + (surname != null ? surname.hashCode() : 0);
+ result = 31 * result + age;
+ return result;
+ }
+}
Property changes on:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/Person.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/PersonKey2StringMapper.java
===================================================================
---
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/PersonKey2StringMapper.java
(rev 0)
+++
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/PersonKey2StringMapper.java 2009-03-04
18:04:58 UTC (rev 7851)
@@ -0,0 +1,17 @@
+package org.horizon.loader.jdbc.stringbased;
+
+/**
+ * Used for testing jdbc cache stores.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ */
+public class PersonKey2StringMapper implements Key2StringMapper {
+ public boolean isSupportedType(Class keyType) {
+ return keyType == Person.class;
+ }
+
+ public String getStringMapping(Object key) {
+ Person person = (Person) key;
+ return person.getName() + "_" + person.getSurname() + "_" +
person.getAge();
+ }
+}
Property changes on:
core/branches/flat/src/test/java/org/horizon/loader/jdbc/stringbased/PersonKey2StringMapper.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF