public class CompleteComponentPropertyRefTest extends FunctionalTestCase { public CompleteComponentPropertyRefTest(String name) { super( name ); } public String[] getMappings() { return new String[] { "propertyref/component/complete/Mapping.hbm.xml" }; } public static Test suite() { return new FunctionalTestClassTestSuite( CompleteComponentPropertyRefTest.class ); } public void testComponentPropertyRef() { Person p = new Person(); p.setIdentity( new Identity() ); Account a = new Account(); a.setNumber("123-12345-1236"); a.setOwner(p); p.getIdentity().setName("Gavin"); p.getIdentity().setSsn("123-12-1234"); Session s = openSession(); Transaction tx = s.beginTransaction(); s.persist(p); s.persist(a); s.flush(); s.clear(); a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult(); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); s.clear(); a = (Account) s.get(Account.class, "123-12345-1236"); assertFalse( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.clear(); getSessions().evict(Account.class); getSessions().evict(Person.class); a = (Account) s.get(Account.class, "123-12345-1236"); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.delete( a ); s.delete( a.getOwner() ); tx.commit(); s.close();
public class PartialComponentPropertyRefTest extends FunctionalTestCase { public PartialComponentPropertyRefTest(String name) { super( name ); } public String[] getMappings() { return new String[] { "propertyref/component/partial/Mapping.hbm.xml" }; } public static Test suite() { return new FunctionalTestClassTestSuite( PartialComponentPropertyRefTest.class ); } public void testComponentPropertyRef() { Person p = new Person(); p.setIdentity( new Identity() ); Account a = new Account(); a.setNumber("123-12345-1236"); a.setOwner(p); p.getIdentity().setName("Gavin"); p.getIdentity().setSsn("123-12-1234"); Session s = openSession(); Transaction tx = s.beginTransaction(); s.persist(p); s.persist(a); s.flush(); s.clear(); a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult(); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); s.clear(); a = (Account) s.get(Account.class, "123-12345-1236"); assertFalse( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.clear(); getSessions().evict(Account.class); getSessions().evict(Person.class); a = (Account) s.get(Account.class, "123-12345-1236"); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); assertNotNull( a.getOwner() ); assertEquals( "Gavin", a.getOwner().getIdentity().getName() ); assertTrue( Hibernate.isInitialized( a.getOwner() ) ); s.delete( a ); s.delete( a.getOwner() ); tx.commit(); s.close();
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/propertyref/component/complete/CompleteComponentPropertyRefTest.java File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/propertyref/component/partial/PartialComponentPropertyRefTest.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class CompleteComponentPropertyRefTest extends FunctionalTestCase {
1
public class PartialComponentPropertyRefTest extends FunctionalTestCase {
2
	
2
	public CompleteComponentPropertyRefTest(String name) {
3
	public PartialComponentPropertyRefTest(String name) {
3
		super( name );
4
		super( name );
4
	}
5
	}
5
	public String[] getMappings() {
6
	public String[] getMappings() {
6
		return new String[] { "propertyref/component/complete/Mapping.hbm.xml" };
7
		return new String[] { "propertyref/component/partial/Mapping.hbm.xml" };
7
	}
8
	}
8
	public static Test suite() {
9
	public static Test suite() {
9
		return new FunctionalTestClassTestSuite( CompleteComponentPropertyRefTest.class );
10
		return new FunctionalTestClassTestSuite( PartialComponentPropertyRefTest.class );
10
	}
11
	}
12
	
11
	public void testComponentPropertyRef() {
13
	public void testComponentPropertyRef() {
12
		Person p = new Person();
14
		Person p = new Person();
13
		p.setIdentity( new Identity() );
15
		p.setIdentity( new Identity() );
14
		Account a = new Account();
16
		Account a = new Account();
15
		a.setNumber("123-12345-1236");
17
		a.setNumber("123-12345-1236");
16
		a.setOwner(p);
18
		a.setOwner(p);
17
		p.getIdentity().setName("Gavin");
19
		p.getIdentity().setName("Gavin");
18
		p.getIdentity().setSsn("123-12-1234");
20
		p.getIdentity().setSsn("123-12-1234");
19
		Session s = openSession();
21
		Session s = openSession();
20
		Transaction tx = s.beginTransaction();
22
		Transaction tx = s.beginTransaction();
21
		s.persist(p);
23
		s.persist(p);
22
		s.persist(a);
24
		s.persist(a);
23
		s.flush();
25
		s.flush();
24
		s.clear();
26
		s.clear();
27
		
25
		a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
28
		a = (Account) s.createQuery("from Account a left join fetch a.owner").uniqueResult();
26
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
29
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
27
		assertNotNull( a.getOwner() );
30
		assertNotNull( a.getOwner() );
28
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
31
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
29
		s.clear();
32
		s.clear();
33
		
30
		a = (Account) s.get(Account.class, "123-12345-1236");
34
		a = (Account) s.get(Account.class, "123-12345-1236");
31
		assertFalse( Hibernate.isInitialized( a.getOwner() ) );
35
		assertFalse( Hibernate.isInitialized( a.getOwner() ) );
32
		assertNotNull( a.getOwner() );
36
		assertNotNull( a.getOwner() );
33
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
37
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
34
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
38
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
39
		
35
		s.clear();
40
		s.clear();
41
		
36
		getSessions().evict(Account.class);
42
		getSessions().evict(Account.class);
37
		getSessions().evict(Person.class);
43
		getSessions().evict(Person.class);
44
		
38
		a = (Account) s.get(Account.class, "123-12345-1236");
45
		a = (Account) s.get(Account.class, "123-12345-1236");
39
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
46
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
40
		assertNotNull( a.getOwner() );
47
		assertNotNull( a.getOwner() );
41
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
48
		assertEquals( "Gavin", a.getOwner().getIdentity().getName() );
42
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
49
		assertTrue( Hibernate.isInitialized( a.getOwner() ) );
50
		
43
		s.delete( a );
51
		s.delete( a );
44
		s.delete( a.getOwner() );
52
		s.delete( a.getOwner() );
45
		tx.commit();
53
		tx.commit();
46
		s.close();
54
		s.close();
47
	
55
	
Summary
Number of common nesting structure subtrees0
Number of refactorable cases0
Number of non-refactorable cases0
Time elapsed for finding largest common nesting structure subtrees (ms)0.0
Clones location
Number of node comparisons0