Skip to content

Commit

Permalink
Changing tests to use singleton RegistryProtocol instead of making ne…
Browse files Browse the repository at this point in the history
…w instances (apache#3849)
  • Loading branch information
OrDTesters authored and ralf0131 committed Apr 12, 2019
1 parent a0f3408 commit 1706807
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ public class RegistryProtocolTest {

@Test
public void testDefaultPort() {
RegistryProtocol registryProtocol = new RegistryProtocol();
RegistryProtocol registryProtocol = RegistryProtocol.getRegistryProtocol();
assertEquals(9090, registryProtocol.getDefaultPort());
}

@Test
public void testExportUrlNull() {
Assertions.assertThrows(IllegalArgumentException.class, () -> {
RegistryProtocol registryProtocol = new RegistryProtocol();
RegistryProtocol registryProtocol = RegistryProtocol.getRegistryProtocol();
registryProtocol.setCluster(new FailfastCluster());

Protocol dubboProtocol = DubboProtocol.getDubboProtocol();
Expand All @@ -81,7 +81,7 @@ public void testExportUrlNull() {

@Test
public void testExport() {
RegistryProtocol registryProtocol = new RegistryProtocol();
RegistryProtocol registryProtocol = RegistryProtocol.getRegistryProtocol();
registryProtocol.setCluster(new FailfastCluster());
registryProtocol.setRegistryFactory(ExtensionLoader.getExtensionLoader(RegistryFactory.class).getAdaptiveExtension());

Expand Down Expand Up @@ -165,7 +165,7 @@ public void testDestoryRegistry() {

@Test
public void testGetParamsToRegistry() {
RegistryProtocol registryProtocol = new RegistryProtocol();
RegistryProtocol registryProtocol = RegistryProtocol.getRegistryProtocol();
String[] additionalParams = new String[]{"key1", "key2"};
String[] registryParams = registryProtocol.getParamsToRegistry(DEFAULT_REGISTER_PROVIDER_KEYS, additionalParams);
String[] expectParams = ArrayUtils.addAll(DEFAULT_REGISTER_PROVIDER_KEYS, additionalParams);
Expand Down

0 comments on commit 1706807

Please sign in to comment.