[Issue 12040]
fix MultipleListenerValidatorTest
@@ -32,15 +32,6 @@ import static org.testng.AssertJUnit.assertEquals;
*/
public class MultipleListenerValidatorTest {
- @Test(expectedExceptions = IllegalArgumentException.class)
- public void testAppearTogether() {
- ServiceConfiguration config = new ServiceConfiguration();
- config.setAdvertisedAddress("127.0.0.1");
- config.setAdvertisedListeners("internal:pulsar://192.168.1.11:6660,internal:pulsar+ssl://192.168.1.11:6651");
- config.setInternalListenerName("internal");
- MultipleListenerValidator.validateAndAnalysisAdvertisedListener(config);
- }
-
@Test
public void testGetAppliedAdvertised() throws Exception {
ServiceConfiguration config = new ServiceConfiguration();
@@ -67,6 +58,20 @@ public class MultipleListenerValidatorTest {
ServiceConfigurationUtils.getDefaultOrConfiguredAddress(null));
}
+ @Test
+ public void testListenerDefaulting() {
+ ServiceConfiguration config = new ServiceConfiguration();
+ config.setAdvertisedListeners(" internal:pulsar://127.0.0.1:6660, internal:pulsar+ssl://127.0.0.1:6651");
+ MultipleListenerValidator.validateAndAnalysisAdvertisedListener(config);
+ assertEquals("internal", config.getInternalListenerName());
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testMalformedListener() {
+ ServiceConfiguration config = new ServiceConfiguration();
+ config.setAdvertisedListeners(":pulsar://127.0.0.1:6660");
+ MultipleListenerValidator.validateAndAnalysisAdvertisedListener(config);
+ }
@Test(expectedExceptions = IllegalArgumentException.class)
public void testListenerDuplicate_1() {
@@ -86,18 +91,17 @@ public class MultipleListenerValidatorTest {
}
@Test(expectedExceptions = IllegalArgumentException.class)
- public void testDifferentListenerWithSameHostPort() {
+ public void testListenerDuplicate_3() {
ServiceConfiguration config = new ServiceConfiguration();
- config.setAdvertisedListeners(" internal:pulsar://127.0.0.1:6660," + " external:pulsar://127.0.0.1:6660");
+ config.setAdvertisedListeners(" internal:pulsar+ssl://127.0.0.1:6661," + " internal:pulsar+ssl://192.168.1.11:6661");
config.setInternalListenerName("internal");
MultipleListenerValidator.validateAndAnalysisAdvertisedListener(config);
}
- @Test
- public void testListenerWithTLSPort() {
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testDifferentListenerWithSameHostPort() {
ServiceConfiguration config = new ServiceConfiguration();
- config.setBrokerServicePortTls(Optional.of(6651));
- config.setAdvertisedListeners(" internal:pulsar://127.0.0.1:6660, internal:pulsar+ssl://127.0.0.1:6651");
+ config.setAdvertisedListeners(" internal:pulsar://127.0.0.1:6660," + " external:pulsar://127.0.0.1:6660");
config.setInternalListenerName("internal");
MultipleListenerValidator.validateAndAnalysisAdvertisedListener(config);
}
@@ -105,7 +109,6 @@ public class MultipleListenerValidatorTest {
@Test(expectedExceptions = IllegalArgumentException.class)
public void testWithoutListenerNameInAdvertisedListeners() {
ServiceConfiguration config = new ServiceConfiguration();
- config.setBrokerServicePortTls(Optional.of(6651));
config.setAdvertisedListeners(" internal:pulsar://127.0.0.1:6660, internal:pulsar+ssl://127.0.0.1:6651");
config.setInternalListenerName("external");
MultipleListenerValidator.validateAndAnalysisAdvertisedListener(config);
