Skip to content

Commit 180d9aa

Browse files
authored
Remove List tests asserting timeouts (#4051)
As a client library, it should be enough to send the command arguments and get & parse the reply properly.
1 parent a55da99 commit 180d9aa

File tree

3 files changed

+7
-63
lines changed

3 files changed

+7
-63
lines changed

src/test/java/redis/clients/jedis/commands/jedis/ListCommandsTest.java

+2-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static org.junit.Assert.assertEquals;
55
import static org.junit.Assert.assertNotNull;
66
import static org.junit.Assert.assertNull;
7-
import static org.junit.Assert.assertTrue;
87
import static org.junit.Assert.fail;
98
import static redis.clients.jedis.util.AssertUtil.assertByteArrayListEquals;
109

@@ -495,17 +494,11 @@ public void blpopDouble() throws InterruptedException {
495494
assertArrayEquals(bbar, bresult.getValue());
496495
}
497496

498-
@Test
497+
@Test(timeout = 5000L)
499498
public void blpopDoubleWithSleep() {
500-
long startMillis, totalMillis;
501-
502-
startMillis = System.currentTimeMillis();
503499
KeyValue<String, String> result = jedis.blpop(0.04, "foo");
504-
totalMillis = System.currentTimeMillis() - startMillis;
505-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
506500
assertNull(result);
507501

508-
startMillis = System.currentTimeMillis();
509502
new Thread(() -> {
510503
try {
511504
Thread.sleep(30);
@@ -517,8 +510,6 @@ public void blpopDoubleWithSleep() {
517510
}
518511
}).start();
519512
result = jedis.blpop(1.2, "foo");
520-
totalMillis = System.currentTimeMillis() - startMillis;
521-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
522513

523514
assertNotNull(result);
524515
assertEquals("foo", result.getKey());
@@ -617,17 +608,11 @@ public void brpopDouble() throws InterruptedException {
617608
assertArrayEquals(bbar, bresult.getValue());
618609
}
619610

620-
@Test
611+
@Test(timeout = 5000L)
621612
public void brpopDoubleWithSleep() {
622-
long startMillis, totalMillis;
623-
624-
startMillis = System.currentTimeMillis();
625613
KeyValue<String, String> result = jedis.brpop(0.04, "foo");
626-
totalMillis = System.currentTimeMillis() - startMillis;
627-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
628614
assertNull(result);
629615

630-
startMillis = System.currentTimeMillis();
631616
new Thread(() -> {
632617
try {
633618
Thread.sleep(30);
@@ -639,8 +624,6 @@ public void brpopDoubleWithSleep() {
639624
}
640625
}).start();
641626
result = jedis.brpop(1.2, "foo");
642-
totalMillis = System.currentTimeMillis() - startMillis;
643-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
644627

645628
assertNotNull(result);
646629
assertEquals("foo", result.getKey());

src/test/java/redis/clients/jedis/commands/unified/ListCommandsTestBase.java

+2-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import static org.junit.Assert.assertEquals;
55
import static org.junit.Assert.assertNotNull;
66
import static org.junit.Assert.assertNull;
7-
import static org.junit.Assert.assertTrue;
87
import static org.junit.Assert.fail;
98
import static redis.clients.jedis.util.AssertUtil.assertByteArrayListEquals;
109

@@ -491,17 +490,11 @@ public void blpopDouble() throws InterruptedException {
491490
assertArrayEquals(bbar, bresult.getValue());
492491
}
493492

494-
@Test
493+
@Test(timeout = 5000L)
495494
public void blpopDoubleWithSleep() {
496-
long startMillis, totalMillis;
497-
498-
startMillis = System.currentTimeMillis();
499495
KeyValue<String, String> result = jedis.blpop(0.04, "foo");
500-
totalMillis = System.currentTimeMillis() - startMillis;
501-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
502496
assertNull(result);
503497

504-
startMillis = System.currentTimeMillis();
505498
new Thread(() -> {
506499
try {
507500
Thread.sleep(30);
@@ -511,8 +504,6 @@ public void blpopDoubleWithSleep() {
511504
jedis.lpush("foo", "bar");
512505
}).start();
513506
result = jedis.blpop(1.2, "foo");
514-
totalMillis = System.currentTimeMillis() - startMillis;
515-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
516507

517508
assertNotNull(result);
518509
assertEquals("foo", result.getKey());
@@ -611,17 +602,11 @@ public void brpopDouble() throws InterruptedException {
611602
assertArrayEquals(bbar, bresult.getValue());
612603
}
613604

614-
@Test
605+
@Test(timeout = 5000L)
615606
public void brpopDoubleWithSleep() {
616-
long startMillis, totalMillis;
617-
618-
startMillis = System.currentTimeMillis();
619607
KeyValue<String, String> result = jedis.brpop(0.04, "foo");
620-
totalMillis = System.currentTimeMillis() - startMillis;
621-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
622608
assertNull(result);
623609

624-
startMillis = System.currentTimeMillis();
625610
new Thread(() -> {
626611
try {
627612
Thread.sleep(30);
@@ -631,8 +616,6 @@ public void brpopDoubleWithSleep() {
631616
jedis.lpush("foo", "bar");
632617
}).start();
633618
result = jedis.brpop(1.2, "foo");
634-
totalMillis = System.currentTimeMillis() - startMillis;
635-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
636619

637620
assertNotNull(result);
638621
assertEquals("foo", result.getKey());

src/test/java/redis/clients/jedis/commands/unified/pipeline/ListPipelineCommandsTest.java

+3-25
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import static org.hamcrest.Matchers.equalTo;
77
import static org.hamcrest.Matchers.instanceOf;
88
import static org.hamcrest.Matchers.nullValue;
9-
import static org.junit.Assert.assertTrue;
109

1110
import java.util.List;
1211

@@ -15,6 +14,7 @@
1514
import org.junit.runners.Parameterized;
1615
import org.slf4j.Logger;
1716
import org.slf4j.LoggerFactory;
17+
1818
import redis.clients.jedis.RedisProtocol;
1919
import redis.clients.jedis.Response;
2020
import redis.clients.jedis.args.ListDirection;
@@ -524,21 +524,13 @@ public void blpopDouble() {
524524
assertThat(bresult3.get().getValue(), equalTo(bcar));
525525
}
526526

527-
@Test
527+
@Test(timeout = 5000L)
528528
public void blpopDoubleWithSleep() {
529-
long startMillis, totalMillis;
530-
531-
startMillis = System.currentTimeMillis();
532-
533529
Response<KeyValue<String, String>> result = pipe.blpop(0.04, "foo");
534530
pipe.sync();
535531

536-
totalMillis = System.currentTimeMillis() - startMillis;
537-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
538-
539532
assertThat(result.get(), nullValue());
540533

541-
startMillis = System.currentTimeMillis();
542534
new Thread(() -> {
543535
try {
544536
Thread.sleep(30);
@@ -551,9 +543,6 @@ public void blpopDoubleWithSleep() {
551543
result = pipe.blpop(1.2, "foo");
552544
pipe.sync();
553545

554-
totalMillis = System.currentTimeMillis() - startMillis;
555-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
556-
557546
assertThat(result.get().getKey(), equalTo("foo"));
558547
assertThat(result.get().getValue(), equalTo("bar"));
559548
}
@@ -646,21 +635,13 @@ public void brpopDouble() {
646635
assertThat(bresult3.get().getValue(), equalTo(bcar));
647636
}
648637

649-
@Test
638+
@Test(timeout = 5000L)
650639
public void brpopDoubleWithSleep() {
651-
long startMillis, totalMillis;
652-
653-
startMillis = System.currentTimeMillis();
654-
655640
Response<KeyValue<String, String>> result = pipe.brpop(0.04, "foo");
656641
pipe.sync();
657642

658-
totalMillis = System.currentTimeMillis() - startMillis;
659-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
660-
661643
assertThat(result.get(), nullValue());
662644

663-
startMillis = System.currentTimeMillis();
664645
new Thread(() -> {
665646
try {
666647
Thread.sleep(30);
@@ -673,9 +654,6 @@ public void brpopDoubleWithSleep() {
673654
result = pipe.brpop(1.2, "foo");
674655
pipe.sync();
675656

676-
totalMillis = System.currentTimeMillis() - startMillis;
677-
assertTrue("TotalMillis=" + totalMillis, totalMillis < 200);
678-
679657
assertThat(result.get().getKey(), equalTo("foo"));
680658
assertThat(result.get().getValue(), equalTo("bar"));
681659
}

0 commit comments

Comments
 (0)