More Related Content
Similar to Java EE Arquillian Testing with Docker & The Cloud (20)
More from Bruno Borges (20)
Java EE Arquillian Testing with Docker & The Cloud
- 1. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java EE Testing with Arquillian, using
Docker, or the Cloud
SES12023 – JavaOne LAD 2016
Bruno Borges
Principal Product Manager
Oracle Cloud
@brunoborges
- 2. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
•Bruno Borges
–Product Manager / Developer Advocate
–Oracle Cloud
–Twitter: @brunoborges
Speaker
@brunoborges
- 3. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java EE Testing with Arquillian, using
Docker, or the Cloud
@brunoborges
- 4. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Safe Harbor Statement
The following is intended to outline our general product direction. It is intended for
information purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or functionality, and should not be relied upon
in making purchasing decisions. The development, release, and timing of any features or
functionality described for Oracle’s products remains at the sole discretion of Oracle.
@brunoborges
- 5. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java EE Testing Enablers
@brunoborges
- 6. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
How to test Java EE applications
• No direct support (i.e. testing features) within the platform
• Although, Java EE provides other features that enable testing
– Arquillian is an integration testing platform that takes advantage of these features
• Other solutions available, but Arquillian is considerably the best
@brunoborges
- 7. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | 7
Testing with Arquillian
Java EE
Container
src
test
resources
dependen
cies
• Test Case
• Code Under
Test
• Libraries
• Resolvers
ShrinkWrap
Start
Project
Execute Tests
Fetch Results
Deploy
• Testing platform for Java
Applications
• Functions
– Server lifecycle management
– Packages application + test code
– Deploys, executes, reports test
results
• What we’re doing with it
– Using Adapters internally
– Contributing to project – REST
• Adapters available now
Oracle Confidential - Do Not Redistribute
- 8. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Testing Servlets
• How to bootstrap containers from tests
– Arquillian does this by coordinating lifecycle
– Production-like environment
– Isolated tests
• JAX-RS Client API helps a lot, being the caller
– Other alternatives are HtmlUnit, HttpUnit, Arquillian Warp extension
– Java SE 9 considering a better native HTTP client API
@brunoborges
- 9. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Testing JAX-RS, WebSockets, JAX-WS
• Same concept as Servlets testing
• You can use the client APIs, of these specifications, with Arquillian
• For more complex tests consider tools like soapUI for REST/SOAP
– JUnit integration possible
@brunoborges
- 10. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Testing JSF
• JSF 2 stages invaluable for debugging and testing
– You want production-like testing
• Arquillian Warp extension is complete for JSF testing
– Client and Server-side testing
• Navigate to a JSF page, then check state on Server-side
• Drone/Selenium, Graphene often sufficient
– Client-side only
@brunoborges
- 11. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Testing EJB 3 and CDI
• EJB 3 much more testable as they are simple POJOs now
• Testing enabled either by
– Embedded containers
– Generic POJO dependency injection
– @Alternative
– XML deployment descriptors
– Interceptors
• Arquillian test enrichment through injection/scoping
• Both mock object testing and integration testing are possible
@brunoborges
- 12. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Testing JPA
• CDI, EJB 3 and Arquillian works towards JPA testing
– Isolated JPA testing possible, but unecessary
• JPA 2.1 data loading, schema generation
• Define data sources within the application, not in the container
• persistence.xml and orm.xml overrides
• Use embedded databases like Java DB, Derby, HSQL
• Tests can have transactions in Arquillian
@brunoborges
- 13. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Arquillian Support for Java EE-related containers
Container Support Method
GlassFish Embedded, Managed, Remote
WildFly, JBoss Embedded, Managed, Remote
Weld SE, Weld EE Embedded
TomEE, OpenEJB, OpenWebBeans Embedded, Managed, Remote
WebSphere, Liberty Embedded, Managed, Remote
Oracle WebLogic Managed, Remote
@brunoborges
- 14. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Unit Testing with Arquillian and WebLogic Server
14
WebLogic
Server
Instance
Test Case
Code Under Test
Libraries
Resolvers
ShrinkWrap
Start
Project
Execute Tests
Fetch Results
REST|JMX
$ mvn test
src
test
resources
dependencies
Arquillian Adapter
weblogic-remote-rest
Stop
REST
Deploy
Archive
- 15. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Demo
Arquillian and Maven
with local WebLogic
15@brunoborges
- 16. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Arquillian and WebLogic
On Docker and Cloud
@brunoborges
- 17. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Oracle Tools for Team Development
• Cloud Tooling
– Developer Cloud Service, integrated
with OEPE
– JCS supports 12.2.1, 12.1.3, and
10.3.6
– Leverage Popular Tools
– Maven plug-ins, updated public
Repo
– 12.1.3+ certified on Docker
• WebLogic Cloud APIs
– Automated Elasticity
– REST
– Partitions
– Oracle Cloud PaaS
Java
WebLogic Server
WebLogic
REST
Automated
Elasticity
Pluggable
Partitions
PaaS
- 18. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java Cloud Service
Java EE platform for running business applications in the cloud
• Self-service application platform with advanced cloud tools
• Save time and cost with simplified provisioning
• Reduce down time: automated patching, backup, recovery
• Increase data and processing capacity on demand to scale
for new business needs
• Includes Oracle Coherence for caching and data grid
functions and Oracle Traffic Director for load balancing
• Pre-configured for Database and Developer Cloud Services
for complete cloud application management
JAVA CLOUD SERVICE
@brunoborges
- 19. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java Cloud Service
Java Cloud Service Architecture
Enterprise Class Java Development and Deployment Platform
Developer
…
Messaging Cloud Service
Mobile Cloud Service
Database Cloud Service
Java SE Cloud Service
Developer Cloud Service
Application
Server
Application
Server
Application
Server
Application Cluster
Data Cluster
Managed
Coherence
Server
Managed
Coherence
Server
Managed
Coherence
Server
Load Balancer
@brunoborges
- 20. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Java Cloud Service Main Use Cases
Dev/Test in the Cloud New App Development Migrate Apps to Cloud
@brunoborges
- 21. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Demo
Java Cloud Service
Web Dashboard and REST APIs
Arquillian Remote
21@brunoborges
- 22. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
WebLogic and Docker
For more information
github.com/oracle/docker-images
@brunoborges
- 23. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
WebLogic Domain
Cluster
23
MS Container 1
NM
MS
App
JMS
(A) Topology - Lightweight VM – Example
Expand a Cluster: Add Managed Servers Into Domain
MS Container 2
NM
MS
App
JMS
MS Container 3
NM
MS
App
JMS
Admin Container
WLS
Admin Server
MS Container 4
NM
MS
App
JMS
MS Container 5
NM
MS
App
JMS
MS Container 6
NM
MS
App
JMS
# docker run –-name wlsadmin –d mywlsimage startWebLogic.sh
LBR WebTier
OHS
# docker run –-link wlsadmin:wlsadmin –d mywlsimage createServer.sh
# docker run –-link wlsadmin:wlsadmin –d mywlsimage createServer.sh
Linux Host (physical/virtual server 1)
- 24. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Linux Host
server 0
Domain
Cluster 1
24
WLS Container 1
NM
MS
App
JMS
(A) Topology - Lightweight VM – Multiple Host
Starting with Docker 1.9+, containers can communicate across hosts using Overlay Network
WLS Container 2
NM
MS
App
JMS
WLS Container 3
NM
MS
App
JMS
Admin Container
WLS
Admin Server
WLS Container 4
NM
MS
App
JMS
WLS Container 5
NM
MS
App
JMS
WLS Container 6
NM
MS
App
JMS
Linux Host (physical/virtual server 2)Linux Host (physical/virtual server 1)
LBR Container
OHS
OTD
- 25. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Linux Host 0 Linux Host 3Linux Host 1 Linux Host 2
25
(B) Topology - Containerized Apps – Single/Multi Host
Load Balancing only. There is no real clustering replication. No failover.
LBR WebTier
OHS
WLSContainerized
AS
App
JMS
Domain App 0
WLSContainerized
AS
App
JMS
Domain App 0
WLSContainerized
AS
App
JMS
Domain App 0
WLSContainerized
AS
App
JMS
Domain App 1
WLSContainerized
AS
App
JMS
Domain App 1
WLSContainerized
AS
App
JMS
Domain App 1
root@host_1 # docker run –d mywlsapp0 startWebLogic.sh
root@host_2 # docker run –d mywlsapp0 startWebLogic.sh
root@host_3 # docker run –d mywlsapp0 startWebLogic.sh
root@host_1 # docker run –d mywlsapp1 startWebLogic.sh
root@host_2 # docker run –d mywlsapp1 startWebLogic.sh
root@host_3 # docker run –d mywlsapp1 startWebLogic.sh
- 26. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Demo
WebLogic on Docker
Arquillian Cube
26@brunoborges
- 27. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. |
Try Oracle Java Cloud Service!
cloud.oracle.com/java
@brunoborges
- 28. Copyright © 2016, Oracle and/or its affiliates. All rights reserved. | @brunoborges