/
EventTest.java
36 lines (33 loc) · 1.08 KB
/
EventTest.java
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
package org.agilewiki.jactor.lpc;
import junit.framework.TestCase;
import org.agilewiki.jactor.*;
import org.agilewiki.jactor.JAFuture;
import org.agilewiki.jactor.JAMailboxFactory;
import org.agilewiki.jactor.MailboxFactory;
import org.agilewiki.jactor.RP;
/**
* Test code.
*/
public class EventTest extends TestCase {
public void test() {
MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
try {
JLPCActor a = new EventAReceiver();
a.initialize(mailboxFactory.createMailbox());
JAFuture future = new JAFuture();
SimpleRequest eventA = new SimpleRequest();
eventA.sendEvent(a);
eventA.send(future, a);
} catch (Throwable e) {
e.printStackTrace();
} finally {
mailboxFactory.close();
}
}
}
class EventAReceiver extends JLPCActor implements SimpleRequestReceiver {
public void processRequest(SimpleRequest request, RP rp) throws Exception {
System.err.println("A got request");
rp.processResponse(request);
}
}