Fixed issue with CacheServerNamespaceTest.testBasicCacheServer test case method, finishing/rounding out the work that was done in SGF-218.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.data.gemfire.config;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
@@ -26,28 +27,57 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import com.gemstone.gemfire.cache.server.ClientSubscriptionConfig;
|
||||
|
||||
/**
|
||||
*
|
||||
* The CacheServerNamespaceTest class is a test suite of test cases testing the functionality of the SDG XML namespace
|
||||
* when configuring a GemFire Cache Servers and Client Subscription.
|
||||
* <p/>
|
||||
* @author Costin Leau
|
||||
* @author David Turanski
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @see com.gemstone.gemfire.cache.server.CacheServer
|
||||
* @see com.gemstone.gemfire.cache.server.ClientSubscriptionConfig
|
||||
*/
|
||||
@ContextConfiguration(locations="server-ns.xml", initializers=GemfireTestApplicationContextInitializer.class)
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="server-ns.xml",
|
||||
initializers=GemfireTestApplicationContextInitializer.class)
|
||||
public class CacheServerNamespaceTest {
|
||||
|
||||
@Autowired ApplicationContext ctx;
|
||||
@Autowired
|
||||
private ApplicationContext context;
|
||||
|
||||
@Test
|
||||
public void testBasicCacheServer() throws Exception {
|
||||
CacheServer cacheServer = ctx.getBean("advanced-config", CacheServer.class);
|
||||
assertTrue(cacheServer.isRunning());
|
||||
assertEquals(1, cacheServer.getGroups().length);
|
||||
assertEquals("test-server", cacheServer.getGroups()[0]);
|
||||
assertEquals(22, cacheServer.getMaxConnections());
|
||||
CacheServer cacheServer = context.getBean("advanced-config", CacheServer.class);
|
||||
|
||||
assertNotNull(cacheServer);
|
||||
assertEquals(1, cacheServer.getGroups().length);
|
||||
assertEquals("localhost", cacheServer.getBindAddress());
|
||||
assertTrue(cacheServer.getPort() != 0);
|
||||
assertEquals("localhost", cacheServer.getHostnameForClients());
|
||||
assertEquals("test-server", cacheServer.getGroups()[0]);
|
||||
assertEquals(2000l, cacheServer.getLoadPollInterval());
|
||||
assertEquals(22, cacheServer.getMaxConnections());
|
||||
assertEquals(16, cacheServer.getMaxThreads());
|
||||
assertEquals(1000, cacheServer.getMaximumMessageCount());
|
||||
assertEquals(30000, cacheServer.getMaximumTimeBetweenPings());
|
||||
assertTrue(cacheServer.isRunning());
|
||||
|
||||
ClientSubscriptionConfig clientSubscriptionConfig = cacheServer.getClientSubscriptionConfig();
|
||||
|
||||
assertNotNull(clientSubscriptionConfig);
|
||||
assertEquals(1000, clientSubscriptionConfig.getCapacity());
|
||||
assertTrue("ENTRY".equalsIgnoreCase(clientSubscriptionConfig.getEvictionPolicy()));
|
||||
assertTrue(String.format("Expected empty DiskStoreName; but was (%1$s)", clientSubscriptionConfig.getDiskStoreName()),
|
||||
StringUtils.isEmpty(clientSubscriptionConfig.getDiskStoreName()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,30 +21,38 @@ import com.gemstone.gemfire.cache.server.CacheServer;
|
||||
import com.gemstone.gemfire.cache.server.ClientSubscriptionConfig;
|
||||
import com.gemstone.gemfire.cache.server.ServerLoadProbe;
|
||||
import com.gemstone.gemfire.distributed.DistributedMember;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
/**
|
||||
* @author David Turanski
|
||||
*
|
||||
* @author John Blum
|
||||
*/
|
||||
public class StubCacheServer implements CacheServer {
|
||||
|
||||
private boolean isRunning;
|
||||
private boolean notifyBySubscription;
|
||||
|
||||
private int maxConnections;
|
||||
private int maximumMessageCount;
|
||||
private int maximumTimeBetweenPings;
|
||||
private int maxThreads;
|
||||
private int messageTimeToLive;
|
||||
private int port;
|
||||
private int socketBufferSize;
|
||||
|
||||
private long loadPollInterval;
|
||||
|
||||
private ClientSession clientSession;
|
||||
|
||||
private ClientSubscriptionConfig clientSubscriptionConfig = mockClientSubscriptionConfig();
|
||||
|
||||
private Set<ClientSession> clientSessions;
|
||||
|
||||
private ServerLoadProbe serverLoadProbe;
|
||||
|
||||
private String bindAddress;
|
||||
private String hostNameForClients;
|
||||
private boolean notifyBySubscription;
|
||||
private int socketBufferSize;
|
||||
private int maximumTimeBetweenPings;
|
||||
private int maxConnections;
|
||||
private int maxThreads;
|
||||
private int maximumMessageCount;
|
||||
private int messageTimeToLive;
|
||||
private String[] groups;
|
||||
private ServerLoadProbe serverLoadProbe;
|
||||
private long loadPollInterval;
|
||||
private ClientSubscriptionConfig clientSubscriptionConfig = mockClientSubscriptionConfig();
|
||||
private ClientSession clientSession;
|
||||
private Set<ClientSession> clientSessions;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see com.gemstone.gemfire.cache.server.CacheServer#getPort()
|
||||
*/
|
||||
@@ -339,14 +347,58 @@ public class StubCacheServer implements CacheServer {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
|
||||
ClientSubscriptionConfig mockClientSubscriptionConfig() {
|
||||
// TODO Auto-generated method stub
|
||||
return mock(ClientSubscriptionConfig.class);
|
||||
return new MockClientSubscriptionConfig();
|
||||
}
|
||||
|
||||
protected static class MockClientSubscriptionConfig implements ClientSubscriptionConfig {
|
||||
|
||||
private int capacity;
|
||||
|
||||
private String diskStoreName;
|
||||
private String evictionPolicy;
|
||||
private String overflowDirectory;
|
||||
|
||||
@Override
|
||||
public int getCapacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCapacity(final int capacity) {
|
||||
this.capacity = capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDiskStoreName() {
|
||||
return diskStoreName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDiskStoreName(final String diskStoreName) {
|
||||
this.diskStoreName = diskStoreName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEvictionPolicy() {
|
||||
return evictionPolicy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEvictionPolicy(final String policy) {
|
||||
this.evictionPolicy = policy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOverflowDirectory() {
|
||||
return overflowDirectory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOverflowDirectory(final String overflowDirectory) {
|
||||
this.overflowDirectory = overflowDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user