File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/lazycache/InstrumentCacheTest.java | |||
Method name: void testInitFromCache2()
|
Method name: void testInitFromCache()
|
|||
Number of AST nodes: 34 | Number of AST nodes: 34 | |||
1 | if ( !isRunnable() ) {↵ | 1 | if ( !isRunnable() ) {↵ | |
2 | reportSkip( "classes not instrumented", "instrumentation tests" );↵ | 2 | reportSkip( "classes not instrumented", "instrumentation tests" );↵ | |
3 | return;↵ | 3 | return;↵ | |
4 | }↵ | 4 | }↵ | |
5 | Session s;↵ | 5 | Session s;↵ | |
6 | Transaction tx;↵ | 6 | Transaction tx;↵ | |
7 | s = getSessions().openSession();↵ | 7 | s = getSessions().openSession();↵ | |
8 | tx = s.beginTransaction();↵ | 8 | tx = s.beginTransaction();↵ | |
9 | s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );↵ | 9 | s.persist( new Document("HiA", "Hibernate book", "Hibernate is....") );↵ | |
10 | tx.commit();↵ | 10 | tx.commit();↵ | |
11 | s.close();↵ | 11 | s.close();↵ | |
12 | s = getSessions().openSession();↵ | 12 | s = getSessions().openSession();↵ | |
13 | tx = s.beginTransaction();↵ | 13 | tx = s.beginTransaction();↵ | |
14 | s.createQuery("from Document fetch all properties").uniqueResult();↵ | 14 | s.createQuery("from Document fetch all properties").uniqueResult();↵ | |
15 | tx.commit();↵ | 15 | tx.commit();↵ | |
16 | s.close();↵ | 16 | s.close();↵ | |
17 | getSessions().getStatistics().clear();↵ | 17 | getSessions().getStatistics().clear();↵ | |
18 | s = getSessions().openSession();↵ | 18 | s = getSessions().openSession();↵ | |
19 | tx = s.beginTransaction();↵ | 19 | tx = s.beginTransaction();↵ | |
20 | Document d = (Document) s.createCriteria(Document.class).uniqueResult();↵ | 20 | Document d = (Document) s.createCriteria(Document.class).uniqueResult();↵ | |
21 | assertFalse( Hibernate.isPropertyInitialized(d, "text") );↵ | 21 | assertFalse( Hibernate.isPropertyInitialized(d, "text") );↵ | |
22 | assertFalse( Hibernate.isPropertyInitialized(d, "summary") );↵ | 22 | assertFalse( Hibernate.isPropertyInitialized(d, "summary") );↵ | |
23 | assertEquals( "Hibernate is....", d.getText() );↵ | 23 | assertEquals( "Hibernate is....", d.getText() );↵ | |
24 | assertTrue( Hibernate.isPropertyInitialized(d, "text") );↵ | 24 | assertTrue( Hibernate.isPropertyInitialized(d, "text") );↵ | |
25 | assertTrue( Hibernate.isPropertyInitialized(d, "summary") );↵ | 25 | assertTrue( Hibernate.isPropertyInitialized(d, "summary") );↵ | |
26 | tx.commit();↵ | 26 | tx.commit();↵ | |
27 | s.close();↵ | 27 | s.close();↵ | |
28 | assertEquals( 1, getSessions().getStatistics().getPrepareStatementCount() );↵ | 28 | assertEquals( 2, getSessions().getStatistics().getPrepareStatementCount() );↵ | |
29 | s = getSessions().openSession();↵ | 29 | s = getSessions().openSession();↵ | |
30 | tx = s.beginTransaction();↵ | 30 | tx = s.beginTransaction();↵ | |
31 | d = (Document) s.get(Document.class, d.getId());↵ | 31 | d = (Document) s.get(Document.class, d.getId());↵ | |
32 | assertTrue( Hibernate.isPropertyInitialized(d, "text") );↵ | 32 | assertFalse( Hibernate.isPropertyInitialized(d, "text") );↵ | |
33 | assertTrue( Hibernate.isPropertyInitialized(d, "summary") );↵ | 33 | assertFalse( Hibernate.isPropertyInitialized(d, "summary") );↵ | |
34 | tx.commit();↵ | 34 | tx.commit();↵ | |
35 | s.close(); | 35 |
| |
See real code fragment | See real code fragment |
Number of common nesting structure subtrees | 1 |
Number of refactorable cases | 0 |
Number of non-refactorable cases | 1 |
Time elapsed for finding largest common nesting structure subtrees (ms) | 0.1 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 278 |
Number of mapped statements | 34 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 0 |
Time elapsed for statement mapping (ms) | 27.1 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | if (!isRunnable()) | 1 | if (!isRunnable()) | |||||||||||||||
2 | reportSkip("classes not instrumented", "instrumentation tests"); | 2 | reportSkip("classes not instrumented", "instrumentation tests"); | |||||||||||||||
3 | return; | 3 | return; | |||||||||||||||
4 | Session s; | 4 | Session s; | |||||||||||||||
5 | Transaction tx; | 5 | Transaction tx; | |||||||||||||||
6 | s = getSessions().openSession(); | 6 | s = getSessions().openSession(); | |||||||||||||||
7 | tx = s.beginTransaction(); | 7 | tx = s.beginTransaction(); | |||||||||||||||
8 | s.persist(new Document("HiA", "Hibernate book", "Hibernate is....")); | 8 | s.persist(new Document("HiA", "Hibernate book", "Hibernate is....")); | |||||||||||||||
9 | tx.commit(); | 9 | tx.commit(); | |||||||||||||||
10 | s.close(); | 10 | s.close(); | |||||||||||||||
11 | s = getSessions().openSession(); | 11 | s = getSessions().openSession(); | |||||||||||||||
12 | tx = s.beginTransaction(); | 12 | tx = s.beginTransaction(); | |||||||||||||||
13 | s.createQuery("from Document fetch all properties").uniqueResult(); | 13 | s.createQuery("from Document fetch all properties").uniqueResult(); | |||||||||||||||
14 | tx.commit(); | 14 | tx.commit(); | |||||||||||||||
15 | s.close(); | 15 | s.close(); | |||||||||||||||
16 | getSessions().getStatistics().clear(); | 16 | getSessions().getStatistics().clear(); | |||||||||||||||
17 | s = getSessions().openSession(); | 17 | s = getSessions().openSession(); | |||||||||||||||
18 | tx = s.beginTransaction(); | 18 | tx = s.beginTransaction(); | |||||||||||||||
19 | Document d = (Document)s.createCriteria(Document.class).uniqueResult(); | 19 | Document d = (Document)s.createCriteria(Document.class).uniqueResult(); | |||||||||||||||
20 | assertFalse(Hibernate.isPropertyInitialized(d, "text")); | 20 | assertFalse(Hibernate.isPropertyInitialized(d, "text")); | |||||||||||||||
21 | assertFalse(Hibernate.isPropertyInitialized(d, "summary")); | 21 | assertFalse(Hibernate.isPropertyInitialized(d, "summary")); | |||||||||||||||
22 | assertEquals("Hibernate is....", d.getText()); | 22 | assertEquals("Hibernate is....", d.getText()); | |||||||||||||||
23 | assertTrue(Hibernate.isPropertyInitialized(d, "text")); | 23 | assertTrue(Hibernate.isPropertyInitialized(d, "text")); | |||||||||||||||
24 | assertTrue(Hibernate.isPropertyInitialized(d, "summary")); | 24 | assertTrue(Hibernate.isPropertyInitialized(d, "summary")); | |||||||||||||||
25 | tx.commit(); | 25 | tx.commit(); | |||||||||||||||
26 | s.close(); | 26 | s.close(); | |||||||||||||||
27 | assertEquals(1, getSessions().getStatistics().getPrepareStatementCount()); |
| 27 | assertEquals(2, getSessions().getStatistics().getPrepareStatementCount()); | ||||||||||||||
28 | s = getSessions().openSession(); | 28 | s = getSessions().openSession(); | |||||||||||||||
29 | tx = s.beginTransaction(); | 29 | tx = s.beginTransaction(); | |||||||||||||||
30 | d = (Document)s.get(Document.class, d.getId()); | 30 | d = (Document)s.get(Document.class, d.getId()); | |||||||||||||||
31 | assertTrue(Hibernate.isPropertyInitialized(d, "text")); |
| 31 | assertFalse(Hibernate.isPropertyInitialized(d, "text")); | ||||||||||||||
32 | assertTrue(Hibernate.isPropertyInitialized(d, "summary")); |
| 32 | assertFalse(Hibernate.isPropertyInitialized(d, "summary")); | ||||||||||||||
33 | tx.commit(); | 33 | tx.commit(); | |||||||||||||||
34 | s.close(); | 34 | s.close(); |
Row | Violation |
---|---|
1 | Expression assertTrue(Hibernate.isPropertyInitialized(d,"text")) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
2 | Expression assertFalse(Hibernate.isPropertyInitialized(d,"text")) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
3 | Expression assertTrue(Hibernate.isPropertyInitialized(d,"text")) is a void method call, and thus it cannot be parameterized |
4 | Expression assertFalse(Hibernate.isPropertyInitialized(d,"text")) is a void method call, and thus it cannot be parameterized |
5 | Expression assertTrue(Hibernate.isPropertyInitialized(d,"summary")) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
6 | Expression assertFalse(Hibernate.isPropertyInitialized(d,"summary")) cannot be parameterized, because it has dependencies to/from statements that will be extracted |
7 | Expression assertTrue(Hibernate.isPropertyInitialized(d,"summary")) is a void method call, and thus it cannot be parameterized |
8 | Expression assertFalse(Hibernate.isPropertyInitialized(d,"summary")) is a void method call, and thus it cannot be parameterized |