Source:
public void descriptorDiskStoreTest() throws URISyntaxException { PersistentCacheManager persistentCacheManager = null; try { ManagementRegistryService managementRegistry = new DefaultManagementRegistryService(new DefaultManagementRegistryConfiguration().setCacheManagerAlias("myCM")); persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder() .with(CacheManagerBuilder.persistence(getStoragePath() + File.separator + "myData")) .withCache("persistent-cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.newResourcePoolsBuilder() .heap(10, EntryUnit.ENTRIES) .disk(10, MemoryUnit.MB, true)) ) .using(managementRegistry) .build(true); assertThat(managementRegistry.getCapabilities(), hasSize(4)); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(0).getName(), equalTo("ActionsCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(1).getName(), equalTo("StatisticsCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(2).getName(), equalTo("StatisticCollectorCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(3).getName(), equalTo("SettingsCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(0).getDescriptors(), hasSize(4)); Collection<Descriptor> descriptors = new ArrayList<Capability>(managementRegistry.getCapabilities()).get(1).getDescriptors(); Collection<Descriptor> allDescriptors = new ArrayList<Descriptor>(); allDescriptors.addAll(StatsUtil.ONHEAP_DESCRIPTORS); allDescriptors.addAll(StatsUtil.DISK_DESCRIPTORS); allDescriptors.addAll(StatsUtil.CACHE_DESCRIPTORS); assertThat(descriptors, hasSize(allDescriptors.size())); assertThat(descriptors, containsInAnyOrder(allDescriptors.toArray())); } finally { if(persistentCacheManager != null) persistentCacheManager.close(); } }

Target:
public void descriptorDiskStoreTest() throws URISyntaxException { PersistentCacheManager persistentCacheManager = null; try { ManagementRegistryService managementRegistry = new DefaultManagementRegistryService(new DefaultManagementRegistryConfiguration().setCacheManagerAlias("myCM")); persistentCacheManager = CacheManagerBuilder.newCacheManagerBuilder() .with(CacheManagerBuilder.persistence(getStoragePath() + File.separator + "myData")) .withCache("persistent-cache", CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, ResourcePoolsBuilder.newResourcePoolsBuilder() .heap(10, EntryUnit.ENTRIES) .disk(10, MemoryUnit.MB, true)) ) .using(managementRegistry) .build(true); assertThat(managementRegistry.getCapabilities(), hasSize(4)); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(0).getName(), equalTo("ActionsCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(1).getName(), equalTo("StatisticsCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(2).getName(), equalTo("StatisticCollectorCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(3).getName(), equalTo("SettingsCapability")); assertThat(new ArrayList<Capability>(managementRegistry.getCapabilities()).get(0).getDescriptors(), hasSize(4)); Collection<Descriptor> descriptors = new ArrayList<Capability>(managementRegistry.getCapabilities()).get(1).getDescriptors(); Collection<Descriptor> allDescriptors = new ArrayList<Descriptor>(); allDescriptors.addAll(ONHEAP_DESCRIPTORS); allDescriptors.addAll(DISK_DESCRIPTORS); allDescriptors.addAll(CACHE_DESCRIPTORS); assertThat(descriptors, containsInAnyOrder(allDescriptors.toArray())); assertThat(descriptors, hasSize(allDescriptors.size())); } finally { if(persistentCacheManager != null) persistentCacheManager.close(); } }