DATAREDIS-1030 - Refine RedisScript creation.

Allow RedisScript.of(…) creation from a Resource.

Original Pull Request: #473
This commit is contained in:
Mark Paluch
2019-09-02 15:18:29 +02:00
committed by Christoph Strobl
parent ac4909f139
commit 85669e6e69
3 changed files with 53 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ import org.springframework.scripting.support.StaticScriptSource;
*
* @author Jennifer Hickey
* @author Christoph Strobl
* @author Mark Paluch
*/
public class DefaultRedisScriptTests {
@@ -55,6 +56,14 @@ public class DefaultRedisScriptTests {
assertThat(redisScript.getScriptAsString()).isEqualTo("return ARGS[1]");
}
@Test // DATAREDIS-1030
public void testGetScriptAsStringFromResource() {
RedisScript<String> redisScript = RedisScript
.of(new ClassPathResource("org/springframework/data/redis/core/script/cas.lua"));
assertThat(redisScript.getScriptAsString()).startsWith("local current = redis.call('GET', KEYS[1])");
}
@Test(expected = ScriptingException.class)
public void testGetScriptAsStringError() {