added additional test

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@12928 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2007-08-13 22:15:53 +00:00
parent b1fdf81549
commit 81f31939c5
1 changed files with 32 additions and 1 deletions

View File

@ -28,7 +28,7 @@ public class ReadOnlyTest extends FunctionalTestCase {
}
public String[] getMappings() {
return new String[] { "readonly/DataPoint.hbm.xml" };
return new String[] { "readonly/DataPoint.hbm.xml", "readonly/TextHolder.hbm.xml" };
}
public void configure(Configuration cfg) {
@ -117,5 +117,36 @@ public class ReadOnlyTest extends FunctionalTestCase {
}
public void testReadOnlyOnTextType() {
final String origText = "some huge text string";
final String newText = "some even bigger text string";
Session s = openSession();
s.beginTransaction();
s.setCacheMode( CacheMode.IGNORE );
TextHolder holder = new TextHolder( origText );
s.save( holder );
Long id = holder.getId();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
s.setCacheMode( CacheMode.IGNORE );
holder = ( TextHolder ) s.get( TextHolder.class, id );
s.setReadOnly( holder, true );
holder.setTheText( newText );
s.flush();
s.getTransaction().commit();
s.close();
s = openSession();
s.beginTransaction();
holder = ( TextHolder ) s.get( TextHolder.class, id );
assertEquals( "change written to database", origText, holder.getTheText() );
s.delete( holder );
s.getTransaction().commit();
s.close();
}
}