2. SPEAKER
CHRISTOPH DEPPISCH
▸ Senior software developer
▸ @ConSol* Munich, Germany
▸ 10 years of experience in Java
▸ Passionate about automated software testing
▸ Founder of the OpenSource framework Citrus
@freaky_styley
3. ALIENS UND ZITRONEN IM KAMPF GEGEN BUGS
▸ http://arquillian.org
▸ http://citrusframework.org
4. ARQUILLIAN & CITRUS
BOTH TOOLS ARE
▸ Test frameworks
▸ Written in Java
▸ Automated integration & acceptance tests
▸ OpenSource
6. INTEGRATION TESTS
WHAT ARE INTEGRATION TESTS?
Unit Integration
Focus: small software units
No dependencies
Test in isolation
Mocks
Low-Level
Focus: interaction of units
Dependencies
Messaging interfaces
Simulators
High-Level
8. INTEGRATION TESTS
INTEGRATION CHALLENGES
▸ Infrastructure setup
▸ Dependencies
▸ to other applications (messaging)
▸ to Mail-servers, FTP-servers, LDAP-servers
▸ to JMS message broker
▸ …
▸ Test execution slow
9. INTEGRATION TESTS
WHY ARE WE DOING THIS?
▸ Consequences of mocking and isolation in Unit tests
▸ Untested configuration
▸ Untested dependency injection
▸ Untested messaging interfaces
▸ We need to test
▸ Non-functional requirements (Logging, Monitoring, Configuration, …)
▸ Security (Authorization, Authentication, Certificates)
▸ Reliability (Failover, High Availability)
19. ARQUILLIAN
CONTAINER MODE
▸ Remote
▸ completely separate container
▸ Managed
▸ separate JVM, but Arquillian managed
▸ Embedded
▸ same JVM process as Arquillian
▸ Embedded is the fastest - but no class path separation
27. ARQUILLIAN
SUMMARY
▸ Arquillian makes it easy to run in-container tests
▸ Container lifecycle management
▸ Micro-deployments
▸ Access to container-managed resources
▸ Runs via command line or Java IDE
36. ADDING CITRUS TO ARQUILLIAN
@RunWith(Arquillian.class)
@RunAsClient
public class EmployeeResourceTest {
@CitrusFramework
private Citrus citrusFramework;
@ArquillianResource
private URL baseUri;
@Deployment(testable = false)
public static WebArchive createDeployment() {
return Deployments.employeeWebRegistry();
}
@Test
@CitrusTest
public void testGetSingle(@CitrusResource TestDesigner citrus) {
String serviceUri = new URL(baseUri, "").toExternalForm();
citrus.http().client(serviceUri)
.get("/registry/employee/1")
.accept(MediaType.APPLICATION_XML);
citrus.http().client(serviceUri)
.response(HttpStatus.OK)
.payload("<employee><age>21</age><name>Leonard</name></employee>");
citrusFramework.run(citrus.getTestCase());
}
}
37. TEST ACTIONS
TEST ACTIONS
Action Description
echo Log message to console
send Sends a message
receive Receives a message
sleep Wait some time
sql Execute SQL statements
parallel Execute actions in parallel
conditional Execute actions based on
iterate Execute actions in iteration
repeat-on-error Failsafe action execution
…
45. ENDPOINTS
ENDPOINTS
Component Description
citrus-http Http REST client and server
citrus-jms JMS queue or topic destination
citrus-ws SOAP client and server
citrus-mail SMTP mail client and server
citrus-docker Docker container management
citrus-camel Apache Camel endpoint
citrus-ftp FTP client and server
citrus-vertx Vert.x endpoint
citrus-ssh SSH client and server
…
46. CITRUS
SUMMARY
▸ Citrus makes it easy to test messaging
▸ Simulate messaging interfaces on client and server
▸ Citrus Arquillian extension
▸ @CitrusResource, @CitrusEndpoint, @CitrusFramework
▸ Runs via command line or Java IDE