DATAREDIS-538 - Allow @TimeToLive methods that are not accessible by default.

We allow now the use of non-public classes with a @TimeToLive method and @TimeToLive on non-public methods.

Original Pull Request: #231
This commit is contained in:
Mark Paluch
2016-07-20 15:30:18 +02:00
committed by Christoph Strobl
parent 54229d2388
commit e62ecbb1a9
2 changed files with 29 additions and 0 deletions

View File

@@ -28,7 +28,10 @@ import org.springframework.data.redis.core.convert.KeyspaceConfiguration.Keyspac
import org.springframework.data.redis.core.mapping.RedisMappingContext.ConfigAwareTimeToLiveAccessor;
/**
* Unit tests for {@link ConfigAwareTimeToLiveAccessor}.
*
* @author Christoph Strobl
* @author Mark Paluch
*/
public class ConfigAwareTimeToLiveAccessorUnitTests {
@@ -137,6 +140,11 @@ public class ConfigAwareTimeToLiveAccessorUnitTests {
assertThat(accessor.getTimeToLive(new TypeWithTtlOnMethod(100L))).isEqualTo(100L);
}
@Test // DATAREDIS-538
public void getTimeToLiveShouldReturnMethodLevelTimeToLiveOfNonPublicTypeIfPresent() {
assertThat(accessor.getTimeToLive(new PrivateTypeWithTtlOnMethod(10L))).isEqualTo(10L);
}
@Test // DATAREDIS-471
public void getTimeToLiveShouldReturnDefaultValue() {
@@ -212,6 +220,22 @@ public class ConfigAwareTimeToLiveAccessorUnitTests {
this.value = value;
}
@TimeToLive
private Long getTimeToLive() {
return value;
}
}
// Type must be private so it does not fall in the
// package-default scope like the types from above
private static class PrivateTypeWithTtlOnMethod {
Long value;
public PrivateTypeWithTtlOnMethod(Long value) {
this.value = value;
}
@TimeToLive
Long getTimeToLive() {
return value;