sdk 测试代码中区分社区版和专业版
This commit is contained in:
@@ -61,8 +61,8 @@ public class CreateChannelAction extends AdminAction {
|
|||||||
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (errorCode == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
byte[] data = new byte[byteBuf.readableBytes()];
|
byte[] data = new byte[byteBuf.readableBytes()];
|
||||||
byteBuf.readBytes(data);
|
byteBuf.readBytes(data);
|
||||||
String secret = new String(data);
|
String channelId = new String(data);
|
||||||
sendResponse(response, null, new OutputCreateChannel(inputCreateChannel.getTargetId(), secret));
|
sendResponse(response, null, new OutputCreateChannel(channelId));
|
||||||
} else {
|
} else {
|
||||||
sendResponse(response, errorCode, null);
|
sendResponse(response, errorCode, null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,11 +13,9 @@ import cn.wildfirechat.proto.WFCMessage;
|
|||||||
|
|
||||||
public class OutputCreateChannel {
|
public class OutputCreateChannel {
|
||||||
private String targetId;
|
private String targetId;
|
||||||
private String secret;
|
|
||||||
|
|
||||||
public OutputCreateChannel(String targetId, String secret) {
|
public OutputCreateChannel(String targetId) {
|
||||||
this.targetId = targetId;
|
this.targetId = targetId;
|
||||||
this.secret = secret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTargetId() {
|
public String getTargetId() {
|
||||||
@@ -27,12 +25,4 @@ public class OutputCreateChannel {
|
|||||||
public void setTargetId(String targetId) {
|
public void setTargetId(String targetId) {
|
||||||
this.targetId = targetId;
|
this.targetId = targetId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSecret() {
|
|
||||||
return secret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSecret(String secret) {
|
|
||||||
this.secret = secret;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,15 @@ import java.util.List;
|
|||||||
import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_Member_Count;
|
import static cn.wildfirechat.proto.ProtoConstants.SystemSettingType.Group_Max_Member_Count;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
|
private static boolean commercialServer = false;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
//admin使用的是18080端口,超级管理接口,理论上不能对外开放端口,也不能让非内部服务知悉密钥。
|
//admin使用的是18080端口,超级管理接口,理论上不能对外开放端口,也不能让非内部服务知悉密钥。
|
||||||
testAdmin();
|
testAdmin();
|
||||||
|
|
||||||
//Robot和Channel都是使用的80端口,第三方可以创建或者为第三方创建,第三方可以使用robot或者channel与IM系统进行对接。
|
//Robot和Channel都是使用的80端口,第三方可以创建或者为第三方创建,第三方可以使用robot或者channel与IM系统进行对接。
|
||||||
testRobot();
|
testRobot();
|
||||||
//testChannel();
|
testChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -37,7 +39,10 @@ public class Main {
|
|||||||
testChatroom();
|
testChatroom();
|
||||||
testMessage();
|
testMessage();
|
||||||
testGeneralApi();
|
testGeneralApi();
|
||||||
|
if (commercialServer) {
|
||||||
testDevice();
|
testDevice();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
System.out.println("Congratulation, all admin test case passed!!!!!!!");
|
||||||
}
|
}
|
||||||
@@ -418,6 +423,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commercialServer) {
|
||||||
voidIMResult = GroupAdmin.muteGroupMemeber("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
voidIMResult = GroupAdmin.muteGroupMemeber("user1", groupInfo.getTarget_id(), Arrays.asList("user4", "user5"), true, null, null);
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("mute group member success");
|
System.out.println("mute group member success");
|
||||||
@@ -433,6 +439,8 @@ public class Main {
|
|||||||
System.out.println("unmute group member failure");
|
System.out.println("unmute group member failure");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -487,6 +495,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commercialServer) {
|
||||||
voidIMResult = MessageAdmin.deleteMessage(resultSendMessage.getResult().getMessageUid());
|
voidIMResult = MessageAdmin.deleteMessage(resultSendMessage.getResult().getMessageUid());
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("delete message success");
|
System.out.println("delete message success");
|
||||||
@@ -502,6 +511,7 @@ public class Main {
|
|||||||
System.out.println("broad message failure");
|
System.out.println("broad message failure");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<String> multicastReceivers = Arrays.asList("user2", "user3", "user4");
|
List<String> multicastReceivers = Arrays.asList("user2", "user3", "user4");
|
||||||
IMResult<MultiMessageResult> resultMulticastMessage = MessageAdmin.multicastMessage("user1", multicastReceivers, 0, payload);
|
IMResult<MultiMessageResult> resultMulticastMessage = MessageAdmin.multicastMessage("user1", multicastReceivers, 0, payload);
|
||||||
@@ -790,6 +800,8 @@ public class Main {
|
|||||||
InputCreateChannel inputCreateChannel = new InputCreateChannel();
|
InputCreateChannel inputCreateChannel = new InputCreateChannel();
|
||||||
inputCreateChannel.setName("testChannel");
|
inputCreateChannel.setName("testChannel");
|
||||||
inputCreateChannel.setOwner("userId1");
|
inputCreateChannel.setOwner("userId1");
|
||||||
|
String secret = "channelsecret";
|
||||||
|
inputCreateChannel.setSecret(secret);
|
||||||
IMResult<OutputCreateChannel> resultCreateChannel = GeneralAdmin.createChannel(inputCreateChannel);
|
IMResult<OutputCreateChannel> resultCreateChannel = GeneralAdmin.createChannel(inputCreateChannel);
|
||||||
if (resultCreateChannel != null && resultCreateChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (resultCreateChannel != null && resultCreateChannel.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("create channel success");
|
System.out.println("create channel success");
|
||||||
@@ -798,9 +810,13 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//2. 初始化api
|
|
||||||
ChannelServiceApi channelServiceApi = new ChannelServiceApi("http://localhost", resultCreateChannel.getResult().getTargetId(), resultCreateChannel.getResult().getSecret());
|
|
||||||
|
|
||||||
|
//2. 初始化api
|
||||||
|
ChannelServiceApi channelServiceApi = new ChannelServiceApi("http://localhost", resultCreateChannel.getResult().getTargetId(), secret);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (commercialServer) {
|
||||||
//3. 测试channel api功能
|
//3. 测试channel api功能
|
||||||
IMResult<Void> resultVoid = channelServiceApi.subscribe("userId2");
|
IMResult<Void> resultVoid = channelServiceApi.subscribe("userId2");
|
||||||
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (resultVoid != null && resultVoid.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
@@ -849,6 +865,7 @@ public class Main {
|
|||||||
System.out.println("get user info failure");
|
System.out.println("get user info failure");
|
||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MessagePayload payload = new MessagePayload();
|
MessagePayload payload = new MessagePayload();
|
||||||
@@ -873,6 +890,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (commercialServer) {
|
||||||
IMResult<Void> voidIMResult = channelServiceApi.modifyChannelInfo(ProtoConstants.ModifyChannelInfoType.Modify_Channel_Desc, "this is a test channel, update at:" + new Date().toString());
|
IMResult<Void> voidIMResult = channelServiceApi.modifyChannelInfo(ProtoConstants.ModifyChannelInfoType.Modify_Channel_Desc, "this is a test channel, update at:" + new Date().toString());
|
||||||
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
if (voidIMResult != null && voidIMResult.getErrorCode() == ErrorCode.ERROR_CODE_SUCCESS) {
|
||||||
System.out.println("modify channel profile success");
|
System.out.println("modify channel profile success");
|
||||||
@@ -889,6 +907,7 @@ public class Main {
|
|||||||
System.exit(-1);
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//***********************************************
|
//***********************************************
|
||||||
//**** 物联网相关的API,仅专业版支持
|
//**** 物联网相关的API,仅专业版支持
|
||||||
|
|||||||
Reference in New Issue
Block a user