Add additional test case for the auto-configuration of a GemfireTemplate bean given a Region (FactoryBean) bean definition using a generic signature.
This commit is contained in:
@@ -66,9 +66,17 @@ public class DeclaredRegionTemplateAutoConfigurationIntegrationTests extends Int
|
||||
@Qualifier("exampleTemplate")
|
||||
private GemfireTemplate exampleTemplate;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("testRegionTemplate")
|
||||
private GemfireTemplate testRegionTemplate;
|
||||
|
||||
@Resource(name = "Example")
|
||||
private Region<Long, String> exampleRegion;
|
||||
|
||||
@Resource(name = "TestRegion")
|
||||
@SuppressWarnings("rawtypes")
|
||||
private Region testRegion;
|
||||
|
||||
@Test
|
||||
public void exampleRegionIsPresent() {
|
||||
|
||||
@@ -83,6 +91,21 @@ public class DeclaredRegionTemplateAutoConfigurationIntegrationTests extends Int
|
||||
assertThat(this.exampleTemplate.getRegion()).isEqualTo(this.exampleRegion);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testRegionIsPresent() {
|
||||
|
||||
assertThat(this.testRegion).isNotNull();
|
||||
assertThat(this.testRegion.getName()).isEqualTo("TestRegion");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRegionTemplateIsPresent() {
|
||||
|
||||
assertThat(this.testRegionTemplate).isNotNull();
|
||||
assertThat(this.testRegionTemplate.getRegion()).isEqualTo(this.testRegion);
|
||||
}
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableGemFireMockObjects
|
||||
static class TestConfiguration {
|
||||
@@ -102,5 +125,19 @@ public class DeclaredRegionTemplateAutoConfigurationIntegrationTests extends Int
|
||||
public Object testBean(@Qualifier("exampleTemplate") GemfireTemplate exampleTemplate) {
|
||||
return "TEST";
|
||||
}
|
||||
|
||||
// NOTE: Raw type definition is deliberate to ensure the generic FactoryBean and Region signature
|
||||
// can be properly autowired/injected into the auto-configured GemfireTemplate for this Region!
|
||||
@Bean("TestRegion")
|
||||
@SuppressWarnings("rawtypes")
|
||||
public ClientRegionFactoryBean testRegion(GemFireCache gemfireCache) {
|
||||
|
||||
ClientRegionFactoryBean clientRegion = new ClientRegionFactoryBean();
|
||||
|
||||
clientRegion.setCache(gemfireCache);
|
||||
clientRegion.setShortcut(ClientRegionShortcut.PROXY);
|
||||
|
||||
return clientRegion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user