Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dubbo-remoting-zookeeper-curator5 module remove dubbo-test-check and dubbo-test-common #15082

Draft
wants to merge 1 commit into
base: 3.3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions dubbo-remoting/dubbo-remoting-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-check</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions dubbo-remoting/dubbo-remoting-http12/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-check</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions dubbo-remoting/dubbo-remoting-http3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,11 @@
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-check</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions dubbo-remoting/dubbo-remoting-netty/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-check</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
6 changes: 6 additions & 0 deletions dubbo-remoting/dubbo-remoting-netty4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-check</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
Expand Down
6 changes: 6 additions & 0 deletions dubbo-remoting/dubbo-remoting-websocket/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,11 @@
<artifactId>dubbo-remoting-http12</artifactId>
<version>${project.parent.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-check</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
7 changes: 0 additions & 7 deletions dubbo-remoting/dubbo-remoting-zookeeper-curator5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@
<version>${project.parent.version}</version>
</dependency>

<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-common</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,17 @@
*/
package org.apache.dubbo.remoting.zookeeper.curator5;

import org.apache.curator.framework.CuratorFrameworkFactory.Builder;

import org.apache.curator.framework.api.CreateBuilder;
import org.apache.curator.framework.api.ExistsBuilder;
import org.apache.curator.framework.listen.StandardListenerManager;

import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.config.configcenter.ConfigItem;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -35,31 +42,67 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.mockito.MockedStatic;
import org.mockito.Mockito;
import org.mockito.Spy;

import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;

class Curator5ZookeeperClientTest {
private static Curator5ZookeeperClient curatorClient;
private static CuratorFramework client = null;

private static int zookeeperServerPort1;
private static int zookeeperServerMockPort1;
private static String zookeeperConnectionAddress1;

@Spy
CuratorFrameworkFactory.Builder spyBuilder = CuratorFrameworkFactory.builder();

@BeforeAll
public static void setUp() throws Exception {
zookeeperConnectionAddress1 = System.getProperty("zookeeper.connection.address.1");
zookeeperServerPort1 = Integer.parseInt(
zookeeperConnectionAddress1.substring(zookeeperConnectionAddress1.lastIndexOf(":") + 1));
zookeeperServerMockPort1 = 2181;
zookeeperConnectionAddress1 = "zookeeper://localhost:" + zookeeperServerMockPort1;

// mock begin
// create mock bean begin
CuratorFrameworkFactory.Builder realBuilder = CuratorFrameworkFactory.builder();
CuratorFrameworkFactory.Builder spyBuilder = spy(realBuilder);
CreateBuilder mockCreateBuilder = mock(CreateBuilder.class);
ExistsBuilder mockExistsBuilder = mock(ExistsBuilder.class);
CuratorFramework mockCuratorFramework = Mockito.mock(CuratorFramework.class);
MockedStatic<CuratorFrameworkFactory> curatorFrameworkFactoryMockedStatic = Mockito.mockStatic(CuratorFrameworkFactory.class);
curatorFrameworkFactoryMockedStatic.when(CuratorFrameworkFactory::builder).thenReturn(spyBuilder);
doReturn(mockCuratorFramework).when(spyBuilder).build();
Mockito.when(mockCuratorFramework.blockUntilConnected(anyInt(), any())).thenReturn(true);
Mockito.when(mockCuratorFramework.getConnectionStateListenable()).thenReturn(StandardListenerManager.standard());
Mockito.when(mockCuratorFramework.create()).thenReturn(mockCreateBuilder);
Mockito.when(mockCuratorFramework.checkExists()).thenReturn(mockExistsBuilder);
List<String> paths = new ArrayList<>();
Mockito.when(mockCreateBuilder.forPath(anyString())).thenAnswer(i-> {
paths.add(i.getArgument(0));
return i.getArgument(0);
});
Mockito.when(mockExistsBuilder.forPath(anyString())).thenAnswer(i-> {
if (paths.contains(i.getArgument(0))) {
return new Stat();
}
return null;
});


curatorClient = new Curator5ZookeeperClient(
URL.valueOf(zookeeperConnectionAddress1 + "/org.apache.dubbo.registry.RegistryService"));
client = CuratorFrameworkFactory.newClient(
"127.0.0.1:" + zookeeperServerPort1, new ExponentialBackoffRetry(1000, 3));
client.start();

}

@Test
Expand Down
9 changes: 1 addition & 8 deletions dubbo-remoting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,5 @@
<skip_maven_deploy>false</skip_maven_deploy>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-test-check</artifactId>
<version>${project.parent.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Loading