blob: 01b103ad9564dfd8a87464ae36acfe475a369d62 (
plain)
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
50
51
52
53
54
55
|
package com.e1.pdj.test;
import com.cycling74.max.*;
import com.cycling74.net.*;
import junit.framework.TestCase;
public class NetTest extends TestCase {
Atom value[];
public void testUDP() {
UdpReceiver receive = new UdpReceiver(7500);
receive.setCallback(this, "callback_test");
receive.setActive(true);
value = null;
UdpSender send = new UdpSender("localhost", 7500);
send.send(7500);
try {
Thread.sleep(1000);
} catch ( InterruptedException e ) {
}
receive.close();
assertNotNull(value);
assertEquals(Integer.parseInt(value[0].toString()), 7500);
}
public void callback_test(Atom args[]) {
value = args;
}
public void testTCP() {
TcpReceiver receive = new TcpReceiver(7500);
receive.setCallback(this, "callback_test");
receive.setActive(true);
value = null;
TcpSender send = new TcpSender("localhost", 7500);
send.send(7500);
try {
Thread.sleep(1000);
} catch ( InterruptedException e ) {
}
receive.close();
assertNotNull(value);
assertEquals(Integer.parseInt(value[0].toString()), 7500);
}
}
|