Package com.gemstone.gemfire.cache

Examples of com.gemstone.gemfire.cache.Region


    Cache cache2 = context2.getBean(Cache.class);

    assertNotNull(cache1);
    assertSame(cache1, cache2);

    Region region1 = context1.getBean(Region.class);
    Region region2 = context2.getBean(Region.class);

    assertNotNull(region1);
    assertSame(region1, region2);
    assertFalse(cache1.isClosed());
    assertFalse(region1.isDestroyed());
View Full Code Here


  public void testGatewaysInGemfire() {
    Cache cache = ctx.getBean("gemfireCache", Cache.class);
    GatewayHub gwh = cache.getGatewayHub("gateway-hub");
    assertNotNull(gwh);

    Region region = ctx.getBean("region-with-gateway", Region.class);
    assertTrue(region.getAttributes().getEnableGateway());
    assertEquals("gateway-hub", region.getAttributes().getGatewayHubId());
  }
View Full Code Here

  @Test
  @SuppressWarnings("rawtypes")
  public void testReplicatedRegionWithAttributes() throws Exception {
    assertTrue(context.containsBean("replicated-with-attributes"));

    Region region = context.getBean("replicated-with-attributes", Region.class);

    assertNotNull("The 'replicated-with-attributes' Region was not properly configured and initialized!", region);

    RegionAttributes regionAttributes = region.getAttributes();

    assertNotNull(regionAttributes);
    assertFalse(regionAttributes.getCloningEnabled());
    assertEquals(10, regionAttributes.getConcurrencyLevel());
    assertTrue(regionAttributes.isDiskSynchronous());
View Full Code Here

  @Test
  @SuppressWarnings("rawtypes")
  public void testRegionLookup() throws Exception {
    Cache cache = context.getBean(Cache.class);
    Region existing = cache.createRegionFactory().create("existing");

    assertTrue(context.containsBean("lookup"));

    RegionLookupFactoryBean regionLookupFactoryBean = context.getBean("&lookup", RegionLookupFactoryBean.class);
View Full Code Here

    final RegionFactory<K, V> regionFactory = mock(RegionFactory.class);

    when(regionFactory.create(anyString())).thenAnswer(new Answer<Region>() {
      @Override public Region answer(InvocationOnMock invocation) throws Throwable {
        String name = (String) invocation.getArguments()[0];
        Region region = mockRegion(name);

        cache.allRegions().put(name, region);

        return region;
      }
    });

    when(regionFactory.createSubregion(any(Region.class), anyString())).thenAnswer(new Answer<Region>() {
      @Override public Region answer(InvocationOnMock invocation) throws Throwable {
        Region parent = (Region) invocation.getArguments()[0];
        String name = (String) invocation.getArguments()[1];
        String parentRegionName = null;

        for (String key: cache.allRegions().keySet()) {
          if (cache.allRegions().get(key).equals(parent)) {
            parentRegionName = key;
          }
        }

        assert parentRegionName != null : "The parent Region name was null!";

        String subRegionName = (parentRegionName.startsWith("/") ? parentRegionName+"/"+name
          : "/"+parentRegionName+"/"+ name);

        Region subRegion = mockRegion(subRegionName);

        cache.allRegions().put(subRegionName, subRegion);
        cache.allRegions().put(name, subRegion);

        return subRegion;
View Full Code Here

  @SuppressWarnings({ "rawtypes", "unchecked" })
  public Region mockRegion(String name) {
    regionAttributes = attributesFactory.create();

    RegionService mockRegionService = mockRegionService();
    Region region = mock(Region.class);

    when(region.getAttributes()).thenReturn(regionAttributes);

    String regionFullPath = (name.startsWith(Region.SEPARATOR) ? name : Region.SEPARATOR + name);
    String regionName = (name.lastIndexOf(Region.SEPARATOR) > 0 ?
      name.substring(name.lastIndexOf(Region.SEPARATOR) + Region.SEPARATOR.length()) : name);

    when(region.getFullPath()).thenReturn(regionFullPath);
    when(region.getName()).thenReturn(regionName);
      when(region.getRegionService()).thenReturn(mockRegionService);

      when(region.getSubregion(anyString())).thenAnswer(new Answer<Region>() {
      @Override
      public Region answer(InvocationOnMock invocation) throws Throwable {
        Region parent = (Region) invocation.getMock();

        String parentRegionName = parent.getFullPath();
        String subRegionName = (String) invocation.getArguments()[0];
        String subRegionPath = (parentRegionName.startsWith("/") ? parentRegionName+"/"+subRegionName
          : "/"+parentRegionName+"/"+subRegionName);

        return cache.getRegion(subRegionPath);
      }
    });

    when(region.createSubregion(anyString(), any(RegionAttributes.class))).thenAnswer(new Answer<Region>() {
      @Override
      public Region answer(InvocationOnMock invocation) throws Throwable {
        String name = (String) invocation.getArguments()[0];
        RegionAttributes attributes = (RegionAttributes) invocation.getArguments()[1];

        Region parent = (Region) invocation.getMock();
        String parentName = parent.getName();
        String regionName = parentName.startsWith("/") ? parentName+"/"+name : "/"+parentName+"/"+ name;

        Region subRegion = new MockRegionFactory(cache).createMockRegionFactory(attributes).create(regionName);
        when(subRegion.getFullPath()).thenReturn(regionName);

        cache.allRegions().put(regionName, subRegion);

        return subRegion;
      }
View Full Code Here

    when(idx.getName()).thenReturn(indexName);
    when(idx.getType()).thenReturn(indexType);
   
   
    if (fromClause != null && fromClause.length() >= 2) {
      Region region = mock(Region.class);
      String name = fromClause.substring(1).split(" ")[0];
      when(region.getName()).thenReturn(name);
      when(idx.getRegion()).thenReturn(region);
    }
    return idx;
  }
View Full Code Here

TOP

Related Classes of com.gemstone.gemfire.cache.Region

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.