SlideShare a Scribd company logo
1 of 54
Download to read offline
2011   9   23
2011   9   23
2011   9   23
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
HelloWorld.java

       public class HelloWorld {
         public static void main(String[] args) {
           System.out.println("Hello, World!");
         }
       }




2011   9   23
HelloWorld.groovy

       public class HelloWorld {
         public static void main(String[] args) {
           System.out.println("Hello, World!");
         }
       }


                 Java



2011   9   23
HelloWorld.groovy


                 println "Hello, World!"




2011   9   23
Grails




2011   9   23
2011   9   23
2011   9   23
G*Magazine




2011   9   23
G*Magazine Vol.3




2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
class Book {

                    String title
                    String isbn

                    static constraints = {
                        title blank:false
                        isbn blank:false, unique:true
                    }
                }


2011   9   23
class Book {

                    static mapWith = 'mongo'

                    String title
                    String isbn

                    static constraints = {
                        title blank:false
                        isbn blank:false, unique:true
                    }
                }

2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
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
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
2011   9   23
2011   9   23
import spock.lang.*

                class HelloSpock extends Specification {

                    def "                  "() {
                        expect:
                        name.size() == length

                        where:
                        name       |   length
                        "Spock"    |   5
                        "Kirk"     |   4
                        "Scotty"   |   6
                    }
                }

2011   9   23
@Test
                public void test() {
                    assert 1 + 1 * 2 == 4
                }


                //
                Assertion failed:

                assert 1 + 1 * 2 == 4
                         |   |   |
                         3   2   false
2011   9   23
2011   9   23
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
class LoginPage {
             static at = { title == 'Login'}
             static content = {
               username { $('input[name="username"]') }
               password { $('input[name="password"]') }
               loginButton { $('input[name="login_button"]') }
             }
           }




2011   9   23
class LoginSpec extends GebSpec {
                  def '          '() {
                        given: '                '
                        to LoginPage

                        when: '        /        '
                        username = 'username'
                        password = 'password'
                        loginButton.click()

                        then: '                 '
                        at TopPage
                    }
                }
2011   9   23
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
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
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23
2011   9   23

More Related Content

What's hot

Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
elliando dias
 
G*におけるソフトウェアテスト・シーズンIII
G*におけるソフトウェアテスト・シーズンIIIG*におけるソフトウェアテスト・シーズンIII
G*におけるソフトウェアテスト・シーズンIII
Takuma Watabiki
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
julien.ponge
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
Kiyotaka Oku
 

What's hot (20)

Clojure - A new Lisp
Clojure - A new LispClojure - A new Lisp
Clojure - A new Lisp
 
G*におけるソフトウェアテスト・シーズンIII
G*におけるソフトウェアテスト・シーズンIIIG*におけるソフトウェアテスト・シーズンIII
G*におけるソフトウェアテスト・シーズンIII
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
 
Java 7 LavaJUG
Java 7 LavaJUGJava 7 LavaJUG
Java 7 LavaJUG
 
5. Ввод-вывод, доступ к файловой системе
5. Ввод-вывод, доступ к файловой системе5. Ввод-вывод, доступ к файловой системе
5. Ввод-вывод, доступ к файловой системе
 
JJUG CCC 2011 Spring
JJUG CCC 2011 SpringJJUG CCC 2011 Spring
JJUG CCC 2011 Spring
 
Unit/Integration Testing using Spock
Unit/Integration Testing using SpockUnit/Integration Testing using Spock
Unit/Integration Testing using Spock
 
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -Stubる - Mockingjayを使ったHTTPクライアントのテスト -
Stubる - Mockingjayを使ったHTTPクライアントのテスト -
 
GeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with GroovyGeeCON Prague 2014 - Metaprogramming with Groovy
GeeCON Prague 2014 - Metaprogramming with Groovy
 
COScheduler In Depth
COScheduler In DepthCOScheduler In Depth
COScheduler In Depth
 
Core java pract_sem iii
Core java pract_sem iiiCore java pract_sem iii
Core java pract_sem iii
 
Java
JavaJava
Java
 
Unit Testing with Foq
Unit Testing with FoqUnit Testing with Foq
Unit Testing with Foq
 
DCN Practical
DCN PracticalDCN Practical
DCN Practical
 
srgoc
srgocsrgoc
srgoc
 
Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»Слава Бобик «NancyFx для самых маленьких»
Слава Бобик «NancyFx для самых маленьких»
 
Spockを使おう!
Spockを使おう!Spockを使おう!
Spockを使おう!
 
What’s new in C# 6
What’s new in C# 6What’s new in C# 6
What’s new in C# 6
 
Network
NetworkNetwork
Network
 

Viewers also liked

Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化
Kenichi Kambara
 
Jenkinsプラグインの作り方
Jenkinsプラグインの作り方Jenkinsプラグインの作り方
Jenkinsプラグインの作り方
Kiyotaka Oku
 
Jenkinsプラグイン開発
Jenkinsプラグイン開発Jenkinsプラグイン開発
Jenkinsプラグイン開発
Takahisa Wada
 
レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場
Hiroyuki Ohnaka
 

Viewers also liked (20)

Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化Jenkinsを用いたAndroidアプリビルド作業効率化
Jenkinsを用いたAndroidアプリビルド作業効率化
 
Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010Gradle talk, Javarsovia 2010
Gradle talk, Javarsovia 2010
 
The outlineoftestprocess
The outlineoftestprocessThe outlineoftestprocess
The outlineoftestprocess
 
Groovy Testing Aug2009
Groovy Testing Aug2009Groovy Testing Aug2009
Groovy Testing Aug2009
 
Groovy 1.8の新機能について
Groovy 1.8の新機能についてGroovy 1.8の新機能について
Groovy 1.8の新機能について
 
うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-うさぎ組 in G* WorkShop -うさみみの日常-
うさぎ組 in G* WorkShop -うさみみの日常-
 
AgileJapan2010 基調講演:野中郁次郎先生による「実践知のリーダシップ~スクラムと知の場作り」
AgileJapan2010 基調講演:野中郁次郎先生による「実践知のリーダシップ~スクラムと知の場作り」AgileJapan2010 基調講演:野中郁次郎先生による「実践知のリーダシップ~スクラムと知の場作り」
AgileJapan2010 基調講演:野中郁次郎先生による「実践知のリーダシップ~スクラムと知の場作り」
 
Groovier testing with Spock
Groovier testing with SpockGroovier testing with Spock
Groovier testing with Spock
 
Spock Framework 2
Spock Framework 2Spock Framework 2
Spock Framework 2
 
Gradle a new Generation Build Tool
Gradle a new Generation Build ToolGradle a new Generation Build Tool
Gradle a new Generation Build Tool
 
Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)Androidリリース作業の効率化(2)
Androidリリース作業の効率化(2)
 
Spock Framework
Spock FrameworkSpock Framework
Spock Framework
 
Groovy, Transforming Language
Groovy, Transforming LanguageGroovy, Transforming Language
Groovy, Transforming Language
 
Jenkinsプラグインの作り方
Jenkinsプラグインの作り方Jenkinsプラグインの作り方
Jenkinsプラグインの作り方
 
Hands on the Gradle
Hands on the GradleHands on the Gradle
Hands on the Gradle
 
Jenkins導入ライブ
Jenkins導入ライブJenkins導入ライブ
Jenkins導入ライブ
 
How about Gradle?
How about Gradle?How about Gradle?
How about Gradle?
 
Jenkinsプラグイン開発
Jenkinsプラグイン開発Jenkinsプラグイン開発
Jenkinsプラグイン開発
 
レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場レガシーコード改善はじめました 横浜道場
レガシーコード改善はじめました 横浜道場
 
Testing Web Applications with GEB
Testing Web Applications with GEBTesting Web Applications with GEB
Testing Web Applications with GEB
 

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

Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜
Kiyotaka Oku
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
Dmitry Soshnikov
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
Pramod Kumar
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
Codecamp Romania
 
GR8Conf 2011: Effective Groovy
GR8Conf 2011: Effective GroovyGR8Conf 2011: Effective Groovy
GR8Conf 2011: Effective Groovy
GR8Conf
 

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

Groovy intro for OUDL
Groovy intro for OUDLGroovy intro for OUDL
Groovy intro for OUDL
 
Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜Griffon不定期便〜G*ワークショップ編〜
Griffon不定期便〜G*ワークショップ編〜
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!Implicit parameters, when to use them (or not)!
Implicit parameters, when to use them (or not)!
 
Realm to Json & Royal
Realm to Json & RoyalRealm to Json & Royal
Realm to Json & Royal
 
[2019-07] GraphQL in depth (serverside)
[2019-07] GraphQL in depth (serverside)[2019-07] GraphQL in depth (serverside)
[2019-07] GraphQL in depth (serverside)
 
Introduction kot iin
Introduction kot iinIntroduction kot iin
Introduction kot iin
 
Hidden Treasures of the Python Standard Library
Hidden Treasures of the Python Standard LibraryHidden Treasures of the Python Standard Library
Hidden Treasures of the Python Standard Library
 
create-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdfcreate-netflix-clone-02-server.pdf
create-netflix-clone-02-server.pdf
 
Java Concurrency Gotchas
Java Concurrency GotchasJava Concurrency Gotchas
Java Concurrency Gotchas
 
The Future of JVM Languages
The Future of JVM Languages The Future of JVM Languages
The Future of JVM Languages
 
Use of Apache Commons and Utilities
Use of Apache Commons and UtilitiesUse of Apache Commons and Utilities
Use of Apache Commons and Utilities
 
Ast transformations
Ast transformationsAst transformations
Ast transformations
 
CodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical GroovyCodeCamp Iasi 10 march 2012 - Practical Groovy
CodeCamp Iasi 10 march 2012 - Practical Groovy
 
GR8Conf 2011: Effective Groovy
GR8Conf 2011: Effective GroovyGR8Conf 2011: Effective Groovy
GR8Conf 2011: Effective Groovy
 
ConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with GroovyConFess Vienna 2015 - Metaprogramming with Groovy
ConFess Vienna 2015 - Metaprogramming with Groovy
 
Presentatie - Introductie in Groovy
Presentatie - Introductie in GroovyPresentatie - Introductie in Groovy
Presentatie - Introductie in Groovy
 
Closures for Java
Closures for JavaClosures for Java
Closures for Java
 
Groovy grails types, operators, objects
Groovy grails types, operators, objectsGroovy grails types, operators, objects
Groovy grails types, operators, objects
 
FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6FalsyValues. Dmitry Soshnikov - ECMAScript 6
FalsyValues. Dmitry Soshnikov - ECMAScript 6
 

More from Kiyotaka Oku (20)

Osaka Venture Meetup #3
Osaka Venture Meetup #3Osaka Venture Meetup #3
Osaka Venture Meetup #3
 
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
巨大不明ビルドの継続的統合を目的とするビルドパイプラインを主軸とした作戦要綱
 
BaseScriptについて
BaseScriptについてBaseScriptについて
BaseScriptについて
 
javafx-mini4wd
javafx-mini4wdjavafx-mini4wd
javafx-mini4wd
 
ミニ四駆ジャパンカップで勝つ方法を考える
ミニ四駆ジャパンカップで勝つ方法を考えるミニ四駆ジャパンカップで勝つ方法を考える
ミニ四駆ジャパンカップで勝つ方法を考える
 
Jenkins plugin memo
Jenkins plugin memoJenkins plugin memo
Jenkins plugin memo
 
Spockの基礎
Spockの基礎Spockの基礎
Spockの基礎
 
JUC2012
JUC2012JUC2012
JUC2012
 
GDK48総選挙の裏側
GDK48総選挙の裏側GDK48総選挙の裏側
GDK48総選挙の裏側
 
Jenkins入門
Jenkins入門Jenkins入門
Jenkins入門
 
日本Grails/Groovyユーザーグループ
日本Grails/Groovyユーザーグループ日本Grails/Groovyユーザーグループ
日本Grails/Groovyユーザーグループ
 
GroovyConsole2
GroovyConsole2GroovyConsole2
GroovyConsole2
 
GroovyConsole
GroovyConsoleGroovyConsole
GroovyConsole
 
Devsumi Openjam
Devsumi OpenjamDevsumi Openjam
Devsumi Openjam
 
Jenkins and Groovy
Jenkins and GroovyJenkins and Groovy
Jenkins and Groovy
 
とある断片の超動的言語
とある断片の超動的言語とある断片の超動的言語
とある断片の超動的言語
 
Mote Hudson
Mote HudsonMote Hudson
Mote Hudson
 
Groovy and-hudson2
Groovy and-hudson2Groovy and-hudson2
Groovy and-hudson2
 
Gaelyk
GaelykGaelyk
Gaelyk
 
JDO
JDOJDO
JDO
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 

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

  • 1. 2011 9 23
  • 2. 2011 9 23
  • 3. 2011 9 23
  • 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. HelloWorld.java public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } 2011 9 23
  • 6. HelloWorld.groovy public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World!"); } } Java 2011 9 23
  • 7. HelloWorld.groovy println "Hello, World!" 2011 9 23
  • 8. Grails 2011 9 23
  • 9. 2011 9 23
  • 10. 2011 9 23
  • 13. 2011 9 23
  • 14. 2011 9 23
  • 15. 2011 9 23
  • 16. 2011 9 23
  • 17. 2011 9 23
  • 18. 2011 9 23
  • 19. 2011 9 23
  • 20. 2011 9 23
  • 21. 2011 9 23
  • 22. 2011 9 23
  • 23. 2011 9 23
  • 24. 2011 9 23
  • 25. 2011 9 23
  • 26. 2011 9 23
  • 27. 2011 9 23
  • 28. class Book { String title String isbn static constraints = { title blank:false isbn blank:false, unique:true } } 2011 9 23
  • 29. class Book { static mapWith = 'mongo' String title String isbn static constraints = { title blank:false isbn blank:false, unique:true } } 2011 9 23
  • 30. 2011 9 23
  • 31. 2011 9 23
  • 32. 2011 9 23
  • 33. 2011 9 23
  • 34. 2011 9 23
  • 35. 2011 9 23
  • 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. 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. 2011 9 23
  • 39. 2011 9 23
  • 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. @Test public void test() { assert 1 + 1 * 2 == 4 } // Assertion failed: assert 1 + 1 * 2 == 4 | | | 3 2 false 2011 9 23
  • 42. 2011 9 23
  • 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. 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. class LoginSpec extends GebSpec { def ' '() { given: ' ' to LoginPage when: ' / ' username = 'username' password = 'password' loginButton.click() then: ' ' at TopPage } } 2011 9 23
  • 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. 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. 2011 9 23
  • 49. 2011 9 23
  • 50. 2011 9 23
  • 51. 2011 9 23
  • 52. 2011 9 23
  • 53. 2011 9 23
  • 54. 2011 9 23