-
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.
Migrate to Java: MultiNonBlockingTest
- Loading branch information
1 parent
723cbc7
commit 0025cdb
Showing
2 changed files
with
70 additions
and
61 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package tlschannel; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.AfterAll; | ||
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.NonBlockingLoops; | ||
import tlschannel.helpers.SocketPair; | ||
import tlschannel.helpers.SocketPairFactory; | ||
import tlschannel.helpers.SslContextFactory; | ||
|
||
@TestInstance(Lifecycle.PER_CLASS) | ||
public class MultiNonBlockingTest { | ||
|
||
private final SslContextFactory sslContextFactory = new SslContextFactory(); | ||
private final SocketPairFactory factory = new SocketPairFactory(sslContextFactory.defaultContext()); | ||
private final int dataSize = 50 * 1024; | ||
private final int totalConnections = 200; | ||
|
||
// running tasks in non-blocking loop - no renegotiation | ||
@Test | ||
public void testTaskLoop() { | ||
System.out.println("testTasksInExecutorWithRenegotiation():"); | ||
Seq<SocketPair> pairs = factory.nioNioN( | ||
Option.apply(null), totalConnections, Option.apply(null), true, false, Option.apply(null)); | ||
NonBlockingLoops.Report report = NonBlockingLoops.loop(pairs, dataSize, false); | ||
assertEquals(0, report.asyncTasksRun()); | ||
report.print(); | ||
} | ||
|
||
// running tasks in executor - no renegotiation | ||
@Test | ||
public void testTasksInExecutor() { | ||
System.out.println("testTasksInExecutorWithRenegotiation():"); | ||
Seq<SocketPair> pairs = factory.nioNioN( | ||
Option.apply(null), totalConnections, Option.apply(null), false, false, Option.apply(null)); | ||
NonBlockingLoops.Report report = NonBlockingLoops.loop(pairs, dataSize, false); | ||
report.print(); | ||
} | ||
|
||
// running tasks in non-blocking loop - with renegotiation | ||
@Test | ||
public void testTasksInLoopWithRenegotiation() { | ||
System.out.println("testTasksInExecutorWithRenegotiation():"); | ||
Seq<tlschannel.helpers.SocketPair> pairs = factory.nioNioN( | ||
Option.apply(null), totalConnections, Option.apply(null), true, false, Option.apply(null)); | ||
NonBlockingLoops.Report report = NonBlockingLoops.loop(pairs, dataSize, true); | ||
assertEquals(0, report.asyncTasksRun()); | ||
report.print(); | ||
} | ||
|
||
// running tasks in executor - with renegotiation | ||
@Test | ||
public void testTasksInExecutorWithRenegotiation() { | ||
System.out.println("testTasksInExecutorWithRenegotiation():"); | ||
Seq<tlschannel.helpers.SocketPair> pairs = factory.nioNioN( | ||
Option.apply(null), totalConnections, Option.apply(null), false, false, Option.apply(null)); | ||
NonBlockingLoops.Report report = NonBlockingLoops.loop(pairs, dataSize, true); | ||
report.print(); | ||
} | ||
|
||
@AfterAll | ||
public void afterAll() { | ||
System.out.println(factory.getGlobalAllocationReport()); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.