Skip to content

Commit 7e08e88

Browse files
committed
add test
1 parent 90bb6e5 commit 7e08e88

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.pekko.util
19+
20+
import com.typesafe.config.ConfigFactory
21+
import org.scalatest.matchers.should.Matchers
22+
import org.scalatest.wordspec.AnyWordSpec
23+
24+
class RandomNumberGeneratorJava21Spec extends AnyWordSpec with Matchers {
25+
26+
"RandomNumberGenerator (Java 21+)" should {
27+
28+
"support config" in {
29+
val config = ConfigFactory.parseString(
30+
"""pekko.random.generator.generator-implementation = "Xoroshiro128PlusPlus"""")
31+
val rng = RandomNumberGenerator.createGenerator(config)
32+
rng shouldBe a[Jep356RandomNumberGenerator]
33+
rng.nextInt(10) should (be >= 0 and be < 10)
34+
}
35+
36+
}
37+
}

actor-tests/src/test/scala/org/apache/pekko/util/RandomNumberGeneratorSpec.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class RandomNumberGeneratorSpec extends AnyWordSpec with Matchers {
2525
"RandomNumberGenerator" should {
2626

2727
"default to ThreadLocalRandom" in {
28-
RandomNumberGenerator.get() shouldEqual ThreadLocalRandomNumberGenerator
28+
val rng = RandomNumberGenerator.get()
29+
rng shouldEqual ThreadLocalRandomNumberGenerator
30+
rng.nextInt(10) should (be >= 0 and be < 10)
2931
}
3032

3133
}

actor/src/main/scala/org/apache/pekko/util/RandomNumberGenerator.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ private[pekko] object ThreadLocalRandomNumberGenerator extends RandomNumberGener
5353
* INTERNAL API
5454
*/
5555
@InternalApi
56-
private[pekko] class Jep356RandomNumberGenerator(impl: String) extends RandomNumberGenerator {
56+
private[pekko] final class Jep356RandomNumberGenerator(impl: String) extends RandomNumberGenerator {
5757

5858
// https://openjdk.org/jeps/356
5959

0 commit comments

Comments
 (0)