~ubuntu-branches/ubuntu/wily/libhibernate3-java/wily-proposed

« back to all changes in this revision

Viewing changes to test/org/hibernate/test/instrument/cases/TestIsPropertyInitializedExecutable.java

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2007-10-14 14:43:34 UTC
  • Revision ID: james.westby@ubuntu.com-20071014144334-eamc8i0q10gs1aro
Tags: upstream-3.2.5
ImportĀ upstreamĀ versionĀ 3.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//$Id: $
 
2
package org.hibernate.test.instrument.cases;
 
3
 
 
4
import org.hibernate.Session;
 
5
import org.hibernate.Transaction;
 
6
import org.hibernate.Hibernate;
 
7
import org.hibernate.test.instrument.domain.Owner;
 
8
import org.hibernate.test.instrument.domain.Document;
 
9
import org.hibernate.test.instrument.domain.Folder;
 
10
import junit.framework.Assert;
 
11
 
 
12
/**
 
13
 * @author Steve Ebersole
 
14
 */
 
15
public class TestIsPropertyInitializedExecutable extends AbstractExecutable {
 
16
        public void execute() {
 
17
                Session s = getFactory().openSession();
 
18
                Transaction t = s.beginTransaction();
 
19
                Owner o = new Owner();
 
20
                Document doc = new Document();
 
21
                Folder fol = new Folder();
 
22
                o.setName("gavin");
 
23
                doc.setName("Hibernate in Action");
 
24
                doc.setSummary("blah");
 
25
                doc.updateText("blah blah");
 
26
                fol.setName("books");
 
27
                doc.setOwner(o);
 
28
                doc.setFolder(fol);
 
29
                fol.getDocuments().add(doc);
 
30
                Assert.assertTrue( Hibernate.isPropertyInitialized( doc, "summary" ) );
 
31
                s.persist(o);
 
32
                s.persist(fol);
 
33
                t.commit();
 
34
                s.close();
 
35
 
 
36
                s = getFactory().openSession();
 
37
                t = s.beginTransaction();
 
38
                doc = (Document) s.get( Document.class, doc.getId() );
 
39
                Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "summary" ) );
 
40
                Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "upperCaseName" ) );
 
41
                Assert.assertFalse( Hibernate.isPropertyInitialized( doc, "owner" ) );
 
42
                s.delete(doc);
 
43
                s.delete( doc.getOwner() );
 
44
                s.delete( doc.getFolder() );
 
45
                t.commit();
 
46
                s.close();
 
47
        }
 
48
}