-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2149 from codeimport/develop-fuzzyget-subscriber
[ISSUE #2148] subscribers list page support fuzzy query
- Loading branch information
Showing
4 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
naming/src/test/java/com/alibaba/nacos/naming/core/PushServiceTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package com.alibaba.nacos.naming.core; | ||
|
||
import com.alibaba.nacos.naming.BaseTest; | ||
import com.alibaba.nacos.naming.pojo.Subscriber; | ||
import com.alibaba.nacos.naming.push.PushService; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.springframework.mock.web.MockServletContext; | ||
import org.springframework.test.context.ContextConfiguration; | ||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; | ||
import org.springframework.test.context.web.WebAppConfiguration; | ||
|
||
import java.net.InetSocketAddress; | ||
import java.util.List; | ||
|
||
/** | ||
* @description: | ||
* @author: codeimport | ||
* @create: 2019/12/6 18:30 | ||
**/ | ||
@RunWith(SpringJUnit4ClassRunner.class) | ||
@ContextConfiguration(classes = MockServletContext.class) | ||
@WebAppConfiguration | ||
public class PushServiceTest extends BaseTest { | ||
@InjectMocks | ||
private PushService pushService; | ||
|
||
@Before | ||
public void before() { | ||
super.before(); | ||
} | ||
|
||
@Test | ||
public void testGetClientsFuzzy() throws Exception { | ||
|
||
String namespaceId = "public"; | ||
String clusters = "DEFAULT"; | ||
String agent = "Nacos-Java-Client:v1.1.4"; | ||
String clientIp = "localhost"; | ||
String app = "nacos"; | ||
int udpPort = 10000; | ||
|
||
String helloServiceName = "helloGroupName@@helloServiceName"; | ||
int helloUdpPort = 10000; | ||
|
||
String testServiceName = "testGroupName@@testServiceName"; | ||
int testUdpPort = 10001; | ||
|
||
pushService.addClient(namespaceId | ||
, helloServiceName | ||
, clusters | ||
, agent | ||
, new InetSocketAddress(clientIp, helloUdpPort) | ||
, null | ||
, namespaceId | ||
, app); | ||
|
||
pushService.addClient(namespaceId | ||
, testServiceName | ||
, clusters | ||
, agent | ||
, new InetSocketAddress(clientIp, testUdpPort) | ||
, null | ||
, namespaceId | ||
, app); | ||
|
||
List<Subscriber> fuzzylist = pushService.getClientsFuzzy("hello@@hello","public"); | ||
Assert.assertEquals(fuzzylist.size(),1); | ||
Assert.assertEquals(fuzzylist.get(0).getServiceName(),"helloGroupName@@helloServiceName"); | ||
|
||
List<Subscriber> list = pushService.getClientsFuzzy("helloGroupName@@helloServiceName","public"); | ||
Assert.assertEquals(list.size(),1); | ||
Assert.assertEquals(list.get(0).getServiceName(),"helloGroupName@@helloServiceName"); | ||
|
||
List<Subscriber> noDataList = pushService.getClientsFuzzy("badGroupName@@badServiceName","public"); | ||
Assert.assertEquals(noDataList.size(),0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters