forked from socketio/socket.io-client-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecutionTest.java
More file actions
49 lines (39 loc) · 1.62 KB
/
Copy pathExecutionTest.java
File metadata and controls
49 lines (39 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package io.socket.client;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Logger;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
@RunWith(JUnit4.class)
public class ExecutionTest extends Connection {
private static final Logger logger = Logger.getLogger(ExecutionTest.class.getName());
final static int TIMEOUT = 100 * 1000;
@Test(timeout = TIMEOUT)
public void execConnection() throws InterruptedException, IOException {
exec("io.socket.client.executions.Connection");
}
@Test(timeout = TIMEOUT)
public void execConnectionFailure() throws InterruptedException, IOException {
exec("io.socket.client.executions.ConnectionFailure");
}
@Test(timeout = TIMEOUT)
public void execImmediateClose() throws InterruptedException, IOException {
exec("io.socket.client.executions.ImmediateClose");
}
private void exec(String mainClass) throws InterruptedException, IOException {
Process process = Runtime.getRuntime().exec(String.format("mvn --quiet exec:java" +
" -Dexec.mainClass=%s -Dexec.classpathScope=test", mainClass), createEnv());
BufferedReader input = new BufferedReader(
new InputStreamReader(process.getInputStream()));
String line;
while ((line = input.readLine()) != null) {
logger.fine("EXEC OUT: " + line);
}
process.waitFor();
assertThat(process.exitValue(), is(0));
}
}