public class CollectionRegionImplTestCase extends AbstractEntityCollectionRegionTestCase { /** * Create a new EntityRegionImplTestCase. * * @param name */ public CollectionRegionImplTestCase(String name) { super(name); } @Override protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) { CollectionRegion region = regionFactory.buildCollectionRegion("test", properties, null); assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL).lockRegion()); try { region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion(); fail("Did not get READ_ONLY"); } catch (UnsupportedOperationException good) {} try { region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE); fail("Incorrectly got NONSTRICT_READ_WRITE"); } catch (CacheException good) {} try { region.buildAccessStrategy(AccessType.READ_WRITE); fail("Incorrectly got READ_WRITE"); } catch (CacheException good) {} } @Override protected Region createRegion(JBossCacheRegionFactory regionFactory, String regionName, Properties properties, CacheDataDescription cdd) { return regionFactory.buildCollectionRegion(regionName, properties, cdd); } @Override protected Cache getJBossCache(JBossCacheRegionFactory regionFactory) { CacheInstanceManager mgr = regionFactory.getCacheInstanceManager(); return mgr.getCollectionCacheInstance(); } @Override protected Fqn getRegionFqn(String regionName, String regionPrefix) { return BasicRegionAdapter.getTypeLastRegionFqn(regionName, regionPrefix, CollectionRegionImpl.TYPE); } @Override protected void putInRegion(Region region, Object key, Object value) { ((CollectionRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).putFromLoad(key, value, System.currentTimeMillis(), new Integer(1)); } @Override protected void removeFromRegion(Region region, Object key) { ((CollectionRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).remove(key)
public class EntityRegionImplTestCase extends AbstractEntityCollectionRegionTestCase { /** * Create a new EntityRegionImplTestCase. * * @param name */ public EntityRegionImplTestCase(String name) { super(name); } @Override protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) { EntityRegion region = regionFactory.buildEntityRegion("test", properties, null); assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL).lockRegion()); try { region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion(); fail("Did not get READ_ONLY"); } catch (UnsupportedOperationException good) {} try { region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE); fail("Incorrectly got NONSTRICT_READ_WRITE"); } catch (CacheException good) {} try { region.buildAccessStrategy(AccessType.READ_WRITE); fail("Incorrectly got READ_WRITE"); } catch (CacheException good) {} } @Override protected Region createRegion(JBossCacheRegionFactory regionFactory, String regionName, Properties properties, CacheDataDescription cdd) { return regionFactory.buildEntityRegion(regionName, properties, cdd); } @Override protected Cache getJBossCache(JBossCacheRegionFactory regionFactory) { CacheInstanceManager mgr = regionFactory.getCacheInstanceManager(); return mgr.getEntityCacheInstance(); } @Override protected Fqn getRegionFqn(String regionName, String regionPrefix) { return BasicRegionAdapter.getTypeLastRegionFqn(regionName, regionPrefix, EntityRegionImpl.TYPE); } @Override protected void putInRegion(Region region, Object key, Object value) { ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).insert(key, value, new Integer(1)); } @Override protected void removeFromRegion(Region region, Object key) { ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).remove(key)
Clone fragments detected by clone detection tool
File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/collection/CollectionRegionImplTestCase.java File path: /hibernate-distribution-3.3.2.GA/project/cache-jbosscache2/src/test/java/org/hibernate/test/cache/jbc2/entity/EntityRegionImplTestCase.java
Method name: Method name:
Number of AST nodes: 0 Number of AST nodes: 0
1
public class CollectionRegionImplTestCase extends AbstractEntityCollectionRegionTestCase {
1
public class EntityRegionImplTestCase extends AbstractEntityCollectionRegionTestCase {
2
    
2
    /**
3
    /**
3
     * Create a new EntityRegionImplTestCase.
4
     * Create a new EntityRegionImplTestCase.
4
     * 
5
     * 
5
     * @param name
6
     * @param name
6
     */
7
     */
7
    public CollectionRegionImplTestCase(String name) {
8
    public EntityRegionImplTestCase(String name) {
8
        super(name);
9
        super(name);
9
    }
10
    } 
10
    
11
    
11
    @Override
12
    @Override
12
    protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) {
13
    protected void supportedAccessTypeTest(RegionFactory regionFactory, Properties properties) {
13
        
14
        
14
        CollectionRegion region = regionFactory.buildCollectionRegion("test", properties, null);
15
        EntityRegion region = regionFactory.buildEntityRegion("test", properties, null);
15
        
16
        
16
        assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL).lockRegion());
17
        assertNull("Got TRANSACTIONAL", region.buildAccessStrategy(AccessType.TRANSACTIONAL).lockRegion());
17
        
18
        
18
        try
19
        try
19
        {
20
        {
20
            region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion();
21
            region.buildAccessStrategy(AccessType.READ_ONLY).lockRegion();
21
            fail("Did not get READ_ONLY");
22
            fail("Did not get READ_ONLY");
22
        }
23
        }
23
        catch (UnsupportedOperationException good) {}
24
        catch (UnsupportedOperationException good) {}
24
        
25
        
25
        try
26
        try
26
        {
27
        {
27
            region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE);
28
            region.buildAccessStrategy(AccessType.NONSTRICT_READ_WRITE);
28
            fail("Incorrectly got NONSTRICT_READ_WRITE");
29
            fail("Incorrectly got NONSTRICT_READ_WRITE");
29
        }
30
        }
