Author: steve.ebersole(a)jboss.com
Date: 2007-10-17 00:15:47 -0400 (Wed, 17 Oct 2007)
New Revision: 14089
Modified:
core/branches/Branch_3_2/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java
Log:
cleanup
Modified:
core/branches/Branch_3_2/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java
===================================================================
---
core/branches/Branch_3_2/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java 2007-10-17
04:12:49 UTC (rev 14088)
+++
core/branches/Branch_3_2/test/org/hibernate/test/naturalid/mutable/MutableNaturalIdTest.java 2007-10-17
04:15:47 UTC (rev 14089)
@@ -18,7 +18,7 @@
* @author Gavin King
*/
public class MutableNaturalIdTest extends FunctionalTestCase {
-
+
public MutableNaturalIdTest(String str) {
super(str);
}
@@ -75,78 +75,78 @@
s.getTransaction().commit();
s.close();
}
-
+
public void testNonexistentNaturalIdCache() {
getSessions().getStatistics().clear();
Session s = openSession();
Transaction t = s.beginTransaction();
-
+
Object nullUser = s.createCriteria(User.class)
.add( Restrictions.naturalId()
.set("name", "gavin")
- .set("org", "hb")
+ .set("org", "hb")
)
.setCacheable(true)
.uniqueResult();
-
+
assertNull(nullUser);
-
+
t.commit();
s.close();
-
+
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
-
+
s = openSession();
t = s.beginTransaction();
-
+
User u = new User("gavin", "hb", "secret");
s.persist(u);
-
+
t.commit();
s.close();
-
+
getSessions().getStatistics().clear();
s = openSession();
t = s.beginTransaction();
-
+
u = (User) s.createCriteria(User.class)
.add( Restrictions.naturalId()
.set("name", "gavin")
- .set("org", "hb")
+ .set("org", "hb")
)
.setCacheable(true)
.uniqueResult();
-
+
assertNotNull(u);
-
+
t.commit();
s.close();
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
-
+
getSessions().getStatistics().clear();
s = openSession();
t = s.beginTransaction();
-
+
u = (User) s.createCriteria(User.class)
.add( Restrictions.naturalId()
.set("name", "gavin")
- .set("org", "hb")
+ .set("org", "hb")
).setCacheable(true)
.uniqueResult();
-
+
s.delete(u);
-
+
t.commit();
s.close();
-
+
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
@@ -154,94 +154,86 @@
s = openSession();
t = s.beginTransaction();
-
+
nullUser = s.createCriteria(User.class)
.add( Restrictions.naturalId()
.set("name", "gavin")
- .set("org", "hb")
+ .set("org", "hb")
)
.setCacheable(true)
.uniqueResult();
-
+
assertNull(nullUser);
-
+
t.commit();
s.close();
-
+
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 0 );
-
+
}
public void testNaturalIdCache() {
Session s = openSession();
Transaction t = s.beginTransaction();
-
- User u = new User("gavin", "hb", "secret");
- s.persist(u);
-
+ User u = new User( "gavin", "hb", "secret" );
+ s.persist( u );
t.commit();
s.close();
-
+
getSessions().getStatistics().clear();
s = openSession();
t = s.beginTransaction();
-
- u = (User) s.createCriteria(User.class)
- .add( Restrictions.naturalId()
- .set("name", "gavin")
- .set("org", "hb")
- )
- .setCacheable(true)
- .uniqueResult();
-
- assertNotNull(u);
-
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set( "name", "gavin" )
+ .set( "org", "hb" )
+ )
+ .setCacheable( true )
+ .uniqueResult();
+ assertNotNull( u );
t.commit();
s.close();
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
assertEquals( getSessions().getStatistics().getQueryCachePutCount(), 1 );
-
+
s = openSession();
t = s.beginTransaction();
-
User v = new User("xam", "hb", "foobar");
s.persist(v);
-
t.commit();
s.close();
-
+
getSessions().getStatistics().clear();
s = openSession();
t = s.beginTransaction();
-
- u = (User) s.createCriteria( User.class)
- .add( Restrictions.naturalId()
- .set("name", "gavin")
- .set("org", "hb")
- ).setCacheable(true)
- .uniqueResult();
-
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set("name", "gavin")
+ .set("org", "hb")
+ )
+ .setCacheable( true )
+ .uniqueResult();
assertNotNull(u);
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 0 );
- u = (User) s.createCriteria( User.class)
- .add( Restrictions.naturalId()
- .set("name", "gavin")
- .set("org", "hb")
- ).setCacheable(true)
- .uniqueResult();
-
+ u = ( User ) s.createCriteria( User.class )
+ .add( Restrictions.naturalId()
+ .set("name", "gavin")
+ .set("org", "hb")
+ )
+ .setCacheable( true )
+ .uniqueResult();
assertNotNull(u);
assertEquals( getSessions().getStatistics().getQueryExecutionCount(), 1 );
assertEquals( getSessions().getStatistics().getQueryCacheHitCount(), 1 );
-
+
t.commit();
s.close();