Three TestNG tests are implemented and verified with Aspose.Font for Java 26.8:
- Apply a license from a file: Example-SetLicenseFromFile.java.
- Apply a license from a stream: Example-SetLicenseFromStream.java.
- Clear a license: Example-ClearLicense.java.
The file and stream examples come from the Java licensing documentation. The clear-license example follows the .NET test category and the Java License API.
From the examples repository root:
mvn -f src/Aspose.Font.Java/pom.xml -Dtest=LicensingTests -Dgroups=LicensingExamples testProvide a valid license at tests-data/licenses/Aspose.Font.Java.lic and these test fonts:
- tests-data/Aspose.Font/TTF/verdana.ttf
- tests-data/Aspose.Font/Type1/courier.pfb
- tests-data/Aspose.Font/CFF/29645.cff
Each test verifies that these specific fonts cannot be opened in evaluation mode and can be opened with the correct type and a nonzero glyph count after licensing. This does not imply that all fonts are restricted in evaluation mode.
The class runs sequentially. It clears the license before each test and restores the configured license afterward, including after failures. Do not run licensing tests concurrently with other font tests in the same JVM. The alwaysRun lifecycle hooks also execute when selecting the LicensingExamples group.
BaseTest writes its normal log under tests-out/Aspose.Font.Java; these examples do not save font files or print license contents.
For the file and stream snippets, supply licenseFilePath as the full path to your license file. The stream snippet requires java.io.InputStream and java.io.FileInputStream imports and uses try-with-resources. Calling methods must handle or declare Exception. Test setup, font loading checks and assertions are outside the snippet markers.
- Documentation - Aspose.Font for Java
- Product page - Aspose.Font for Java
- Free Support Forum - Aspose.Font
- Blog - Aspose.Font Product Family
- API Reference - Aspose.Font for Java
- Releases - Aspose.Font for Java
- JDK 8 or later and Maven for this test project
- Aspose.Font for Java library