Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
merlante committed Aug 22, 2024
1 parent a55e94c commit a8e7176
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/test/java/org/project_kessel/clients/ChannelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@

class ChannelManagerTest {
ChannelManager defaultChannelManager = ChannelManager.getInstance("defaultChannelManager");
ChannelManager otherChannelManager = ChannelManager.getInstance("otherChannelManager");

@AfterEach
void testTeardown() {
/* Make sure all client managers shutdown/removed after each test */
defaultChannelManager.shutdownAll();
otherChannelManager.shutdownAll();
}

@Test
Expand Down Expand Up @@ -59,6 +61,27 @@ void testManagerChannelReusePatterns() {
assertNotEquals(four, five);
}

@Test
void testManagerChannelReusePatternsAcrossChannelManagers() {
var one = defaultChannelManager.forInsecureClients("localhost:8080");
var two = defaultChannelManager.forInsecureClients("localhost:8080"); // same as one
var three = otherChannelManager.forInsecureClients("localhost1:8080");
var four = otherChannelManager.forSecureClients("localhost:8080");
var five = otherChannelManager.forSecureClients("localhost1:8080");
var six = defaultChannelManager.forSecureClients("localhost1:8080"); // same as five but different manager

assertNotNull(one);
assertNotNull(two);
assertNotNull(three);
assertNotNull(four);
assertNotNull(five);
assertNotNull(six);
assertEquals(one, two);
assertNotEquals(two, three);
assertNotEquals(five, six);
assertNotEquals(four, five);
}

@Test
void testThreadingChaos() {
/* Basic testing to ensure that we don't get ConcurrentModificationExceptions, or any other exceptions, when
Expand Down

0 comments on commit a8e7176

Please sign in to comment.