Skip to content
Merged
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
3 changes: 3 additions & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7221](https://github.com/apache/incubator-seata/pull/7221)] add UT for gRPC Encoder/Decode
- [[#7227](https://github.com/apache/incubator-seata/pull/7227)] add mock test for seata-discovery-consul module
- [[#7233][https://github.com/apache/incubator-seata/pull/7233]] add mock test for seata-discovery-etcd3
- [[#7243](https://github.com/apache/incubator-seata/pull/7243)] add unit test for seata-discovery-eureka
- [[#7255](https://github.com/apache/incubator-seata/pull/7255)] more unit tests for Discovery-Eureka

### refactor:

Expand Down Expand Up @@ -139,5 +141,6 @@ Thanks to these contributors for their code commits. Please report an unintended
- [mehedikhan72](https://github.com/mehedikhan72)
- [AndrewSf](https://github.com/andrewseif)
- [bigcyy](https://github.com/bigcyy)
- [wjwang00](https://github.com/wjwang00)

Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
3 changes: 3 additions & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@
- [[#7221](https://github.com/apache/incubator-seata/pull/7221)] 增加 gRPC Encoder/Decoder的测试用例
- [[#7227](https://github.com/apache/incubator-seata/pull/7227)] 为 seata-discovery-consul 增加mock测试
- [[#7233][https://github.com/apache/incubator-seata/pull/7233]] 增加对 seata-discovery-etcd3 的mock测试
- [[#7243](https://github.com/apache/incubator-seata/pull/7243)] 增加对 seata-discovery-eureka的单测
- [[#7255](https://github.com/apache/incubator-seata/pull/7255)] 补充更多seata-discovery-eureka模块的单测提高覆盖率
### refactor:

- [[#7145](https://github.com/apache/incubator-seata/pull/7145)] 重构不满足 license 要求的代码
Expand Down Expand Up @@ -131,5 +133,6 @@
- [YoWuwuuuw](https://github.com/YoWuwuuuw)
- [AndrewSf](https://github.com/andrewseif)
- [bigcyy](https://github.com/bigcyy)
- [wjwang00](https://github.com/wjwang00)

同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class EurekaRegistryProviderTest {

@Test
void testProvide(){
assertThat(new EurekaRegistryProvider()).isInstanceOf(EurekaRegistryProvider.class);
EurekaRegistryProvider provider = new EurekaRegistryProvider();
assertThat(provider.provide()).isInstanceOf(EurekaRegistryServiceImpl.class);
assertThat(provider.provide()).isSameAs(provider.provide());

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.netflix.discovery.shared.Application;
import org.apache.seata.config.Configuration;
import org.apache.seata.config.ConfigurationFactory;
import org.apache.seata.config.exception.ConfigNotFoundException;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -97,6 +98,16 @@ public void testRegister() throws Exception {
verify(mockAppInfoManager).setInstanceStatus(InstanceInfo.InstanceStatus.UP);
}

@Test
void testRegisterWhenEurekaClientIsNull() throws Exception {
setStaticField(EurekaRegistryServiceImpl.class, "eurekaClient", null);
InetSocketAddress address = new InetSocketAddress("127.0.0.1", 8091);
registryService.register(address);
verify(mockAppInfoManager, times(0)).setInstanceStatus(any());
}



@Test
void testSubscribe() throws Exception {
String testCluster = "TEST_CLUSTER";
Expand Down Expand Up @@ -125,6 +136,13 @@ void testUnsubscribe() throws Exception {
verify(mockEurekaClient, times(1)).unregisterEventListener(mockEventListener);
}

@Test
void testUnsubscribeWhenEurekaClientIsNull() throws Exception {
setStaticField(EurekaRegistryServiceImpl.class, "eurekaClient", null);
registryService.unsubscribe("TEST_CLUSTER", mockEventListener);
verify(mockEurekaClient, times(0)).unregisterEventListener(any());
}

@Test
void testUnsubscribeWithNoExistingListeners() throws Exception {
String testCluster = "NON_EXISTENT_CLUSTER";
Expand Down Expand Up @@ -165,6 +183,17 @@ public void testLookup() throws Exception {
Assertions.assertEquals(new InetSocketAddress("192.168.1.1", 8091), addresses.get(0));
}
}
@Test
void testLookUpWithNoClusterName(){
Configuration mockConfig = mock(Configuration.class);
when(mockConfig.getConfig("service.vgroupMapping.test-group")).thenReturn(null);
try (MockedStatic<ConfigurationFactory> mockedFactory = mockStatic(ConfigurationFactory.class)) {
mockedFactory.when(ConfigurationFactory::getInstance).thenReturn(mockConfig);
Assertions.assertThrows(ConfigNotFoundException.class,()->{
registryService.lookup("test-group");
});
}
}

@Test
public void testClose() throws Exception {
Expand Down
Loading