Author: max.ross
Date: 2007-09-04 18:34:13 -0400 (Tue, 04 Sep 2007)
New Revision: 14000
Modified:
shards/trunk/src/java/org/hibernate/shards/session/ShardedSessionImpl.java
shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java
shards/trunk/src/test/org/hibernate/shards/session/ShardedSessionImplTest.java
Log:
HSHARDS-46
ShardedSessionImpl.isOpen() now behaves the same way SessionImpl.isOpen() does
Modified: shards/trunk/src/java/org/hibernate/shards/session/ShardedSessionImpl.java
===================================================================
--- shards/trunk/src/java/org/hibernate/shards/session/ShardedSessionImpl.java 2007-09-04
11:52:01 UTC (rev 13999)
+++ shards/trunk/src/java/org/hibernate/shards/session/ShardedSessionImpl.java 2007-09-04
22:34:13 UTC (rev 14000)
@@ -456,13 +456,7 @@
}
public boolean isOpen() {
- // one open session means the sharded session is open
- for (Shard shard : shards) {
- if (shard.getSession() != null && shard.getSession().isOpen()) {
- return true;
- }
- }
- return false;
+ return !closed;
}
public boolean isConnected() {
Modified:
shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java
===================================================================
---
shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java 2007-09-04
11:52:01 UTC (rev 13999)
+++
shards/trunk/src/test/org/hibernate/shards/integration/model/ModelCriteriaPermutedIntegrationTest.java 2007-09-04
22:34:13 UTC (rev 14000)
@@ -229,10 +229,10 @@
Criteria officeCrit = floorCrit.createCriteria("offices");
officeCrit.add(Restrictions.eq("label", "LAHGE"));
// now how we execute the query via the floorcrit
- List<Integer> l = list(officeCrit);
- assertEquals(1, l.size());
+ List<Integer> list = list(officeCrit);
+ assertEquals(1, list.size());
int total = 0;
- for(int shardTotal : l) {
+ for(int shardTotal : list) {
total += shardTotal;
}
assertEquals(2, total);
Modified: shards/trunk/src/test/org/hibernate/shards/session/ShardedSessionImplTest.java
===================================================================
---
shards/trunk/src/test/org/hibernate/shards/session/ShardedSessionImplTest.java 2007-09-04
11:52:01 UTC (rev 13999)
+++
shards/trunk/src/test/org/hibernate/shards/session/ShardedSessionImplTest.java 2007-09-04
22:34:13 UTC (rev 14000)
@@ -667,4 +667,20 @@
}
}
+ public void testIsOpen() {
+ ShardedSessionFactoryImplementor ssf = new ShardedSessionFactoryDefaultMock() {
+ @Override
+ public Map<SessionFactoryImplementor, Set<ShardId>>
getSessionFactoryShardIdMap() {
+ return Collections.emptyMap();
+ }
+ };
+
+ ShardStrategy shardStrategy = new ShardStrategyDefaultMock();
+ Set<Class<?>> classesRequiringShardLocks = Sets.newHashSet();
+ ShardedSessionImpl ssi =
+ new ShardedSessionImpl(ssf, shardStrategy, classesRequiringShardLocks, true);
+ assertTrue(ssi.isOpen());
+ ssi.close();
+ assertFalse(ssi.isOpen());
+ }
}
Show replies by date