Package com.springsource.insight.plugin.files.tracker.AbstractFilesTrackerAspectSupport

Examples of com.springsource.insight.plugin.files.tracker.AbstractFilesTrackerAspectSupport.FilesCache


    protected void runSynchronizedAspectPerformance(FileAccessor accessor) {
        for (int threads : new int[]{1, 4}) {
            final Map<CacheKey, String> orgCache = AbstractFilesTrackerAspectSupport.trackedFilesMap;
            try {
                FilesCache cache = new FilesCache(5);
                AbstractFilesTrackerAspectSupport.trackedFilesMap =
                        (threads > 1) ? Collections.synchronizedMap(cache) : cache;
                runSynchronizedAspectPerformance(accessor, threads);
                assertTrue("Tracking map not empty for threads=" + threads + ": " + cache, cache.isEmpty());
            } finally {
                AbstractFilesTrackerAspectSupport.trackedFilesMap = orgCache;
            }
        }
    }
View Full Code Here


    }

    @Test
    public void testFilesCacheSize() {
        final int MAX_CAPACITY = 16;
        FilesCache cache = new FilesCache(MAX_CAPACITY);

        for (int index = 0; index < 2 * MAX_CAPACITY; index++) {
            CacheKey key = CacheKey.getFileKey(Mockito.mock(Closeable.class));
            assertNull("Multiple mappings for " + key, cache.put(key, String.valueOf(index)));

            if (index < MAX_CAPACITY) {
                assertEquals("Mismatched pre-populated cache size", index + 1, cache.size());
            } else {
                assertEquals("Mismatched post-populated cache size", MAX_CAPACITY, cache.size());
                assertTrue("Last value was bumped unpexpectedly", cache.containsKey(key));
            }
        }
    }
View Full Code Here

        }
    }

    @Test
    public void testFilesCacheCapacityUpdateWithNumber() {
        FilesCache cache = AbstractFilesTrackerAspectSupport.filesCache;
        int oldCapacity = cache.getMaxCapacity(), newCapacity = oldCapacity + 7365;
        CollectionSettingsRegistry registry = CollectionSettingsRegistry.getInstance();
        registry.set(AbstractFilesTrackerAspectSupport.MAX_TRACKED_FILES_SETTING, Integer.valueOf(newCapacity));
        assertEquals("Mismatched capacity after update", newCapacity, cache.getMaxCapacity());
    }
View Full Code Here

        assertEquals("Mismatched capacity after update", newCapacity, cache.getMaxCapacity());
    }

    @Test
    public void testFilesCacheCapacityUpdateWithString() {
        FilesCache cache = AbstractFilesTrackerAspectSupport.filesCache;
        int oldCapacity = cache.getMaxCapacity(), newCapacity = oldCapacity + 7365;
        CollectionSettingsRegistry registry = CollectionSettingsRegistry.getInstance();
        registry.set(AbstractFilesTrackerAspectSupport.MAX_TRACKED_FILES_SETTING, String.valueOf(newCapacity));
        assertEquals("Mismatched capacity after update", newCapacity, cache.getMaxCapacity());
    }
View Full Code Here

        assertEquals("Mismatched capacity after update", newCapacity, cache.getMaxCapacity());
    }

    @Test
    public void testFilesCacheCapacityUpdateWithBadString() {
        FilesCache cache = AbstractFilesTrackerAspectSupport.filesCache;
        int capacity = cache.getMaxCapacity();
        CollectionSettingsRegistry registry = CollectionSettingsRegistry.getInstance();
        registry.set(AbstractFilesTrackerAspectSupport.MAX_TRACKED_FILES_SETTING, "lyor");
        assertEquals("Unexpected capacity update success", capacity, cache.getMaxCapacity());
    }
View Full Code Here

        assertEquals("Unexpected capacity update success", capacity, cache.getMaxCapacity());
    }

    @Test
    public void testFilesCacheCapacityUpdateFailOnNegativeNumber() {
        FilesCache cache = AbstractFilesTrackerAspectSupport.filesCache;
        int oldCapacity = cache.getMaxCapacity(), newCapacity = 0 - oldCapacity;
        CollectionSettingsRegistry registry = CollectionSettingsRegistry.getInstance();
        registry.set(AbstractFilesTrackerAspectSupport.MAX_TRACKED_FILES_SETTING, Integer.valueOf(newCapacity));
        assertEquals("Unexpected capacity update success", oldCapacity, cache.getMaxCapacity());
    }
View Full Code Here

        assertEquals("Unexpected capacity update success", oldCapacity, cache.getMaxCapacity());
    }

    @Test
    public void testFilesCacheCapacityUpdateFailOnBadValueType() {
        FilesCache cache = AbstractFilesTrackerAspectSupport.filesCache;
        int oldCapacity = cache.getMaxCapacity(), newCapacity = oldCapacity + 3777;
        CollectionSettingsRegistry registry = CollectionSettingsRegistry.getInstance();
        registry.set(AbstractFilesTrackerAspectSupport.MAX_TRACKED_FILES_SETTING, new StringBuilder().append(newCapacity));
        assertEquals("Unexpected capacity update success", oldCapacity, cache.getMaxCapacity());
    }
View Full Code Here

TOP

Related Classes of com.springsource.insight.plugin.files.tracker.AbstractFilesTrackerAspectSupport.FilesCache

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.