Skip to content

Commit

Permalink
test independent of config change (apache#13459)
Browse files Browse the repository at this point in the history
  • Loading branch information
hezhangjian authored Dec 28, 2021
1 parent 7f4aac5 commit fced796
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Properties;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

@Test(groups = "broker")
public class ProxyConfigurationTest {
Expand All @@ -42,19 +40,16 @@ public void testConfigFileDefaults() throws Exception {
final ProxyConfiguration javaConfig = PulsarConfigurationLoader.create(new Properties(), ProxyConfiguration.class);
final ProxyConfiguration fileConfig = PulsarConfigurationLoader.create(stream, ProxyConfiguration.class);
List<String> toSkip = Arrays.asList("properties", "class");
int counter = 0;
for (PropertyDescriptor pd : Introspector.getBeanInfo(ProxyConfiguration.class).getPropertyDescriptors()) {
if (pd.getReadMethod() == null || toSkip.contains(pd.getName())) {
continue;
}
final String key = pd.getName();
final Object javaValue = pd.getReadMethod().invoke(javaConfig);
final Object fileValue = pd.getReadMethod().invoke(fileConfig);
assertTrue(Objects.equals(javaValue, fileValue), "property '"
+ key + "' conf/proxy.conf default value doesn't match java default value\nConf: "+ fileValue + "\nJava: " + javaValue);
counter++;
assertEquals(fileValue, javaValue, "property '"
+ key + "' conf/proxy.conf default value doesn't match java default value\nConf: " + fileValue + "\nJava: " + javaValue);
}
assertEquals(79, counter);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@
import java.io.FileInputStream;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.Properties;

import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

@Test(groups = "broker")
public class WebSocketProxyConfigurationTest {
Expand All @@ -41,19 +39,16 @@ public void testConfigFileDefaults() throws Exception {
final WebSocketProxyConfiguration javaConfig = PulsarConfigurationLoader.create(new Properties(), WebSocketProxyConfiguration.class);
final WebSocketProxyConfiguration fileConfig = PulsarConfigurationLoader.create(stream, WebSocketProxyConfiguration.class);
List<String> toSkip = Arrays.asList("properties", "class");
int counter = 0;
for (PropertyDescriptor pd : Introspector.getBeanInfo(WebSocketProxyConfiguration.class).getPropertyDescriptors()) {
if (pd.getReadMethod() == null || toSkip.contains(pd.getName())) {
continue;
}
final String key = pd.getName();
final Object javaValue = pd.getReadMethod().invoke(javaConfig);
final Object fileValue = pd.getReadMethod().invoke(fileConfig);
assertTrue(Objects.equals(javaValue, fileValue), "property '"
+ key + "' conf/websocket.conf default value doesn't match java default value\nConf: "+ fileValue + "\nJava: " + javaValue);
counter++;
assertEquals(fileValue, javaValue, "property '"
+ key + "' conf/websocket.conf default value doesn't match java default value\nConf: " + fileValue + "\nJava: " + javaValue);
}
assertEquals(36, counter);
}
}

Expand Down

0 comments on commit fced796

Please sign in to comment.