Upload
ericsword
View
1.628
Download
1
Tags:
Embed Size (px)
Citation preview
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 1
Grails Goto PluginsEric Sword
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 2
Who am I
● Professional geek for 17 years● Turned management refugee in 2005● Now full-time dev and tech lead for SAIC● Java '97, Groovy '07, Grails '09● Blog: http://www.swordsystems.com● [email protected]
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 3
This Presentation● Start from nothing - almost● Full app in 1 hour
DB Persistence Authentication Audit Logging
Load Monitoring DB Monitoring Remote Debugging
Unit Tests Integration Tests Functional Tests
Test Data Fixtures Lucene Indexes Tags and Tag Clouds
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 4
Get the Code● https://github.com/esword/grails-plugin-sandbox
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 5
All Together Now
Groovy on RailsGroovy on Grails
Grails
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 6
Grails Recipe
● Take most popular Java web techs
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 7
● Apply dollop of groovy glue● Conventions from top to bottom● Minimal boiler plate code
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 8
Your Choice of 745 Fixings
●
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 9
Bake with fully integrated testing tools
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 10
Enjoy!
● Full stack web-application framework
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 11
Running App in 3 Lines
● grails create-app bookstore● cd bookstore● grails run-app
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 12
Add MVC
● create-domain-class Author● cre<tab> Book● create-scaffold-controller <tab> Author● <up arrow> Book
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 13
Define Domain
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 14
New in 2.0
● Much improved interactive shell● Better class reloading● Web-based dbconsole
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 15
dbconsole
● drool,drool, drool
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 16
Get Real
● Authentication● Test Data● Testing● Audit Logging● Monitoring
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 17
IDE Integration
● Intellij Rocks– Does require $ for Ultimate Edition
● STS – Spring Source Toolsuite– A solid “meh”
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 18
Plugins
● Project Overlay● Augment Build● Add Common Libs● Add Capabilities
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 19
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 20
Authentication
● Do it first● Avoid mocking stuff for user session
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 21
Spring Security Plugin
● grails install-plugin spring-security-core
or● BuildConfig.groovy:● compile ':spring-security-core:1.2.7.2'● grails s2-quickstart bookstore.auth
BookstoreUser AuthRole●
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 22
BuildConfig.groovy
● Ivy Dependency Management● SCM● Repository Deployment● Plugin Definitions
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 23
Init Security
● grails s2-quickstart bookstore.auth BookstoreUser AuthRole
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 24
Config.groovy
● Tip: Break it up● Makes it easier to upgrade grails● Easier to find settings of different types● Don't forget to test it
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 25
Unit vs Integration Tests
● Grails 2 unit test enhancements● Integration tests go through init sequence
● create-integration-test BootStrap● test-app integration:● open test-report
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 26
Back to Security
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 27
Lock it Down
● Can use Annotation in controllers
or● Centralized url-access map
http://grails-plugins.github.com/grails-spring-security-core/docs/manual/
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 28
Fixtures Plugin
● grails install-plugin fixtures● Concise DSL for creating domain objects● Test data sets● Initialization data
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 29
Fixtures Shortcomings
● Can't load external file● Doesn't load in production● No easy “if exists” check● Can work around all of these
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 30
Fixtures Plugin
● Fixture for roles and system user● Fixture for test/demo users● Test! Test! Test!
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 31
Why so many tests?
● It's easy● Compile time checking no longer there● Do you value your sanity?
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 32
Productivity Chart
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 33
Grails without Tests
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 34
Activate Fixtures
● A bit about Bootstrap.groovy
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 35
App-Specific Config Settings
● ConfigSlurper - a very smart properties file● Remember - can overload with other files
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 36
BuildTestData Plugin
● Fills in non-essential bean fields● Keeps data in-tests
– Also Integrates with Fixture plugin
● As of last week, works in Unit Tests– new Book().validate() vs
Book.build().validate()
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 37
● Have– DB persistence, authentication, unit and
integration tests, auto-initialized user and data sets
● Need– Audit logging, Load monitoring, remote
debugging, functional tests, code coverage metrics, Lucene indexed queries, UI niceties
Status Check
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 38
● grails install-plugin audit-logging
● grails install-plugin code-coverage
● grails install-plugin console
● grails install-plugin codenarc
● grails install-plugin geb
● grails install-plugin grails-melody
● grails install-plugin runtime-logging
…Oh eff it...● Add plugin dependencies to BuildConfig
Bam!
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 39
● CodeNarc– Warning: Will not run in interactive console
● Coberturra– Need to tweak include/exclude sets
● Both integrate well with Jenkins
Code Analysisand
Test Coverage
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 40
● static auditable = true● Hooks into grails persistence events● Record changes down to property level● Integrates with spring security to capture
user● Controller to view some audit info
Audit Logging
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 41
● SELECT * FROM AUDIT_LOG order by id desc
Audit Logging
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 42
Monitoring with Melody
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 43
● dbconsole● console● App-info
– Warning: Not working with grails 2 yet
Remote Debugging
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 44
● Have– DB persistence, authentication, unit and
integration tests, auto-initialized user and data sets, audit logging, load monitoring, remote debugging, code coverage metrics
● Need– functional tests, Lucene indexed queries,
UI niceties
Status Check
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 45
● static searchable = true● Lucene index against domain classes
Searchable Plugin
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 46
● Functional Testing with Geb
Or● Tags and Tag Cloud
Audience Choice
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 47
● static searchable = true● Lucene index against domain classes
Taggable and Tag Cloud
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 48
● http://grails.org/
● http://grails.org/plugins/
● https://github.com/esword/grails-plugin-sandbox
● http://groovyblogs.org/entries/recent
● http://glaforge.appspot.com/article/videos-and-slides-of-groovy-grails-exchange-2011
● http://mrhaki.blogspot.com/
Resources
February 15, 2012 Grails Goto Plugins DC GUG Copyright 2012 Eric Sword 49
Thanks!
● Happy Plugging!● http://www.swordsystems.com● http://www.slideshare.net/ericsword/grails-
goto-plugins● [email protected]