-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ID-4250: fikse config, fjerne dependabot (#22)
* fikse config, fjerne dependabot * fikse config, fjerne dependabot * testfix * test with one node
- Loading branch information
Showing
4 changed files
with
87 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
eidas-redis/src/test/java/no/idporten/eidas/redis/cache/RedisConfigTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package no.idporten.eidas.redis.cache; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
|
||
public class RedisConfigTest { | ||
|
||
private RedisConfig config; | ||
|
||
|
||
@Before | ||
public void setUp() { | ||
config = new RedisConfig(); | ||
config.setRedisHost("localhost"); | ||
config.setRedisPort("6379"); | ||
config.setRedisPassword("password"); | ||
} | ||
|
||
@Test | ||
public void testStandaloneRedisConnectionFactory() { | ||
config.setSentinelNodes(null); | ||
LettuceConnectionFactory factory = config.redisConnectionFactory(); | ||
assertNotNull(factory); | ||
assertEquals("localhost", factory.getHostName()); | ||
assertEquals(6379, factory.getPort()); | ||
assertFalse(factory.isRedisSentinelAware()); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testStandaloneRedisConnectionFactoryMissingHost() { | ||
config.setRedisHost(null); | ||
config.redisConnectionFactory(); | ||
} | ||
|
||
@Test | ||
public void testSentinelRedisConnectionFactory() { | ||
config.setSentinelNodes("node1:26379"); | ||
config.setSentinelMaster("mymaster"); | ||
LettuceConnectionFactory factory = config.redisConnectionFactory(); | ||
assertNotNull(factory); | ||
assertTrue(factory.isRedisSentinelAware()); | ||
} | ||
|
||
@Test | ||
public void testMultipleSentinelRedisConnectionFactory() { | ||
config.setSentinelNodes("node1:26379,node2:26379"); | ||
config.setSentinelMaster("mymaster"); | ||
LettuceConnectionFactory factory = config.redisConnectionFactory(); | ||
assertNotNull(factory); | ||
assertTrue(factory.isRedisSentinelAware()); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testSentinelRedisConnectionFactoryInvalidNode() { | ||
config.setSentinelNodes("node1:26379,invalid_node"); | ||
config.redisConnectionFactory(); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void testSentinelRedisConnectionFactoryMissingPassword() { | ||
config.setSentinelNodes("node1:26379,node2:26379"); | ||
config.setSentinelMaster("mymaster"); | ||
config.setRedisPassword(null); | ||
config.redisConnectionFactory(); | ||
} | ||
} |