poorbarcode commented on code in PR #16781:
URL: https://github.com/apache/pulsar/pull/16781#discussion_r929472080


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/AdminRestTest.java:
##########
@@ -60,15 +65,36 @@ public void testRejectUnknownEntityProperties() throws 
Exception{
         Response response = 
target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(data)).invoke();
         Assert.assertTrue(response.getStatus() / 200 == 1);
         // Enabled feature, bad request response.
-        
pulsar.getWebService().getSharedUnknownPropertyHandler().setSkipUnknownProperty(false);
+        
admin.brokers().updateDynamicConfiguration("httpRequestsFailOnUnknownPropertiesEnabled",
 "true");
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).until(
+                () -> 
!pulsar.getWebService().getSharedUnknownPropertyHandler().isSkipUnknownProperty()
+        );
         response = 
target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(data)).invoke();
+        Assert.assertEquals(MediaType.valueOf(MediaType.TEXT_PLAIN), 
response.getMediaType());
+        String responseBody = parseResponseEntity(response.getEntity());
+        Assert.assertEquals(responseBody, "Unknown property 
retention_time_in_minutes, perhaps you want to use"
+                + " one of these: [retentionSizeInMB, 
retentionTimeInMinutes]");
         Assert.assertEquals(response.getStatus(), 400);
         // Disabled feature, response success.
-        
pulsar.getWebService().getSharedUnknownPropertyHandler().setSkipUnknownProperty(true);
+        
admin.brokers().updateDynamicConfiguration("httpRequestsFailOnUnknownPropertiesEnabled",
 "false");
+        Awaitility.await().atMost(2, TimeUnit.SECONDS).until(
+                () -> 
pulsar.getWebService().getSharedUnknownPropertyHandler().isSkipUnknownProperty()
+        );
         response = 
target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(data)).invoke();
         Assert.assertTrue(response.getStatus() / 200 == 1);
     }
 
+    private String parseResponseEntity(Object entity) throws Exception {
+        InputStream in = (InputStream) entity;
+        BufferedReader bufferedReader = new BufferedReader(new 
InputStreamReader(in));

Review Comment:
   Already fixed. Thanks.
   
   The newly submitted: input stream has closed by `response.close`



-- 
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]

Reply via email to