Testing OSGi the "groovy" way - Lars Pfannenschmidt, Dennis Nobel
Upcoming SlideShare
Loading in...5
×
 

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

on

  • 995 views

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

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.

Statistics

Views

Total Views
995
Views on SlideShare
995
Embed Views
0

Actions

Likes
0
Downloads
16
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

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

  • 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 Maven and Tycho
  • How to write our tests?
  • 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
  • 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 iz ih B ac ny( dfpza=Pzaule.ePza) e iz izBidrnwiz( .ihac(B) wtSueBQ .ul( bid) asrTa pzasue i(B) setht iz.ac, sBQ }      
  • How to test our OSGi Services?
  • 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..; .. . } }          
  • STSET TINU +Executed fast +Focussed on the component ­No OSGi Runtime features ­Dependencies must be mocked ­No testing of declarative OSGi parts
  • STSET METSYS +Cover complete system +Real target environment +No mocking or special configuration ­Embedded device is needed (high execution effort) ­Slow execution ­Not focussed
  • STSET RENI TNOC NI Executed in OSGi environment Focussed on the component Testing of declarative OSGi parts Only partial mocking
  • ...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: tig opnI, og rdtadubr > asrTa cmayd i(qaT(LII_IZ_EVC') setht opnI, seulo'UGSPZASRIE) tascinald=tu rnatoCle re } ]a CeiCrPyetevc s rdtadamnSrie          
  • Register OSGi service mocks (1)               casPzaevcTs etnsOGTs { ls izSrieet xed Siet @vrie Oerd poetdBnlCnetgtudeotx( { rtce udeotx eBnlCnet) Atvtrcnet ciao.otx } .. . }          
  • 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) }          
  • 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) } .. .          
  • NOIT MOTU with Maven and Tycho
  • 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          
  • 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 .. .          
  • 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!
  • 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