Skip to content

Commit

Permalink
Merge pull request #127 from marszub/crucialConnectionChanges
Browse files Browse the repository at this point in the history
crucialConnectionChanges
  • Loading branch information
JanuszJakubiec authored Feb 11, 2022
2 parents 9867e97 + b6d5735 commit d81d265
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public void read(List messages) {

public void reconnect(){
try {
socketChannel = SocketChannel.open(ipAddress);
socketChannel.configureBlocking(false);
socketChannel = SocketChannel.open(ipAddress);
try {
super.register(selector);
} catch (ClosedChannelException ignored) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,6 @@

public class StaticConnectionTest
{
@Test
void testIfConnectionWillKeepItselfAliveAfterDisconnectRead() throws IOException {
DummyMessage message = new DummyMessage("TESTMESSAGE");
InetSocketAddress ip1 = new InetSocketAddress("localhost", 50000);
InetSocketAddress ip2 = new InetSocketAddress("localhost", 50001);
SelectorServerPair result1 = createServer(ip1);
SelectorServerPair result2 = createServer(ip2);
Selector selector1 = result1.selector();
Selector selector2 = result2.selector();
StaticConnection connection = new StaticConnection(ip2);
connection.register(selector1);
connection.send(message);
DynamicConnection dynamicConnection = addNewConnection(selector2);
dynamicConnection.close();
getMessage(selector1);
dynamicConnection = addNewConnection(selector2);
dynamicConnection.send(message);
assertEquals(message.serialize(), getMessage(selector1).get(0));
selector1.close();
selector2.close();
connection.close();
dynamicConnection.close();
result1.server().close();
result2.server().close();
}

@Test
void checkIfStaticConnectionReadsProperly() throws IOException
Expand Down

0 comments on commit d81d265

Please sign in to comment.