Fixed issue with CacheServerNamespaceTest.testBasicCacheServer test case method, finishing/rounding out the work that was done in SGF-218.
This commit is contained in:
@@ -385,8 +385,7 @@ across concurrent threads in the same VM, whether or not transactions are used.
|
|||||||
<!-- nested bean definition -->
|
<!-- nested bean definition -->
|
||||||
<xsd:complexType name="beanDeclarationType">
|
<xsd:complexType name="beanDeclarationType">
|
||||||
<xsd:sequence>
|
<xsd:sequence>
|
||||||
<xsd:any namespace="##other" processContents="skip"
|
<xsd:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="1">
|
||||||
minOccurs="0" maxOccurs="1">
|
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[
|
<xsd:documentation><![CDATA[
|
||||||
Inner bean definition. The nested declaration serves as an alternative to bean references (using
|
Inner bean definition. The nested declaration serves as an alternative to bean references (using
|
||||||
@@ -1960,8 +1959,7 @@ Note: In order to instantiate a cacheserver, a GemFire cache needs to be avaialb
|
|||||||
</xsd:annotation>
|
</xsd:annotation>
|
||||||
<xsd:complexType>
|
<xsd:complexType>
|
||||||
<xsd:sequence minOccurs="0" maxOccurs="1">
|
<xsd:sequence minOccurs="0" maxOccurs="1">
|
||||||
<xsd:element name="subscription-config" minOccurs="0"
|
<xsd:element name="subscription-config" minOccurs="0" maxOccurs="1">
|
||||||
maxOccurs="1">
|
|
||||||
<xsd:annotation>
|
<xsd:annotation>
|
||||||
<xsd:documentation><![CDATA[
|
<xsd:documentation><![CDATA[
|
||||||
The client subscription configuration that is used to control a clients use of server resources towards notification queues.
|
The client subscription configuration that is used to control a clients use of server resources towards notification queues.
|
||||||
@@ -1980,8 +1978,7 @@ The client subscription configuration that is used to control a clients use of s
|
|||||||
</xsd:attribute>
|
</xsd:attribute>
|
||||||
<xsd:attribute name="capacity" type="xsd:string"
|
<xsd:attribute name="capacity" type="xsd:string"
|
||||||
use="optional" default="1" />
|
use="optional" default="1" />
|
||||||
<xsd:attribute name="disk-store" type="xsd:string"
|
<xsd:attribute name="disk-store" type="xsd:string" use="optional"/>
|
||||||
use="optional" default="." />
|
|
||||||
</xsd:complexType>
|
</xsd:complexType>
|
||||||
</xsd:element>
|
</xsd:element>
|
||||||
</xsd:sequence>
|
</xsd:sequence>
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.springframework.data.gemfire.config;
|
package org.springframework.data.gemfire.config;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -26,28 +27,57 @@ import org.springframework.context.ApplicationContext;
|
|||||||
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
|
||||||
import org.springframework.test.context.ContextConfiguration;
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
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.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 Costin Leau
|
||||||
* @author David Turanski
|
* @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)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@ContextConfiguration(locations="server-ns.xml",
|
|
||||||
initializers=GemfireTestApplicationContextInitializer.class)
|
|
||||||
public class CacheServerNamespaceTest {
|
public class CacheServerNamespaceTest {
|
||||||
|
|
||||||
@Autowired ApplicationContext ctx;
|
@Autowired
|
||||||
|
private ApplicationContext context;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBasicCacheServer() throws Exception {
|
public void testBasicCacheServer() throws Exception {
|
||||||
CacheServer cacheServer = ctx.getBean("advanced-config", CacheServer.class);
|
CacheServer cacheServer = context.getBean("advanced-config", CacheServer.class);
|
||||||
assertTrue(cacheServer.isRunning());
|
|
||||||
assertEquals(1, cacheServer.getGroups().length);
|
|
||||||
assertEquals("test-server", cacheServer.getGroups()[0]);
|
|
||||||
assertEquals(22, cacheServer.getMaxConnections());
|
|
||||||
|
|
||||||
|
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.ClientSubscriptionConfig;
|
||||||
import com.gemstone.gemfire.cache.server.ServerLoadProbe;
|
import com.gemstone.gemfire.cache.server.ServerLoadProbe;
|
||||||
import com.gemstone.gemfire.distributed.DistributedMember;
|
import com.gemstone.gemfire.distributed.DistributedMember;
|
||||||
import static org.mockito.Mockito.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author David Turanski
|
* @author David Turanski
|
||||||
*
|
* @author John Blum
|
||||||
*/
|
*/
|
||||||
public class StubCacheServer implements CacheServer {
|
public class StubCacheServer implements CacheServer {
|
||||||
|
|
||||||
private boolean isRunning;
|
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 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 bindAddress;
|
||||||
private String hostNameForClients;
|
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 String[] groups;
|
||||||
private ServerLoadProbe serverLoadProbe;
|
|
||||||
private long loadPollInterval;
|
|
||||||
private ClientSubscriptionConfig clientSubscriptionConfig = mockClientSubscriptionConfig();
|
|
||||||
private ClientSession clientSession;
|
|
||||||
private Set<ClientSession> clientSessions;
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see com.gemstone.gemfire.cache.server.CacheServer#getPort()
|
* @see com.gemstone.gemfire.cache.server.CacheServer#getPort()
|
||||||
*/
|
*/
|
||||||
@@ -339,14 +347,58 @@ public class StubCacheServer implements CacheServer {
|
|||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
ClientSubscriptionConfig mockClientSubscriptionConfig() {
|
ClientSubscriptionConfig mockClientSubscriptionConfig() {
|
||||||
// TODO Auto-generated method stub
|
return new MockClientSubscriptionConfig();
|
||||||
return mock(ClientSubscriptionConfig.class);
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||||
xmlns:p="http://www.springframework.org/schema/p"
|
xmlns:p="http://www.springframework.org/schema/p"
|
||||||
xmlns:context="http://www.springframework.org/schema/context"
|
xmlns:context="http://www.springframework.org/schema/context"
|
||||||
xmlns:util="http://www.springframework.org/schema/util"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
xsi:schemaLocation="
|
||||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
|
||||||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
|
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||||
|
">
|
||||||
|
|
||||||
<gfe:cache />
|
<gfe:cache/>
|
||||||
|
|
||||||
<bean id="bean1" class="org.springframework.data.gemfire.Init"/>
|
<bean id="bean1" class="org.springframework.data.gemfire.Init"/>
|
||||||
|
|
||||||
@@ -23,6 +23,6 @@
|
|||||||
|
|
||||||
<bean id="bean2" class="org.springframework.data.gemfire.Init"/>
|
<bean id="bean2" class="org.springframework.data.gemfire.Init"/>
|
||||||
|
|
||||||
<context:property-placeholder location="classpath:port.properties" />
|
<context:property-placeholder location="classpath:port.properties"/>
|
||||||
|
|
||||||
</beans>
|
</beans>
|
||||||
|
|||||||
Reference in New Issue
Block a user