Skip to content

Commit

Permalink
Migrate to Java: MultiNonBlockingTest
Browse files Browse the repository at this point in the history
  • Loading branch information
marianobarrios committed Apr 1, 2024
1 parent 723cbc7 commit 0025cdb
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 61 deletions.
70 changes: 70 additions & 0 deletions src/test/scala/tlschannel/MultiNonBlockingTest.java
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());
}
}
61 changes: 0 additions & 61 deletions src/test/scala/tlschannel/MultiNonBlockingTest.scala

This file was deleted.

0 comments on commit 0025cdb

Please sign in to comment.