AttributesFactory factory = new AttributesFactory(); RegionAttributes attrs = factory.create(); assertNull(attrs.getCacheLoader()); assertNull(attrs.getCacheWriter()); assertNull(attrs.getCacheListener()); assertEquals(Arrays.asList(new CacheListener[0]), Arrays.asList(attrs.getCacheListeners())); assertEquals(0, attrs.getRegionTimeToLive().getTimeout()); assertEquals(0, attrs.getRegionIdleTimeout().getTimeout()); assertEquals(0, attrs.getEntryTimeToLive().getTimeout()); assertEquals(null, attrs.getCustomEntryTimeToLive()); assertEquals(0, attrs.getEntryIdleTimeout().getTimeout()); assertEquals(null, attrs.getCustomEntryIdleTimeout()); assertEquals(Scope.DISTRIBUTED_NO_ACK, attrs.getScope()); assertEquals(DataPolicy.DEFAULT, attrs.getDataPolicy()); assertEquals(InterestPolicy.DEFAULT, attrs.getSubscriptionAttributes().getInterestPolicy()); assertEquals(MirrorType.NONE, attrs.getMirrorType()); assertEquals(null, attrs.getDiskStoreName()); assertEquals(AttributesFactory.DEFAULT_DISK_SYNCHRONOUS, attrs.isDiskSynchronous()); assertNull(attrs.getKeyConstraint()); assertEquals(16, attrs.getInitialCapacity()); assertEquals(0.75, attrs.getLoadFactor(), 0.0); assertFalse(attrs.getStatisticsEnabled()); assertFalse(attrs.getPersistBackup()); DiskWriteAttributes dwa = attrs.getDiskWriteAttributes(); assertNotNull(dwa); assertEquals(dwaf.create(), dwa); assertNull(attrs.getDiskStoreName());
CacheListener cl1 = new MyCacheListener(); CacheListener cl2 = new MyCacheListener(); assertFalse(cl1.equals(cl2)); assertFalse((Arrays.asList(new CacheListener[]{cl1, cl2})).equals(Arrays.asList(new CacheListener[]{cl2, cl1}))); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { fail("expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { assertEquals(null, ra.getCacheListener()); assertEquals(Arrays.asList(new CacheListener[0]), Arrays.asList(ra.getCacheListeners())); assertEquals(cl1, ra.getCacheListener()); assertEquals(Arrays.asList(new CacheListener[]{cl1}), Arrays.asList(ra.getCacheListeners())); assertEquals(cl2, ra.getCacheListener()); assertEquals(Arrays.asList(new CacheListener[]{cl2}), Arrays.asList(ra.getCacheListeners())); assertEquals(null, ra.getCacheListener()); assertEquals(Arrays.asList(new CacheListener[0]), Arrays.asList(ra.getCacheListeners())); try { ra.getCacheListener(); fail("expected IllegalStateException"); } catch (IllegalStateException expected) { assertEquals(Arrays.asList(new CacheListener[]{cl1, cl2}), Arrays.asList(ra.getCacheListeners()));
assertEquals(DataPolicy.PRELOADED, ra.getDataPolicy()); assertEquals(new SubscriptionAttributes(InterestPolicy.ALL), ra.getSubscriptionAttributes()); assertEquals(DataPolicy.PRELOADED, ra.getDataPolicy()); assertEquals(new SubscriptionAttributes(InterestPolicy.ALL), ra.getSubscriptionAttributes()); assertEquals(DataPolicy.PRELOADED, ra.getDataPolicy()); assertEquals(new SubscriptionAttributes(InterestPolicy.ALL), ra.getSubscriptionAttributes()); assertEquals(DataPolicy.PRELOADED, ra.getDataPolicy()); assertEquals(new SubscriptionAttributes(InterestPolicy.ALL), ra.getSubscriptionAttributes()); try { factory.create(); fail("Should have thrown an IllegalStateException"); assertTrue(ex instanceof IllegalStateException); try { factory.create(); fail("Should have thrown an IllegalStateException"); assertTrue(ex instanceof IllegalStateException); try {
public void testCopyConstructor() { AttributesFactory f1 = new AttributesFactory(); f1.setLockGrantor(true); RegionAttributes origAttrs = f1.create(); assertEquals(true, origAttrs.isLockGrantor()); AttributesFactory f2 = new AttributesFactory(origAttrs); RegionAttributes attrs = f2.create(); assertEquals(true, attrs.isLockGrantor()); }
factory.setDiskSynchronous(true); RegionAttributes attrs = factory.create(); assertEquals(true, attrs.isDiskSynchronous()); assertEquals(true, attrs.getDiskWriteAttributes().isSynchronous()); factory.setDiskSynchronous(false); RegionAttributes attrs = factory.create(); assertEquals(false, attrs.isDiskSynchronous()); assertEquals(false, attrs.getDiskWriteAttributes().isSynchronous()); factory.setDiskWriteAttributes(dwaf.create()); RegionAttributes attrs = factory.create(); assertEquals(false, attrs.getDiskWriteAttributes().isSynchronous()); assertEquals(false, attrs.isDiskSynchronous()); factory.setDiskDirs(new File[] {new File("").getAbsoluteFile()}); RegionAttributes attrs = factory.create(); assertEquals(false, attrs.getDiskWriteAttributes().isSynchronous()); assertEquals(false, attrs.isDiskSynchronous()); new int[] {100}); RegionAttributes attrs = factory.create(); assertEquals(false, attrs.getDiskWriteAttributes().isSynchronous()); assertEquals(false, attrs.isDiskSynchronous());