Fixes JIRA issue SGF-241 adding support for defining client sub-Regions using the gfe:client-region XML namespace element in an nested fashion.
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* Copyright 2010-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.client;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.gemfire.ForkUtil;
|
||||
import org.springframework.data.gemfire.GemfireTemplate;
|
||||
import org.springframework.data.gemfire.fork.SpringCacheServerProcess;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.gemstone.gemfire.cache.Region;
|
||||
import com.gemstone.gemfire.cache.client.ClientCache;
|
||||
|
||||
/**
|
||||
* The ClientSubRegionTest class is a test suite of test cases testing SubRegion functionality from a client
|
||||
* GemFire Cache.
|
||||
* <p/>
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.junit.runner.RunWith
|
||||
* @see org.springframework.test.context.ContextConfiguration
|
||||
* @see org.springframework.test.context.junit4.SpringJUnit4ClassRunner
|
||||
* @since 1.4.0
|
||||
* @since 7.0.1 (GemFire)
|
||||
*/
|
||||
@ContextConfiguration("clientcache-with-subregion-config.xml")
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SuppressWarnings("unused")
|
||||
public class ClientSubRegionTest {
|
||||
|
||||
@Autowired
|
||||
private ClientCache clientCache;
|
||||
|
||||
@Resource(name = "parentTemplate")
|
||||
private GemfireTemplate parentTemplate;
|
||||
|
||||
@Resource(name = "childTemplate")
|
||||
private GemfireTemplate childTemplate;
|
||||
|
||||
@Resource(name = "Parent")
|
||||
private Region parent;
|
||||
|
||||
@Resource(name = "/Parent/Child")
|
||||
private Region child;
|
||||
|
||||
@BeforeClass
|
||||
public static void startCacheServer() throws Exception {
|
||||
ForkUtil.startCacheServer(SpringCacheServerProcess.class.getName() + " "
|
||||
+ "/org/springframework/data/gemfire/client/servercache-with-region-for-client.xml");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGemFireSubRegionCreationConfiguration() {
|
||||
assertNotNull("The Client Cache was not properly initialized!", clientCache);
|
||||
|
||||
Region parent = clientCache.getRegion("Parent");
|
||||
|
||||
assertNotNull(parent);
|
||||
assertEquals("Parent", parent.getName());
|
||||
assertEquals("/Parent", parent.getFullPath());
|
||||
|
||||
Region child = parent.getSubregion("Child");
|
||||
|
||||
assertNotNull(child);
|
||||
assertEquals("Child", child.getName());
|
||||
assertEquals("/Parent/Child", child.getFullPath());
|
||||
|
||||
Region clientCacheChild = clientCache.getRegion("/Parent/Child");
|
||||
|
||||
assertSame(child, clientCacheChild);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSpringSubRegionCreationConfiguration() {
|
||||
assertNotNull(parent);
|
||||
assertEquals("Parent", parent.getName());
|
||||
assertEquals("/Parent", parent.getFullPath());
|
||||
assertNotNull(child);
|
||||
assertEquals("Child", child.getName());
|
||||
assertEquals("/Parent/Child", child.getFullPath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemplateCreationConfiguration() {
|
||||
assertNotNull(parentTemplate);
|
||||
assertSame(parent, parentTemplate.getRegion());
|
||||
assertNotNull(childTemplate);
|
||||
assertSame(child, childTemplate.getRegion());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:gfe="http://www.springframework.org/schema/gemfire"
|
||||
xmlns:p="http://www.springframework.org/schema/p"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
|
||||
http://www.springframework.org/schema/gemfire http://www.springframework.org/schema/gemfire/spring-gemfire.xsd
|
||||
">
|
||||
|
||||
<gfe:client-cache/>
|
||||
|
||||
<gfe:pool>
|
||||
<gfe:server host="localhost" port="54321"/>
|
||||
</gfe:pool>
|
||||
|
||||
<gfe:client-region id="Parent" shortcut="PROXY">
|
||||
<gfe:client-region name="Child" shortcut="PROXY"/>
|
||||
</gfe:client-region>
|
||||
|
||||
<bean id="parentTemplate" class="org.springframework.data.gemfire.GemfireTemplate" p:region-ref="Parent"/>
|
||||
|
||||
<bean id="childTemplate" class="org.springframework.data.gemfire.GemfireTemplate" p:region-ref="/Parent/Child"/>
|
||||
|
||||
</beans>
|
||||
@@ -11,4 +11,8 @@
|
||||
<gfe:cache-server auto-startup="true" port="54321"/>
|
||||
<gfe:local-region id="localAppDataRegion" name="LocalAppData"/>
|
||||
|
||||
<gfe:replicated-region id="Parent" persistent="false">
|
||||
<gfe:replicated-region name="Child" persistent="false"/>
|
||||
</gfe:replicated-region>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user