Source:
public void descriptorOnHeapTest() { CacheManager cacheManager1 = null; try { CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(10)) .build(); ManagementRegistryService managementRegistry = new DefaultManagementRegistryService(new DefaultManagementRegistryConfiguration().setCacheManagerAlias("myCM")); cacheManager1 = CacheManagerBuilder.newCacheManagerBuilder() .withCache("aCache", cacheConfiguration) .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.CACHE_DESCRIPTORS); assertThat(descriptors, hasSize(allDescriptors.size())); assertThat(descriptors, containsInAnyOrder(allDescriptors.toArray())); } finally { if(cacheManager1 != null) cacheManager1.close(); } }

Target:
public void descriptorOnHeapTest() { CacheManager cacheManager1 = null; try { CacheConfiguration<Long, String> cacheConfiguration = CacheConfigurationBuilder.newCacheConfigurationBuilder(Long.class, String.class, heap(10)) .build(); ManagementRegistryService managementRegistry = new DefaultManagementRegistryService(new DefaultManagementRegistryConfiguration().setCacheManagerAlias("myCM")); cacheManager1 = CacheManagerBuilder.newCacheManagerBuilder() .withCache("aCache", cacheConfiguration) .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(CACHE_DESCRIPTORS); assertThat(descriptors, containsInAnyOrder(allDescriptors.toArray())); assertThat(descriptors, hasSize(allDescriptors.size())); } finally { if(cacheManager1 != null) cacheManager1.close(); } }