You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2015/09/25 15:43:48 UTC

svn commit: r1705306 - in /sling/site/trunk/content/documentation: development.mdtext development/hamcrest.md

Author: rombert
Date: Fri Sep 25 13:43:48 2015
New Revision: 1705306

URL: http://svn.apache.org/viewvc?rev=1705306&view=rev
Log:
SLING-5063 - Create a set of Hamcrest matchers for JUnit tests

Added documentation about the Hamcrest integration

Added:
    sling/site/trunk/content/documentation/development/hamcrest.md
Modified:
    sling/site/trunk/content/documentation/development.mdtext

Modified: sling/site/trunk/content/documentation/development.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development.mdtext?rev=1705306&r1=1705305&r2=1705306&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development.mdtext (original)
+++ sling/site/trunk/content/documentation/development.mdtext Fri Sep 25 13:43:48 2015
@@ -25,6 +25,7 @@ Look here for more information on develo
 * [Sling Mocks]({{ refs.sling-mock.path }})
 * [OSGi Mocks]({{ refs.osgi-mock.path }})
 * [JCR Mocks]({{ refs.jcr-mock.path }})
+* [Hamcrest integration]({{ refs.hamcrest.path }})
 
 
 ## Maven Stuff

Added: sling/site/trunk/content/documentation/development/hamcrest.md
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/hamcrest.md?rev=1705306&view=auto
==============================================================================
--- sling/site/trunk/content/documentation/development/hamcrest.md (added)
+++ sling/site/trunk/content/documentation/development/hamcrest.md Fri Sep 25 13:43:48 2015
@@ -0,0 +1,39 @@
+Title: Hamcrest Integration
+
+Deeper integration with the [Hamcrest matcher library](http://hamcrest.org/).
+
+## Maven Dependency
+
+<div class="warning">
+This module has not yet been officially released.
+</div>
+
+    #!xml
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.testing.hamcrest</artifactId>
+    </dependency>
+
+Note that to keep the classpath consistent this module has all its dependencies marked as `provided`. It relies on your own project to define the needed dependencies, such as `org.hamcrest:hamcrest-core` and `org.apache.sling:org.apache.sling.api` .
+
+See latest version on the [downloads page](/downloads.cgi).
+
+## Usage
+
+The class `org.apache.sling.testing.hamcrest.ResourceMatchers` is the main entry point. It contains static methods that can be used to create assertions.
+
+    #!java
+    import static org.apache.sling.hamcrest.ResourceMatchers.resourceOfType;
+    
+    public void MyServiceTest {
+    
+      @Test 
+      public void loadResources() {
+        Resource resource = /* load resource */ null;
+        
+        assertThat(resource, resourceOfType('my/app'));
+      } 
+    
+    }
+
+The Slingshot sample application uses these matchers, see [SetupServiceTest.java](http://svn.apache.org/repos/asf/sling/trunk/samples/slingshot/src/test/java/org/apache/sling/sample/slingshot/impl/SetupServiceTest.java) for an example.
\ No newline at end of file