5
5
import java .io .BufferedReader ;
6
6
import java .io .IOException ;
7
7
import java .io .InputStreamReader ;
8
- import java .net .MalformedURLException ;
9
8
import java .util .Arrays ;
10
- import java .util .LinkedList ;
11
9
import java .util .concurrent .LinkedBlockingQueue ;
12
10
import java .util .concurrent .TimeUnit ;
13
11
21
19
22
20
@ RunWith (io .socket .RandomBlockJUnit4ClassRunner .class )
23
21
public class TestSocketIO implements IOCallback {
24
- private final static String NODE = "C: \\ Program Files (x86) \\ nodejs \\ node.exe " ;
22
+ private final static String NODE = "/opt/local/bin/ node" ;
25
23
private static final int PORT = 10214 ;
26
- private static final int TIMEOUT = 2 ;
24
+ private static final int TIMEOUT = 200 ;
27
25
LinkedBlockingQueue <String > events ;
28
26
LinkedBlockingQueue <String > outputs ;
29
27
LinkedBlockingQueue <Object > args ;
@@ -47,7 +45,7 @@ public void setUp() throws Exception {
47
45
outputs = new LinkedBlockingQueue <String >();
48
46
args = new LinkedBlockingQueue <Object >();
49
47
node = Runtime .getRuntime ().exec (
50
- new String [] { NODE , "./node /socketio.js" , "" + PORT });
48
+ new String [] { NODE , "./tests/io/socket /socketio.js" , "" + PORT });
51
49
52
50
stdoutThread = new Thread ("stdoutThread" ) {
53
51
public void run () {
@@ -222,6 +220,21 @@ public void error() throws Exception {
222
220
assertEquals ("onError" , takeEvent ());
223
221
doClose ();
224
222
}
223
+
224
+ @ Test
225
+ public void acknowledge () throws Exception {
226
+ doConnect ();
227
+ socket .emit ("echoAck" , new IOAcknowledge () {
228
+ @ Override
229
+ public void ack (Object ... args ) {
230
+ events .add ("ack" );
231
+ TestSocketIO .this .args .addAll (Arrays .asList (args ));
232
+ }
233
+ }, "TESTSTRING" );
234
+ assertEquals ("ack" , takeEvent ());
235
+ assertEquals ("TESTSTRING" , takeArg ());
236
+ doClose ();
237
+ }
225
238
226
239
// END TESTS
227
240
0 commit comments