Package com.gemstone.gemfire.cache.client

Examples of com.gemstone.gemfire.cache.client.ClientCache


    // TODO reference to an internal GemFire class!
    if (cache instanceof GemFireCacheImpl) {
      Assert.isTrue(((GemFireCacheImpl) cache).isClient(), "A client-cache instance is required.");
    }

    ClientCache clientCache = (ClientCache) cache;

    ClientRegionFactory<K, V> factory = clientCache.createClientRegionFactory(resolveClientRegionShortcut());

    // map region attributes onto the client region factory
    if (attributes != null) {
      factory.setCloningEnabled(attributes.getCloningEnabled());
      factory.setCompressor(attributes.getCompressor());
View Full Code Here


  /**
   * Inform the GemFire cluster that this client cache is ready to receive events.
   */
  private void readyForEvents(){
    ClientCache clientCache = ClientCacheFactory.getAnyInstance();

    if (Boolean.TRUE.equals(readyForEvents) && !clientCache.isClosed()) {
      try {
        clientCache.readyForEvents();
      }
      catch (IllegalStateException ignore) {
        // cannot be called for a non-durable client so exception is thrown
      }
    }
View Full Code Here

  }

  @Test
  @SuppressWarnings("unchecked")
  public void testLookupQueryService() {
    ClientCache mockClientCache = mock(ClientCache.class, "testLookupQueryService.ClientCache");
    QueryService mockQueryService = mock(QueryService.class, "testLookupQueryService.QueryService");
    Region<Object, Object> mockRegion = mock(Region.class, "testLookupQueryService.Region");

    when(mockRegion.getRegionService()).thenReturn(mockClientCache);
    when(mockClientCache.getQueryService()).thenReturn(mockQueryService);

    GemfireTemplate localTemplate = new GemfireTemplate(mockRegion) {
      @Override boolean isLocalWithNoServerProxy(final Region<?, ?> region) {
        return false;
      }
View Full Code Here

  }

  @Test
  @SuppressWarnings("unchecked")
  public void testLookupLocalQueryService() {
    ClientCache mockClientCache = mock(ClientCache.class, "testLookupLocalQueryService.ClientCache");
    QueryService mockQueryService = mock(QueryService.class, "testLookupLocalQueryService.QueryService");
    Region<Object, Object> mockRegion = mock(Region.class, "testLookupLocalQueryService.Region");
    RegionAttributes<Object, Object> mockRegionAttributes = mock(RegionAttributes.class, "testLookupLocalQueryService.RegionAttributes");

    when(mockClientCache.getLocalQueryService()).thenReturn(mockQueryService);
    when(mockRegion.getRegionService()).thenReturn(mockClientCache);
    when(mockRegion.getAttributes()).thenReturn(mockRegionAttributes);
    when(mockRegionAttributes.getScope()).thenReturn(Scope.LOCAL);

    GemfireTemplate localTemplate = new GemfireTemplate(mockRegion) {
View Full Code Here

  ApplicationContext context;

  @Test
  public void testContextCreated() throws Exception {

    ClientCache cache = context.getBean("gemfireCache", ClientCache.class);
    Pool pool = context.getBean("gemfirePool", Pool.class);
    assertEquals("gemfirePool", pool.getName());
    assertEquals(1, cache.getDefaultPool().getServers().size());
    assertEquals(pool.getServers().get(0), cache.getDefaultPool().getServers().get(0));

    context.getBean("r1", Region.class);

    GemfireOnServerFunctionTemplate template = context.getBean(GemfireOnServerFunctionTemplate.class);
    assertTrue(template.getResultCollector() instanceof MyResultCollector);
View Full Code Here

    when(beanFactory.getBean(Pool.class)).thenReturn(pool);

    factoryBean.setBeanFactory(beanFactory);

    ClientCache cache = mock(ClientCache.class);
    ClientRegionFactory<Object, Object> clientRegionFactory = mock(ClientRegionFactory.class);
    Region<Object, Object> expectedRegion = mock(Region.class);

    when(cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY)).thenReturn(clientRegionFactory);
    when(clientRegionFactory.create("testRegion")).thenReturn(expectedRegion);

    Region<Object, Object> actualRegion = factoryBean.lookupFallback(cache, "testRegion");

    assertSame(expectedRegion, actualRegion);
View Full Code Here

TOP

Related Classes of com.gemstone.gemfire.cache.client.ClientCache

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.