-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b001ca1
commit 3bf2b5a
Showing
3 changed files
with
92 additions
and
80 deletions.
There are no files selected for viewing
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
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,86 @@ | ||
package tlschannel.async; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.TestInstance.Lifecycle; | ||
import scala.Option; | ||
import scala.collection.immutable.Seq; | ||
import tlschannel.helpers.AsyncLoops; | ||
import tlschannel.helpers.AsyncSocketPair; | ||
import tlschannel.helpers.SocketPairFactory; | ||
import tlschannel.helpers.SslContextFactory; | ||
|
||
@TestInstance(Lifecycle.PER_CLASS) | ||
public class AsyncTest implements AsyncTestBase { | ||
|
||
private final SslContextFactory sslContextFactory = new SslContextFactory(); | ||
private final SocketPairFactory factory = new SocketPairFactory(sslContextFactory.defaultContext()); | ||
private final int socketPairCount = 50; | ||
|
||
// real engine - run tasks | ||
@Test | ||
public void testRunTasks() { | ||
System.out.println("testRunTasks():"); | ||
AsynchronousTlsChannelGroup channelGroup = new AsynchronousTlsChannelGroup(); | ||
int dataSize = 5 * 1024 * 1024; | ||
System.out.printf("data size: %d\n", dataSize); | ||
Seq<AsyncSocketPair> socketPairs = | ||
factory.asyncN(Option.apply(null), channelGroup, socketPairCount, true, false); | ||
AsyncLoops.Report report = AsyncLoops.loop(socketPairs, dataSize); | ||
|
||
shutdownChannelGroup(channelGroup); | ||
assertChannelGroupConsistency(channelGroup); | ||
assertEquals(0, channelGroup.getFailedReadCount()); | ||
assertEquals(0, channelGroup.getFailedWriteCount()); | ||
|
||
report.print(); | ||
printChannelGroupStatus(channelGroup); | ||
} | ||
|
||
// real engine - do not run tasks | ||
@Test | ||
public void testNotRunTasks() { | ||
System.out.println("testNotRunTasks():"); | ||
AsynchronousTlsChannelGroup channelGroup = new AsynchronousTlsChannelGroup(); | ||
int dataSize = 2 * 1024 * 1024; | ||
System.out.printf("data size: %d\n", dataSize); | ||
Seq<AsyncSocketPair> socketPairs = | ||
factory.asyncN(Option.apply(null), channelGroup, socketPairCount, false, false); | ||
AsyncLoops.Report report = AsyncLoops.loop(socketPairs, dataSize); | ||
|
||
shutdownChannelGroup(channelGroup); | ||
assertChannelGroupConsistency(channelGroup); | ||
|
||
assertEquals(0, channelGroup.getFailedReadCount()); | ||
assertEquals(0, channelGroup.getFailedWriteCount()); | ||
assertEquals(0, channelGroup.getCancelledReadCount()); | ||
assertEquals(0, channelGroup.getCancelledWriteCount()); | ||
|
||
report.print(); | ||
printChannelGroupStatus(channelGroup); | ||
} | ||
|
||
// null engine | ||
@Test | ||
public void testNullEngine() { | ||
System.out.println("testNullEngine():"); | ||
AsynchronousTlsChannelGroup channelGroup = new AsynchronousTlsChannelGroup(); | ||
int dataSize = 12 * 1024 * 1024; | ||
System.out.printf("data size: %d\n", dataSize); | ||
Seq<AsyncSocketPair> socketPairs = factory.asyncN(null, channelGroup, socketPairCount, true, false); | ||
AsyncLoops.Report report = AsyncLoops.loop(socketPairs, dataSize); | ||
|
||
shutdownChannelGroup(channelGroup); | ||
assertChannelGroupConsistency(channelGroup); | ||
|
||
assertEquals(0, channelGroup.getFailedReadCount()); | ||
assertEquals(0, channelGroup.getFailedWriteCount()); | ||
assertEquals(0, channelGroup.getCancelledReadCount()); | ||
assertEquals(0, channelGroup.getCancelledWriteCount()); | ||
|
||
report.print(); | ||
printChannelGroupStatus(channelGroup); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.