File tree Expand file tree Collapse file tree 3 files changed +45
-0
lines changed
Expand file tree Collapse file tree 3 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,15 @@ If the license key has expired when the `ActorSystem` is started the system will
6464The expiry date is exposed by @apidoc [ akka.actor.typed.ActorSystem] {scala="#licenseKeyExpiry" java="#getLicenseKeyExpiry"}
6565so that you can write a test to remind yourself that it is time for renewal before it has expired.
6666
67+ To verify that your license key is still valid (for example during CI/CD integration), you can use the following test
68+ that will start to fail one month before the license key will expire:
69+
70+ Scala
71+ : @@snip [ ConfigDocSpec.scala] ( /akka-docs/src/test/scala/docs/config/ConfigDocSpec.scala ) { #check-is-key-valid }
72+
73+ Java
74+ : @@snip [ ConfigDocTest.java] ( /akka-docs/src/test/java/jdocs/config/ConfigDocTest.java ) { #check-is-key-valid }
75+
6776## When using JarJar, OneJar, Assembly or any jar-bundler
6877
6978@@@ warning
Original file line number Diff line number Diff line change 1414// #imports
1515import akka .actor .testkit .typed .javadsl .ActorTestKit ;
1616
17+ //#check-is-key-valid
18+ import java .time .LocalDate ;
19+ import java .util .Optional ;
20+
21+ //#check-is-key-valid
22+
23+ import static org .junit .Assert .*;
24+
1725public class ConfigDocTest {
1826
1927 private Behavior <Void > rootBehavior = Behaviors .empty ();
@@ -67,4 +75,18 @@ public ActorSystem createConfiguredSystem() {
6775 // #custom-config-2
6876 return system ;
6977 }
78+
79+ public void compileOnlyIsLicenseKeyValid () {
80+ //#check-is-key-valid
81+ ActorSystem <Void > system = ActorSystem .create (rootBehavior , "name" );
82+ Optional <LocalDate > licenseKey = system .getLicenseKeyExpiry ();
83+
84+ assertFalse (licenseKey .isEmpty ());
85+
86+ LocalDate nextMonth = LocalDate .now ().plusMonths (1 );
87+ assertTrue (licenseKey .get ().isAfter (nextMonth ));
88+
89+ system .terminate ();
90+ //#check-is-key-valid
91+ }
7092}
Original file line number Diff line number Diff line change @@ -109,4 +109,18 @@ class ConfigDocSpec extends AnyWordSpec with Matchers {
109109 val system = ActorSystem (rootBehavior, " MySystem" , conf)
110110 ActorTestKit .shutdown(system)
111111 }
112+
113+ def compileOnlyIsLicenseKeyValid (): Unit = {
114+ // #check-is-key-valid
115+ val system = ActorSystem (rootBehavior, " name" )
116+ val licenseKey = system.licenseKeyExpiry
117+ licenseKey.isEmpty shouldBe false
118+
119+ import java .time .LocalDate
120+ val nextMonth = LocalDate .now().plusMonths(1 )
121+ licenseKey.get.isAfter(nextMonth) shouldBe true
122+
123+ system.terminate()
124+ // #check-is-key-valid
125+ }
112126}
You can’t perform that action at this time.
0 commit comments