-
Notifications
You must be signed in to change notification settings - Fork 888
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit tests to validate contexts can't be reused when constructing…
… clients and drivers.
- Loading branch information
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
aeron-driver/src/test/java/io/aeron/driver/DriverContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.aeron.driver; | ||
|
||
import io.aeron.driver.exceptions.ActiveDriverException; | ||
import io.aeron.exceptions.ConcurrentConcludeException; | ||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.fail; | ||
|
||
public class DriverContextTest | ||
{ | ||
@Test | ||
public void shouldPreventCreatingMultipleDriversWithTheSameContext() | ||
{ | ||
final MediaDriver.Context ctx = new MediaDriver.Context(); | ||
|
||
try ( | ||
MediaDriver mediaDriver1 = MediaDriver.launchEmbedded(ctx); | ||
MediaDriver mediaDriver2 = MediaDriver.launchEmbedded(ctx)) | ||
{ | ||
fail("Exception should be thrown for reuse of the MediaDriver.Context instance"); | ||
} | ||
catch (final ActiveDriverException | ConcurrentConcludeException e) | ||
{ | ||
// Expected | ||
} | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
aeron-system-tests/src/test/java/io/aeron/ClientContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.aeron; | ||
|
||
import io.aeron.driver.MediaDriver; | ||
import io.aeron.exceptions.ConcurrentConcludeException; | ||
import org.junit.Test; | ||
|
||
public class ClientContextTest | ||
{ | ||
@Test(expected = ConcurrentConcludeException.class) | ||
public void shouldPreventCreatingMultipleClientsWithTheSameContext() | ||
{ | ||
try (MediaDriver mediaDriver = MediaDriver.launchEmbedded()) | ||
{ | ||
final Aeron.Context ctx = new Aeron.Context() | ||
.aeronDirectoryName(mediaDriver.aeronDirectoryName()); | ||
|
||
//noinspection EmptyTryBlock | ||
try ( | ||
Aeron aeron1 = Aeron.connect(ctx); | ||
Aeron aeron2 = Aeron.connect(ctx)) | ||
{ | ||
} | ||
} | ||
} | ||
} |