Skip to content

Commit 12c1124

Browse files
committed
[fix][test] Use PositionFactory.create() instead of new ImmutablePositionImpl()
1 parent 88d7feb commit 12c1124

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedCursorTest.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ void cursorPersistence() throws Exception {
12851285
assertEquals(c1.getMarkDeletedPosition(), p1);
12861286
ManagedCursor finalC2 = c2;
12871287
Awaitility.await()
1288-
.untilAsserted(() -> assertEquals(finalC2.getMarkDeletedPosition(), new ImmutablePositionImpl(6, -1)));
1288+
.untilAsserted(() -> assertEquals(finalC2.getMarkDeletedPosition(), PositionFactory.create(6, -1)));
12891289
}
12901290

12911291
@Test(timeOut = 20000)
@@ -1422,8 +1422,8 @@ public void markDeleteComplete(Object ctx) {
14221422
Awaitility.await().untilAsserted(() ->
14231423
assertTrue(
14241424
c2.getMarkDeletedPosition().equals(lastPosition.get())
1425-
|| c2.getMarkDeletedPosition().equals(new ImmutablePositionImpl(lastPositionLedgerId + 2, -1))
1426-
|| c2.getMarkDeletedPosition().equals(new ImmutablePositionImpl(lastPositionLedgerId + 3, -1))
1425+
|| c2.getMarkDeletedPosition().equals(PositionFactory.create(lastPositionLedgerId + 2, -1))
1426+
|| c2.getMarkDeletedPosition().equals(PositionFactory.create(lastPositionLedgerId + 3, -1))
14271427
)
14281428
);
14291429
}
@@ -1464,7 +1464,7 @@ public void addComplete(Position position, ByteBuf entryData, Object ctx) {
14641464
}, null);
14651465
}
14661466
addEntryLatch.await();
1467-
assertEquals(lastPosition.get(), new ImmutablePositionImpl(13, 0));
1467+
assertEquals(lastPosition.get(), PositionFactory.create(13, 0));
14681468

14691469
// If we set num=100, to avoid flaky test, we should add Thread.sleep(1000) here to make sure ledger rollover
14701470
// is finished, but this sleep can not guarantee c1 always recovered with markDeletePosition 12:9.
@@ -1513,7 +1513,7 @@ public void markDeleteComplete(Object ctx) {
15131513
// To make sure ManagedLedgerImpl.maybeUpdateCursorBeforeTrimmingConsumedLedger() is completed, we should
15141514
// wait until c2.getMarkDeletedPosition() equals 15:-1, see PR https://github.com/apache/pulsar/pull/25087.
15151515
Awaitility.await()
1516-
.untilAsserted(() -> assertEquals(c2.getMarkDeletedPosition(), new ImmutablePositionImpl(15, -1)));
1516+
.untilAsserted(() -> assertEquals(c2.getMarkDeletedPosition(), PositionFactory.create(15, -1)));
15171517
}
15181518

15191519
@Test(timeOut = 20000)
@@ -1565,9 +1565,8 @@ public void markDeleteComplete(Object ctx) {
15651565
log.info("c2 markDeletePosition: {}, lastPosition: {}", c2.getMarkDeletedPosition(), lastPosition);
15661566
long lastPositionLedgerId = lastPosition.get().getLedgerId();
15671567
Awaitility.await().untilAsserted(() -> assertTrue(
1568-
c2.getMarkDeletedPosition().equals(new ImmutablePositionImpl(lastPositionLedgerId + 1, -1))
1569-
|| c2.getMarkDeletedPosition()
1570-
.equals(new ImmutablePositionImpl(lastPositionLedgerId + 2, -1))));
1568+
c2.getMarkDeletedPosition().equals(PositionFactory.create(lastPositionLedgerId + 1, -1))
1569+
|| c2.getMarkDeletedPosition().equals(PositionFactory.create(lastPositionLedgerId + 2, -1))));
15711570
}
15721571

15731572
@Test(timeOut = 20000)

0 commit comments

Comments
 (0)