Skip to content

Commit 15bec1e

Browse files
committed
feat: Added unit testing for test connection and command with timeout
1 parent 05d5589 commit 15bec1e

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

src/test/java/com/nerox/client/AppTest.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import java.io.ByteArrayInputStream;
88

99
import com.nerox.client.keepalives.UDPKeepAlive;
10+
import com.nerox.client.misc.TCPTimeouts;
1011
import com.nerox.client.security.Cryptography;
1112
import org.junit.Test;
1213

@@ -62,21 +63,37 @@ private String joinPaths(String ...paths){
6263
return sb.toString();
6364
}
6465

65-
//@Test
66+
@Test
6667
public void runAllTests(){
6768
this.tfprotocolDoesConnect();
69+
this.testConnectionWithTimeout();
6870
//this.loginCommand();
6971
//this.setfsidCommand();
7072
//this.setfspermCommand();
71-
this.supCommand();
72-
this.statCommand();
73+
//this.supCommand();
74+
//this.statCommand();
7375
}
7476

7577
public void tfprotocolDoesConnect()
7678
{
7779
assertTrue(this.tfprotocol.isConnect());
7880
}
79-
81+
82+
public void testConnectionWithTimeout() {
83+
TCPTimeouts tcptimeouts = TCPTimeouts.getInstance(this.callback);
84+
tcptimeouts.setConnectTimeout(5);
85+
tcptimeouts.setDnsResolutionTimeout(5);
86+
Tfprotocol protocol = new Tfprotocol(this.tfprotocol, callback);
87+
try{
88+
// protocol.connect();
89+
protocol.easyreum.getSocket().setSoTimeout(10*1000);
90+
protocol.echoCommand("hola mundo");
91+
}catch(Exception ex){
92+
System.out.println(ex);
93+
}
94+
assertTrue("Tested tcp socket timeout", protocol.isConnect());
95+
}
96+
8097
public void loginCommand(){
8198
this.tfprotocol.loginCommand("user_your_system_user_here", "pwd");
8299
}

src/test/java/com/nerox/client/RPCProxyTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private String joinPaths(String ...paths){
6262
return sb.toString();
6363
}
6464

65-
@Test
65+
//@Test
6666
public void runAllTests(){
6767
this.proxyDoesConnect();
6868
this.testMainProtocol();

0 commit comments

Comments
 (0)