public Region createRegion(String name, String refid) throws RegionExistsException, TimeoutException { RegionCreation region = new RegionCreation(this, name, refid); this.addRootRegion(region); return region; }
/** * After popping the current <code>RegionCreation</code> off the stack, if the element on top of * the stack is a <code>RegionCreation</code>, then it is the parent region. */ private void endRegion() throws RegionExistsException { RegionCreation region = (RegionCreation) stack.pop(); boolean isRoot = false; if (stack.isEmpty()) { isRoot = true; } else if (!(stack.peek() instanceof RegionCreation)) { isRoot = true; } if (isRoot) { this.cache.addRootRegion(region); } else { RegionCreation parent = (RegionCreation) stack.peek(); parent.addSubregion(region.getName(), region); } }
@Override public Region createRegion(String name, RegionAttributes aRegionAttributes) throws RegionExistsException, TimeoutException { if (aRegionAttributes instanceof RegionAttributesCreation) { ((RegionAttributesCreation) aRegionAttributes).inheritAttributes(this); ((RegionAttributesCreation) aRegionAttributes).prepareForValidation(); } AttributesFactory.validateAttributes(aRegionAttributes); RegionCreation region = new RegionCreation(this, name, null); region.setAttributes(aRegionAttributes); this.addRootRegion(region); return region; }
@Test public void shouldCreateGatewaySenderAfterRegions() { CacheCreation cacheCreation = new CacheCreation(); GatewayReceiver receiver = mock(GatewayReceiver.class); cacheCreation.addGatewayReceiver(receiver); cacheCreation.addRootRegion(new RegionCreation(cacheCreation, "region")); InternalCache internalCache = mock(InternalCache.class); GatewayReceiverFactory receiverFactory = mock(GatewayReceiverFactory.class); when(internalCache.createGatewayReceiverFactory()).thenReturn(receiverFactory); when(receiverFactory.create()).thenReturn(receiver); InOrder inOrder = inOrder(internalCache, receiverFactory); cacheCreation.create(internalCache); // inOrder.verify(cache).basicCreateRegion(eq("region"), any()); inOrder.verify(internalCache).createGatewayReceiverFactory(); inOrder.verify(receiverFactory).create(); }