File tree 2 files changed +1
-26
lines changed
main/java/pl/edu/agh/calculationp2p/network/connection
test/java/pl/edu/agh/calculationp2p/network/connection
2 files changed +1
-26
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,8 @@ public void read(List messages) {
60
60
61
61
public void reconnect (){
62
62
try {
63
- socketChannel = SocketChannel .open (ipAddress );
64
63
socketChannel .configureBlocking (false );
64
+ socketChannel = SocketChannel .open (ipAddress );
65
65
try {
66
66
super .register (selector );
67
67
} catch (ClosedChannelException ignored ) {
Original file line number Diff line number Diff line change 15
15
16
16
public class StaticConnectionTest
17
17
{
18
- @ Test
19
- void testIfConnectionWillKeepItselfAliveAfterDisconnectRead () throws IOException {
20
- DummyMessage message = new DummyMessage ("TESTMESSAGE" );
21
- InetSocketAddress ip1 = new InetSocketAddress ("localhost" , 50000 );
22
- InetSocketAddress ip2 = new InetSocketAddress ("localhost" , 50001 );
23
- SelectorServerPair result1 = createServer (ip1 );
24
- SelectorServerPair result2 = createServer (ip2 );
25
- Selector selector1 = result1 .selector ();
26
- Selector selector2 = result2 .selector ();
27
- StaticConnection connection = new StaticConnection (ip2 );
28
- connection .register (selector1 );
29
- connection .send (message );
30
- DynamicConnection dynamicConnection = addNewConnection (selector2 );
31
- dynamicConnection .close ();
32
- getMessage (selector1 );
33
- dynamicConnection = addNewConnection (selector2 );
34
- dynamicConnection .send (message );
35
- assertEquals (message .serialize (), getMessage (selector1 ).get (0 ));
36
- selector1 .close ();
37
- selector2 .close ();
38
- connection .close ();
39
- dynamicConnection .close ();
40
- result1 .server ().close ();
41
- result2 .server ().close ();
42
- }
43
18
44
19
@ Test
45
20
void checkIfStaticConnectionReadsProperly () throws IOException
You can’t perform that action at this time.
0 commit comments