File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/proxy/ProxyTest.java | File path: /hibernate-distribution-3.3.2.GA/project/testsuite/src/test/java/org/hibernate/test/proxy/ProxyTest.java | |||
Method name: void testProxyException()
|
Method name: void testProxySerializationAfterSessionClosed()
|
|||
Number of AST nodes: 17 | Number of AST nodes: 18 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | Transaction t = s.beginTransaction();↵ | 2 | Transaction t = s.beginTransaction();↵ | |
3 | DataPoint dp = new DataPoint();↵ | 3 | DataPoint dp = new DataPoint();↵ | |
4 | dp.setDescription("a data point");↵ | 4 | dp.setDescription("a data point");↵ | |
5 | dp.setX( new BigDecimal(1.0) );↵ | 5 | dp.setX( new BigDecimal(1.0) );↵ | |
6 | dp.setY( new BigDecimal(2.0) );↵ | 6 | dp.setY( new BigDecimal(2.0) );↵ | |
7 | s.persist(dp);↵ | 7 | s.persist(dp);↵ | |
8 | s.flush();↵ | 8 | s.flush();↵ | |
9 | s.clear();↵ | 9 | s.clear();↵ | |
10 | ↵ | |||
11 | dp = (DataPoint) s.load(DataPoint.class, new Long( dp.getId() ) );↵ | 10 | dp = (DataPoint) s.load( DataPoint.class, new Long( dp.getId() ) );↵ | |
12 | assertFalse( Hibernate.isInitialized(dp) );↵ | 11 | assertFalse( Hibernate.isInitialized(dp) );↵ | |
13 | ↵ | 12 | ↵ | |
14 | try {↵ | |||
15 | dp.exception();↵ | |||
16 | fail();↵ | |||
17 | }↵ | |||
18 | catch (Exception e) {↵ | |||
19 | assertTrue( e.getClass()==Exception.class );↵ | |||
20 | }↵ | 13 | s.close();↵ | |
14 | SerializationHelper.clone( dp );↵ | |||
15 | s = openSession();↵ | |||
16 | t = s.beginTransaction();↵ | |||
21 | s.delete(dp);↵ | 17 | s.delete( dp );↵ | |
22 | t.commit();↵ | 18 | t.commit();↵ | |
23 | s.close(); | 19 |
| |
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.0 |
Clones location | Clones are declared in the same class |
Number of node comparisons | 124 |
Number of mapped statements | 14 |
Number of unmapped statements in the first code fragment | 0 |
Number of unmapped statements in the second code fragment | 4 |
Time elapsed for statement mapping (ms) | 0.0 |
Clone type | Type 3 |
ID | Statement | ID | Statement | ||||
---|---|---|---|---|---|---|---|
1 | Session s = openSession(); | 1 | Session s = openSession(); | ||||
2 | Transaction t = s.beginTransaction(); | 2 | Transaction t = s.beginTransaction(); | ||||
3 | DataPoint dp = new DataPoint(); | 3 | DataPoint dp = new DataPoint(); | ||||
4 | dp.setDescription("a data point"); | 4 | dp.setDescription("a data point"); | ||||
5 | dp.setX(new BigDecimal(1.0)); | 5 | dp.setX(new BigDecimal(1.0)); | ||||
6 | dp.setY(new BigDecimal(2.0)); | 6 | dp.setY(new BigDecimal(2.0)); | ||||
7 | s.persist(dp); | 7 | s.persist(dp); | ||||
8 | s.flush(); | 8 | s.flush(); | ||||
9 | s.clear(); | 9 | s.clear(); | ||||
10 | dp = (DataPoint)s.load(DataPoint.class, new Long(dp.getId())); | 10 | dp = (DataPoint)s.load(DataPoint.class, new Long(dp.getId())); | ||||
11 | assertFalse(Hibernate.isInitialized(dp)); | 11 | assertFalse(Hibernate.isInitialized(dp)); | ||||
|
| 13 | SerializationHelper.clone(dp); | ||||
|
| 14 | s = openSession(); | ||||
|
| 15 | t = s.beginTransaction(); | ||||
15 | s.delete(dp); | 16 | s.delete(dp); | ||||
16 | t.commit(); | 17 | t.commit(); | ||||
17 | s.close(); | 12 | s.close(); | ||||
| 18 | s.close(); |
Row | Violation |
---|---|
1 | Unmatched statement SerializationHelper.clone(dp); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
2 | Unmatched statement s=openSession(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
3 | Unmatched statement t=s.beginTransaction(); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
4 | Clone fragment #1 returns variables dp , while Clone fragment #2 returns variables dp, s, t |