Chris Aniszczyk EclipseSource http://aniszczyk.org Paul VanderLei Band XI International
T elematics - O n- A - ST ick Sample from upcoming book equinoxosgi.org Example project in EclipseRT wiki.eclipse.org/Toast OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Emergency Monitor Emergency Servlet GPS Channel Airbag Log
log get location OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Log Emergency Servlet Channel GPS Emergency Monitor Airbag
Versioning Evolving API Tools Issues Summary OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
“ Software versioning is the process of assigning either unique version names or unique version numbers to unique states of computer software.” Versioning is relative though… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Versioning is a marketing thing… User’s don’t really care about versions… Users just want to know if the version of the software they are running is current… e.g., Ubuntu Feisty Fawn – 7.04 Gutsy Gibbon – 7.10 Hardy Heron – 8.04 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Version numbers are like  dog tags * Primarily used in an event of emergency… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 * http://www.codinghorror.com/blog/archives/000793.html
Dependencies are defined on the module and package level Import-Package Require-Bundle Ranges allow for flexibility Import-Package: org.easymock;version=[2.4.0,3.0.0) OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
major.minor.micro.qualifier major – An incompatible update; breaking API minor – A backward compatible update; API stable micro – A bug fix; no API changes qualifier – build date; lexigraphic Versions should encode  compatibility*  at the bundle and package level OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 *http://wiki.eclipse.org/Version_Numbering
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Notice how the version numbers don’t necessarily match the 3.6 release?
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Let’s evolve our GPS API…
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Toast on a plane… we add height…
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Management now wants an altimeter!
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 We broke API, need to fix versions!
Managing versions is important and painful At Eclipse, we learned this lesson and have many experiences in dealing with maintaining and evolving API Other projects eventually learn the importance of versioning… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 “ I still believe a an official compatibility statement are in order. It  includes a definition of the API and a separate definition of the SPI, and possible a third definition of the Configuration. I bet everyone would back such statement, would clarify the "unbreakable“ parts, and what is "features of your own risk" and so on.”
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 http://commons.apache.org/collections/compatibility.html “ 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.”
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Users need to understand the contract when using your software… Good fences make for good neighbors! Binary compatibility is important OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Binary compatibility is important Maintaining binary compatibility is complex Eclipse puts API on an altar… Since Eclipse 3.4, Eclipse uses tools to manage and evolve API… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 *http://java.sun.com/docs/books/jls/second_edition/html/binaryComp.doc.html
Assists developers in API maintenance by reporting API defects such as binary incompatibilities, incorrect bundle version numbers and API usage. Let’s revisit the GPS example… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Version number problems and quickfixes…
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Let’s  unknowingly  break API…
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Never break API again unless you want to!
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Understand API changes…
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Getting proper version ranges correct is difficult if there’s no consistent semantics e.g., log4j case… [1.2.0,1.3.0) or [1.2.0,2.0.0) ? Not all bundles are versioned properly in repositories Tooling doesn’t cover packages yet… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi versions encode compatibility! Don’t treat bundle versions like a marketing number Scope your version ranges properly OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Good Practices Sample Application Unit Testing System Testing Remaining Issues OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Write your application as POJOs (plain-old-java-objects) No Service Trackers! Whiteboard Pattern is tricky Pay attention to dependencies Unit testing depends on getting this right OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Use Junit Use mock objects (EasyMock, jMock...) Minimize delays No human interaction Do TDD OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 “… I think that developers who can’t cope with any level of TDD shouldn’t be coding at all…”
Terminology Unit under test (UUT) Test harness Test each POJO on its own (no OSGi) Mock each dependency OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
log get location OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Log Emergency Servlet Channel GPS Emergency Monitor Airbag
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 get location Log Emergency Servlet GPS Channel Airbag Mock GPS Mock Channel Emergency Monitor Mock Airbag
Keep the test case in a separate project But POJO is not visible Solution: OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Dependencies OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Test as much of system as possible OSGi is present Test full system flow Test bundles coming and going OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
log get location OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 deploy Log Mock Log Emergency Servlet Channel GPS Emergency Monitor Airbag Mock Airbag Test Case
Normal Plug-in Project OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
PDE Junit test infrastructure uses Equinox extensions Declarative Services uses OSGi services OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Junit instantiates the test case as usual setup() testEmergency() Problem: no way to obtain: bundle context mock airbag mock log OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Instantiates the test case as a component DS dependency injection setAirbag(<our mock airbag>) setLog(<our mock log>) startup() Problem: This instance is never used by Junit! OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Still very tricky Not well-supported by PDE tooling Validation by logging is fragile OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Get the slides:  tinyurl.com/osgiVT Get the code:  wiki.eclipse.org/Toast Get the book:  equinoxosgi.org OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0

