Skip to content

Commit

Permalink
Polishing #1528
Browse files Browse the repository at this point in the history
Add unit test to verify nanoseconds in the connection URL
  • Loading branch information
mp911de committed Nov 27, 2020
1 parent bd68d86 commit 6761a91
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/main/java/io/lettuce/core/RedisURI.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,22 @@
*/
package io.lettuce.core;

import static io.lettuce.core.internal.LettuceStrings.isEmpty;
import static io.lettuce.core.internal.LettuceStrings.isNotEmpty;
import static io.lettuce.core.internal.LettuceStrings.*;

import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.function.LongFunction;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
Expand Down Expand Up @@ -128,6 +134,7 @@
*
* @author Mark Paluch
* @author Guy Korland
* @author Johnny Lim
* @since 3.0
*/
@SuppressWarnings("serial")
Expand Down
9 changes: 5 additions & 4 deletions src/test/java/io/lettuce/core/RedisURIUnitTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/
package io.lettuce.core;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.*;

import java.time.Duration;
import java.util.LinkedHashMap;
Expand Down Expand Up @@ -202,8 +201,10 @@ void timeoutParsingTest() {
RedisURI defaultUri = new RedisURI();
checkUriTimeout("redis://auth@localhost:1234/5?timeout=junk", defaultUri.getTimeout().getSeconds(), TimeUnit.SECONDS);

RedisURI redisURI = RedisURI.create("redis://auth@localhost:1234/5?timeout=5000ms");
assertThat(redisURI).hasToString("redis://****@localhost:1234/5?timeout=5s");
assertThat(RedisURI.create("redis://auth@localhost:1234/5?timeout=5000ms"))
.hasToString("redis://****@localhost:1234/5?timeout=5s");
assertThat(RedisURI.create("redis://auth@localhost:1234/5?timeout=123ms"))
.hasToString("redis://****@localhost:1234/5?timeout=123000000ns");
}

@Test
Expand Down

0 comments on commit 6761a91

Please sign in to comment.