Here are the examples of the java api org.apache.geode.cache.GemFireCache taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
60 Examples
18
Source : IntegrationTestsSupport.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
private static GemFireCache close(GemFireCache cache) {
return Optional.ofNullable(cache).map(it -> {
it.close();
return it;
}).orElse(cache);
}
18
Source : CacheNameAutoConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
private void replacedertGemFireCache(GemFireCache gemfireCache, String expectedName) {
replacedertThat(gemfireCache).isNotNull();
replacedertThat(gemfireCache.getDistributedSystem()).isNotNull();
replacedertThat(gemfireCache.getDistributedSystem().getProperties()).isNotNull();
replacedertThat(gemfireCache.getDistributedSystem().getProperties().getProperty("name")).isEqualTo(expectedName);
}
18
Source : EchoServerConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean
public GemfireTemplate echoTemplate(GemFireCache gemfireCache) {
return new GemfireTemplate(gemfireCache.getRegion(RegionUtils.toRegionPath(EchoClientConfiguration.REGION_NAME)));
}
18
Source : EchoClientConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean
public GemfireTemplate echoTemplate(GemFireCache gemfireCache) {
return new GemfireTemplate(gemfireCache.getRegion(RegionUtils.toRegionPath(REGION_NAME)));
}
18
Source : PeerCacheHealthIndicatorConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean("GeodeGatewayReceiversHealthIndicator")
GeodeGatewayReceiversHealthIndicator gatewayReceiversHealthIndicator(GemFireCache gemfireCache) {
return new GeodeGatewayReceiversHealthIndicator(gemfireCache);
}
18
Source : PeerCacheHealthIndicatorConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean("GeodeCacheServersHealthIndicator")
GeodeCacheServersHealthIndicator cacheServersHealthIndicator(GemFireCache gemfireCache) {
return new GeodeCacheServersHealthIndicator(gemfireCache);
}
18
Source : PeerCacheHealthIndicatorConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean("GeodeAsyncEventQueuesHealthIndicator")
GeodeAsyncEventQueuesHealthIndicator asyncEventQueuesHealthIndicator(GemFireCache gemfireCache) {
return new GeodeAsyncEventQueuesHealthIndicator(gemfireCache);
}
18
Source : PeerCacheHealthIndicatorConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean("GeodeGatewaySendersHealthIndicator")
GeodeGatewaySendersHealthIndicator gatewaySendersHealthIndicator(GemFireCache gemfireCache) {
return new GeodeGatewaySendersHealthIndicator(gemfireCache);
}
18
Source : ClientCacheHealthIndicatorConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean("GeodePoolsHealthIndicator")
GeodePoolsHealthIndicator poolsHealthIndicator(GemFireCache gemfireCache) {
return new GeodePoolsHealthIndicator(gemfireCache);
}
18
Source : BaseGeodeHealthIndicatorConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean("GeodeRegionsHealthIndicator")
GeodeRegionsHealthIndicator regionsHealthIndicator(GemFireCache gemfireCache) {
return new GeodeRegionsHealthIndicator(gemfireCache);
}
18
Source : BaseGeodeHealthIndicatorConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean("GeodeCacheHealthIndicator")
GeodeCacheHealthIndicator cacheHealthIndicator(GemFireCache gemfireCache) {
return new GeodeCacheHealthIndicator(gemfireCache);
}
18
Source : AbstractGeodeHealthIndicator.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* The {@link AbstractGeodeHealthIndicator} clreplaced is an abstract base clreplaced encapsulating functionality common to all
* Apache Geode {@link HealthIndicator} objects.
*
* @author John Blum
* @see org.apache.geode.cache.GemFireCache
* @see org.springframework.boot.actuate.health.AbstractHealthIndicator
* @see org.springframework.boot.actuate.health.HealthIndicator
* @since 1.0.0
*/
@SuppressWarnings("unused")
public abstract clreplaced AbstractGeodeHealthIndicator extends AbstractHealthIndicator {
protected static final String UNKNOWN = "unknown";
private final GemFireCache gemfireCache;
/**
* Default constructor to construct an uninitialized instance of {@link AbstractGeodeHealthIndicator},
* which will not provide any health information.
*/
public AbstractGeodeHealthIndicator(String healthCheckedFailedMessage) {
super(healthCheckedFailedMessage);
this.gemfireCache = null;
}
/**
* Constructs an instance of the {@link AbstractGeodeHealthIndicator} initialized with a reference to
* the {@link GemFireCache} instance.
*
* @param gemfireCache reference to the {@link GemFireCache} instance used to collect health information.
* @throws IllegalArgumentException if {@link GemFireCache} is {@literal null}.
* @see org.apache.geode.cache.GemFireCache
*/
public AbstractGeodeHealthIndicator(GemFireCache gemfireCache) {
replacedert.notNull(gemfireCache, "GemFireCache must not be null");
this.gemfireCache = gemfireCache;
}
/**
* Returns a reference to the {@link GemFireCache} instance.
*
* @return a reference to the {@link GemFireCache} instance.
* @see org.apache.geode.cache.GemFireCache
*/
protected Optional<GemFireCache> getGemFireCache() {
return Optional.ofNullable(this.gemfireCache);
}
/**
* Determines the {@link String name} of the {@link Clreplaced} type safely by handling {@literal null}.
*
* @param type {@link Clreplaced} type to evaluate.
* @return the {@link String name} of the {@link Clreplaced} type.
* @see java.lang.Clreplaced#getName()
*/
protected String nullSafeClreplacedName(Clreplaced<?> type) {
return type != null ? type.getName() : "";
}
/**
* Converts a {@link Boolean} value into a {@literal yes} / {@literal no} {@link String}.
*
* @param value {@link Boolean} value to convert.
* @return a {@literal yes} / {@literal no} response for the given {@link Boolean} value.
*/
protected String toYesNoString(Boolean value) {
return Boolean.TRUE.equals(value) ? "Yes" : "No";
}
}
18
Source : PdxInstanceBuilderUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Test(expected = IllegalStateException.clreplaced)
public void fromNonNullSourceObjectWhenCachePdxReadSerializedIsFalse() {
GemFireCache mockCache = mock(GemFireCache.clreplaced);
doReturn(false).when(mockCache).getPdxReadSerialized();
try {
PdxInstanceBuilder.create(mockCache).from("TEST");
} catch (IllegalStateException expected) {
replacedertThat(expected).hasMessage("PDX read-serialized must be set to true");
replacedertThat(expected).hasNoCause();
throw expected;
} finally {
verify(mockCache, times(1)).getPdxReadSerialized();
}
}
18
Source : GeodeClient.java
with MIT License
from aliyun
with MIT License
from aliyun
/**
* Apache Geode client for the YCSB benchmark.<br />
* <p>By default acts as a Geode client and tries to connect
* to Geode cache server running on localhost with default
* cache server port. Hostname and port of a Geode cacheServer
* can be provided using <code>geode.serverport=port</code> and <code>
* geode.serverhost=host</code> properties on YCSB command line.
* A locator may also be used for discovering a cacheServer
* by using the property <code>geode.locator=host[port]</code></p>
* <p>
* <p>To run this client in a peer-to-peer topology with other Geode
* nodes, use the property <code>geode.topology=p2p</code>. Running
* in p2p mode will enable embedded caching in this client.</p>
* <p>
* <p>YCSB by default does its operations against "usertable". When running
* as a client this is a <code>ClientRegionShortcut.PROXY</code> region,
* when running in p2p mode it is a <code>RegionShortcut.PARreplacedION</code>
* region. A cache.xml defining "usertable" region can be placed in the
* working directory to override these region definitions.</p>
*/
public clreplaced GeodeClient extends DB {
/**
* property name of the port where Geode server is listening for connections.
*/
private static final String SERVERPORT_PROPERTY_NAME = "geode.serverport";
/**
* property name of the host where Geode server is running.
*/
private static final String SERVERHOST_PROPERTY_NAME = "geode.serverhost";
/**
* default value of {@link #SERVERHOST_PROPERTY_NAME}.
*/
private static final String SERVERHOST_PROPERTY_DEFAULT = "localhost";
/**
* property name to specify a Geode locator. This property can be used in both
* client server and p2p topology
*/
private static final String LOCATOR_PROPERTY_NAME = "geode.locator";
/**
* property name to specify Geode topology.
*/
private static final String TOPOLOGY_PROPERTY_NAME = "geode.topology";
/**
* value of {@value #TOPOLOGY_PROPERTY_NAME} when peer to peer topology should be used.
* (client-server topology is default)
*/
private static final String TOPOLOGY_P2P_VALUE = "p2p";
/**
* Pattern to split up a locator string in the form host[port].
*/
private static final Pattern LOCATOR_PATTERN = Pattern.compile("(.+)\\[(\\d+)\\]");
private GemFireCache cache;
/**
* true if ycsb client runs as a client to a Geode cache server.
*/
private boolean isClient;
@Override
public void init() throws DBException {
Properties props = getProperties();
// hostName where Geode cacheServer is running
String serverHost = null;
// port of Geode cacheServer
int serverPort = 0;
String locatorStr = null;
if (props != null && !props.isEmpty()) {
String serverPortStr = props.getProperty(SERVERPORT_PROPERTY_NAME);
if (serverPortStr != null) {
serverPort = Integer.parseInt(serverPortStr);
}
serverHost = props.getProperty(SERVERHOST_PROPERTY_NAME, SERVERHOST_PROPERTY_DEFAULT);
locatorStr = props.getProperty(LOCATOR_PROPERTY_NAME);
String topology = props.getProperty(TOPOLOGY_PROPERTY_NAME);
if (topology != null && topology.equals(TOPOLOGY_P2P_VALUE)) {
CacheFactory cf = new CacheFactory();
if (locatorStr != null) {
cf.set("locators", locatorStr);
}
cache = cf.create();
isClient = false;
return;
}
}
isClient = true;
ClientCacheFactory ccf = new ClientCacheFactory();
ccf.setPdxReadSerialized(true);
if (serverPort != 0) {
ccf.addPoolServer(serverHost, serverPort);
} else {
InetSocketAddress locatorAddress = getLocatorAddress(locatorStr);
ccf.addPoolLocator(locatorAddress.getHostName(), locatorAddress.getPort());
}
cache = ccf.create();
}
static InetSocketAddress getLocatorAddress(String locatorStr) {
Matcher matcher = LOCATOR_PATTERN.matcher(locatorStr);
if (!matcher.matches()) {
throw new IllegalStateException("Unable to parse locator: " + locatorStr);
}
return new InetSocketAddress(matcher.group(1), Integer.parseInt(matcher.group(2)));
}
@Override
public Status read(String table, String key, Set<String> fields, Map<String, ByteIterator> result) {
Region<String, PdxInstance> r = getRegion(table);
PdxInstance val = r.get(key);
if (val != null) {
if (fields == null) {
for (String fieldName : val.getFieldNames()) {
result.put(fieldName, new ByteArrayByteIterator((byte[]) val.getField(fieldName)));
}
} else {
for (String field : fields) {
result.put(field, new ByteArrayByteIterator((byte[]) val.getField(field)));
}
}
return Status.OK;
}
return Status.ERROR;
}
@Override
public Status scan(String table, String startkey, int recordcount, Set<String> fields, Vector<HashMap<String, ByteIterator>> result) {
// Geode does not support scan
return Status.ERROR;
}
@Override
public Status update(String table, String key, Map<String, ByteIterator> values) {
getRegion(table).put(key, convertToBytearrayMap(values));
return Status.OK;
}
@Override
public Status insert(String table, String key, Map<String, ByteIterator> values) {
getRegion(table).put(key, convertToBytearrayMap(values));
return Status.OK;
}
@Override
public Status delete(String table, String key) {
getRegion(table).destroy(key);
return Status.OK;
}
private PdxInstance convertToBytearrayMap(Map<String, ByteIterator> values) {
PdxInstanceFactory pdxInstanceFactory = cache.createPdxInstanceFactory(JSONFormatter.JSON_CLreplacedNAME);
for (Map.Entry<String, ByteIterator> entry : values.entrySet()) {
pdxInstanceFactory.writeByteArray(entry.getKey(), entry.getValue().toArray());
}
return pdxInstanceFactory.create();
}
private Region<String, PdxInstance> getRegion(String table) {
Region<String, PdxInstance> r = cache.getRegion(table);
if (r == null) {
try {
if (isClient) {
ClientRegionFactory<String, PdxInstance> crf = ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY);
r = crf.create(table);
} else {
RegionFactory<String, PdxInstance> rf = ((Cache) cache).createRegionFactory(RegionShortcut.PARreplacedION);
r = rf.create(table);
}
} catch (RegionExistsException e) {
// another thread created the region
r = cache.getRegion(table);
}
}
return r;
}
}
17
Source : AsyncInlineCachingRegionConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean
@DependsOn(GOLFERS_REGION_NAME)
public GemfireTemplate golfersTemplate(GemFireCache gemfireCache) {
return new GemfireTemplate(gemfireCache.getRegion(GOLFERS_REGION_NAME));
}
17
Source : GeodeRegionsHealthIndicatorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Unit tests for {@link GeodeRegionsHealthIndicator}.
*
* @author John Blum
* @see org.junit.Test
* @see org.mockito.Mock
* @see org.mockito.Mockito
* @see org.mockito.junit.MockitoJUnitRunner
* @see org.apache.geode.cache.CacheStatistics
* @see org.apache.geode.cache.GemFireCache
* @see org.apache.geode.cache.Region
* @see org.springframework.boot.actuate.health.Health
* @see org.springframework.boot.actuate.health.HealthIndicator
* @see org.springframework.data.gemfire.tests.mock.CacheMockObjects
* @see org.springframework.geode.boot.actuate.GeodeRegionsHealthIndicator
* @since 1.0.0
*/
@RunWith(MockitoJUnitRunner.clreplaced)
public clreplaced GeodeRegionsHealthIndicatorUnitTests {
@Mock
private GemFireCache mockGemFireCache;
private GeodeRegionsHealthIndicator regionsHealthIndicator;
@Before
public void setup() {
this.regionsHealthIndicator = new GeodeRegionsHealthIndicator(this.mockGemFireCache);
}
@Test
@SuppressWarnings({ "rawtypes", "unchecked" })
public void healthCheckCapturesDetails() {
Region<?, ?> mockRegionOne = CacheMockObjects.mockRegion("MockRegionOne", DataPolicy.PARreplacedION);
when(mockRegionOne.getAttributes().getCloningEnabled()).thenReturn(true);
when(mockRegionOne.getAttributes().getInitialCapacity()).thenReturn(101);
when(mockRegionOne.getAttributes().getLoadFactor()).thenReturn(0.75f);
when(mockRegionOne.getAttributes().getKeyConstraint()).thenReturn((Clreplaced) Long.clreplaced);
when(mockRegionOne.getAttributes().getOffHeap()).thenReturn(true);
when(mockRegionOne.getAttributes().getPoolName()).thenReturn("");
when(mockRegionOne.getAttributes().getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
when(mockRegionOne.getAttributes().getStatisticsEnabled()).thenReturn(false);
when(mockRegionOne.getAttributes().getValueConstraint()).thenReturn((Clreplaced) Currency.clreplaced);
ParreplacedionAttributes<?, ?> mockParreplacedionAttributes = mock(ParreplacedionAttributes.clreplaced);
when(mockParreplacedionAttributes.getColocatedWith()).thenReturn("CollocatedRegion");
when(mockParreplacedionAttributes.getLocalMaxMemory()).thenReturn(10240);
when(mockParreplacedionAttributes.getRedundantCopies()).thenReturn(2);
// when(mockParreplacedionAttributes.getTotalMaxMemory()).thenReturn(4096000L);
when(mockParreplacedionAttributes.getTotalNumBuckets()).thenReturn(226);
when(mockRegionOne.getAttributes().getParreplacedionAttributes()).thenReturn(mockParreplacedionAttributes);
EvictionAttributes mockEvictionAttributes = mock(EvictionAttributes.clreplaced);
when(mockEvictionAttributes.getAction()).thenReturn(EvictionAction.LOCAL_DESTROY);
when(mockEvictionAttributes.getAlgorithm()).thenReturn(EvictionAlgorithm.LRU_ENTRY);
when(mockEvictionAttributes.getMaximum()).thenReturn(10000);
when(mockRegionOne.getAttributes().getEvictionAttributes()).thenReturn(mockEvictionAttributes);
Region<?, ?> mockRegionTwo = CacheMockObjects.mockRegion("MockRegionTwo", DataPolicy.EMPTY);
when(mockRegionTwo.getAttributes().getCloningEnabled()).thenReturn(false);
when(mockRegionTwo.getAttributes().getInitialCapacity()).thenReturn(0);
when(mockRegionTwo.getAttributes().getLoadFactor()).thenReturn(0.0f);
when(mockRegionTwo.getAttributes().getKeyConstraint()).thenReturn((Clreplaced) Integer.clreplaced);
when(mockRegionTwo.getAttributes().getOffHeap()).thenReturn(false);
when(mockRegionTwo.getAttributes().getPoolName()).thenReturn("TestPool");
when(mockRegionTwo.getAttributes().getScope()).thenReturn(Scope.DISTRIBUTED_NO_ACK);
when(mockRegionTwo.getAttributes().getStatisticsEnabled()).thenReturn(true);
when(mockRegionTwo.getAttributes().getValueConstraint()).thenReturn((Clreplaced) String.clreplaced);
ExpirationAttributes mockIdleTimeoutEntryExpirationAttributes = mock(ExpirationAttributes.clreplaced, "Entry-TTI");
when(mockIdleTimeoutEntryExpirationAttributes.getAction()).thenReturn(ExpirationAction.INVALIDATE);
when(mockIdleTimeoutEntryExpirationAttributes.getTimeout()).thenReturn(600);
when(mockRegionTwo.getAttributes().getEntryIdleTimeout()).thenReturn(mockIdleTimeoutEntryExpirationAttributes);
ExpirationAttributes mockTimeToLiveEntryExpirationAttributes = mock(ExpirationAttributes.clreplaced, "Entry-TTL");
when(mockTimeToLiveEntryExpirationAttributes.getAction()).thenReturn(ExpirationAction.DESTROY);
when(mockTimeToLiveEntryExpirationAttributes.getTimeout()).thenReturn(900);
when(mockRegionTwo.getAttributes().getEntryTimeToLive()).thenReturn(mockTimeToLiveEntryExpirationAttributes);
CacheStatistics mockCacheStatistics = mock(CacheStatistics.clreplaced);
when(mockCacheStatistics.getHitCount()).thenReturn(202408L);
when(mockCacheStatistics.getHitRatio()).thenReturn(0.82f);
when(mockCacheStatistics.getLastAccessedTime()).thenReturn(1L);
when(mockCacheStatistics.getLastModifiedTime()).thenReturn(2L);
when(mockCacheStatistics.getMissCount()).thenReturn(767L);
when(mockRegionTwo.getStatistics()).thenReturn(mockCacheStatistics);
Set<Region<?, ?>> mockRegions = replacedet(mockRegionOne, mockRegionTwo);
when(this.mockGemFireCache.rootRegions()).thenReturn(mockRegions);
Health.Builder builder = new Health.Builder();
this.regionsHealthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getStatus()).isEqualTo(Status.UP);
Map<String, Object> healthDetails = health.getDetails();
replacedertThat(healthDetails).isNotNull();
replacedertThat(healthDetails).isNotEmpty();
replacedertThat(healthDetails).containsEntry("geode.cache.regions", Arrays.asList("/MockRegionOne", "/MockRegionTwo"));
replacedertThat(healthDetails).containsEntry("geode.cache.regions.count", (long) mockRegions.size());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.cloning-enabled", "Yes");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.data-policy", DataPolicy.PARreplacedION.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.initial-capacity", 101);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.load-factor", 0.75f);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.key-constraint", Long.clreplaced.getName());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.off-heap", "Yes");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.eviction.action", EvictionAction.LOCAL_DESTROY.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.eviction.algorithm", EvictionAlgorithm.LRU_ENTRY.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.eviction.maximum", 10000);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.parreplacedion.collocated-with", "CollocatedRegion");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.parreplacedion.local-max-memory", 10240);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.parreplacedion.redundant-copies", 2);
// replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.parreplacedion.total-max-memory", 4096000L);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.parreplacedion.total-number-of-buckets", 226);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.pool-name", "");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.scope", Scope.DISTRIBUTED_ACK.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.statistics-enabled", "No");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionOne.value-constraint", Currency.clreplaced.getName());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.cloning-enabled", "No");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.data-policy", DataPolicy.EMPTY.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.initial-capacity", 0);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.load-factor", 0.0f);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.key-constraint", Integer.clreplaced.getName());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.off-heap", "No");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.pool-name", "TestPool");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.scope", Scope.DISTRIBUTED_NO_ACK.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.statistics-enabled", "Yes");
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.expiration.entry.tti.action", ExpirationAction.INVALIDATE.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.expiration.entry.tti.timeout", 600);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.expiration.entry.ttl.action", ExpirationAction.DESTROY.toString());
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.expiration.entry.ttl.timeout", 900);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.statistics.hit-count", 202408L);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.statistics.hit-ratio", 0.82f);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.statistics.last-accessed-time", 1L);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.statistics.last-modified-time", 2L);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.statistics.miss-count", 767L);
replacedertThat(healthDetails).containsEntry("geode.cache.regions.MockRegionTwo.value-constraint", String.clreplaced.getName());
verify(this.mockGemFireCache, times(1)).rootRegions();
}
@Test
public void healthCheckFailsWhenGemFireCacheIsNotPresent() {
GeodeRegionsHealthIndicator healthIndicator = new GeodeRegionsHealthIndicator();
Health.Builder builder = new Health.Builder();
healthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getDetails()).isEmpty();
replacedertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
}
}
17
Source : GeodeCacheHealthIndicatorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Unit tests for {@link GeodeCacheHealthIndicator}.
*
* @author John Blum
* @see org.junit.Test
* @see org.mockito.Mock
* @see org.mockito.Mockito
* @see org.mockito.junit.MockitoJUnitRunner
* @see org.apache.geode.CancelCriterion
* @see org.apache.geode.cache.GemFireCache
* @see org.apache.geode.cache.control.ResourceManager
* @see org.apache.geode.distributed.DistributedMember
* @see org.apache.geode.distributed.DistributedSystem
* @see org.springframework.boot.actuate.health.Health
* @see org.springframework.boot.actuate.health.HealthIndicator
* @see org.springframework.data.gemfire.tests.mock.CacheMockObjects
* @see org.springframework.geode.boot.actuate.GeodeCacheHealthIndicator
* @since 1.0.0
*/
@RunWith(MockitoJUnitRunner.clreplaced)
public clreplaced GeodeCacheHealthIndicatorUnitTests {
@Mock
private GemFireCache mockGemFireCache;
private GeodeCacheHealthIndicator cacheHealthIndicator;
@Before
public void setup() {
this.cacheHealthIndicator = new GeodeCacheHealthIndicator(this.mockGemFireCache);
}
@SuppressWarnings("all")
private Set<DistributedMember> mockDistributedMembers(int size) {
return IntStream.range(0, size).mapToObj(it -> mock(DistributedMember.clreplaced)).collect(Collectors.toSet());
}
@Test
public void healthCheckCapturesDetails() throws Exception {
DistributedMember mockDistributedMember = CacheMockObjects.mockDistributedMember("TestMember", "TestGroup", "MockGroup");
when(mockDistributedMember.getHost()).thenReturn("Skullbox");
when(mockDistributedMember.getProcessId()).thenReturn(12345);
DistributedSystem mockDistributedSystem = CacheMockObjects.mockDistributedSystem(mockDistributedMember);
when(mockDistributedSystem.getAllOtherMembers()).thenAnswer(invocation -> mockDistributedMembers(8));
when(mockDistributedSystem.isConnected()).thenReturn(true);
when(mockDistributedSystem.isReconnecting()).thenReturn(false);
ResourceManager mockResourceManager = CacheMockObjects.mockResourceManager(0.9f, 0.95f, 0.85f, 0.9f);
GemFireCache mockGemFireCache = CacheMockObjects.mockGemFireCache(this.mockGemFireCache, "MockGemFireCache", mockDistributedSystem, mockResourceManager);
CancelCriterion mockCancelCriterion = mock(CancelCriterion.clreplaced);
when(mockCancelCriterion.isCancelInProgress()).thenReturn(false);
when(mockGemFireCache.getCancelCriterion()).thenReturn(mockCancelCriterion);
when(mockGemFireCache.isClosed()).thenReturn(false);
Health.Builder builder = new Health.Builder();
this.cacheHealthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getStatus()).isEqualTo(Status.UP);
Map<String, Object> healthDetails = health.getDetails();
replacedertThat(healthDetails).isNotNull();
replacedertThat(healthDetails).isNotEmpty();
replacedertThat(healthDetails).containsEntry("geode.cache.name", "MockGemFireCache");
replacedertThat(healthDetails).containsEntry("geode.cache.closed", "No");
replacedertThat(healthDetails).containsEntry("geode.cache.cancel-in-progress", "No");
replacedertThat(healthDetails).containsKey("geode.distributed-member.id");
replacedertThat(String.valueOf(healthDetails.get("geode.distributed-member.id"))).isNotEqualToIgnoringCase("null");
replacedertThat(healthDetails).containsEntry("geode.distributed-member.name", "TestMember");
replacedertThat(healthDetails).containsEntry("geode.distributed-member.groups", Arrays.asList("TestGroup", "MockGroup"));
replacedertThat(healthDetails).containsEntry("geode.distributed-member.host", "Skullbox");
replacedertThat(healthDetails).containsEntry("geode.distributed-member.process-id", 12345);
replacedertThat(healthDetails).containsEntry("geode.distributed-system.member-count", 9);
replacedertThat(healthDetails).containsEntry("geode.distributed-system.connection", "Connected");
replacedertThat(healthDetails).containsEntry("geode.distributed-system.reconnecting", "No");
// replacedertThat(healthDetails).containsKey("geode.distributed-member.properties-location");
// replacedertThat(healthDetails).containsKey("geode.distributed-member.security-properties-location");
replacedertThat(healthDetails).containsEntry("geode.resource-manager.critical-heap-percentage", 0.9f);
replacedertThat(healthDetails).containsEntry("geode.resource-manager.critical-off-heap-percentage", 0.95f);
replacedertThat(healthDetails).containsEntry("geode.resource-manager.eviction-heap-percentage", 0.85f);
replacedertThat(healthDetails).containsEntry("geode.resource-manager.eviction-off-heap-percentage", 0.9f);
verify(this.mockGemFireCache, times(1)).getCancelCriterion();
verify(this.mockGemFireCache, times(2)).getDistributedSystem();
verify(this.mockGemFireCache, times(1)).getResourceManager();
verify(mockDistributedSystem, times(1)).getDistributedMember();
}
@Test
public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception {
GeodeCacheHealthIndicator healthIndicator = new GeodeCacheHealthIndicator();
Health.Builder builder = new Health.Builder();
healthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getDetails()).isEmpty();
replacedertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
}
}
17
Source : PdxInstanceBuilderUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Test(expected = IllegalArgumentException.clreplaced)
public void fromNonNullSourceObjectReturningNullOnPdxInstanceFactoryCreateIsNullSafe() {
Object source = mock(Object.clreplaced);
GemFireCache mockCache = mock(GemFireCache.clreplaced);
PdxInstanceFactory mockPdxInstanceFactory = mock(PdxInstanceFactory.clreplaced);
doReturn(true).when(mockCache).getPdxReadSerialized();
doReturn(mockPdxInstanceFactory).when(mockCache).createPdxInstanceFactory(eq(source.getClreplaced().getName()));
doReturn(null).when(mockPdxInstanceFactory).create();
PdxInstanceBuilder builder = PdxInstanceBuilder.create(mockCache);
replacedertThat(builder).isNotNull();
replacedertThat(builder.getRegionService()).isEqualTo(mockCache);
PdxInstanceBuilder.Factory factory = builder.from(source);
replacedertThat(factory).isNotNull();
try {
factory.create();
} catch (IllegalArgumentException expected) {
replacedertThat(expected).hasMessage("Expected an instance of PDX but was an instance of type [null];" + " Was PDX read-serialized set to true");
replacedertThat(expected).hasNoCause();
throw expected;
} finally {
verify(mockCache, times(1)).getPdxReadSerialized();
verify(mockCache, times(1)).createPdxInstanceFactory(eq(source.getClreplaced().getName()));
verify(mockPdxInstanceFactory, times(1)).writeObject(eq("source"), eq(source));
verifyNoInteractions(source);
}
}
17
Source : GeodeSchema.java
with Apache License 2.0
from polypheny
with Apache License 2.0
from polypheny
/**
* Schema mapped onto a Geode Region.
*/
public clreplaced GeodeSchema extends AbstractSchema {
final GemFireCache cache;
private final List<String> regionNames;
private ImmutableMap<String, Table> tableMap;
GeodeSchema(String locatorHost, int locatorPort, Iterable<String> regionNames, String pdxAutoSerializerPackageExp) {
this(GeodeUtils.createClientCache(locatorHost, locatorPort, pdxAutoSerializerPackageExp, true), regionNames);
}
GeodeSchema(final GemFireCache cache, final Iterable<String> regionNames) {
super();
this.cache = Objects.requireNonNull(cache, "clientCache");
this.regionNames = ImmutableList.copyOf(Objects.requireNonNull(regionNames, "regionNames"));
}
@Override
protected Map<String, Table> getTableMap() {
if (tableMap == null) {
final ImmutableMap.Builder<String, Table> builder = ImmutableMap.builder();
for (String regionName : regionNames) {
Region region = GeodeUtils.createRegion(cache, regionName);
Table table = new GeodeTable(region);
builder.put(regionName, table);
}
tableMap = builder.build();
}
return tableMap;
}
}
16
Source : ManuallyConfiguredWithPropertiesSessionCachingIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Test(expected = NoSuchBeanDefinitionException.clreplaced)
public void gemfireSessionRegionAndSessionRepositoryAreNotPresent() {
String sessionsRegionName = GemFireHttpSessionConfiguration.DEFAULT_SESSION_REGION_NAME;
replacedertThat(this.applicationContext.containsBean("gemfireCache")).isTrue();
replacedertThat(this.applicationContext.containsBean("sessionRepository")).isFalse();
replacedertThat(this.applicationContext.containsBean(sessionsRegionName)).isFalse();
replacedertThat(this.applicationContext.getBeansOfType(SessionRepository.clreplaced)).isEmpty();
GemFireCache gemfireCache = this.applicationContext.getBean(GemFireCache.clreplaced);
replacedertThat(gemfireCache).isNotNull();
replacedertThat(gemfireCache.rootRegions()).isEmpty();
this.applicationContext.getBean(SessionRepository.clreplaced);
}
16
Source : PdxInstanceBuilderUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Test(expected = IllegalArgumentException.clreplaced)
public void fromNonNullSourceObjectReturningNonPdxInstanceThrowsIllegalArgumentException() {
Object source = new Object();
GemFireCache mockCache = mock(GemFireCache.clreplaced);
PdxInstance mockPdxInstanceHolder = mock(PdxInstance.clreplaced);
PdxInstanceFactory mockPdxInstanceFactory = mock(PdxInstanceFactory.clreplaced);
doReturn(true).when(mockCache).getPdxReadSerialized();
doReturn(mockPdxInstanceFactory).when(mockCache).createPdxInstanceFactory(eq(source.getClreplaced().getName()));
doReturn(mockPdxInstanceHolder).when(mockPdxInstanceFactory).create();
doReturn(source).when(mockPdxInstanceHolder).getField(eq("source"));
PdxInstanceBuilder builder = PdxInstanceBuilder.create(mockCache);
replacedertThat(builder).isNotNull();
replacedertThat(builder.getRegionService()).isEqualTo(mockCache);
PdxInstanceBuilder.Factory factory = builder.from(source);
replacedertThat(factory).isNotNull();
try {
factory.create();
} catch (IllegalArgumentException expected) {
replacedertThat(expected).hasMessage("Expected an instance of PDX but was an instance of type [%s];" + " Was PDX read-serialized set to true", source.getClreplaced().getName());
replacedertThat(expected).hasNoCause();
throw expected;
} finally {
verify(mockCache, times(1)).getPdxReadSerialized();
verify(mockCache, times(1)).createPdxInstanceFactory(eq(source.getClreplaced().getName()));
verify(mockPdxInstanceFactory, times(1)).writeObject(eq("source"), eq(source));
verify(mockPdxInstanceHolder, times(1)).getField(eq("source"));
}
}
16
Source : PdxInstanceBuilderUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Test
public void fromSourceObject() {
Object source = new Object();
GemFireCache mockCache = mock(GemFireCache.clreplaced);
PdxInstance mockPdxInstanceHolder = mock(PdxInstance.clreplaced);
PdxInstance mockPdxInstanceSource = mock(PdxInstance.clreplaced);
PdxInstanceFactory mockPdxInstanceFactory = mock(PdxInstanceFactory.clreplaced);
doReturn(true).when(mockCache).getPdxReadSerialized();
doReturn(mockPdxInstanceFactory).when(mockCache).createPdxInstanceFactory(eq(source.getClreplaced().getName()));
doReturn(mockPdxInstanceHolder).when(mockPdxInstanceFactory).create();
doReturn(mockPdxInstanceSource).when(mockPdxInstanceHolder).getField(eq("source"));
PdxInstanceBuilder builder = PdxInstanceBuilder.create(mockCache);
replacedertThat(builder).isNotNull();
replacedertThat(builder.getRegionService()).isEqualTo(mockCache);
PdxInstanceBuilder.Factory factory = builder.from(source);
replacedertThat(factory).isNotNull();
replacedertThat(factory.create()).isEqualTo(mockPdxInstanceSource);
verify(mockCache, times(1)).getPdxReadSerialized();
verify(mockCache, times(1)).createPdxInstanceFactory(eq(source.getClreplaced().getName()));
verify(mockPdxInstanceFactory, times(1)).writeObject(eq("source"), eq(source));
verify(mockPdxInstanceFactory, times(1)).create();
verify(mockPdxInstanceHolder, times(1)).getField(eq("source"));
verifyNoInteractions(mockPdxInstanceSource);
}
15
Source : GemFireMockObjectsBeanPostProcessorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Test
public void postProcessAfterInitializationWithGemFireCache() {
GemFireMockObjectsBeanPostProcessor beanPostProcessor = spy(new GemFireMockObjectsBeanPostProcessor());
Properties gemfireProperties = new PropertiesBuilder().setProperty("name", "postProcessAfterInitializationWithGemFireCacheTest").setProperty("log-level", "error").build();
doReturn(gemfireProperties).when(beanPostProcessor).getGemFireProperties();
GemFireCache mockCache = mock(GemFireCache.clreplaced);
DistributedSystem mockDistributedSystem = mock(DistributedSystem.clreplaced);
doReturn(mockDistributedSystem).when(mockCache).getDistributedSystem();
replacedertThat(beanPostProcessor.postProcessAfterInitialization(mockCache, "gemfireCache")).isEqualTo(mockCache);
replacedertThat(mockCache.getDistributedSystem().getProperties()).isSameAs(gemfireProperties);
verify(beanPostProcessor, times(1)).getGemFireProperties();
}
15
Source : GemFireObjectCreationTriggeredByGemFirePropertyConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration Tests for Apache Geode & VMware GemFire {@link Object} creation when the {@link Object} configuration
* and {@link Clreplaced} type is expressed in {@link Properties}.
*
* @author John Blum
* @see org.junit.Test
* @see org.springframework.data.gemfire.config.annotation.EnableSecurity
* @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.clreplaced)
@ContextConfiguration
@SuppressWarnings("unused")
public clreplaced GemFireObjectCreationTriggeredByGemFirePropertyConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache gemfireCache;
@Test
public void securityManagerIsPresent() {
replacedertThat(this.gemfireCache).isNotNull();
replacedertThat(TestSecurityManager.getInstance()).isInstanceOf(TestSecurityManager.clreplaced);
}
@PeerCacheApplication
@EnableGemFireMockObjects
@EnableSecurity(securityManagerClreplacedName = "org.springframework.data.gemfire.tests.objects.geode.security.TestSecurityManager")
static clreplaced TestConfiguration {
}
}
15
Source : GemFireMockObjectsBeanPostProcessor.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Nullable
@Override
public Object postProcessAfterInitialization(@NonNull Object bean, String beanName) throws BeansException {
if (bean instanceof GemFireCache) {
GemFireCache gemfireCache = (GemFireCache) bean;
DistributedSystem distributedSystem = gemfireCache.getDistributedSystem();
doReturn(getGemFireProperties()).when(distributedSystem).getProperties();
}
return bean;
}
15
Source : AsyncInlineCachingRegionConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean(GOLFERS_REGION_NAME)
public ReplicatedRegionFactoryBean<Object, Object> golfersRegion(GemFireCache gemfireCache, AsyncInlineCachingRegionConfigurer<Golfer, String> asyncInlineCachingRegionConfigurer) {
ReplicatedRegionFactoryBean<Object, Object> golfersRegion = new ReplicatedRegionFactoryBean<>();
golfersRegion.setCache(gemfireCache);
golfersRegion.setPersistent(false);
golfersRegion.setRegionConfigurers(asyncInlineCachingRegionConfigurer);
return golfersRegion;
}
15
Source : LoggingAutoConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration Tests replacederting the configuration and behavior of Apache Geode logging when configured with
* Spring Boot auto-configuration.
*
* @author John Blum
* @see java.util.Properties
* @see org.junit.Test
* @see org.apache.geode.cache.GemFireCache
* @see org.apache.geode.distributed.internal.DistributionConfig
* @see org.springframework.boot.autoconfigure.SpringBootApplication
* @see org.springframework.boot.test.context.SpringBootTest
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.1.0
*/
@RunWith(SpringRunner.clreplaced)
@SpringBootTest(properties = { "spring.data.gemfire.logging.level=fine", "spring.data.gemfire.logging.log-disk-space-limit=4096", "spring.data.gemfire.logging.log-file=/path/to/gemfire.log", "spring.data.gemfire.logging.log-file-size-limit=512" }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SuppressWarnings("unused")
public clreplaced LoggingAutoConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache gemfireCache;
@Test
public void loggingConfigurationWasApplied() {
replacedertThat(this.gemfireCache).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem()).isNotNull();
Properties distributedSystemProperties = this.gemfireCache.getDistributedSystem().getProperties();
replacedertThat(distributedSystemProperties.getProperty(GeodeConstants.LOG_DISK_SPACE_LIMIT)).isEqualTo("4096");
replacedertThat(distributedSystemProperties.getProperty(GeodeConstants.LOG_FILE)).isEqualTo("/path/to/gemfire.log");
replacedertThat(distributedSystemProperties.getProperty(GeodeConstants.LOG_FILE_SIZE_LIMIT)).isEqualTo("512");
replacedertThat(distributedSystemProperties.getProperty(GeodeConstants.LOG_LEVEL)).isEqualTo("fine");
}
@SpringBootApplication
@EnableGemFireMockObjects
static clreplaced TestConfiguration {
}
}
15
Source : SpringBootApacheGeodePeerCacheApplicationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration Tests testing the auto-configuration of an Apache Geode peer {@link Cache} instance, overriding
* the default {@link ClientCache} instance.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.Cache
* @see org.apache.geode.cache.GemFireCache
* @see org.apache.geode.cache.Region
* @see org.springframework.boot.autoconfigure.SpringBootApplication
* @see org.springframework.boot.test.context.SpringBootTest
* @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.clreplaced)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SuppressWarnings("unused")
public clreplaced SpringBootApacheGeodePeerCacheApplicationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache peerCache;
@Test
public void peerCacheWithPeerLocalRegionAreAvailable() {
Optional.ofNullable(this.peerCache).map(it -> replacedertThat(GemfireUtils.isClient(it)).isFalse()).orElseThrow(() -> newIllegalStateException("Peer cache was null"));
Region<Object, Object> example = this.peerCache.getRegion("/Example");
replacedertThat(example).isNotNull();
replacedertThat(example.getName()).isEqualTo("Example");
replacedertThat(example.getFullPath()).isEqualTo(RegionUtils.toRegionPath("Example"));
example.put(1, "test");
replacedertThat(example.get(1)).isEqualTo("test");
}
@SpringBootApplication
@PeerCacheApplication
static clreplaced TestConfiguration {
@Bean("Example")
public LocalRegionFactoryBean<Object, Object> exampleRegion(GemFireCache gemfireCache) {
LocalRegionFactoryBean<Object, Object> exampleRegion = new LocalRegionFactoryBean<>();
exampleRegion.setCache(gemfireCache);
exampleRegion.setClose(false);
exampleRegion.setPersistent(false);
return exampleRegion;
}
}
}
15
Source : GeodePoolsHealthIndicatorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
public void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) {
GeodePoolsHealthIndicator healthIndicator = gemfireCache != null ? new GeodePoolsHealthIndicator(gemfireCache) : new GeodePoolsHealthIndicator();
Health.Builder builder = new Health.Builder();
healthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getDetails()).isEmpty();
replacedertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
}
15
Source : GeodeGatewaySendersHealthIndicatorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
private void testHealthCheckFailsWithInvalidGemFireCache(GemFireCache gemfireCache) throws Exception {
GeodeGatewaySendersHealthIndicator healthIndicator = gemfireCache != null ? new GeodeGatewaySendersHealthIndicator(gemfireCache) : new GeodeGatewaySendersHealthIndicator();
Health.Builder builder = new Health.Builder();
healthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
replacedertThat(health.getDetails()).isEmpty();
}
15
Source : GeodeGatewayReceiversHealthIndicatorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
private void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception {
GeodeGatewayReceiversHealthIndicator healthIndicator = gemfireCache != null ? new GeodeGatewayReceiversHealthIndicator(gemfireCache) : new GeodeGatewayReceiversHealthIndicator();
Health.Builder builder = new Health.Builder();
healthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getDetails()).isEmpty();
replacedertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
}
15
Source : GeodeCacheServersHealthIndicatorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
private void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception {
GeodeCacheServersHealthIndicator healthIndicator = gemfireCache != null ? new GeodeCacheServersHealthIndicator(gemfireCache) : new GeodeCacheServersHealthIndicator();
Health.Builder builder = new Health.Builder();
healthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getDetails()).isEmpty();
replacedertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
}
15
Source : GeodeAsyncEventQueuesHealthIndicatorUnitTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
public void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception {
GeodeAsyncEventQueuesHealthIndicator healthIndicator = gemfireCache != null ? new GeodeAsyncEventQueuesHealthIndicator(gemfireCache) : new GeodeAsyncEventQueuesHealthIndicator();
Health.Builder builder = new Health.Builder();
healthIndicator.doHealthCheck(builder);
Health health = builder.build();
replacedertThat(health).isNotNull();
replacedertThat(health.getDetails()).isEmpty();
replacedertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
}
15
Source : MemberNameOverridesCacheNameIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration tests for {@link UseMemberName} and {@link MemberNameConfiguration} replacederting that {@link UseMemberName}
* overrides the cache name specified using the {@literal name} attribute of the corresponding caching annotation
* (e.g. {@link ClientCacheApplication#name()} or {@link PeerCacheApplication#name()}.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.GemFireCache
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.clreplaced)
@ContextConfiguration
@SuppressWarnings("unused")
public clreplaced MemberNameOverridesCacheNameIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache gemfireCache;
@Test
public void gemfireNameIsMemberName() {
replacedertThat(this.gemfireCache).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties().getProperty("name")).isEqualTo("TestMemberName");
}
@ClientCacheApplication(name = "TestCacheName")
@UseMemberName("TestMemberName")
@EnableGemFireMockObjects
static clreplaced TestConfiguration {
}
}
15
Source : MemberNameConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration tests for {@link UseMemberName} and {@link MemberNameConfiguration}.
*
* @author John Blum
* @see org.apache.geode.cache.GemFireCache
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.clreplaced)
@ContextConfiguration
@SuppressWarnings("unused")
public clreplaced MemberNameConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache gemfireCache;
@Test
public void memberNameWasConfiguredCorrectly() {
replacedertThat(this.gemfireCache).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties().getProperty("name")).isEqualTo("TestClient");
}
@ClientCacheApplication
@EnableGemFireMockObjects
@UseMemberName("TestClient")
static clreplaced TestConfiguration {
}
}
15
Source : GroupsConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration tests for {@link UseGroups} and {@link GroupsConfiguration}.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.GemFireCache
* @see org.springframework.data.gemfire.config.annotation.ClientCacheApplication
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.clreplaced)
@ContextConfiguration
@SuppressWarnings("unused")
public clreplaced GroupsConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache gemfireCache;
@Test
public void groupsAreConfiguredCorrectly() {
replacedertThat(this.gemfireCache).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties().getProperty("groups")).isEqualTo("MockGroup,TestGroup");
}
@ClientCacheApplication
@EnableGemFireMockObjects
@UseGroups({ "MockGroup", "TestGroup" })
static clreplaced TestConfiguration {
}
}
15
Source : DistributedSystemIdConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration tests for {@link UseDistributedSystemId} and {@link DistributedSystemIdConfiguration}.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.GemFireCache
* @see org.springframework.data.gemfire.config.annotation.PeerCacheApplication
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.geode.config.annotation.DistributedSystemIdConfiguration
* @see org.springframework.geode.config.annotation.UseDistributedSystemId
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.clreplaced)
@ContextConfiguration
@SuppressWarnings("unused")
public clreplaced DistributedSystemIdConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache gemfireCache;
@Test
public void distributedSystemIdWasConfiguredCorrectly() {
replacedertThat(this.gemfireCache).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties()).isNotNull();
replacedertThat(this.gemfireCache.getDistributedSystem().getProperties().getProperty("distributed-system-id")).isEqualTo("42");
}
@PeerCacheApplication
@EnableGemFireMockObjects
@UseDistributedSystemId(42)
static clreplaced TestConfiguration {
}
}
15
Source : GeodeUtils.java
with Apache License 2.0
from polypheny
with Apache License 2.0
from polypheny
/**
* Obtains a proxy pointing to an existing Region on the server
*
* @param cache {@link GemFireCache} instance to interact with the Geode server
* @param regionName Name of the region to create proxy for.
* @return Returns a Region proxy to a remote (on the Server) regions.
*/
public static synchronized Region createRegion(GemFireCache cache, String regionName) {
Objects.requireNonNull(cache, "cache");
Objects.requireNonNull(regionName, "regionName");
Region region = REGION_MAP.get(regionName);
if (region == null) {
try {
region = ((ClientCache) cache).createClientRegionFactory(ClientRegionShortcut.PROXY).create(regionName);
} catch (IllegalStateException e) {
// means this is a server cache (probably part of embedded testing)
region = cache.getRegion(regionName);
}
REGION_MAP.put(regionName, region);
}
return region;
}
15
Source : AppController.java
with Apache License 2.0
from pivotal-cf
with Apache License 2.0
from pivotal-cf
/**
* Implementation of all the REST APIs exposed by pizza store app
*/
@RestController
@SuppressWarnings("unused")
public clreplaced AppController {
private final GemFireCache gemfireCache;
private final NameRepository nameRepository;
private final PizzaRepository pizzaRepository;
public AppController(GemFireCache gemfireCache, NameRepository nameRepository, PizzaRepository pizzaRepository) {
this.gemfireCache = gemfireCache;
this.nameRepository = nameRepository;
this.pizzaRepository = pizzaRepository;
}
/**
* Clears data from all regions.
*/
@GetMapping("/cleanSlate")
public String cleanSlate() {
this.nameRepository.deleteAll();
this.pizzaRepository.deleteAll();
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<h1>OVEN EMPTY!</h1>").append("<p><a href=\"/\">/home</a></p>");
return stringBuilder.toString();
}
/**
* Health checks
*/
@GetMapping("/")
public String ping() {
StringBuilder sb = new StringBuilder();
sb.append("<h1>Welcome to Pizza Store!</h1>").append("<p>Below are the endpoints available to you.</p>").append("<p><a href=\"/\">/</a> -> App healthcheck and usage.</p>").append("<p><a href=\"/ping\">/ping</a> -> App healthcheck. Responds with an HTTP status code of `200 - OK` and an HTTP message body\n" + " of \"PONG!\" if the app is running correctly.\n</p>").append("<p><a href=\"/preheatOven\">/preheatOven</a> -> Loads pre defined Pizzas into a GemFire region.</p>").append("<p><a href=\"/pizzas\">/pizzas</a> -> Gets all Pizzas from GemFire region.</p>").append("<p>/pizzas/{name} -> Gets a Pizza from GemFire region.<br /></p>").append("<p>/pizzas/order/{name} -> Orders a given pizza. example `https://APP-URL/pizzas/order/myCustomPizza?sauce=MARINARA&toppings=CHEESE,PEPPERONI,MUSHROOM`</p>").append("<p>/pizzas/pestoOrder/{name} -> Orders a pesto pizza. example `https://APP-URL/pizzas/pestoOrder/myPesto`</p>").append("<p><a href=\"/cleanSlate\">/cleanSlate</a> -> Deletes all Pizzas from GemFire region.</p>");
return sb.toString();
}
// Simple endpoint for testing
@GetMapping("/ping")
public String pingPong() {
return "<h1>PONG!</h1>";
}
/**
* Creates some predefined pizzas.
*/
@RequestMapping("/preheatOven")
public ResponseEnreplacedy<Object> preheatOven() {
LogWriter logger = gemfireCache.getLogger();
Pizza plainPizza = makePlainPizza();
Pizza fancyPizza = makeFancyPizza();
Pizza superFancyPizza = makeSuperFancyPizza("test");
this.pizzaRepository.save(plainPizza);
this.pizzaRepository.save(fancyPizza);
this.pizzaRepository.save(superFancyPizza);
logger.info("Finished baking pizzas");
Optional<Pizza> pizza = this.pizzaRepository.findById("plain");
if (!pizza.isPresent()) {
return new ResponseEnreplacedy<>(HttpStatus.NOT_FOUND);
}
if (!pizza.filter(it -> it.uses(Pizza.Sauce.TOMATO)).isPresent()) {
logger.info(String.format("I ordered tomato sauce; Pizza was [%s]", pizza.map(Pizza::toString).orElse(null)));
return new ResponseEnreplacedy<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
if (!pizza.filter(it -> it.has(Pizza.Topping.CHEESE)).isPresent()) {
logger.info(String.format("Where's my cheese? Pizza was [%s]", pizza.map(Pizza::toString).orElse(null)));
return new ResponseEnreplacedy<>(HttpStatus.INTERNAL_SERVER_ERROR);
}
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<h1>OVEN HEATED!</h1>").append("<p><a href=\"/\">/home</a></p>");
return new ResponseEnreplacedy<>(stringBuilder.toString(), HttpStatus.OK);
}
/**
* Returns all pizzas from Pizza region.
*/
@GetMapping("/pizzas")
public Object getPizzas() {
Iterable<Pizza> pizzas = this.pizzaRepository.findAll();
return nullSafeIterable(pizzas).iterator().hasNext() ? pizzas : "<h1>No Pizzas Found</h1>";
}
/**
* Returns details of a given pizza.
* @param pizzaName
*/
@GetMapping("/pizzas/{name}")
public Object getNamedPizza(@PathVariable("name") String pizzaName) {
Pizza namedPizza = this.pizzaRepository.findById(pizzaName).orElse(null);
return namedPizza != null ? namedPizza : String.format("<h1>Pizza [%s] Not Found</h1>", pizzaName);
}
/**
* Creates a new pizza with the given name, toppings and sauce.
* @param name
* @param pizzaSauce
* @param toppings
*/
@GetMapping("/pizzas/order/{name}")
public String order(@PathVariable("name") String name, @RequestParam(name = "sauce", defaultValue = "TOMATO") Pizza.Sauce pizzaSauce, @RequestParam(name = "toppings", defaultValue = "CHEESE") Pizza.Topping[] toppings) {
Pizza namedPizza = Pizza.named(name).having(pizzaSauce);
Arrays.stream(toppings).forEach(namedPizza::with);
this.pizzaRepository.save(namedPizza);
return String.format("<h1>Pizza [%s] Ordered</h1>", namedPizza);
}
/**
* Orders a Pesto Pizza
* @param name
*/
// Technically, this should be a POST, but...
@GetMapping("/pizzas/pestoOrder/{name}")
public String pestoOrder(@PathVariable("name") String name) {
this.pizzaRepository.save(makeSuperFancyPizza(name));
return String.format("<h1>Pesto Pizza [%s] Ordered</h1>", name);
}
private Pizza makeFancyPizza() {
return Pizza.named("fancy").having(Pizza.Sauce.ALFREDO).with(Pizza.Topping.ARUGULA).with(Pizza.Topping.CHICKEN);
}
private Pizza makePlainPizza() {
return Pizza.named("plain").with(Pizza.Topping.CHEESE);
}
private Pizza makeSuperFancyPizza(String name) {
return Pizza.named(name).having(Pizza.Sauce.PESTO).with(Pizza.Topping.CHICKEN).with(Pizza.Topping.PARMESAN).with(Pizza.Topping.CHERRY_TOMATOES);
}
private <T> Iterable<T> nullSafeIterable(Iterable<T> iterable) {
return iterable != null ? iterable : Collections::emptyIterator;
}
}
14
Source : SpringBootApacheGeodeDockerClientCacheApplication.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
private void replacedertClientCacheAndConfigureMappingPdxSerializer(GemFireCache cache) {
replacedertThat(cache).isNotNull();
replacedertThat(cache.getName()).isEqualTo(SpringBootApacheGeodeDockerClientCacheApplication.clreplaced.getSimpleName());
replacedertThat(cache.getPdxSerializer()).isInstanceOf(MappingPdxSerializer.clreplaced);
MappingPdxSerializer serializer = (MappingPdxSerializer) cache.getPdxSerializer();
serializer.setIncludeTypeFilters(type -> Optional.ofNullable(type).map(Clreplaced::getPackage).map(Package::getName).filter(packageName -> packageName.startsWith(this.getClreplaced().getPackage().getName())).isPresent());
}
14
Source : ManuallyConfiguredSessionCachingIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Test
public void gemfireSessionRegionAndSessionRepositoryAreNotPresent() {
replacedertThat(this.applicationContext.containsBean("gemfireCache")).isTrue();
replacedertThat(this.applicationContext.containsBean("sessionRepository")).isTrue();
replacedertThat(this.applicationContext.containsBean(GemFireHttpSessionConfiguration.DEFAULT_SESSION_REGION_NAME)).isFalse();
GemFireCache gemfireCache = this.applicationContext.getBean(GemFireCache.clreplaced);
replacedertThat(gemfireCache).isNotNull();
replacedertThat(gemfireCache.rootRegions()).isEmpty();
SessionRepository<?> sessionRepository = this.applicationContext.getBean(SessionRepository.clreplaced);
replacedertThat(sessionRepository).isNotNull();
replacedertThat(sessionRepository).isNotInstanceOf(GemFireOperationsSessionRepository.clreplaced);
replacedertThat(sessionRepository.getClreplaced().getName().toLowerCase()).doesNotContain("redis");
}
14
Source : MappingPdxSerializerPdxSerializationAutoConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Unit Tests for {@link PdxSerializationAutoConfiguration} replacederting that SDG's {@link MappingPdxSerializer}
* is {@literal auto-configured} on the cache when a custom, user-defined {@link PdxSerializer} is not declared.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.GemFireCache
* @see org.apache.geode.pdx.PdxSerializer
* @see org.springframework.boot.autoconfigure.SpringBootApplication
* @see org.springframework.boot.test.context.SpringBootTest
* @see org.springframework.context.annotation.Profile
* @see org.springframework.data.gemfire.mapping.MappingPdxSerializer
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.geode.boot.autoconfigure.PdxSerializationAutoConfiguration
* @see org.springframework.test.context.ActiveProfiles
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.3.0
*/
@ActiveProfiles("MAPPING_PDX_SERIALIZER")
@RunWith(SpringRunner.clreplaced)
@SpringBootTest(properties = "spring.application.name=MappingPdxSerializerPdxSerializationAutoConfigurationIntegrationTests", webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SuppressWarnings("unused")
public clreplaced MappingPdxSerializerPdxSerializationAutoConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache cache;
@Test
public void cacheIsAutoConfiguredWithMappingPdxSerializer() {
replacedertThat(this.cache).isNotNull();
replacedertThat(this.cache.getName()).isEqualTo(MappingPdxSerializerPdxSerializationAutoConfigurationIntegrationTests.clreplaced.getSimpleName());
replacedertThat(this.cache.getPdxSerializer()).isInstanceOf(MappingPdxSerializer.clreplaced);
}
@SpringBootApplication
@EnableGemFireMockObjects
@Profile("MAPPING_PDX_SERIALIZER")
static clreplaced TestGeodeConfiguration {
}
}
14
Source : LoggingManualConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration Tests testing the manual configuration of Apache Geode Logging.
*
* @author John Blum
* @see java.util.Properties
* @see org.junit.Test
* @see org.apache.geode.cache.GemFireCache
* @see org.springframework.boot.autoconfigure.SpringBootApplication
* @see org.springframework.boot.test.context.SpringBootTest
* @see org.springframework.data.gemfire.config.annotation.EnableLogging
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.3.0
*/
@RunWith(SpringRunner.clreplaced)
@SpringBootTest(properties = { "spring.data.gemfire.logging.level=warn", "spring.main.allow-bean-definition-overriding=false" }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SuppressWarnings("unused")
public clreplaced LoggingManualConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private Environment environment;
@Autowired
private GemFireCache cache;
@Before
public void setup() {
replacedertThat(this.environment.getProperty("spring.main.allow-bean-definition-overriding", Boolean.clreplaced, true)).isFalse();
}
@Test
public void manualLogConfigurationIsCorrect() {
replacedertThat(this.cache).isNotNull();
replacedertThat(this.cache.getName()).isEqualTo(LoggingManualConfigurationIntegrationTests.clreplaced.getSimpleName());
Properties gemfireProperties = this.cache.getDistributedSystem().getProperties();
replacedertThat(gemfireProperties).isNotNull();
replacedertThat(gemfireProperties.getProperty("log-level")).isEqualTo("warn");
}
@SpringBootApplication
@EnableGemFireMockObjects
@EnableLogging
@UseMemberName("LoggingManualConfigurationIntegrationTests")
static clreplaced TestConfigurationOne {
}
/*
@Configuration
@EnableLogging(logLevel = "info")
static clreplaced TestConfigurationTwo { }
*/
}
14
Source : EchoClientConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean(REGION_NAME)
public ClientRegionFactoryBean<String, String> ecreplacedgion(GemFireCache gemfireCache) {
ClientRegionFactoryBean<String, String> ecreplacedgion = new ClientRegionFactoryBean<>();
ecreplacedgion.setCache(gemfireCache);
ecreplacedgion.setClose(false);
ecreplacedgion.setShortcut(ClientRegionShortcut.PROXY);
return ecreplacedgion;
}
14
Source : RegionTemplateAutoConfiguration.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
private void registerRegionTemplatesForCacheRegions(@NonNull ConfigurableApplicationContext applicationContext, @NonNull GemFireCache cache) {
for (Region<?, ?> region : CollectionUtils.nullSafeSet(cache.rootRegions())) {
String regionTemplateBeanName = toRegionTemplateBeanName(region.getName());
registerRegionTemplateBean(applicationContext, region, regionTemplateBeanName);
}
}
13
Source : BootGeodeServerApplication.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean
@DependsOn("TemperatureReadings")
IndexFactoryBean temperatureReadingTemperatureIndex(GemFireCache gemfireCache) {
IndexFactoryBean temperatureTimestampIndex = new IndexFactoryBean();
temperatureTimestampIndex.setCache(gemfireCache);
temperatureTimestampIndex.setExpression("temperature");
temperatureTimestampIndex.setFrom("/TemperatureReadings");
temperatureTimestampIndex.setName("TemperatureReadingTemperatureIdx");
return temperatureTimestampIndex;
}
13
Source : BootGeodeServerApplication.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
@Bean
@DependsOn("TemperatureReadings")
IndexFactoryBean temperatureReadingTimestampIndex(GemFireCache gemfireCache) {
IndexFactoryBean temperatureTimestampIndex = new IndexFactoryBean();
temperatureTimestampIndex.setCache(gemfireCache);
temperatureTimestampIndex.setExpression("timestamp");
temperatureTimestampIndex.setFrom("/TemperatureReadings");
temperatureTimestampIndex.setName("TemperatureReadingTimestampIdx");
return temperatureTimestampIndex;
}
13
Source : NativeDefinedRegionTemplateAutoConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration Tests for {@link RegionTemplateAutoConfiguration} using natively declared {@link Region} definitions
* in Apache Geode {@literal cache.xml}.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.Region
* @see org.springframework.boot.autoconfigure.SpringBootApplication
* @see org.springframework.boot.test.context.SpringBootTest
* @see org.springframework.data.gemfire.config.annotation.EnableGemFireProperties
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.geode.boot.autoconfigure.RegionTemplateAutoConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.0.0
*/
@RunWith(SpringRunner.clreplaced)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SuppressWarnings("unused")
public clreplaced NativeDefinedRegionTemplateAutoConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private ApplicationContext applicationContext;
@Autowired
private GemFireCache cache;
@Autowired
private GemfireTemplate exampleTemplate;
@Test
public void cacheContainsExampleRegion() {
replacedertThat(this.cache).isNotNull();
replacedertThat(CollectionUtils.nullSafeSet(this.cache.rootRegions()).stream().map(Region::getName).collect(Collectors.toSet())).containsExactly("Example");
}
@Test(expected = NoSuchBeanDefinitionException.clreplaced)
public void exampleRegionBeanIsNotPresent() {
this.applicationContext.getBean("Example", Region.clreplaced);
}
@Test
public void exampleRegionTemplateIsPresent() {
replacedertThat(this.exampleTemplate).isNotNull();
replacedertThat(this.exampleTemplate.getRegion()).isNotNull();
replacedertThat(this.exampleTemplate.getRegion().getName()).isEqualTo("Example");
}
@SpringBootApplication
@EnableGemFireProperties(cacheXmlFile = "template-cache.xml")
static clreplaced TestConfiguration {
@Bean("TestBean")
@DependsOn("gemfireCache")
Object testBean(@Qualifier("exampleTemplate") GemfireTemplate exampleTemplate) {
return "TEST";
}
}
}
13
Source : ManuallyConfiguredPdxSerializerWithPdxSerializationAutoConfigurationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Unit Tests for {@link PdxSerializationAutoConfiguration} replacederting that user-defined PDX configuration
* {@literal overrides} SBDG's PDX {@literal auto-configuration}.
*
* @author John Blum
* @see org.junit.Test
* @see org.mockito.Mockito
* @see org.apache.geode.cache.GemFireCache
* @see org.apache.geode.pdx.PdxSerializer
* @see org.springframework.boot.autoconfigure.SpringBootApplication
* @see org.springframework.boot.test.context.SpringBootTest
* @see org.springframework.context.annotation.Bean
* @see org.springframework.context.annotation.Profile
* @see org.springframework.data.gemfire.config.annotation.EnablePdx
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.data.gemfire.tests.integration.IntegrationTestsSupport
* @see org.springframework.geode.boot.autoconfigure.PdxSerializationAutoConfiguration
* @see org.springframework.test.context.ActiveProfiles
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.3.0
*/
@ActiveProfiles("MANUALLY_CONFIGURED_PDX_SERIALIZER")
@RunWith(SpringRunner.clreplaced)
@SpringBootTest(properties = { "spring.application.name=ManuallyConfiguredPdxSerializerWithPdxSerializationAutoConfigurationIntegrationTests" }, webEnvironment = SpringBootTest.WebEnvironment.NONE)
@SuppressWarnings("unused")
public clreplaced ManuallyConfiguredPdxSerializerWithPdxSerializationAutoConfigurationIntegrationTests extends IntegrationTestsSupport {
@Autowired
private GemFireCache cache;
@Autowired
@Qualifier("mockPdxSerializer")
private PdxSerializer mockPdxSerializer;
@Test
public void cacheIsManuallyConfiguredWithPdxSerializer() {
replacedertThat(this.cache).isNotNull();
replacedertThat(this.cache.getName()).isEqualTo(ManuallyConfiguredPdxSerializerWithPdxSerializationAutoConfigurationIntegrationTests.clreplaced.getSimpleName());
replacedertThat(this.cache.getPdxSerializer()).isEqualTo(this.mockPdxSerializer);
}
@SpringBootApplication
@EnableGemFireMockObjects
@EnablePdx(serializerBeanName = "mockPdxSerializer")
@Profile("MANUALLY_CONFIGURED_PDX_SERIALIZER")
static clreplaced TestGeodeConfiguration {
@Bean
PdxSerializer mockPdxSerializer() {
return mock(PdxSerializer.clreplaced, "MockPdxSerializer");
}
}
}
13
Source : SpringBootLocatorApplicationIntegrationTests.java
with Apache License 2.0
from spring-projects
with Apache License 2.0
from spring-projects
/**
* Integration Tests replacederting that a {@link ClientCache} is not auto-configured by SBDG if a {{@link Locator} bean
* is present in the Spring container.
*
* @author John Blum
* @see org.junit.Test
* @see org.apache.geode.cache.GemFireCache
* @see org.apache.geode.cache.client.ClientCache
* @see org.apache.geode.distributed.Locator
* @see org.springframework.boot.autoconfigure.SpringBootApplication
* @see org.springframework.data.gemfire.tests.mock.annotation.EnableGemFireMockObjects
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @since 1.1.0
*/
@RunWith(SpringRunner.clreplaced)
@ContextConfiguration
@SuppressWarnings("unused")
public clreplaced SpringBootLocatorApplicationIntegrationTests {
@Autowired(required = false)
private GemFireCache clientCache;
@Autowired
private Locator mockLocator;
@Test
public void noCacheInstanceIsAutoConfiguredWhenLocatorBeanIsPresent() {
replacedertThat(this.clientCache).isNull();
replacedertThat(this.mockLocator).isNotNull();
}
@SpringBootApplication
@EnableGemFireMockObjects
static clreplaced TestConfiguration {
@Bean
Locator mockLocator() {
return mock(Locator.clreplaced);
}
}
}
See More Examples