Successfully reported this slideshow.
Your SlideShare is downloading. ×

Grails/Groovyによる開発事例紹介

Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Ad
Loading in …3
×

Check these out next

1 of 54 Ad
Advertisement

More Related Content

Slideshows for you (20)

Viewers also liked (20)

Advertisement

Similar to Grails/Groovyによる開発事例紹介 (20)

More from Kiyotaka Oku (20)

Advertisement

Recently uploaded (20)

Grails/Groovyによる開発事例紹介

  1. 1. 2011 9 23
  2. 2. 2011 9 23
  3. 3. 2011 9 23
  4. 4. JSR241 • Groovyis an agile, dynamic programming language for the Java Virtual Machine. • Groovyincludes features found in Python, Ruby, and Smalltalk, but uses syntax similar to the Java programming language. 2011 9 23
  5. 5. HelloWorld.java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } 2011 9 23
  6. 6. HelloWorld.groovy public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } Java 2011 9 23
  7. 7. HelloWorld.groovy println "Hello, World!" 2011 9 23
  8. 8. Grails 2011 9 23
  9. 9. 2011 9 23
  10. 10. 2011 9 23
  11. 11. G*Magazine 2011 9 23
  12. 12. G*Magazine Vol.3 2011 9 23
  13. 13. 2011 9 23
  14. 14. 2011 9 23
  15. 15. 2011 9 23
  16. 16. 2011 9 23
  17. 17. 2011 9 23
  18. 18. 2011 9 23
  19. 19. 2011 9 23
  20. 20. 2011 9 23
  21. 21. 2011 9 23
  22. 22. 2011 9 23
  23. 23. 2011 9 23
  24. 24. 2011 9 23
  25. 25. 2011 9 23
  26. 26. 2011 9 23
  27. 27. 2011 9 23
  28. 28. class Book { String title String isbn static constraints = { title blank:false isbn blank:false, unique:true } } 2011 9 23
  29. 29. class Book { static mapWith = 'mongo' String title String isbn static constraints = { title blank:false isbn blank:false, unique:true } } 2011 9 23
  30. 30. 2011 9 23
  31. 31. 2011 9 23
  32. 32. 2011 9 23
  33. 33. 2011 9 23
  34. 34. 2011 9 23
  35. 35. 2011 9 23
  36. 36. class FolderService { void rename(Long id, String newName) { def folder = Folder.get(id) folder.name = newName folder.save() } List<Folder> findAll() { Folder.findAll() } } 2011 9 23
  37. 37. class FolderService { @PreAuthorize("hasPermission(#id, 'sample.Folder', admin)") void rename(Long id, String newName) { def folder = Folder.get(id) folder.name = newName folder.save() } @PostFilter("hasPermission(filterObject, read)") List<Folder> findAll() { Folder.findAll() } } 2011 9 23
  38. 38. 2011 9 23
  39. 39. 2011 9 23
  40. 40. import spock.lang.* class HelloSpock extends Specification { def " "() { expect: name.size() == length where: name | length "Spock" | 5 "Kirk" | 4 "Scotty" | 6 } } 2011 9 23
  41. 41. @Test public void test() { assert 1 + 1 * 2 == 4 } // Assertion failed: assert 1 + 1 * 2 == 4 | | | 3 2 false 2011 9 23
  42. 42. 2011 9 23
  43. 43. class LoginSpec extends GebSpec { def ' '() { when: ' ' to 'login' at { title == 'Login' } and: ' / ' $('input[name="username"]').value 'username' $('input[name="password"]').value 'password' $('input[name="login_button"]').click() then: ' ' at { title == 'Welcome' } } } 2011 9 23
  44. 44. class LoginPage { static at = { title == 'Login'} static content = { username { $('input[name="username"]') } password { $('input[name="password"]') } loginButton { $('input[name="login_button"]') } } } 2011 9 23
  45. 45. class LoginSpec extends GebSpec { def ' '() { given: ' ' to LoginPage when: ' / ' username = 'username' password = 'password' loginButton.click() then: ' ' at TopPage } } 2011 9 23
  46. 46. class LoginSpec extends GebSpec { def ' '() { given: new User(username:'user', password:'pass').save() to LoginPage when: username = 'username' password = 'password' loginButton.click() then: at TopPage } } 2011 9 23
  47. 47. class LoginSpec extends GebSpec { def ' '() { given: fixtureLoader.load { user User, username:'user', password:'pass' admin User, username:'admin', password:'pass' } to LoginPage when: username = 'username' password = 'password' loginButton.click() then: at TopPage } } 2011 9 23
  48. 48. 2011 9 23
  49. 49. 2011 9 23
  50. 50. 2011 9 23
  51. 51. 2011 9 23
  52. 52. 2011 9 23
  53. 53. 2011 9 23
  54. 54. 2011 9 23

×