OSGi Versioning & Testing

  • 1.
    Chris Aniszczyk EclipseSourcehttp://aniszczyk.org Paul VanderLei Band XI International
  • 2.
    T elematics -O n- A - ST ick Sample from upcoming book equinoxosgi.org Example project in EclipseRT wiki.eclipse.org/Toast OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 3.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Emergency Monitor Emergency Servlet GPS Channel Airbag Log
  • 4.
    log get locationOSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Log Emergency Servlet Channel GPS Emergency Monitor Airbag
  • 5.
    Versioning Evolving APITools Issues Summary OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 6.
    “ Software versioningis the process of assigning either unique version names or unique version numbers to unique states of computer software.” Versioning is relative though… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 7.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 8.
    Versioning is amarketing thing… User’s don’t really care about versions… Users just want to know if the version of the software they are running is current… e.g., Ubuntu Feisty Fawn – 7.04 Gutsy Gibbon – 7.10 Hardy Heron – 8.04 OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 9.
    Version numbers arelike dog tags * Primarily used in an event of emergency… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 * http://www.codinghorror.com/blog/archives/000793.html
  • 10.
    Dependencies are definedon the module and package level Import-Package Require-Bundle Ranges allow for flexibility Import-Package: org.easymock;version=[2.4.0,3.0.0) OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 11.
    major.minor.micro.qualifier major –An incompatible update; breaking API minor – A backward compatible update; API stable micro – A bug fix; no API changes qualifier – build date; lexigraphic Versions should encode compatibility* at the bundle and package level OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 *http://wiki.eclipse.org/Version_Numbering
  • 12.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Notice how the version numbers don’t necessarily match the 3.6 release?
  • 13.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Let’s evolve our GPS API…
  • 14.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Toast on a plane… we add height…
  • 15.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Management now wants an altimeter!
  • 16.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 We broke API, need to fix versions!
  • 17.
    Managing versions isimportant and painful At Eclipse, we learned this lesson and have many experiences in dealing with maintaining and evolving API Other projects eventually learn the importance of versioning… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 18.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 “ I still believe a an official compatibility statement are in order. It includes a definition of the API and a separate definition of the SPI, and possible a third definition of the Configuration. I bet everyone would back such statement, would clarify the &quot;unbreakable“ parts, and what is &quot;features of your own risk&quot; and so on.”
  • 19.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 http://commons.apache.org/collections/compatibility.html “ 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.”
  • 20.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 21.
    Users need tounderstand the contract when using your software… Good fences make for good neighbors! Binary compatibility is important OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 22.
    Binary compatibility isimportant Maintaining binary compatibility is complex Eclipse puts API on an altar… Since Eclipse 3.4, Eclipse uses tools to manage and evolve API… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 *http://java.sun.com/docs/books/jls/second_edition/html/binaryComp.doc.html
  • 23.
    Assists developers inAPI maintenance by reporting API defects such as binary incompatibilities, incorrect bundle version numbers and API usage. Let’s revisit the GPS example… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 24.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 25.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Version number problems and quickfixes…
  • 26.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Let’s unknowingly break API…
  • 27.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Never break API again unless you want to!
  • 28.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 29.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Understand API changes…
  • 30.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 31.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 32.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 33.
    Getting proper versionranges correct is difficult if there’s no consistent semantics e.g., log4j case… [1.2.0,1.3.0) or [1.2.0,2.0.0) ? Not all bundles are versioned properly in repositories Tooling doesn’t cover packages yet… OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 34.
    OSGi versions encodecompatibility! Don’t treat bundle versions like a marketing number Scope your version ranges properly OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 35.
    Good Practices SampleApplication Unit Testing System Testing Remaining Issues OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 36.
    Write your applicationas POJOs (plain-old-java-objects) No Service Trackers! Whiteboard Pattern is tricky Pay attention to dependencies Unit testing depends on getting this right OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 37.
    Use Junit Usemock objects (EasyMock, jMock...) Minimize delays No human interaction Do TDD OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 “… I think that developers who can’t cope with any level of TDD shouldn’t be coding at all…”
  • 38.
    Terminology Unit undertest (UUT) Test harness Test each POJO on its own (no OSGi) Mock each dependency OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 39.
    log get locationOSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 Log Emergency Servlet Channel GPS Emergency Monitor Airbag
  • 40.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 get location Log Emergency Servlet GPS Channel Airbag Mock GPS Mock Channel Emergency Monitor Mock Airbag
  • 41.
    Keep the testcase in a separate project But POJO is not visible Solution: OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 42.
    Dependencies OSGi Versioningand Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 43.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 44.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 45.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 46.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 47.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 48.
    Test as muchof system as possible OSGi is present Test full system flow Test bundles coming and going OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 49.
    log get locationOSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0 deploy Log Mock Log Emergency Servlet Channel GPS Emergency Monitor Airbag Mock Airbag Test Case
  • 50.
    Normal Plug-in ProjectOSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 51.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 52.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 53.
    PDE Junit testinfrastructure uses Equinox extensions Declarative Services uses OSGi services OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 54.
    Junit instantiates thetest case as usual setup() testEmergency() Problem: no way to obtain: bundle context mock airbag mock log OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 55.
    Instantiates the testcase as a component DS dependency injection setAirbag(<our mock airbag>) setLog(<our mock log>) startup() Problem: This instance is never used by Junit! OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 56.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 57.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 58.
    OSGi Versioning andTesting | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 59.
    Still very trickyNot well-supported by PDE tooling Validation by logging is fragile OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 60.
    Get the slides: tinyurl.com/osgiVT Get the code: wiki.eclipse.org/Toast Get the book: equinoxosgi.org OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0