Skip to content

Commit

Permalink
[fix][broker] Don't allow creating a non-persistent partitioned topic…
Browse files Browse the repository at this point in the history
… with '-partition-' in name
  • Loading branch information
hanmz committed Feb 12, 2025
1 parent cc8282d commit 1277fb5
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2011,4 +2011,20 @@ public void testPeekMessageWithProperties() throws Exception {
assertEquals(batchMessage.getProperties().get("BaTcH-kEy3"), "BaTcH-vAlUe3");
}
}

@Test
public void testCreateNonPersistentPartitionedTopic() {
AsyncResponse response = mock(AsyncResponse.class);
ArgumentCaptor<Response> responseCaptor = ArgumentCaptor.forClass(Response.class);
nonPersistentTopic.createPartitionedTopic(response, testTenant, testNamespace, "test-topic", 3, true);
verify(response, timeout(5000).times(1)).resume(responseCaptor.capture());
Assert.assertEquals(responseCaptor.getValue().getStatus(), Response.Status.NO_CONTENT.getStatusCode());

response = mock(AsyncResponse.class);
ArgumentCaptor<RestException> errorCaptor = ArgumentCaptor.forClass(RestException.class);
nonPersistentTopic.createPartitionedTopic(response, testTenant, testNamespace, "test-topic-partition-0", 3, true);
verify(response, timeout(5000).times(1)).resume(errorCaptor.capture());
Assert.assertEquals(errorCaptor.getValue().getResponse().getStatus(),
Response.Status.PRECONDITION_FAILED.getStatusCode());
}
}

0 comments on commit 1277fb5

Please sign in to comment.