-
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
f70b70d
commit 359096d
Showing
2 changed files
with
63 additions
and
46 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,63 @@ | ||
package tlschannel; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import org.junit.jupiter.api.DynamicTest; | ||
import org.junit.jupiter.api.TestFactory; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.api.TestInstance.Lifecycle; | ||
import scala.Option; | ||
import scala.Some; | ||
import scala.jdk.javaapi.CollectionConverters; | ||
import tlschannel.helpers.NonBlockingLoops; | ||
import tlschannel.helpers.SocketPair; | ||
import tlschannel.helpers.SocketPairFactory; | ||
import tlschannel.helpers.SocketPairFactory.ChuckSizes; | ||
import tlschannel.helpers.SocketPairFactory.ChunkSizeConfig; | ||
import tlschannel.helpers.SslContextFactory; | ||
import tlschannel.util.ListUtils; | ||
import tlschannel.util.StreamUtils; | ||
|
||
@TestInstance(Lifecycle.PER_CLASS) | ||
public class NonBlockingTest { | ||
|
||
private final SslContextFactory sslContextFactory = new SslContextFactory(); | ||
private final SocketPairFactory factory = new SocketPairFactory(sslContextFactory.defaultContext()); | ||
private final int dataSize = 200 * 1024; | ||
|
||
@TestFactory | ||
public Collection<DynamicTest> testSelectorLoop() { | ||
System.out.println("testSelectorLoop():"); | ||
List<Integer> sizes = StreamUtils.iterate(1, x -> x < SslContextFactory.tlsMaxDataSize() * 2, x -> x * 2) | ||
.collect(Collectors.toList()); | ||
List<Integer> reversedSizes = ListUtils.reversed(sizes); | ||
List<DynamicTest> ret = new ArrayList<>(); | ||
for (int i = 0; i < sizes.size(); i++) { | ||
int size1 = sizes.get(i); | ||
int size2 = reversedSizes.get(i); | ||
ret.add(DynamicTest.dynamicTest( | ||
String.format("testSelectorLoop() - size1=%d, size2=%d", size1, size2), () -> { | ||
SocketPair socketPair = factory.nioNio( | ||
Option.apply(null), | ||
Some.apply(new ChunkSizeConfig( | ||
new ChuckSizes(Some.apply(size1), Some.apply(size2)), | ||
new ChuckSizes(Some.apply(size1), Some.apply(size2)))), | ||
true, | ||
false, | ||
Option.apply(null)); | ||
|
||
NonBlockingLoops.Report report = NonBlockingLoops.loop( | ||
CollectionConverters.asScala(Collections.singletonList(socketPair)) | ||
.toSeq(), | ||
dataSize, | ||
true); | ||
System.out.printf("%5d -eng-> %5d -net-> %5d -eng-> %5d\n", size1, size2, size1, size2); | ||
report.print(); | ||
})); | ||
} | ||
return ret; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.