Skip to content

Commit

Permalink
Test reconnect with a local connector.
Browse files Browse the repository at this point in the history
  • Loading branch information
broneill committed Oct 7, 2024
1 parent f11460d commit 73a1632
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/test/java/org/cojen/dirmi/RestorableTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ public void setup() throws Exception {
mSession = mEnv.connect(R1.class, "main", "localhost", mServerSocket.getLocalPort());
}

private void setupLocal() throws Exception {
mEnv = Environment.create();
mEnv.connector(Connector.local(mEnv));
mEnv.export("main", new R1Server());
mEnv.reconnectDelayMillis(100);
mEnv.pingTimeoutMillis(1000);

mSession = mEnv.connect(R1.class, "main", null);
}

@After
public void teardown() throws Exception {
if (mAcceptor != null) {
Expand Down Expand Up @@ -169,6 +179,20 @@ public boolean test(Session<?> session, Throwable ex) {

@Test
public void explicitReconnect() throws Exception {
explicitReconnect(false);
}

@Test
public void explicitReconnectLocal() throws Exception {
explicitReconnect(true);
}

private void explicitReconnect(boolean local) throws Exception {
if (local) {
teardown();
setupLocal();
}

assertEquals(Session.State.CONNECTED, mSession.state());

R1 root = mSession.root();
Expand Down

0 comments on commit 73a1632

Please sign in to comment.