DATAGEODE-168 - Polish.

Resolves gh-7.
This commit is contained in:
John Blum
2019-06-14 00:59:06 -07:00
parent f9512d91fb
commit 9eb38f1fe4
9 changed files with 340 additions and 249 deletions

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2019 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
*
* https://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.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
@@ -10,22 +25,21 @@ import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewayTransportFilter;
import org.junit.After;
import org.junit.Test;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewayTransportFilter;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiver;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiverConfiguration;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiverConfigurer;
/**
* Tests for {@link org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiver}.
* Tests for {@link EnableGatewayReceiver}.
*
* @author Udo Kohlmeyer
* @see org.junit.Test
@@ -35,8 +49,8 @@ import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiverConf
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean
* @see EnableGatewayReceiverConfigurer
* @see EnableGatewayReceiverConfiguration
* @see GatewayReceiverConfigurer
* @see GatewayReceiverConfiguration
* @since 2.2.0
*/
public class EnableGatewayReceiverConfigurationTests {
@@ -44,8 +58,7 @@ public class EnableGatewayReceiverConfigurationTests {
private ConfigurableApplicationContext applicationContext;
@After
public void shutdown()
{
public void shutdown() {
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
}
@@ -69,7 +82,7 @@ public class EnableGatewayReceiverConfigurationTests {
}
@Bean("gatewayConfigurer")
EnableGatewayReceiverConfigurer gatewayReceiverConfigurer() {
GatewayReceiverConfigurer gatewayReceiverConfigurer() {
return new TestGatewayReceiverConfigurer();
}
}
@@ -92,16 +105,18 @@ public class EnableGatewayReceiverConfigurationTests {
}
@Bean("gatewayConfigurer")
EnableGatewayReceiverConfigurer gatewayReceiverConfigurer() {
GatewayReceiverConfigurer gatewayReceiverConfigurer() {
return new TestGatewayReceiverConfigurer();
}
}
@Test
public void annotationConfiguredGatewayTransportFiltersOrdered() {
this.applicationContext = newApplicationContext(TestConfigurationFromAnnotation.class);
TestGatewayReceiverConfigurer gatewayReceiverConfigurer = (TestGatewayReceiverConfigurer) this.applicationContext.getBean(
EnableGatewayReceiverConfigurer.class);
TestGatewayReceiverConfigurer gatewayReceiverConfigurer =
(TestGatewayReceiverConfigurer) this.applicationContext.getBean(GatewayReceiverConfigurer.class);
GatewayReceiver gatewayReceiver = this.applicationContext.getBean("GatewayReceiver",GatewayReceiver.class);
@@ -120,9 +135,11 @@ public class EnableGatewayReceiverConfigurationTests {
@Test
public void beanConfiguredGatewayTransportFiltersOrdered() {
this.applicationContext = newApplicationContext(TestConfigurationWithOrder.class);
TestGatewayReceiverConfigurer gatewayReceiverConfigurer = (TestGatewayReceiverConfigurer) this.applicationContext.getBean(
EnableGatewayReceiverConfigurer.class);
TestGatewayReceiverConfigurer gatewayReceiverConfigurer =
(TestGatewayReceiverConfigurer) this.applicationContext.getBean(GatewayReceiverConfigurer.class);
GatewayReceiver gatewayReceiver = this.applicationContext.getBean("GatewayReceiver",GatewayReceiver.class);
@@ -139,7 +156,7 @@ public class EnableGatewayReceiverConfigurationTests {
assertThat(gatewayReceiverConfigurer.beanNames.toArray()).isEqualTo(new String[]{"transportBean1", "transportBean2"});
}
private static class TestGatewayReceiverConfigurer implements EnableGatewayReceiverConfigurer, Iterable<String> {
private static class TestGatewayReceiverConfigurer implements GatewayReceiverConfigurer, Iterable<String> {
private final List<String> beanNames = new ArrayList<>();
@@ -155,6 +172,7 @@ public class EnableGatewayReceiverConfigurationTests {
}
private static class TestGatewayTransportFilter implements GatewayTransportFilter {
private String name;
public TestGatewayTransportFilter(String name) {

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2019 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
*
* https://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.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
@@ -7,10 +22,12 @@ import java.io.OutputStream;
import java.util.Arrays;
import java.util.Optional;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewayTransportFilter;
import org.junit.After;
import org.junit.Test;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewayTransportFilter;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -18,13 +35,10 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiver;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiverConfiguration;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiverConfigurer;
import org.springframework.mock.env.MockPropertySource;
/**
* Tests for {@link org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiver}.
* Tests for {@link EnableGatewayReceiver}.
*
* @author Udo Kohlmeyer
* @see org.junit.Test
@@ -34,11 +48,11 @@ import org.springframework.mock.env.MockPropertySource;
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean
* @see EnableGatewayReceiverConfigurer
* @see EnableGatewayReceiverConfiguration
* @see GatewayReceiverConfigurer
* @see GatewayReceiverConfiguration
* @since 2.2.0
*/
public class EnableEnableGatewayReceiverConfigurerTests {
public class GatewayReceiverConfigurerTests {
private ConfigurableApplicationContext applicationContext;
@@ -48,7 +62,7 @@ public class EnableEnableGatewayReceiverConfigurerTests {
}
private ConfigurableApplicationContext newApplicationContext(PropertySource<?> testPropertySource,
Class<?>... annotatedClasses) {
Class<?>... annotatedClasses) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
@@ -69,7 +83,7 @@ public class EnableEnableGatewayReceiverConfigurerTests {
MockPropertySource testPropertySource = new MockPropertySource();
this.applicationContext = newApplicationContext(testPropertySource,
EnableEnableGatewayReceiverConfigurerTests.TestConfigurationWithProperties.class);
GatewayReceiverConfigurerTests.TestConfigurationWithProperties.class);
assertThat(this.applicationContext).isNotNull();
assertThat(this.applicationContext.containsBean("GatewayReceiver")).isTrue();
@@ -103,7 +117,7 @@ public class EnableEnableGatewayReceiverConfigurerTests {
.withProperty("spring.data.gemfire.gateway.receiver.transport-filters", "transportBean1,transportBean2");
this.applicationContext = newApplicationContext(testPropertySource,
EnableEnableGatewayReceiverConfigurerTests.TestConfigurationWithProperties.class);
GatewayReceiverConfigurerTests.TestConfigurationWithProperties.class);
assertThat(this.applicationContext).isNotNull();
assertThat(this.applicationContext.containsBean("GatewayReceiver")).isTrue();
@@ -134,7 +148,7 @@ public class EnableEnableGatewayReceiverConfigurerTests {
.withProperty("spring.data.gemfire.gateway.receiver.transport-filters", "transportBean2,transportBean1");
this.applicationContext = newApplicationContext(testPropertySource,
EnableEnableGatewayReceiverConfigurerTests.TestConfiguration.class);
GatewayReceiverConfigurerTests.TestConfiguration.class);
assertThat(this.applicationContext).isNotNull();
assertThat(this.applicationContext.containsBean("GatewayReceiver")).isTrue();
@@ -164,16 +178,16 @@ public class EnableEnableGatewayReceiverConfigurerTests {
@Bean("transportBean1")
GatewayTransportFilter createGatewayTransportBean1() {
return new EnableEnableGatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean1");
return new GatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean1");
}
@Bean("transportBean2")
GatewayTransportFilter createGatewayTransportBean2() {
return new EnableEnableGatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean2");
return new GatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean2");
}
@Bean("gatewayConfigurer")
EnableGatewayReceiverConfigurer gatewayReceiverConfigurer() {
GatewayReceiverConfigurer gatewayReceiverConfigurer() {
return (String beanName, GatewayReceiverFactoryBean bean) -> {
bean.setBindAddress("127.0.0.1");
bean.setEndPort(25000);
@@ -196,16 +210,16 @@ public class EnableEnableGatewayReceiverConfigurerTests {
@Bean("transportBean1")
GatewayTransportFilter createGatewayTransportBean1() {
return new EnableEnableGatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean1");
return new GatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean1");
}
@Bean("transportBean2")
GatewayTransportFilter createGatewayTransportBean2() {
return new EnableEnableGatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean2");
return new GatewayReceiverConfigurerTests.TestGatewayTransportFilter("transportBean2");
}
@Bean("gatewayConfigurer")
EnableGatewayReceiverConfigurer gatewayReceiverConfigurer() {
GatewayReceiverConfigurer gatewayReceiverConfigurer() {
return (String beanName, GatewayReceiverFactoryBean bean) -> {
bean.setBindAddress("127.0.0.1");
bean.setHostnameForSenders("testHostNameReceiverForSender");

View File

@@ -1,3 +1,18 @@
/*
* Copyright 2019 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
*
* https://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.config.annotation;
import static org.assertj.core.api.Assertions.assertThat;
@@ -10,24 +25,22 @@ import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewayTransportFilter;
import org.junit.After;
import org.junit.Test;
import org.apache.geode.cache.wan.GatewayReceiver;
import org.apache.geode.cache.wan.GatewayTransportFilter;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.MutablePropertySources;
import org.springframework.core.env.PropertySource;
import org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiver;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiverConfiguration;
import org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiverConfigurer;
import org.springframework.mock.env.MockPropertySource;
/**
* Tests for {@link org.springframework.data.gemfire.wan.annotation.EnableGatewayReceiver}.
* Tests for {@link EnableGatewayReceiver}.
*
* @author Udo Kohlmeyer
* @see org.junit.Test
@@ -37,11 +50,11 @@ import org.springframework.mock.env.MockPropertySource;
* @see org.springframework.test.context.ContextConfiguration
* @see org.springframework.test.context.junit4.SpringRunner
* @see org.springframework.data.gemfire.wan.GatewayReceiverFactoryBean
* @see EnableGatewayReceiverConfigurer
* @see EnableGatewayReceiverConfiguration
* @see GatewayReceiverConfigurer
* @see GatewayReceiverConfiguration
* @since 2.2.0
*/
public class EnableGatewayReceiverPropertiesTests {
public class GatewayReceiverPropertiesTests {
private ConfigurableApplicationContext applicationContext;
@@ -51,7 +64,7 @@ public class EnableGatewayReceiverPropertiesTests {
}
private ConfigurableApplicationContext newApplicationContext(PropertySource<?> testPropertySource,
Class<?>... annotatedClasses) {
Class<?>... annotatedClasses) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
@@ -70,16 +83,17 @@ public class EnableGatewayReceiverPropertiesTests {
public void gatewayReceiverPropertiesConfiguration() {
MockPropertySource testPropertySource = new MockPropertySource()
.withProperty("spring.data.gemfire.gateway.receiver.bindAddress", "123.123.123.123")
.withProperty("spring.data.gemfire.gateway.receiver.hostnameForSenders", "testHostName")
.withProperty("spring.data.gemfire.gateway.receiver.startPort", 16000)
.withProperty("spring.data.gemfire.gateway.receiver.endPort", 17000)
.withProperty("spring.data.gemfire.gateway.receiver.maximumTimeBetweenPings", 30000)
.withProperty("spring.data.gemfire.gateway.receiver.socketBufferSize", 32768)
.withProperty("spring.data.gemfire.gateway.receiver.manualStart", true)
.withProperty("spring.data.gemfire.gateway.receiver.transportFilters", "transportBean2,transportBean1");
.withProperty("spring.data.gemfire.gateway.receiver.bind-address", "123.123.123.123")
.withProperty("spring.data.gemfire.gateway.receiver.hostname-for-senders", "testHostName")
.withProperty("spring.data.gemfire.gateway.receiver.start-port", 16000)
.withProperty("spring.data.gemfire.gateway.receiver.end-port", 17000)
.withProperty("spring.data.gemfire.gateway.receiver.maximum-time-between-pings", 30000)
.withProperty("spring.data.gemfire.gateway.receiver.socket-buffer-size", 32768)
.withProperty("spring.data.gemfire.gateway.receiver.manual-start", true)
.withProperty("spring.data.gemfire.gateway.receiver.transport-filters", "transportBean2,transportBean1");
this.applicationContext = newApplicationContext(testPropertySource, EnableGatewayReceiverPropertiesTests.TestConfigurationWithProperties.class);
this.applicationContext = newApplicationContext(testPropertySource,
GatewayReceiverPropertiesTests.TestConfigurationWithProperties.class);
assertThat(this.applicationContext).isNotNull();
assertThat(this.applicationContext.containsBean("GatewayReceiver")).isTrue();
@@ -98,28 +112,28 @@ public class EnableGatewayReceiverPropertiesTests {
}
@Configuration
@CacheServerApplication
@EnableGatewayReceiver
static class TestConfigurationWithProperties{
@Bean("transportBean1")
GatewayTransportFilter createGatewayTransportBean1() {
return new EnableGatewayReceiverPropertiesTests.TestGatewayTransportFilter("transportBean1");
return new GatewayReceiverPropertiesTests.TestGatewayTransportFilter("transportBean1");
}
@Bean("transportBean2")
GatewayTransportFilter createGatewayTransportBean2() {
return new EnableGatewayReceiverPropertiesTests.TestGatewayTransportFilter("transportBean2");
return new GatewayReceiverPropertiesTests.TestGatewayTransportFilter("transportBean2");
}
@Bean("gatewayConfigurer")
EnableGatewayReceiverConfigurer gatewayReceiverConfigurer() {
return new EnableGatewayReceiverPropertiesTests.TestGatewayReceiverConfigurer();
GatewayReceiverConfigurer gatewayReceiverConfigurer() {
return new GatewayReceiverPropertiesTests.TestGatewayReceiverConfigurer();
}
}
private static class TestGatewayTransportFilter implements GatewayTransportFilter {
private String name;
public TestGatewayTransportFilter(String name) {
@@ -137,7 +151,7 @@ public class EnableGatewayReceiverPropertiesTests {
}
}
private static class TestGatewayReceiverConfigurer implements EnableGatewayReceiverConfigurer, Iterable<String> {
private static class TestGatewayReceiverConfigurer implements GatewayReceiverConfigurer, Iterable<String> {
private final List<String> beanNames = new ArrayList<>();
@@ -148,7 +162,7 @@ public class EnableGatewayReceiverPropertiesTests {
@Override
public void configure(String beanName, GatewayReceiverFactoryBean bean) {
bean.getTransportFilters().stream().forEach(o -> beanNames.add(((EnableGatewayReceiverPropertiesTests.TestGatewayTransportFilter) o).name));
bean.getTransportFilters().stream().forEach(o -> beanNames.add(((GatewayReceiverPropertiesTests.TestGatewayTransportFilter) o).name));
}
}
}