Tuesday, 27. September 2016 11:00 - 11:30 (30 min)
As automated testing has become a hot topic in ths Sling community (as seen in the 2015 adaptTo sessions), more effort is being put into developing test tooling for applications built on top of Sling. The need arised for a base framework that encapsulates the core functionality and patterns. The Sling Http Testing Framework is an elegant solution that gives freedom to the developers, while taking care of thread-safety, adapting clients and performing basic Sling tasks over HTTP. It has already proven its usefulness by allowing easy development and maintenance of application-level clients and tests for Adobe AEM.
Sling Http Testing Framework is the evolution of existing http clients from sling testing tools. It provides out-of-the-box clients for automating various operations on a Sling instance, such as create / delete nodes and users, manipulate OSGi settings. It is built on top of Apache HttpClient 4.5 using the fluid, immutable style and it comes with Sling-specific configurable defaults for http settings, cookies, authentication, authorization and interceptors. The clients were designed with extensibility in mind, so developers can write their own application-specific layer.
Coincidentally named ""adaptTo()”, this method is the main mechanism that allows clients to change facets while keeping the same http internal settings.
The framework also comes with a collection of JUnit Rules that encapsulate boilerplate code for writing Sling tests. Tests using these rules are very easy to write since they bring out-of-the-box things like filtering tests, http timeouts or automatically instantiating the Sling Clients based on available instances, while allowing a high level of configurability.
The well-designed architecture allows seamless integration with other tools based on Apache HttpClient like HApi - the Hypermedia API Tools.