OSGi Versioning and Testing<br />Chris AniszczykEclipseSource<br />http://aniszczyk.org<br />Paul VanderLei<br />Band XI I...
Sample Application: Toast<br />Telematics-On-A-STick<br />Sample from upcoming bookequinoxosgi.org<br />Example project in...
Toast Dependencies<br />3<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made ...
get location<br />EmergencyMonitor<br />notify<br />EmergencyServlet<br />send<br />HTTP<br />GPS<br />log<br />Channel<br...
Versioning: Overview<br />Versioning<br />Evolving API<br />Tools<br />Issues<br />Summary<br />5<br />OSGi Versioning and...
Define Versioning<br />“Software versioning is the process of assigning either unique version names or unique version numb...
Versioning: User Perspective<br />7<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internatio...
Versioning: Dev Perspective<br />8<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internation...
OSGi Versions<br />Dependencies are defined on the module and package level<br />Import-Package<br />Require-Bundle<br />R...
OSGi Versioning Scheme<br />major.minor.micro.qualifier<br />major – An incompatible update; breaking API<br />minor – A b...
Bundle Versions in Eclipse<br />11<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internation...
Evolving API: GPS 1.0<br />12<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; m...
Log4j…<br />17<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available u...
Commons Collections !@#$<br />18<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International...
Developer Reaction…<br />19<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; mad...
Contracts are Important<br />Good fences make for good neighbors!<br />Binary compatibility* is important<br />20<br />OSG...
Tools<br />Binary compatibility is important<br />Maintaining binary compatibility is complex<br />Eclipse puts API on an ...
PDE API Tools<br />Assists developers in API maintenance by reporting API defects such as binary incompatibilities, incorr...
GPS Example using API Tools<br />23<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internatio...
Version Scheme Compliance<br />24<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internationa...
API Comparison<br />28<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made ava...
API Usage Report<br />30<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made a...
API Usage Report<br />31<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made a...
Issues<br />Getting proper version ranges correct is difficult if there’s no consistent semantics<br />e.g., log4j case<br...
Summary<br />OSGi versions encode compatibility!<br />Don’t treat bundle versions like a marketing number<br />Scope your ...
Testing: Overview<br />Good Practices<br />Sample Application<br />Unit Testing<br />System Testing<br />Remaining Issues<...
Good Practices: Testability<br />Write your application as POJOs(plain-old-java-objects)<br />No Service Trackers!<br />Wh...
Good Practices: Testing<br />Use Junit<br />Use mock objects (EasyMock, jMock...)<br />Minimize delays<br />No human inter...
Unit Testing: Overview<br />Terminology<br />Unit under test (UUT)<br />Test harness<br />Test each POJO on its own (no OS...
get location<br />EmergencyMonitor<br />notify<br />EmergencyServlet<br />send<br />HTTP<br />GPS<br />log<br />Channel<br...
UUT<br />test harness<br />Unit Testing: Example<br />39<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource...
Unit Testing: Test Case Project<br />Keep the test case in a separate project<br />But POJO is not visible<br />Solution:<...
Unit Testing: Test Case Project<br />41<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Intern...
Unit Testing: Test Case Code<br />42<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internati...
Unit Testing: Test Case Code<br />43<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internati...
Unit Testing: Test Case Code<br />44<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internati...
Unit Testing: Test Case Code<br />45<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internati...
Unit Testing: Running<br />46<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; m...
System Testing: Overview<br />Test as much of system as possible<br />OSGi is present<br />Test full system flow<br />Test...
UUT<br />get location<br />EmergencyMonitor<br />notify<br />EmergencyServlet<br />send<br />HTTP<br />GPS<br />?<br />log...
System Testing: Test Case Project<br />49<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Inte...
System Testing: Test Harness<br />50<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internati...
System Testing: Test Harness<br />51<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Internati...
System Testing:Competing Programming Models<br />PDE Junit test infrastructure<br />uses Equinoxextensions<br />Declarativ...
System Testing:PDE Junit Test Infrastructure<br />Junit instantiates the test case as usual<br />setup()<br />testEmergenc...
System Testing:Declarative Services<br />Instantiates the test case as a component<br />DS dependency injection<br />setAi...
System Testing: Test Case Code<br />55<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Interna...
System Testing: Test Case Code<br />56<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI Interna...
System Testing:Launch Configuration<br />57<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI In...
Remaining Issues<br />Still very tricky<br />Not well-supported by PDE tooling<br />Validation by logging is fragile<br />...
Availability<br />Get the slides: tinyurl.com/osgiVT<br />Get the code: wiki.eclipse.org/Toast<br />Get the book: equinoxo...
Sample Application:Emergency Scenario<br />60<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI ...
OSGi Versioning And Testing
OSGi Versioning And Testing
OSGi Versioning And Testing
OSGi Versioning And Testing
OSGi Versioning And Testing
OSGi Versioning And Testing
OSGi Versioning And Testing
Upcoming SlideShare
Loading in …5
×

OSGi Versioning And Testing

1,608
-1

Published on

Slides from the Eclipse Summit Europe talk by Chris Aniszczyk and Paul VanderLei on October 28, 2009.

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,608
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
27
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

OSGi Versioning And Testing

  1. 1. OSGi Versioning and Testing<br />Chris AniszczykEclipseSource<br />http://aniszczyk.org<br />Paul VanderLei<br />Band XI International<br />
  2. 2. Sample Application: Toast<br />Telematics-On-A-STick<br />Sample from upcoming bookequinoxosgi.org<br />Example project in EclipseRTwiki.eclipse.org/Toast<br />2<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  3. 3. Toast Dependencies<br />3<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />EmergencyMonitor<br />EmergencyServlet<br />GPS<br />Channel<br />Airbag<br />Log<br />
  4. 4. get location<br />EmergencyMonitor<br />notify<br />EmergencyServlet<br />send<br />HTTP<br />GPS<br />log<br />Channel<br />Log<br />Toast: Emergency Scenario<br />4<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Airbag<br />
  5. 5. Versioning: Overview<br />Versioning<br />Evolving API<br />Tools<br />Issues<br />Summary<br />5<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  6. 6. Define Versioning<br />“Software versioning is the process of assigning either unique version names or unique version numbers to unique states of computer software.”<br />Versioning is relative though…<br />6<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  7. 7. Versioning: User Perspective<br />7<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Versioning is a marketing thing…<br />User’s don’t really care about versions…<br />Users just want to know if the version of the software they are running is current…<br />e.g., Ubuntu<br />Feisty Fawn – 7.04<br />Gutsy Gibbon – 7.10<br />Hardy Heron – 8.04<br />
  8. 8. Versioning: Dev Perspective<br />8<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Version numbers are like dog tags*<br />Primarily used in an event of emergency…<br />*http://www.codinghorror.com/blog/archives/000793.html<br />
  9. 9. OSGi Versions<br />Dependencies are defined on the module and package level<br />Import-Package<br />Require-Bundle<br />Ranges allow for flexibility<br />Import-Package: org.easymock;version=[2.4.0,3.0.0)<br />9<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  10. 10. OSGi Versioning Scheme<br />major.minor.micro.qualifier<br />major – An incompatible update; breaking API<br />minor – A backward compatible update; API stable<br />micro – A bug fix; no API changes<br />qualifier – build date; lexigraphic<br />Versions should encode compatibility* at the bundle and package level<br />10<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />*http://wiki.eclipse.org/Version_Numbering<br />
  11. 11. Bundle Versions in Eclipse<br />11<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Notice how the version numbers don’t necessarily match the 3.6 release?<br />
  12. 12. Evolving API: GPS 1.0<br />12<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>Let’s evolve our GPS API…</li></li></ul><li>Evolving API: GPS 1.1<br />13<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>Toast on a plane… we add height…</li></li></ul><li>Evolving API: GPS 1.2?<br />14<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>Management now wants an altimeter!</li></li></ul><li>Evolving API: GPS 2.0<br />15<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>We broke API, need to fix versions!</li></li></ul><li>Managing Versions<br />Managing versions is important and painful<br />At Eclipse, we learned this quickly…<br />Other projects eventually learn this…<br />16<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  13. 13. Log4j…<br />17<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  14. 14. Commons Collections !@#$<br />18<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />“Commons collections 3.0 is binary compatible with version 2.1 and 2.0 except for certain methods on one class . As the release was a major version, this is permitted, however it was unintentional and an error… the chosen solution is to provide a work around by releasing v2.1.1 and v3.1.”<br />http://commons.apache.org/collections/compatibility.html<br />
  15. 15. Developer Reaction…<br />19<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  16. 16. Contracts are Important<br />Good fences make for good neighbors!<br />Binary compatibility* is important<br />20<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  17. 17. Tools<br />Binary compatibility is important<br />Maintaining binary compatibility is complex<br />Eclipse puts API on an altar…<br />Since Eclipse 3.4, Eclipse uses tools to manage and evolve API…<br />21<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />*http://java.sun.com/docs/books/jls/second_edition/html/binaryComp.doc.html<br />
  18. 18. PDE API Tools<br />Assists developers in API maintenance by reporting API defects such as binary incompatibilities, incorrect bundle version numbers and API usage.<br />Let’s see an example…<br />22<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  19. 19. GPS Example using API Tools<br />23<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />We need height!<br />
  20. 20. Version Scheme Compliance<br />24<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>Version number problems and quickfixes…</li></li></ul><li>Binary Compatibility Compliance<br />25<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>Let’s unknowingly break API…</li></li></ul><li>Version Compliance Checking<br />26<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>Never break API again unless you want to!</li></li></ul><li>API Comparison<br />27<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  21. 21. API Comparison<br />28<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br /><ul><li>Understand API changes…</li></li></ul><li>API Usage Scan<br />29<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Understand who uses your API given a set of bundles<br />
  22. 22. API Usage Report<br />30<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />22 GPS API References<br />
  23. 23. API Usage Report<br />31<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />API Reference Details<br />
  24. 24. Issues<br />Getting proper version ranges correct is difficult if there’s no consistent semantics<br />e.g., log4j case<br />Not all bundles are versioned properly in repositories<br />Tooling doesn’t cover packages yet…<br />32<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  25. 25. Summary<br />OSGi versions encode compatibility!<br />Don’t treat bundle versions like a marketing number<br />Scope your version ranges properly<br />33<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  26. 26. Testing: Overview<br />Good Practices<br />Sample Application<br />Unit Testing<br />System Testing<br />Remaining Issues<br />34<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  27. 27. Good Practices: Testability<br />Write your application as POJOs(plain-old-java-objects)<br />No Service Trackers!<br />Whiteboard Pattern is tricky<br />Pay attention to dependencies<br />Unit testing depends on getting this right<br />35<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  28. 28. Good Practices: Testing<br />Use Junit<br />Use mock objects (EasyMock, jMock...)<br />Minimize delays<br />No human interaction<br />Do TDD<br />36<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />“…I think that developers who can’t cope with any level of TDD shouldn’t be coding at all…”<br />
  29. 29. Unit Testing: Overview<br />Terminology<br />Unit under test (UUT)<br />Test harness<br />Test each POJO on its own (no OSGi)<br />Mock each dependency<br />37<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  30. 30. get location<br />EmergencyMonitor<br />notify<br />EmergencyServlet<br />send<br />HTTP<br />GPS<br />log<br />Channel<br />Log<br />Toast: Emergency Scenario<br />38<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Airbag<br />
  31. 31. UUT<br />test harness<br />Unit Testing: Example<br />39<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />get location<br />EmergencyMonitor<br />notify<br />EmergencyServlet<br />send<br />GPS<br />MockGPS<br />Channel<br />MockChannel<br />Airbag<br />MockAirbag<br />Log<br />
  32. 32. Unit Testing: Test Case Project<br />Keep the test case in a separate project<br />But POJO is not visible<br />Solution:<br />40<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />fragment bundle<br />
  33. 33. Unit Testing: Test Case Project<br />41<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Dependencies<br />Junit & EasyMock<br />dependencyinterfaces<br />
  34. 34. Unit Testing: Test Case Code<br />42<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />createUUT<br />createmock GPS<br />
  35. 35. Unit Testing: Test Case Code<br />43<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />createmock airbag<br />
  36. 36. Unit Testing: Test Case Code<br />44<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />createmock channel<br />
  37. 37. Unit Testing: Test Case Code<br />45<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />runthe test<br />
  38. 38. Unit Testing: Running<br />46<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  39. 39. System Testing: Overview<br />Test as much of system as possible<br />OSGi is present<br />Test full system flow<br />Test bundles coming and going<br />47<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  40. 40. UUT<br />get location<br />EmergencyMonitor<br />notify<br />EmergencyServlet<br />send<br />HTTP<br />GPS<br />?<br />log<br />Channel<br />test harness<br />Log<br />MockLog<br />System Testing: Example<br />48<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />deploy<br />Airbag<br />MockAirbag<br />verify<br />TestCase<br />
  41. 41. System Testing: Test Case Project<br />49<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Normal Plug-in Project<br />declares 3 components<br />
  42. 42. System Testing: Test Harness<br />50<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />hook for testing<br />
  43. 43. System Testing: Test Harness<br />51<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />hook for testing<br />
  44. 44. System Testing:Competing Programming Models<br />PDE Junit test infrastructure<br />uses Equinoxextensions<br />Declarative Services<br />uses OSGi services<br />52<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />VS<br />
  45. 45. System Testing:PDE Junit Test Infrastructure<br />Junit instantiates the test case as usual<br />setup()<br />testEmergency()<br />Problem: no way to obtain:<br />bundle context<br />mock airbag<br />mock log<br />53<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  46. 46. System Testing:Declarative Services<br />Instantiates the test case as a component<br />DS dependency injection<br />setAirbag(&lt;our mock airbag&gt;)<br />setLog(&lt;our mock log&gt;)<br />startup()<br />Problem:<br />This instance is never used by Junit!<br />54<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  47. 47. System Testing: Test Case Code<br />55<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />instances share these<br />DS invokes these<br />DS invokes these<br />DS invokes these<br />ready to run test case<br />
  48. 48. System Testing: Test Case Code<br />56<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />wait until DS has activated<br />normaltest<br />stop GPS bundle<br />start GPS bundle<br />
  49. 49. System Testing:Launch Configuration<br />57<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  50. 50. Remaining Issues<br />Still very tricky<br />Not well-supported by PDE tooling<br />Validation by logging is fragile<br />58<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />
  51. 51. Availability<br />Get the slides: tinyurl.com/osgiVT<br />Get the code: wiki.eclipse.org/Toast<br />Get the book: equinoxosgi.org<br />59<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />Questions?<br />
  52. 52. Sample Application:Emergency Scenario<br />60<br />OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0<br />EmergencyMonitor<br />EmergencyServlet<br />GPS<br />Channel<br />Airbag<br />Log<br />

×