SlideShare a Scribd company logo
Tecnologie Groovy 
Parte Seconda 
Novembre 2013 
Francesco Lerro 
giovedì 7 novembre 13 1
Nelle puntate 
precedenti... 
giovedì 7 novembre 13 2
+ 
Smalltalk { 
giovedì 7 novembre 13 3
• Agile ed espressivo 
(es. Collection, ?. , ?: , Sluper, Builder, ...) 
• Dinamico (Category, Mixin, Metaclass) 
• Dichiarativo/funzionale (Closures) 
giovedì 7 novembre 13 4
In questa puntata... 
giovedì 7 novembre 13 5
Ecosistema 
Geb, Spock, WSLite... 
giovedì 7 novembre 13 6
• Framework Web ad alta produttività 
• Solido: Spring, Hibernate, Sitemesh 
• Moderno: COC, smart reloading, scaffolding 
• Molti plugin: Spring Security, MongoDB, etc. 
giovedì 7 novembre 13 7
Live Demo 
expense-manager 
giovedì 7 novembre 13 8
Geb 
• Test automatici nel browser 
• Funziona su Firefox, Chrome, IE, Safari 
• Selezione HTML stile jQuery 
• Si integra con JUnit, TestNG, Spock 
giovedì 7 novembre 13 9
import geb.Browser 
Browser.drive { 
go "http://myapp.com/login" 
assert $("h1").text() == "Please Login" 
$("form").find("input", name: "username").value(“admin”) 
$("form").find("input", name: "password").value(“password”) 
$("form").find("input", name: "login").value() 
assert $("h1").text() == "Admin Section" 
} 
Testing con Geb 
giovedì 7 novembre 13 10
import geb.Browser 
Browser.drive { 
go "http://myapp.com/login" 
assert $("h1").text() == "Please Login" 
$("form").with { 
username = "admin" 
password = "password" 
login().click() 
} 
assert $("h1").text() == "Admin Section" 
} 
Testing con Geb 
giovedì 7 novembre 13 11
import geb.Browser 
Browser.drive { 
go "http://myapp.com/login" 
assert $("h1").text() == 
"Please Login" 
$("form").with { 
username = "admin" 
password = "password" 
login().click() 
} 
assert $("h1").text() == 
"Admin Section" 
} 
Testing con Geb 
giovedì 7 novembre 13 12
Spock 
• Testing e specification framework 
• Molto espressivo, facile da imparare 
• Facilita approccio Behaviour Driven 
giovedì 7 novembre 13 13
Spock 
• Testing e specification framework 
• Molto espressivo, facile da imparare 
• Facilita approccio Behaviour Driven 
given: "un nuovo conto bancario" 
when: "verso 10€" 
then: "il saldo del conto è 10€" 
giovedì 7 novembre 13 13
giovedì 7 novembre 13 14
giovedì 7 novembre 13 15
Geb + Spock 
giovedì 7 novembre 13 15
Gradle 
• Tool per l’automazione di build 
• Flessibilità di Ant e convenzioni Maven 
• Definizione dichiarativa via ad-hoc DSL 
• Molto in voga 
giovedì 7 novembre 13 16
Un progetto Java 
[project root] 
/src 
/main 
! /java 
/resources 
/test 
/java 
/resources 
build.gradle 
giovedì 7 novembre 13 17
Un progetto Java ... 
[project root] 
/src 
/main 
! /java 
/resources 
/test 
/java 
/resources 
build.gradle 
giovedì 7 novembre 13 18
Un progetto Java ... 
[project root] 
/src 
/main 
! /java 
/resources 
/test 
/java 
/resources 
build.gradle 
giovedì 7 novembre 13 19
giovedì 7 novembre 13 20
GPars 
• Groovy Parallel Systems 
• Framework per facilitare la costruzione di 
applicazioni concorrenti 
• Costrutti per Dataflow, attori, funzioni 
asicrone componibili, map-reduce... 
• Sfrutta l’espressività di Groovy (Closure) 
giovedì 7 novembre 13 21
Dataflow 
giovedì 7 novembre 13 22
Dataflow 
enfasi sui dati ed il loro ‘flusso’ 
e non sul processo che li manipola 
(deadlock deterministico) 
giovedì 7 novembre 13 22
Attori 
giovedì 7 novembre 13 23
Attori 
oggetti che si scambiano messaggi e 
non condividono stati mutabili 
(VS shared-memor y multi-threading) 
giovedì 7 novembre 13 23
Web: http://rolandfg.net Twitter: @flerro 
giovedì 7 novembre 13 24
Riferimenti 
• Groovy User Guide - http://groovy.codehaus.org/User+Guide 
• Bob Brown - The future is Gr8 - http://wordpress.transentia.com.au/wordpress/ 
2013/05/07/disaster/ 
• Sergey Dolgopolov - Testing the performance of new Groovy 2.0 release with 
GBench - http://www.sergeydolgopolov.me/2012/07/groovy-20-has-been-released-testing- 
new.html 
• Guillame Laforge - Groovy Ecosystem - http://www.slideshare.net/glaforge/groovy-ecosystem- 
jfokus-2011-guillaume-laforge 
• Hubert Klein Ikkink (aka mrhaki) - Groovy goodness blog - 
http://mrhaki.blogspot.it/ 
• Geb Samples - http://www.gebish.org 
• GPars Samples for Dataflow and Actors - http://gpars.codehaus.org 
• Spock Samples - http://code.google.com/p/spock/ 
• Tim Myer - http://timezra.blogspot.it/2011/11/trampoline-and-memoize.html 
giovedì 7 novembre 13 25

More Related Content

Groovy technology ecosystem

  • 1. Tecnologie Groovy Parte Seconda Novembre 2013 Francesco Lerro giovedì 7 novembre 13 1
  • 2. Nelle puntate precedenti... giovedì 7 novembre 13 2
  • 3. + Smalltalk { giovedì 7 novembre 13 3
  • 4. • Agile ed espressivo (es. Collection, ?. , ?: , Sluper, Builder, ...) • Dinamico (Category, Mixin, Metaclass) • Dichiarativo/funzionale (Closures) giovedì 7 novembre 13 4
  • 5. In questa puntata... giovedì 7 novembre 13 5
  • 6. Ecosistema Geb, Spock, WSLite... giovedì 7 novembre 13 6
  • 7. • Framework Web ad alta produttività • Solido: Spring, Hibernate, Sitemesh • Moderno: COC, smart reloading, scaffolding • Molti plugin: Spring Security, MongoDB, etc. giovedì 7 novembre 13 7
  • 8. Live Demo expense-manager giovedì 7 novembre 13 8
  • 9. Geb • Test automatici nel browser • Funziona su Firefox, Chrome, IE, Safari • Selezione HTML stile jQuery • Si integra con JUnit, TestNG, Spock giovedì 7 novembre 13 9
  • 10. import geb.Browser Browser.drive { go "http://myapp.com/login" assert $("h1").text() == "Please Login" $("form").find("input", name: "username").value(“admin”) $("form").find("input", name: "password").value(“password”) $("form").find("input", name: "login").value() assert $("h1").text() == "Admin Section" } Testing con Geb giovedì 7 novembre 13 10
  • 11. import geb.Browser Browser.drive { go "http://myapp.com/login" assert $("h1").text() == "Please Login" $("form").with { username = "admin" password = "password" login().click() } assert $("h1").text() == "Admin Section" } Testing con Geb giovedì 7 novembre 13 11
  • 12. import geb.Browser Browser.drive { go "http://myapp.com/login" assert $("h1").text() == "Please Login" $("form").with { username = "admin" password = "password" login().click() } assert $("h1").text() == "Admin Section" } Testing con Geb giovedì 7 novembre 13 12
  • 13. Spock • Testing e specification framework • Molto espressivo, facile da imparare • Facilita approccio Behaviour Driven giovedì 7 novembre 13 13
  • 14. Spock • Testing e specification framework • Molto espressivo, facile da imparare • Facilita approccio Behaviour Driven given: "un nuovo conto bancario" when: "verso 10€" then: "il saldo del conto è 10€" giovedì 7 novembre 13 13
  • 17. Geb + Spock giovedì 7 novembre 13 15
  • 18. Gradle • Tool per l’automazione di build • Flessibilità di Ant e convenzioni Maven • Definizione dichiarativa via ad-hoc DSL • Molto in voga giovedì 7 novembre 13 16
  • 19. Un progetto Java [project root] /src /main ! /java /resources /test /java /resources build.gradle giovedì 7 novembre 13 17
  • 20. Un progetto Java ... [project root] /src /main ! /java /resources /test /java /resources build.gradle giovedì 7 novembre 13 18
  • 21. Un progetto Java ... [project root] /src /main ! /java /resources /test /java /resources build.gradle giovedì 7 novembre 13 19
  • 23. GPars • Groovy Parallel Systems • Framework per facilitare la costruzione di applicazioni concorrenti • Costrutti per Dataflow, attori, funzioni asicrone componibili, map-reduce... • Sfrutta l’espressività di Groovy (Closure) giovedì 7 novembre 13 21
  • 24. Dataflow giovedì 7 novembre 13 22
  • 25. Dataflow enfasi sui dati ed il loro ‘flusso’ e non sul processo che li manipola (deadlock deterministico) giovedì 7 novembre 13 22
  • 26. Attori giovedì 7 novembre 13 23
  • 27. Attori oggetti che si scambiano messaggi e non condividono stati mutabili (VS shared-memor y multi-threading) giovedì 7 novembre 13 23
  • 28. Web: http://rolandfg.net Twitter: @flerro giovedì 7 novembre 13 24
  • 29. Riferimenti • Groovy User Guide - http://groovy.codehaus.org/User+Guide • Bob Brown - The future is Gr8 - http://wordpress.transentia.com.au/wordpress/ 2013/05/07/disaster/ • Sergey Dolgopolov - Testing the performance of new Groovy 2.0 release with GBench - http://www.sergeydolgopolov.me/2012/07/groovy-20-has-been-released-testing- new.html • Guillame Laforge - Groovy Ecosystem - http://www.slideshare.net/glaforge/groovy-ecosystem- jfokus-2011-guillaume-laforge • Hubert Klein Ikkink (aka mrhaki) - Groovy goodness blog - http://mrhaki.blogspot.it/ • Geb Samples - http://www.gebish.org • GPars Samples for Dataflow and Actors - http://gpars.codehaus.org • Spock Samples - http://code.google.com/p/spock/ • Tim Myer - http://timezra.blogspot.it/2011/11/trampoline-and-memoize.html giovedì 7 novembre 13 25