MCPcopy Create free account
hub / github.com/wildfirechat/im-server / testMesh

Method testMesh

sdk/src/main/java/cn/wildfirechat/sdk/Main.java:3216–3362  ·  view source on GitHub ↗

Mesh(分布式IM)API测试 测试以下分布式IM功能: 搜索用户 - 跨域搜索用户 批量获取用户信息 - 获取多个用户的详细信息 发送好友请求 - 向其他域用户发送好友请求 处理好友请求 - 接受或拒绝好友请求 创建域 - 创建新的Mesh域 获取域信息 - 获取指定域的详细信息 获取所有域 - 获取Mesh网络中的所有域列表 Ping域 - 测试域的连通性 删除域 - 从Mesh网络中移除域 同步群组

()

Source from the content-addressed store, hash-verified

3214 * @throws Exception 当测试过程中发生错误时抛出异常
3215 */
3216 static void testMesh() throws Exception {
3217 //测试搜索用户
3218 IMResult<PojoSearchUserRes> searchUserResult = MeshAdmin.searchUser("test", 0, 0, 1);
3219 if (searchUserResult != null && searchUserResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
3220 System.out.println("mesh search user success");
3221 } else {
3222 System.out.println("mesh search user failure");
3223 }
3224
3225 //测试批量获取用户信息
3226 IMResult<OutputUserInfoList> batchUserInfosResult = MeshAdmin.getBatchUserInfos(Arrays.asList("user1", "user2"));
3227 if (batchUserInfosResult != null && batchUserInfosResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
3228 System.out.println("mesh batch get user info success");
3229 } else {
3230 System.out.println("mesh batch get user info failure");
3231 }
3232
3233 //测试发送好友请求
3234 IMResult<Void> sendFriendRequestResult = MeshAdmin.sendFriendRequest("user1", "user2", "hello");
3235 if (sendFriendRequestResult != null && (sendFriendRequestResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS || sendFriendRequestResult.getErrorCode() == ErrorCode.ERROR_CODE_ALREADY_FRIENDS)) {
3236 System.out.println("mesh send friend request success");
3237 } else {
3238 System.out.println("mesh send friend request failure");
3239 }
3240
3241 //测试处理好友请求
3242 IMResult<Void> handleFriendRequestResult = MeshAdmin.handleFriendRequest("user2", "user1", 1);
3243 if (handleFriendRequestResult != null && handleFriendRequestResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
3244 System.out.println("mesh handle friend request success");
3245 } else {
3246 System.out.println("mesh handle friend request failure");
3247 }
3248
3249 //测试创建域
3250 String domainId = "test_domain_" + System.currentTimeMillis();
3251 InputOutputDomainInfo domainInfo = new InputOutputDomainInfo();
3252 domainInfo.setDomainId(domainId);
3253 domainInfo.setName("Test Domain");
3254 IMResult<Void> createDomainResult = MeshAdmin.createDomain(domainInfo);
3255 if (createDomainResult != null && createDomainResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
3256 System.out.println("mesh create domain success");
3257 } else {
3258 System.out.println("mesh create domain failure");
3259 }
3260
3261 //测试获取域
3262 IMResult<InputOutputDomainInfo> getDomainResult = MeshAdmin.getDomain(domainId);
3263 if (getDomainResult != null && getDomainResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
3264 System.out.println("mesh get domain success");
3265 } else {
3266 System.out.println("mesh get domain failure");
3267 }
3268
3269 //测试获取所有域
3270 IMResult<InputOutputDomainInfoList> getAllDomainResult = MeshAdmin.getAllDomain();
3271 if (getAllDomainResult != null && getAllDomainResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
3272 System.out.println("mesh get all domain success");
3273 } else {

Callers

nothing calls this directly

Calls 15

searchUserMethod · 0.95
getBatchUserInfosMethod · 0.95
sendFriendRequestMethod · 0.95
handleFriendRequestMethod · 0.95
setDomainIdMethod · 0.95
setNameMethod · 0.95
createDomainMethod · 0.95
getDomainMethod · 0.95
getAllDomainMethod · 0.95
pingDomainMethod · 0.95
deleteDomainMethod · 0.95
setTarget_idMethod · 0.95

Tested by

no test coverage detected