mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-03-14 10:45:42 +08:00
fix(chat): include test files
This commit is contained in:
parent
2e6d1b71c8
commit
cf1b82ef87
2
bundle/Chatting-server/.gitignore
vendored
2
bundle/Chatting-server/.gitignore
vendored
@ -1,2 +1,2 @@
|
|||||||
target/
|
target/
|
||||||
test*
|
test.txt
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package com.wsdjeg.chat;
|
||||||
|
|
||||||
|
import java.net.Socket;
|
||||||
|
|
||||||
|
public class ClientTest {
|
||||||
|
public static void main (String[] args) {
|
||||||
|
try {
|
||||||
|
Socket s = new Socket("perfi.wang",2013);
|
||||||
|
System.out.println(s.getInetAddress());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package com.wsdjeg.chat.server;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import junit.framework.Test;
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
|
import com.wsdjeg.chat.server.Account;
|
||||||
|
|
||||||
|
public class AccountTest {
|
||||||
|
/* test register */
|
||||||
|
public void testRegister() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test password */
|
||||||
|
public void testPassword() {
|
||||||
|
System.out.println(Account.password("root", "12341"));
|
||||||
|
System.out.println(Account.login("root", "12341"));
|
||||||
|
}
|
||||||
|
/* test signin */
|
||||||
|
public void testSignin() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test getServerThreads */
|
||||||
|
public void testGetServerThreads() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test loginOut */
|
||||||
|
public void testLoginOut() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test login */
|
||||||
|
public void testLogin() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
public void testLoadDatabase()throws Exception{
|
||||||
|
File f = new File("test.txt");
|
||||||
|
Map<String,String> s = new HashMap<>();
|
||||||
|
s.put("root", "1234");
|
||||||
|
ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream(f));
|
||||||
|
os.writeObject(s);
|
||||||
|
os.close();
|
||||||
|
s = Account.loadDatabase(f);
|
||||||
|
System.out.println(s.get("root"));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.wsdjeg.chat.server;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class CommandTest {
|
||||||
|
/* test help */
|
||||||
|
public void testHelp() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test names */
|
||||||
|
public void testNames() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test parser */
|
||||||
|
public void testParser() {
|
||||||
|
Set<String> s = new HashSet<>();
|
||||||
|
s.add("/msg root 123");
|
||||||
|
s.add("/query root");
|
||||||
|
s.add("/join #vim");
|
||||||
|
for (String cmd : s) {
|
||||||
|
for (String arg :Command.parser(cmd)){
|
||||||
|
System.out.print(arg);
|
||||||
|
System.out.print(" ");
|
||||||
|
}
|
||||||
|
System.out.println();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* test isCommand */
|
||||||
|
public void testIsCommand() {
|
||||||
|
System.out.println(Command.isCommand("/login wsdjeg 1234 "));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.wsdjeg.chat.server;
|
||||||
|
|
||||||
|
public class GroupManagerTest {
|
||||||
|
/* test generateId */
|
||||||
|
public void testGenerateId() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test getGroup */
|
||||||
|
public void testGetGroup() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test newGroup */
|
||||||
|
public void testNewGroup() {
|
||||||
|
User u = new User("wsd");
|
||||||
|
System.out.println(GroupManager.newGroup("vim"));
|
||||||
|
GroupManager.getGroup("vim").addMember(u);
|
||||||
|
}
|
||||||
|
/* test getGroupId */
|
||||||
|
public void testGetGroupId() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.wsdjeg.chat.server;
|
||||||
|
|
||||||
|
public class LoggerTest {
|
||||||
|
/* test log */
|
||||||
|
public void testLog() {
|
||||||
|
Logger.setLevel(3);
|
||||||
|
Logger.log(1, "1234");
|
||||||
|
Logger.log(2, "hello");
|
||||||
|
Logger.log(3, "helloworld");
|
||||||
|
}
|
||||||
|
/* test setLevel */
|
||||||
|
public void testSetLevel() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package com.wsdjeg.chat.server;
|
||||||
|
|
||||||
|
public class MessageTest {
|
||||||
|
/* test format */
|
||||||
|
/* test onWindowChange */
|
||||||
|
public void testOnWindowChange() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test userMessage */
|
||||||
|
public void testUserMessage() {
|
||||||
|
System.out.println(Message.userMessage(new User("root"), new User("wsd"), "helloworld!"));
|
||||||
|
}
|
||||||
|
/* test getTime */
|
||||||
|
public void testGetTime() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test format */
|
||||||
|
public void testFormat() {
|
||||||
|
System.out.println(Message.format("你好我,neo\\\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testOnGetConnection(){
|
||||||
|
System.out.println(Message.onGetConnection());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
package com.wsdjeg.chat.server;
|
||||||
|
|
||||||
|
public class SecurityTest {
|
||||||
|
/* test sign */
|
||||||
|
public void testSign() {
|
||||||
|
Security.sign("127.0.0.1");
|
||||||
|
Security.sign("127.0.0.1");
|
||||||
|
Security.sign("127.0.0.1");
|
||||||
|
Security.sign("127.0.0.1");
|
||||||
|
System.out.println(Security.isBlock("127.0.0.1"));
|
||||||
|
}
|
||||||
|
/* test isBlock */
|
||||||
|
public void testIsBlock() {
|
||||||
|
long i = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
long y = System.currentTimeMillis();
|
||||||
|
System.out.println(i);
|
||||||
|
System.out.println(y);
|
||||||
|
System.out.println(y - i);
|
||||||
|
}
|
||||||
|
/* test block */
|
||||||
|
public void testBlock() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
package com.wsdjeg.chat.server;
|
||||||
|
|
||||||
|
import com.wsdjeg.chat.server.bot.SmartBot;
|
||||||
|
|
||||||
|
public class UserTest {
|
||||||
|
/* test join */
|
||||||
|
public void testJoin() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test hashCode */
|
||||||
|
public void testHashCode() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test equals */
|
||||||
|
public void testEquals() {
|
||||||
|
User u1 = new User("root");
|
||||||
|
User u2 = new User("root");
|
||||||
|
System.out.println(u1.equals(u2));
|
||||||
|
}
|
||||||
|
/* test getClient */
|
||||||
|
public void testGetClient() {
|
||||||
|
String str = "/msg nihao 122 aaa";
|
||||||
|
System.out.println(str.replaceFirst("/msg\\s+", "").replaceFirst("\\S+\\s+", ""));
|
||||||
|
}
|
||||||
|
/* test setClient */
|
||||||
|
public void testSetClient() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test getUserName */
|
||||||
|
public void testGetUserName() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test setUserName */
|
||||||
|
public void testSetUserName() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test getFriends */
|
||||||
|
public void testGetFriends() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test removeFriend */
|
||||||
|
public void testRemoveFriend() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test send */
|
||||||
|
public void testSend() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
/* test addFriend */
|
||||||
|
public void testAddFriend() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testSetSmartBot(){
|
||||||
|
User u = new User("123");
|
||||||
|
u.setSmartBot(new SmartBot());
|
||||||
|
u.setSmartBot(new SmartBot());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.wsdjeg.chat.server.bot;
|
||||||
|
|
||||||
|
public class MathBotTest {
|
||||||
|
/* test isInteger */
|
||||||
|
public void testIsInteger() {
|
||||||
|
String s = "123";
|
||||||
|
System.out.println(s.matches("^[1-9][0-9]*$"));
|
||||||
|
}
|
||||||
|
/* test reply */
|
||||||
|
public void testReply() {
|
||||||
|
//TODO
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.wsdjeg.chat.server.util;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class JsonBuilderTest {
|
||||||
|
/* test decode */
|
||||||
|
public void testDecode() {
|
||||||
|
Map<String,String> o = new HashMap<>();
|
||||||
|
o.put("name", "wsdjeg");
|
||||||
|
o.put("pa\"ssword", "12\\" + "\"34");
|
||||||
|
System.out.println(JsonBuilder.decode(o));
|
||||||
|
// output: {"name":"wsdjeg","pa\\\"ssword":"12\"34"}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user