From 2d36d2a7e4541bfbb16534a048f0aa78c2a81636 Mon Sep 17 00:00:00 2001 From: Jayaram Pradhan Date: Sun, 14 May 2017 07:51:20 +0530 Subject: [PATCH] Add Slice test annotation for Redis This commit adds new annotation `@DataRedisTest` which provides test infrastructure for redis. See gh-9224 --- .../main/asciidoc/spring-boot-features.adoc | 24 +++++ spring-boot-test-autoconfigure/pom.xml | 16 ++++ .../data/redis/AutoConfigureDataRedis.java | 43 +++++++++ .../data/redis/DataRedisTest.java | 94 +++++++++++++++++++ .../redis/DataRedisTypeExcludeFilter.java | 74 +++++++++++++++ .../main/resources/META-INF/spring.factories | 8 +- .../redis/DataRedisTestIntegrationTests.java | 76 +++++++++++++++ ...TestWithIncludeFilterIntegrationTests.java | 54 +++++++++++ .../data/redis/ExampleRedisApplication.java | 29 ++++++ .../data/redis/ExampleRepository.java | 27 ++++++ .../data/redis/ExampleService.java | 46 +++++++++ .../autoconfigure/data/redis/PersonHash.java | 49 ++++++++++ 12 files changed, 539 insertions(+), 1 deletion(-) create mode 100644 spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/AutoConfigureDataRedis.java create mode 100644 spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java create mode 100644 spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java create mode 100644 spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java create mode 100644 spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java create mode 100644 spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRedisApplication.java create mode 100644 spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRepository.java create mode 100644 spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java create mode 100644 spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/PersonHash.java diff --git a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc index c002ab9590..eb6c5b9ca2 100644 --- a/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc +++ b/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc @@ -6010,6 +6010,30 @@ disable transaction management for a test or for the whole class as follows: A list of the auto-configuration that is enabled by `@DataNeo4jTest` can be <>. +[[boot-features-testing-spring-boot-applications-testing-autoconfigured-redis-test]] +==== Auto-configured Data Redis tests +`@DataRedisTest` can be used if you want to test Redis applications. + +[source,java,indent=0] +---- + import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; + import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest; + import org.springframework.test.context.junit4.SpringRunner; + + @RunWith(SpringRunner.class) + @DataRedisTest + public class ExampleDataRedisTests { + + @Autowired + private YourRepository repository; + + // + } +---- + +A list of the auto-configuration that is enabled by `@DataRedisTest` can be +<>. [[boot-features-testing-spring-boot-applications-testing-autoconfigured-ldap-test]] diff --git a/spring-boot-test-autoconfigure/pom.xml b/spring-boot-test-autoconfigure/pom.xml index e47f4e9d6e..b36e860240 100644 --- a/spring-boot-test-autoconfigure/pom.xml +++ b/spring-boot-test-autoconfigure/pom.xml @@ -59,6 +59,11 @@ htmlunit true + + org.apache.commons + commons-pool2 + true + org.hibernate hibernate-core @@ -146,6 +151,17 @@ spring-security-test true + + org.springframework.data + spring-data-redis + true + + + redis.clients + jedis + true + + org.springframework.boot diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/AutoConfigureDataRedis.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/AutoConfigureDataRedis.java new file mode 100644 index 0000000000..28904c614f --- /dev/null +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/AutoConfigureDataRedis.java @@ -0,0 +1,43 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; + +/** + * {@link ImportAutoConfiguration Auto-configuration imports} for typical Data redis + * tests. Most tests should consider using {@link DataRedisTest @DataRedisTest} rather + * than using this annotation directly. + * + * @author Jayaram Pradhan + * + */ +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@ImportAutoConfiguration +public @interface AutoConfigureDataRedis { + +} diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java new file mode 100644 index 0000000000..1435454a31 --- /dev/null +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTest.java @@ -0,0 +1,94 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.springframework.boot.autoconfigure.ImportAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.test.autoconfigure.OverrideAutoConfiguration; +import org.springframework.boot.test.autoconfigure.core.AutoConfigureCache; +import org.springframework.boot.test.autoconfigure.filter.TypeExcludeFilters; +import org.springframework.boot.test.context.SpringBootTestContextBootstrapper; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.core.annotation.AliasFor; +import org.springframework.test.context.BootstrapWith; + + + +/** + * Annotation that can be used in combination with {@code @RunWith(SpringRunner.class)} + * for a typical Data Redis test. Can be used when a test focuses only on + * RedisDB components. + *

+ * Using this annotation will disable full auto-configuration and instead apply only + * configuration relevant to RedisDB tests. + *

+ * + * @author Jayaram Pradhan + * + */ + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +@BootstrapWith(SpringBootTestContextBootstrapper.class) +@OverrideAutoConfiguration(enabled = false) +@TypeExcludeFilters(DataRedisTypeExcludeFilter.class) +@AutoConfigureCache +@AutoConfigureDataRedis +@ImportAutoConfiguration +public @interface DataRedisTest { + + /** + * Determines if default filtering should be used with + * {@link SpringBootApplication @SpringBootApplication}. By default no beans are + * included. + * @see #includeFilters() + * @see #excludeFilters() + * @return if default filters should be used + */ + boolean useDefaultFilters() default true; + + /** + * A set of include filters which can be used to add otherwise filtered beans to the + * application context. + * @return include filters to apply + */ + Filter[] includeFilters() default {}; + + /** + * A set of exclude filters which can be used to filter beans that would otherwise be + * added to the application context. + * @return exclude filters to apply + */ + Filter[] excludeFilters() default {}; + + /** + * Auto-configuration exclusions that should be applied for this test. + * @return auto-configuration exclusions to apply + */ + @AliasFor(annotation = ImportAutoConfiguration.class, attribute = "exclude") + Class[] excludeAutoConfiguration() default {}; + +} diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java new file mode 100644 index 0000000000..204d085205 --- /dev/null +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTypeExcludeFilter.java @@ -0,0 +1,74 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import java.util.Collections; +import java.util.Set; + +import org.springframework.boot.context.TypeExcludeFilter; +import org.springframework.boot.test.autoconfigure.filter.AnnotationCustomizableTypeExcludeFilter; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.core.annotation.AnnotatedElementUtils; + + + +/** + * {@link TypeExcludeFilter} for {@link DataRedisTest @DataRedisTest}. + * + * @author Jayaram Pradhan + */ +class DataRedisTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter { + + private final DataRedisTest annotation; + + DataRedisTypeExcludeFilter(Class testClass) { + this.annotation = AnnotatedElementUtils.getMergedAnnotation(testClass, + DataRedisTest.class); + } + + @Override + protected boolean hasAnnotation() { + return this.annotation != null; + } + + @Override + protected Filter[] getFilters(FilterType type) { + switch (type) { + case INCLUDE: + return this.annotation.includeFilters(); + case EXCLUDE: + return this.annotation.excludeFilters(); + default: + throw new IllegalStateException("Unsupported type " + type); + } + } + + @Override + protected boolean isUseDefaultFilters() { + return this.annotation.useDefaultFilters(); + } + + @Override + protected Set> getDefaultIncludes() { + return Collections.emptySet(); + } + + @Override + protected Set> getComponentIncludes() { + return Collections.emptySet(); + } +} diff --git a/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories b/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories index 4496301144..6d876eb370 100644 --- a/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories +++ b/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories @@ -36,6 +36,12 @@ org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration,\ org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration,\ org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration +# AutoConfigureDataRedis auto-configuration imports +org.springframework.boot.test.autoconfigure.data.redis.AutoConfigureDataRedis=\ +org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration,\ +org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration,\ +org.springframework.boot.autoconfigure.transaction.TransactionAutoConfiguration + # AutoConfigureJdbc auto-configuration imports org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureJdbc=\ org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration,\ @@ -136,4 +142,4 @@ org.springframework.test.context.TestExecutionListener=\ org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener,\ org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener,\ org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener,\ -org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener +org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener \ No newline at end of file diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java new file mode 100644 index 0000000000..b20e37a0dd --- /dev/null +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java @@ -0,0 +1,76 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import java.nio.charset.Charset; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.core.RedisOperations; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + + +/** + * Integration test for {@link DataRedisTest}. + * + * @author Jayaram Pradhan + */ +@RunWith(SpringRunner.class) +@DataRedisTest +public class DataRedisTestIntegrationTests { + + @Autowired + private RedisOperations operations; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @Autowired + private ExampleRepository exampleRepository; + + @Autowired + private ApplicationContext applicationContext; + + private static final Charset CHARSET = Charset.forName("UTF-8"); + + @Test + public void testRepository() { + PersonHash personHash = new PersonHash(); + personHash.setDescription("Look, new @DataRedisTest!"); + assertThat(personHash.getId()).isNull(); + PersonHash savedEntity = this.exampleRepository.save(personHash); + assertThat(savedEntity.getId()).isNotNull(); + assertThat(this.operations.execute((RedisConnection connection) -> connection.exists(("persons:" + savedEntity.getId()).getBytes(CHARSET)))).isTrue(); + this.exampleRepository.deleteAll(); + } + + @Test + public void didNotInjectExampleService() { + this.thrown.expect(NoSuchBeanDefinitionException.class); + this.applicationContext.getBean(ExampleService.class); + } + +} diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java new file mode 100644 index 0000000000..86c73fc23e --- /dev/null +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java @@ -0,0 +1,54 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.ComponentScan.Filter; +import org.springframework.stereotype.Service; +import org.springframework.test.context.junit4.SpringRunner; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Integration test with custom include filter for {@link DataRedisTest}. + * + * @author Jayaram Pradhan + */ +@RunWith(SpringRunner.class) +@DataRedisTest(includeFilters = @Filter(Service.class)) +public class DataRedisTestWithIncludeFilterIntegrationTests { + + @Autowired + private ExampleRepository exampleRepository; + + @Autowired + private ExampleService service; + + @Test + public void testService() { + PersonHash personHash = new PersonHash(); + personHash.setDescription("Look, new @DataRedisTest!"); + assertThat(personHash.getId()).isNull(); + PersonHash savedEntity = this.exampleRepository.save(personHash); + assertThat(this.service.hasRecord(savedEntity)).isTrue(); + this.exampleRepository.deleteAll(); + } + +} diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRedisApplication.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRedisApplication.java new file mode 100644 index 0000000000..6afd3f45e8 --- /dev/null +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRedisApplication.java @@ -0,0 +1,29 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Example {@link SpringBootApplication} used with {@link DataRedisTest} tests. + * + * @author Jayaram Pradhan + */ +@SpringBootApplication +public class ExampleRedisApplication { + +} diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRepository.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRepository.java new file mode 100644 index 0000000000..b8c6549362 --- /dev/null +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleRepository.java @@ -0,0 +1,27 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import org.springframework.data.repository.CrudRepository; + +/** + * Example repository used with {@link DataRedisTest} tests. + * + * @author Jayaram Pradhan + */ +public interface ExampleRepository extends CrudRepository { +} diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java new file mode 100644 index 0000000000..e9588b4d3b --- /dev/null +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/ExampleService.java @@ -0,0 +1,46 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import java.nio.charset.Charset; + +import org.springframework.data.redis.connection.RedisConnection; +import org.springframework.data.redis.core.RedisOperations; +import org.springframework.stereotype.Service; + + +/** + * Example service used with {@link DataRedisTest} tests. + * + * @author Jayaram Pradhan + */ +@Service +public class ExampleService { + + private RedisOperations operations; + private static final Charset CHARSET = Charset.forName("UTF-8"); + + public ExampleService(RedisOperations operations) { + this.operations = operations; + } + + public boolean hasRecord(PersonHash personHash) { + return this.operations.execute( + (RedisConnection connection) -> connection.exists(("persons:" + personHash.getId()).getBytes(CHARSET))); + } + +} diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/PersonHash.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/PersonHash.java new file mode 100644 index 0000000000..cb48da05e8 --- /dev/null +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/PersonHash.java @@ -0,0 +1,49 @@ +/* + * Copyright 2012-2017 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.boot.test.autoconfigure.data.redis; + +import org.springframework.data.annotation.Id; +import org.springframework.data.redis.core.RedisHash; + +/** + * Example graph used with {@link DataRedisTest} tests. + * + * @author Jayaram Pradhan + */ +@RedisHash("persons") +public class PersonHash { + + @Id + private String id; + private String description; + + public String getId() { + return this.id; + } + + public void setId(String id) { + this.id = id; + } + + public String getDescription() { + return this.description; + } + + public void setDescription(String description) { + this.description = description; + } +}