1 Groovy for Java developers and testers How Java developers and testers could use Groovy to increase their efficiency AUGUST 6, 2015
2 Life Science Department, Saint-Petersburg, Russia Mikhail Denisov Demo project:
3 WHY GROOVY? Smooth Java integration. Runs on the JVM, 100% compatible with Java bytecode 1 Concise, familiar and easy to learn syntax (“syntactic sugar”) 3 Dynamic language, with static-typing and static compilation capabilities 4 GDK - the extension to the JDK 5 Metaprogramming (Builders, DSL), functional programming, scripting 6 Supported by many systems and frameworks 2
4 AstraZeneca SOA Factory project Over 20 web-services (DB and AD interaction) Service Bus proxy for each service 4 environments: dev, test, preprod, prod 3 regions: Emea, America, Asia 20 * 2 * 3 * 4 = 480 endpoints SOA Factory project
5 GROOVY BY EXAMPLES Working with database and files 1 HTML, JSON and XML parsing 2 JSON and XML generation 3 Working with SOAP-service 4 Groovlets 5 Advanced Groovy 6
6 Maven POM.xml configuration with Groovy-Eclipse-Compiler
7 GROOVY BASICS: variables and collections
8 GROOVY BASICS: closures and GDK
9 GROOVY BASICS: objects and classes
10 Working with database and files Case: update database with data from file
11 GROOVY TESTS: interface implementation with Map
12 HTML parsing with RegExp
13 JSON parsing with JsonSlurper, GPath expressions
14 JSON parsing with JsonSlurper, GPath expressions
15 XML parsing: Google News RSS
16 GROOVY METAPROGRAMMING: working with metaClass
17 GROOVY METAPROGRAMMING: expanding Java classes
18 GROOVY METAPROGRAMMING: missing method interception
19 XML GENERATION: class MarkupBuilder
20 XML GENERATION: class MarkupBuilder
21 JSON GENERATION: class JsonBuilder
22 SOAP Web Service interaction with WSLite SOAP WebService “Magic Square” WSDL: Add WSLite to pom.xml
23 SOAP Web Service interaction with WSLite
24 SOAP Web Service: service MagicSquare.groovy
25 SOAP Web Service: test MagicSquareTest.groovy
26 Groovlet: display results as HTML page web.xml – add groovy.servlet.GroovyServlet
27 Groovlet: display results as HTML page Create script src/main/webapp/scripts/magic1.groovy Build application, run it in the servlet container Browse the link Result would be like this
28 Groovlet: scripts/magic2.groovy - params,, application, context javax.servlet.ServletContext sessionjavax.servlet.HttpSession requestjavax.servlet.HttpServlet responsejavax.servlet.HttpResponse outresponse.getWriter() Groovlet implicit objects:
29 Groovlet: add parameters and HTML markup: results
30 Groovlet: script/magic3.groovy - add CSS
31 Groovlet: scripts/magic3.groovy - result
32 SOAFactory PROJECT UTILS
33 SOAFactory PROJECT UTILS
34 How many lines are needed to run it as a DSL script? please show the square_root of 1024
35
36 Case: we have to collect data from many independent sources (collect all jokes about Chuck)
37
38 Groovy for Java developers and testers Q & A AUGUST 6, 2015