SGF-80 ClientRegionFactoryBean ignoring ClientRegionShortcut

This commit is contained in:
amaximov
2012-01-26 10:47:03 -05:00
parent d603b85df4
commit 9e09eecb41
2 changed files with 42 additions and 0 deletions

View File

@@ -90,6 +90,8 @@ public class ClientRegionFactoryBean<K, V> extends RegionLookupFactoryBean<K, V>
}
}
s = ClientRegionShortcut.LOCAL;
} else {
s = shortcut;
}
ClientRegionFactory<K, V> factory = c.createClientRegionFactory(s);

View File

@@ -0,0 +1,40 @@
package org.springframework.data.gemfire.client;
import static org.junit.Assert.assertSame;
import org.junit.Test;
import org.mockito.Mockito;
import com.gemstone.gemfire.cache.Region;
import com.gemstone.gemfire.cache.client.ClientCache;
import com.gemstone.gemfire.cache.client.ClientRegionFactory;
import com.gemstone.gemfire.cache.client.ClientRegionShortcut;
public class ClientRegionFactoryBeanTest {
@Test
public void testLookupFallbackFailingToUseProvidedShortcut()
throws Exception {
ClientRegionFactoryBean<Object, Object> fb = new ClientRegionFactoryBean<Object, Object>();
fb.setShortcut(ClientRegionShortcut.CACHING_PROXY);
String regionName = "regionName";
ClientCache cache = Mockito.mock(ClientCache.class);
@SuppressWarnings("unchecked")
ClientRegionFactory<Object, Object> factory = Mockito
.mock(ClientRegionFactory.class);
Mockito.when(
cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY))
.thenReturn(factory);
@SuppressWarnings("unchecked")
Region<Object, Object> region = Mockito.mock(Region.class);
Mockito.when(factory.create(regionName)).thenReturn(region);
Region<Object, Object> result = fb.lookupFallback(cache, regionName);
assertSame(region, result);
}
}