30
        catch (CacheException good) {}
31
        catch (CacheException good) {}
31
        
32
        
32
        try
33
        try
33
        {
34
        {
34
            region.buildAccessStrategy(AccessType.READ_WRITE);
35
            region.buildAccessStrategy(AccessType.READ_WRITE);
35
            fail("Incorrectly got READ_WRITE");
36
            fail("Incorrectly got READ_WRITE");
36
        }
37
        }
37
        catch (CacheException good) {}
38
        catch (CacheException good) {}      
39
        
38
    }
40
    }
39
    @Override
41
    @Override
40
    protected Region createRegion(JBossCacheRegionFactory regionFactory, String regionName, Properties properties, CacheDataDescription cdd) {
42
    protected Region createRegion(JBossCacheRegionFactory regionFactory, String regionName, Properties properties, CacheDataDescription cdd) {
41
        return regionFactory.buildCollectionRegion(regionName, properties, cdd);
43
        return regionFactory.buildEntityRegion(regionName, properties, cdd);
42
    }
44
    }
43
    @Override
45
    @Override
44
    protected Cache getJBossCache(JBossCacheRegionFactory regionFactory) {
46
    protected Cache getJBossCache(JBossCacheRegionFactory regionFactory) {
45
        CacheInstanceManager mgr = regionFactory.getCacheInstanceManager();
47
        CacheInstanceManager mgr = regionFactory.getCacheInstanceManager();
46
        return mgr.getCollectionCacheInstance();
48
        return mgr.getEntityCacheInstance();
47
    }
49
    }
48
    @Override
50
    @Override
49
    protected Fqn getRegionFqn(String regionName, String regionPrefix) {
51
    protected Fqn getRegionFqn(String regionName, String regionPrefix) {
50
        return BasicRegionAdapter.getTypeLastRegionFqn(regionName, regionPrefix, CollectionRegionImpl.TYPE);
52
        return BasicRegionAdapter.getTypeLastRegionFqn(regionName, regionPrefix, EntityRegionImpl.TYPE);
51
    }
53
    }
52
    @Override
54
    @Override
53
    protected void putInRegion(Region region, Object key, Object value) {
55
    protected void putInRegion(Region region, Object key, Object value) {
54
        ((CollectionRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).putFromLoad(key, value, System.currentTimeMillis(), new Integer(1));
56
        ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).insert(key, value, new Integer(1));
55
    }
57
    }
56
    @Override
58
    @Override
57
    protected void removeFromRegion(Region region, Object key) {
59
    protected void removeFromRegion(Region region, Object key) {
58
        ((CollectionRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).remove(key)
60
        ((EntityRegion) region).buildAccessStrategy(AccessType.TRANSACTIONAL).remove(key)
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