Author: gbadner
Date: 2009-12-18 16:42:42 -0500 (Fri, 18 Dec 2009)
New Revision: 18271
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java
Log:
HHH-4642 : added test cases showing unexpected results when an updated entity is changed
from read-only to modifiable
Modified:
core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java
===================================================================
---
core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java 2009-12-18
20:44:35 UTC (rev 18270)
+++
core/trunk/testsuite/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java 2009-12-18
21:42:42 UTC (rev 18271)
@@ -127,7 +127,7 @@
s.close();
}
- public void testSetUpdateReadOnlyTwice() throws Exception {
+ public void testUpdateSetReadOnlyTwice() throws Exception {
Session s = openSession();
s.beginTransaction();
VersionedNode node = new VersionedNode( "node", "node" );
@@ -192,6 +192,72 @@
s.close();
}
+ public void testUpdateSetReadOnlySetModifiableFailureExpected() throws Exception {
+ Session s = openSession();
+ s.beginTransaction();
+ VersionedNode node = new VersionedNode( "node", "node" );
+ s.persist( node );
+ s.getTransaction().commit();
+ s.close();
+
+ clearCounts();
+
+ s = openSession();
+
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ node.setName( "node-name" );
+ s.setReadOnly( node, true );
+ s.setReadOnly( node, false );
+ s.getTransaction().commit();
+ s.close();
+
+ assertUpdateCount( 1 );
+ assertInsertCount( 0 );
+
+ s = openSession();
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ assertEquals( "node-name", node.getName() );
+ assertEquals( 1, node.getVersion() );
+ s.delete( node );
+ s.getTransaction().commit();
+ s.close();
+ }
+
+ public void testSetReadOnlyUpdateSetModifiableFailureExpected() throws Exception {
+ Session s = openSession();
+ s.beginTransaction();
+ VersionedNode node = new VersionedNode( "node", "node" );
+ s.persist( node );
+ s.getTransaction().commit();
+ s.close();
+
+ clearCounts();
+
+ s = openSession();
+
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ s.setReadOnly( node, true );
+ node.setName( "node-name" );
+ s.setReadOnly( node, false );
+ s.getTransaction().commit();
+ s.close();
+
+ assertUpdateCount( 1 );
+ assertInsertCount( 0 );
+
+ s = openSession();
+ s.beginTransaction();
+ node = ( VersionedNode ) s.get( VersionedNode.class, node.getId() );
+ assertEquals( "node-name", node.getName() );
+ assertEquals( 1, node.getVersion() );
+ s.delete( node );
+ s.getTransaction().commit();
+ s.close();
+ }
+
public void testAddNewChildToReadOnlyParent() throws Exception {
Session s = openSession();
s.beginTransaction();