File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/functional/AbstractQueryCacheFunctionalTestCase.java | File path: /hibernate-distribution-3.3.2.GA/project/testing/src/main/java/org/hibernate/test/cache/BaseCacheProviderTestCase.java | |||
Method name: void testQueryCacheInvalidation()
|
Method name: void testQueryCacheInvalidation()
|
|||
Number of AST nodes: 33 | Number of AST nodes: 33 | |||
1 | Session s = openSession();↵ | 1 | Session s = openSession();↵ | |
2 | ↵ | |||
3 | Transaction t = s.beginTransaction();↵ | 2 | Transaction t = s.beginTransaction();↵ | |
4 | ↵ | |||
5 | Item i = new Item();↵ | 3 | Item i = new Item();↵ | |
6 | ↵ | |||
7 | i.setName("widget");↵ | 4 | i.setName("widget");↵ | |
8 | ↵ | |||
9 | i.setDescription("A really top-quality, full-featured widget.");↵ | 5 | i.setDescription("A really top-quality, full-featured widget.");↵ | |
10 | ↵ | |||
11 | s.persist(i);↵ | 6 | s.persist(i);↵ | |
12 | ↵ | |||
13 | t.commit();↵ | 7 | t.commit();↵ | |
14 | s.close();↵ | |||
15 | ↵ | |||
8 | s.close();↵ | |||
16 | SecondLevelCacheStatistics slcs = s.getSessionFactory().getStatistics()↵ | 9 | SecondLevelCacheStatistics slcs = s.getSessionFactory().getStatistics()↵ | |
17 | .getSecondLevelCacheStatistics(↵ | 10 | .getSecondLevelCacheStatistics(↵ | |
18 | getPrefixedRegionName(Item.class.getName()));↵ | 11 | Item.class.getName() );↵ | |
19 | ↵ | |||
20 | assertEquals(slcs.getPutCount(), 1);↵ | 12 | assertEquals( slcs.getPutCount(), 1 );↵ | |
21 | ↵ | |||
22 | assertEquals(slcs.getElementCountInMemory(), 1);↵ | 13 | assertEquals( slcs.getElementCountInMemory(), 1 );↵ | |
23 | ↵ | |||
24 | assertEquals(slcs.getEntries().size(), 1);↵ | 14 | assertEquals( slcs.getEntries().size(), 1 );↵ | |
25 | ↵ | |||
26 | s = openSession();↵ | 15 | s = openSession();↵ | |
27 | ↵ | |||
28 | t = s.beginTransaction();↵ | 16 | t = s.beginTransaction();↵ | |
29 | ↵ | |||
30 | i = (Item) s.get(Item.class, i.getId());↵ | 17 | i = (Item) s.get( Item.class, i.getId() );↵ | |
31 | ↵ | |||
32 | assertEquals(slcs.getHitCount(), 1);↵ | 18 | assertEquals( slcs.getHitCount(), 1 );↵ | |
33 | ↵ | |||
34 | assertEquals(slcs.getMissCount(), 0);↵ | 19 | assertEquals( slcs.getMissCount(), 0 );↵ | |
35 | ↵ | |||
36 | i.setDescription("A bog standard item");↵ | 20 | i.setDescription("A bog standard item");↵ | |
37 | ↵ | |||
38 | t.commit();↵ | 21 | t.commit();↵ | |
39 | s.close();↵ | |||
40 | ↵ | |||
22 | s.close();↵ | |||
41 | assertEquals(slcs.getPutCount(), 2);↵ | 23 | assertEquals( slcs.getPutCount(), 2 );↵ | |
42 | ↵ | |||
43 | Object entry = slcs.getEntries().get(i.getId());↵ | 24 | Object entry = slcs.getEntries().get( i.getId() );↵ | |
44 | Map map;↵ | |||
45 | ↵ | |||
25 | Map map;↵ | |||
46 | if (entry instanceof ReadWriteCache.Item) {↵ | 26 | if ( entry instanceof ReadWriteCache.Item ) {↵ | |
47 | ↵ | |||
48 | map = (Map) ((ReadWriteCache.Item) entry).getValue();↵ | 27 | map = (Map) ( (ReadWriteCache.Item) entry ).getValue();↵ | |
49 | } else {↵ | |||
50 | map = (Map) entry;↵ | |||
51 | }↵ | |||
52 | ↵ | |||
28 | }↵ | |||
29 | else {↵ | |||
30 | map = (Map) entry;↵ | |||
31 | }↵ | |||
53 | assertTrue(map.get("description").equals("A bog standard item"));↵ | 32 | assertTrue( map.get("description").equals("A bog standard item") );↵ | |
54 | ↵ | |||
55 | assertTrue(map.get("name").equals("widget"));↵ | 33 | assertTrue( map.get("name").equals("widget") );↵ | |
56 | // cleanup↵ | |||
57 | ↵ | |||
34 | // cleanup↵ | |||
58 | s = openSession();↵ | 35 | s = openSession();↵ | |
59 | ↵ | |||
60 | t = s.beginTransaction();↵ | 36 | t = s.beginTransaction();↵ | |
61 | ↵ | |||
62 | s.delete(i);↵ | 37 | s.delete(↵ | |
63 | ↵ | 38 | i );↵ | |
64 | t.commit();↵ | 39 | t.commit();↵ | |
65 | ↵ | |||
66 | s.close(); | 40 | s.close(); | |
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.2 |
Clones location | Clones are in different classes having the same super class |
Number of node comparisons | 329 |
Number of mapped statements | 31 |
Number of unmapped statements in the first code fragment | 2 |
Number of unmapped statements in the second code fragment | 2 |
Time elapsed for statement mapping (ms) | 27.6 |
Clone type | Type 2 |
ID | Statement | ID | Statement | |||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Session s = openSession(); | 1 | Session s = openSession(); | |||||||||||||||||
2 | Transaction t = s.beginTransaction(); | 2 | Transaction t = s.beginTransaction(); | |||||||||||||||||
| 3 | Item i = new Item(); | ||||||||||||||||||
3 | Item i = new Item(); | | ||||||||||||||||||
4 | i.setName("widget"); |
| 4 | i.setName("widget"); | ||||||||||||||||
5 | i.setDescription("A really top-quality, full-featured widget."); |
| 5 | i.setDescription("A really top-quality, full-featured widget."); | ||||||||||||||||
6 | s.persist(i); |
| 6 | s.persist(i); | ||||||||||||||||
7 | t.commit(); | 7 | t.commit(); | |||||||||||||||||
8 | s.close(); | 8 | s.close(); | |||||||||||||||||
9 | SecondLevelCacheStatistics slcs = s.getSessionFactory().getStatistics().getSecondLevelCacheStatistics(getPrefixedRegionName(Item.class.getName())); |
| 9 | SecondLevelCacheStatistics slcs = s.getSessionFactory().getStatistics().getSecondLevelCacheStatistics(Item.class.getName()); | ||||||||||||||||
10 | assertEquals(slcs.getPutCount(), 1); | 10 | assertEquals(slcs.getPutCount(), 1); | |||||||||||||||||
11 | assertEquals(slcs.getElementCountInMemory(), 1); | 11 | assertEquals(slcs.getElementCountInMemory(), 1); | |||||||||||||||||
12 | assertEquals(slcs.getEntries().size(), 1); | 12 | assertEquals(slcs.getEntries().size(), 1); | |||||||||||||||||
13 | s = openSession(); | 13 | s = openSession(); | |||||||||||||||||
14 | t = s.beginTransaction(); | 14 | t = s.beginTransaction(); | |||||||||||||||||
|
| 15 | i = (Item)s.get(Item.class, i.getId()); | |||||||||||||||||
15 | i = (Item)s.get(Item.class, i.getId()); |
| | |||||||||||||||||
16 | assertEquals(slcs.getHitCount(), 1); | 16 | assertEquals(slcs.getHitCount(), 1); | |||||||||||||||||
17 | assertEquals(slcs.getMissCount(), 0); | 17 | assertEquals(slcs.getMissCount(), 0); | |||||||||||||||||
18 | i.setDescription("A bog standard item"); |
| 18 | i.setDescription("A bog standard item"); | ||||||||||||||||
19 | t.commit(); | 19 | t.commit(); | |||||||||||||||||
20 | s.close(); | 20 | s.close(); | |||||||||||||||||
21 | assertEquals(slcs.getPutCount(), 2); | 21 | assertEquals(slcs.getPutCount(), 2); | |||||||||||||||||
22 | Object entry = slcs.getEntries().get(i.getId()); |
| 22 | Object entry = slcs.getEntries().get(i.getId()); | ||||||||||||||||
23 | Map map; | 23 | Map map; | |||||||||||||||||
24 | if (entry instanceof ReadWriteCache.Item) | 24 | if (entry instanceof ReadWriteCache.Item) | |||||||||||||||||
25 | map = (Map)((ReadWriteCache.Item)entry).getValue(); | 25 | map = (Map)((ReadWriteCache.Item)entry).getValue(); | |||||||||||||||||
else | else | |||||||||||||||||||
26 | map = (Map)entry; | 26 | map = (Map)entry; | |||||||||||||||||
27 | assertTrue(map.get("description").equals("A bog standard item")); | 27 | assertTrue(map.get("description").equals("A bog standard item")); | |||||||||||||||||
28 | assertTrue(map.get("name").equals("widget")); | 28 | assertTrue(map.get("name").equals("widget")); | |||||||||||||||||
29 | s = openSession(); | 29 | s = openSession(); | |||||||||||||||||
30 | t = s.beginTransaction(); | 30 | t = s.beginTransaction(); | |||||||||||||||||
31 | s.delete(i); |
| 31 | s.delete(i); | ||||||||||||||||
32 | t.commit(); | 32 | t.commit(); | |||||||||||||||||
33 | s.close(); | 33 | s.close(); |
Row | Violation |
---|---|
1 | Type org.hibernate.test.cache.jbc2.functional.Item of variable i does not match with type org.hibernate.test.cache.Item of variable i |
2 | Type org.hibernate.test.cache.jbc2.functional.Item of variable i does not match with type org.hibernate.test.cache.Item of variable i |
3 | Type org.hibernate.test.cache.jbc2.functional.Item of variable i does not match with type org.hibernate.test.cache.Item of variable i |
4 | Unmatched statement i=(Item)s.get(Item.class,i.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
5 | Unmatched statement i=(Item)s.get(Item.class,i.getId()); cannot be moved before or after the extracted code, because it has dependencies to/from statements that will be extracted |
6 | Type org.hibernate.test.cache.jbc2.functional.Item of variable i does not match with type org.hibernate.test.cache.Item of variable i |
7 | Type org.hibernate.test.cache.jbc2.functional.Item of variable i does not match with type org.hibernate.test.cache.Item of variable i |
8 | Type org.hibernate.test.cache.jbc2.functional.Item of variable i does not match with type org.hibernate.test.cache.Item of variable i |