Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests in DocumentTest #3617

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/test/java/redis/clients/jedis/modules/search/DocumentTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package redis.clients.jedis.modules.search;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
Expand Down Expand Up @@ -40,9 +41,12 @@ public void serialize() throws IOException, ClassNotFoundException {
assertEquals(score, read.getScore(), 0d);

// use english language to make sure the decimal separator is the same as the toString
String exp = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s",
String exp1 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s",
id, score, "[string=c, float=12.0]");
assertEquals(exp, read.toString());
String exp2 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s",
id, score, "[float=12.0, string=c]");
String actual = read.toString();
assertTrue(actual.equals(exp1)||actual.equals(exp2));
assertEquals("c", read.getString("string"));
assertEquals(Double.valueOf(12d), read.get("float"));
}
Expand All @@ -57,8 +61,11 @@ public void toStringTest() {
Document document = new Document(id, map, score);

// use english language to make sure the decimal separator is the same as the toString
String expected = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s",
String expected1 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s",
id, score, "[string=c, float=12.0]");
assertEquals(expected, document.toString());
String expected2 = String.format(Locale.ENGLISH, "id:%s, score: %.1f, properties:%s",
id, score, "[float=12.0, string=c]");
String actual = document.toString();
assertTrue(actual.equals(expected1)||actual.equals(expected2));
}
}