Your SlideShare is downloading. ×
0
EclipseCon Europe 2013

EHT IGSO GNITSET
Y W YVOORG
Lars Pfannenschmidt & Dennis Nobel
Lars Pfannenschmidt
Senior Software Engineer at Level Up Analytics Intuit
Founder of @mobilecgn
Dennis Nobel
IT Consultant at itemis AG @itemis
Java, Web and OSGi Developer
ENIG MI

writing tests would make fun...
:1 NOITSEUQ

Do you test your OSGi
components?
: 2 NOITSEUQ

Are you using Groovy?
Our Testing Story
Embedded Device with CVM (~Java 1.4)
OSGi framework (Prosyst mBS)
Development with Eclipse
CI Build with...
How to write our tests?
Test Requirements
Easy to write
Modern language
Type-safe access to Java classes
Easy mocking
Executable in Eclipse and Ma...
V J

Modern language?
Not really...
What? Why Groovy?
Because we can!
YVOORG
JVM Language
Syntax Sugar
Closures
Less "Chatty"
Groovy JUnit Test
Type inference, readable asserts, syntax sugar and more:
 

  
 

@et
Ts
vi 'ul pzawt BQsueol'){
od Bid ...
How to test our OSGi Services?
Pizza Service Sample
Services: PizzaService → PaymentService
      
      
pbi casPzaevcIp ipeet Pzaevc {
ulc ls izSrieml ...
STSET TINU

+Executed fast
+Focussed on the component
­No OSGi Runtime features
­Dependencies must be mocked
­No testing o...
STSET METSYS

+Cover complete system
+Real target environment
+No mocking or special configuration
­Embedded device is nee...
STSET RENI TNOC NI
Executed in OSGi environment
Focussed on the component
Testing of declarative OSGi parts
Only partial m...
...we can not run Groovy in CVM
Why not use

XONIUQE

with a modern JVM?
YVOORG

In-Container Testing with
equinox
Mocking
Simply transform a map to a proxy:
      
      
dfpyetevc =[
e amnSrie
hnlTascin {Srn cmayd ln ceiCrNme adernato:...
Register OSGi service mocks (1)
      
      
casPzaevcTs etnsOGTs {
ls izSrieet xed Siet
@vrie
Oerd
poetdBnlCnetgtudeotx(...
Register OSGi service mocks (2)
      
      
@et
Ts
vi 'setta tehnlTascinmto i cle'){
od Asr ht h adernato ehd s ald(
..
...
OSGiTest.groovy
      
      
dfrgseeSrie =[]
e eitrdevcs
:
poetdasrc BnlCnetgtudeotx(
rtce btat udeotx eBnlCnet)
df<>Tgte...
NOIT MOTU

with Maven and Tycho
Tycho Groovy configuration (1)
Groovy & Maven
http://groovy.codehaus.org/GroovyEclipse+compiler+plugin+for+Maven
Groovy Re...
Tycho Groovy configuration (2)
Tycho, Groovy & Surefire
      
      
..
.
<lgn
pui>
<rui>r.cis.yh<gopd
gopdogelpetco/rui>...
NOISULCNOC

Add integrative Tests to your OSGi projects
Easy to add groovy support in equinox and tycho
Groovy makes devel...
UOY KN HT

Checkout "groovy" OSGi testing at github:
    
    
$gtcoehts/gtu.o/roysitsiggt
i ln tp:/ihbcmgovog/etn.i
$c ts...
Testing OSGi the "groovy" way - Lars Pfannenschmidt, Dennis Nobel
Upcoming SlideShare
Loading in...5
×

Testing OSGi the "groovy" way - Lars Pfannenschmidt, Dennis Nobel

871

Published on

OSGi Community Event 2013 (http://www.osgi.org/CommunityEvent2013/Schedule)

ABSTRACT
In order to meet software project requirements, it is important to implement ongoing quality assurance using automated tests. However, for OSGi platforms which are used in various areas such as Embedded or Enterprise this turns out to be difficult. If several components need to be tested together, unit tests written in Java tend to reach their limits. Thus, implementing these tests can be very time consuming. Using the Groovy language, OSGi integration tests are efficient and easy to write, e.g. registering Groovy mocks as a OSGi Service turns out to be very handy. Hereby declarative OSGi components can be tested, too. Even if an OSGi application has to be CDC-compliant, tests can be written using Groovy in a modern syntax.

This presentation demonstrates how to implement Groovy tests for a sample OSGi project and how Groovy tests can be executed in an Equinox OSGi environment. Furthermore, it shows how a continuous integration solution using Maven Tycho can look like.

SPEAKER BIOS
Lars Pfannenschmidt Interested in Mobile Applications, Smart Home, Domain Specific Languages, Machine Learning and agile development methodologies such as Scrum and Kanban. Senior Software Engineer and Founder of mobile.cologne

Dennis Nobel Dennis works as an IT Consultant for itemis in the field of Java, Web and Mobile Development. Moreover he is interested in Agile Development, Continuous Integration, Modeling Technologies, Testing, IoT, Smart Home, OSGi and Groovy.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
871
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
20
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Transcript of "Testing OSGi the "groovy" way - Lars Pfannenschmidt, Dennis Nobel"

  1. 1. EclipseCon Europe 2013 EHT IGSO GNITSET Y W YVOORG Lars Pfannenschmidt & Dennis Nobel
  2. 2. Lars Pfannenschmidt Senior Software Engineer at Level Up Analytics Intuit Founder of @mobilecgn
  3. 3. Dennis Nobel IT Consultant at itemis AG @itemis Java, Web and OSGi Developer
  4. 4. ENIG MI writing tests would make fun...
  5. 5. :1 NOITSEUQ Do you test your OSGi components?
  6. 6. : 2 NOITSEUQ Are you using Groovy?
  7. 7. Our Testing Story Embedded Device with CVM (~Java 1.4) OSGi framework (Prosyst mBS) Development with Eclipse CI Build with Maven and Tycho
  8. 8. How to write our tests?
  9. 9. Test Requirements Easy to write Modern language Type-safe access to Java classes Easy mocking Executable in Eclipse and Maven CI build Good IDE support No side effects for production code
  10. 10. V J Modern language? Not really...
  11. 11. What? Why Groovy?
  12. 12. Because we can!
  13. 13. YVOORG JVM Language Syntax Sugar Closures Less "Chatty"
  14. 14. Groovy JUnit Test Type inference, readable asserts, syntax sugar and more:        @et Ts vi 'ul pzawt BQsueol'){ od Bid iz ih B ac ny( dfpza=Pzaule.ePza) e iz izBidrnwiz( .ihac(B) wtSueBQ .ul( bid) asrTa pzasue i(B) setht iz.ac, sBQ }      
  15. 15. How to test our OSGi Services?
  16. 16. Pizza Service Sample Services: PizzaService → PaymentService               pbi casPzaevcIp ipeet Pzaevc { ulc ls izSrieml mlmns izSrie @vrie Oerd pbi vi paere(ia Odrodr { ulc od lcOdrfnl re re) .. . ceiCrPyetevc.adernato(.) rdtadamnSriehnlTascin..; .. . } }          
  17. 17. STSET TINU +Executed fast +Focussed on the component ­No OSGi Runtime features ­Dependencies must be mocked ­No testing of declarative OSGi parts
  18. 18. STSET METSYS +Cover complete system +Real target environment +No mocking or special configuration ­Embedded device is needed (high execution effort) ­Slow execution ­Not focussed
  19. 19. STSET RENI TNOC NI Executed in OSGi environment Focussed on the component Testing of declarative OSGi parts Only partial mocking
  20. 20. ...we can not run Groovy in CVM
  21. 21. Why not use XONIUQE with a modern JVM?
  22. 22. YVOORG In-Container Testing with equinox
  23. 23. Mocking Simply transform a map to a proxy:               dfpyetevc =[ e amnSrie hnlTascin {Srn cmayd ln ceiCrNme adernato: tig opnI, og rdtadubr > asrTa cmayd i(qaT(LII_IZ_EVC') setht opnI, seulo'UGSPZASRIE) tascinald=tu rnatoCle re } ]a CeiCrPyetevc s rdtadamnSrie          
  24. 24. Register OSGi service mocks (1)               casPzaevcTs etnsOGTs { ls izSrieet xed Siet @vrie Oerd poetdBnlCnetgtudeotx( { rtce udeotx eBnlCnet) Atvtrcnet ciao.otx } .. . }          
  25. 25. Register OSGi service mocks (2)               @et Ts vi 'setta tehnlTascinmto i cle'){ od Asr ht h adernato ehd s ald( .. . rgseMc(amnSrie eitrokpyetevc) Pzaevc pzaevc =gtevc(izSrie izSrie izSrie eSriePzaevc) dfpza=Pzaule.ePza)wtSueSueBQ.ul( e iz izBidrnwiz(.ihac(ac.B)bid) dfcsoeIf =nwCsoeIf(MxMsemn" nwAdes) 44) e utmrno e utmrno"a utran, e drs(, 22 pzaevc.lcOdrnwOdrpza csoeIf) izSriepaere(e re(iz, utmrno) asrTa tascinald i(re setht rnatoCle, stu) }          
  26. 26. OSGiTest.groovy               dfrgseeSrie =[] e eitrdevcs : poetdasrc BnlCnetgtudeotx( rtce btat udeotx eBnlCnet) df<>Tgtevc(ls<>caz{ e T eSrieCasT lz) dfsrieeeec =bnlCnetgtevcRfrnecaznm) e evcRfrne udeotx.eSrieeeec(lz.ae asrTa srieeeec,i(oNlVle) setht evcRfrne sntulau() bnlCnetgtevc(evcRfrne udeotx.eSriesrieeeec) } dfrgseMc(e mc,Hstbepoete =[] { e eitrokdf ok ahal rpris :) dfitraeae=mc.ls.nefcs.id{t).ae e nefcNm okcasitrae?fn(i}?nm asrTa itraeae i(oNlVle) setht nefcNm, sntulau() rgseeSrie.u(nefcNm, eitrdevcsptitraeae bnlCnetrgseSrieitraeae mc,poete) udeotx.eitrevc(nefcNm, ok rpris) } .. .          
  27. 27. NOIT MOTU with Maven and Tycho
  28. 28. Tycho Groovy configuration (1) Groovy & Maven http://groovy.codehaus.org/GroovyEclipse+compiler+plugin+for+Maven Groovy Repository           <eoiois rpstre> .. . <eoioy rpstr> <dgov-cis<i> i>royelpe/d <aotp<lyu> lyu>2/aot <r>tp/ds.pigoreogrlaeGELPEe.//r> ulht:/itsrnsuc.r/ees/RCIS/43<ul <rpstr> /eoioy <rpstre> /eoiois          
  29. 29. Tycho Groovy configuration (2) Tycho, Groovy & Surefire               .. . <lgn pui> <rui>r.cis.yh<gopd gopdogelpetco/rui> <riatdtcosrfr-lgn/riatd atfci>yh-ueiepui<atfci> <eso>{yh.eso}/eso> vrin$tcovrin<vrin <ofgrto> cniuain <nlds icue> <nld>**/nld> icue*/<icue <icue> /nlds .. . <cniuain /ofgrto> <pui> /lgn .. .          
  30. 30. NOISULCNOC Add integrative Tests to your OSGi projects Easy to add groovy support in equinox and tycho Groovy makes developing tests more easier Powerful tests which run as fast as unit tests (>300 Tests in ~3 minutes) Fun!
  31. 31. UOY KN HT Checkout "groovy" OSGi testing at github:           $gtcoehts/gtu.o/roysitsiggt i ln tp:/ihbcmgovog/etn.i $c tsig d etn $mncenisal v la ntl       Lars Pfannenschmidt (Intuit, Inc.) Dennis Nobel (itemis AG) 1/32
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×