Skip to content

Commit

Permalink
Fix flakyness in TestDefaultMessageFormatter (apache#10379)
Browse files Browse the repository at this point in the history
Fixes apache#10378

### Motivation

The TestDefaultMessageFormatter test is flaky, see apache#10378 .

### Modifications

Since the test asserts that an int value must be greater than 0, make changes to the getIntValue method to fullfil this requirement.
  • Loading branch information
lhotari authored Apr 26, 2021
1 parent 5f72699 commit 2ede152
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,14 @@ private String getFloatValue(float size) {
}

private String getIntValue(float size) {
if (size == 0) {
return String.valueOf(r.nextInt());
int i = 0;
if (size != 0) {
i = (int) _getFloatValue(size);
}
if (i == 0) {
i = r.nextInt() + 1;
}
return String.valueOf((int) _getFloatValue(size));
return String.valueOf(i);
}
private String getLongValue(float size) {
if (size == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testFormatMessage() {
Assert.assertTrue(l3 > 0);
Assert.assertTrue(l3 <= 99999);
Assert.assertTrue(i2 < 10);
Assert.assertTrue(0 < i2);
Assert.assertTrue(0 < i2, "i2 was " + i2);
Assert.assertTrue(f2 < 100000);
Assert.assertTrue( -100000 < f2);

Expand Down

0 comments on commit 2ede152

Please sign in to comment.