poorbarcode commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1276630615
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataImplTest.java:
##########
@@ -62,4 +66,34 @@ public void verifyClone() {
assertEquals(clone, originalData, "Clones should have object
equality.");
assertNotSame(clone, originalData, "Clones should not be the same
reference.");
}
+
+ @Test
+ public void testBothServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("");
+ clusterData.setServiceUrlTls("");
+ clusterData.setBrokerServiceUrl("pulsar://pulsar.example.com:6650");
+
clusterData.setBrokerServiceUrlTls("pulsar+ssl://pulsar.example.com:6651");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class,
clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of ServiceUrl or ServiceUrlTls must be
set.", exception.getMessage());
+ }
+
+ @Test
+ public void testBothBrokerServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("http://pulsar.example.com:8080");
+ clusterData.setServiceUrlTls("https://pulsar.example.com:8443");
+ clusterData.setBrokerServiceUrl("");
+ clusterData.setBrokerServiceUrlTls("");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class,
clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of BrokerServiceUrl or BrokerServiceUrlTls
must be set.", exception.getMessage());
Review Comment:
> I have made two testcases to make sure at least one URL is set.
Good work. Thanks.
Since this change affects the API `Update cluster`, could you also add a
test for this API? You can write this test in the class `AdminApi2Test`, and
there are a lot of demos.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]