SlideShare a Scribd company logo
OSGi Versioning and TestingChris AniszczykEclipseSourcehttp://aniszczyk.orgPaul VanderLeiBand XI International
Sample Application: ToastTelematics-On-A-STickSample from upcoming bookequinoxosgi.orgExample project in EclipseRTwiki.eclipse.org/Toast2OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Toast Dependencies3OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0EmergencyMonitorEmergencyServletGPSChannelAirbagLog
get locationEmergencyMonitornotifyEmergencyServletsendHTTPGPSlogChannelLogToast: Emergency Scenario4OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Airbag
Versioning: OverviewVersioningEvolving APIToolsIssuesSummary5OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Define Versioning“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…6OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Versioning: User Perspective7OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Versioning 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., UbuntuFeisty Fawn – 7.04Gutsy Gibbon – 7.10Hardy Heron – 8.04
Versioning: Dev Perspective8OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Version numbers are like dog tags*Primarily used in an event of emergency…*http://www.codinghorror.com/blog/archives/000793.html
OSGi VersionsDependencies are defined on the module and package levelImport-PackageRequire-BundleRanges allow for flexibilityImport-Package: org.easymock;version=[2.4.0,3.0.0)9OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
OSGi Versioning Schememajor.minor.micro.qualifiermajor – An incompatible update; breaking APIminor – A backward compatible update; API stablemicro – A bug fix; no API changesqualifier – build date; lexigraphicVersions should encode compatibility* at the bundle and package level10OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0*http://wiki.eclipse.org/Version_Numbering
Bundle Versions in Eclipse11OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Notice how the version numbers don’t necessarily match the 3.6 release?
Evolving API: GPS 1.012OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Let’s evolve our GPS API…Evolving API: GPS 1.113OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Toast on a plane… we add height…Evolving API: GPS 1.2?14OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Management now wants an altimeter!Evolving API: GPS 2.015OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0We broke API, need to fix versions!Managing VersionsManaging versions is important and painfulAt Eclipse, we learned this quickly…Other projects eventually learn this…16OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Log4j…17OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Commons Collections !@#$18OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0“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.”http://commons.apache.org/collections/compatibility.html
Developer Reaction…19OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Contracts are ImportantGood fences make for good neighbors!Binary compatibility* is important20OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
ToolsBinary compatibility is importantMaintaining binary compatibility is complexEclipse puts API on an altar…Since Eclipse 3.4, Eclipse uses tools to manage and evolve API…21OSGi 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
PDE API ToolsAssists developers in API maintenance by reporting API defects such as binary incompatibilities, incorrect bundle version numbers and API usage.Let’s see an example…22OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
GPS Example using API Tools23OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0We need height!
Version Scheme Compliance24OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Version number problems and quickfixes…Binary Compatibility Compliance25OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Let’s unknowingly break API…Version Compliance Checking26OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Never break API again unless you want to!API Comparison27OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
API Comparison28OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Understand API changes…API Usage Scan29OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Understand who uses your API given a set of bundles
API Usage Report30OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.022 GPS API References
API Usage Report31OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0API Reference Details
IssuesGetting proper version ranges correct is difficult if there’s no consistent semanticse.g., log4j caseNot all bundles are versioned properly in repositoriesTooling doesn’t cover packages yet…32OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
SummaryOSGi versions encode compatibility!Don’t treat bundle versions like a marketing numberScope your version ranges properly33OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Testing: OverviewGood PracticesSample ApplicationUnit TestingSystem TestingRemaining Issues34OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Good Practices: TestabilityWrite your application as POJOs(plain-old-java-objects)No Service Trackers!Whiteboard Pattern is trickyPay attention to dependenciesUnit testing depends on getting this right35OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Good Practices: TestingUse JunitUse mock objects (EasyMock, jMock...)Minimize delaysNo human interactionDo TDD36OSGi 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…”
Unit Testing: OverviewTerminologyUnit under test (UUT)Test harnessTest each POJO on its own (no OSGi)Mock each dependency37OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
get locationEmergencyMonitornotifyEmergencyServletsendHTTPGPSlogChannelLogToast: Emergency Scenario38OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Airbag
UUTtest harnessUnit Testing: Example39OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0get locationEmergencyMonitornotifyEmergencyServletsendGPSMockGPSChannelMockChannelAirbagMockAirbagLog
Unit Testing: Test Case ProjectKeep the test case in a separate projectBut POJO is not visibleSolution:40OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0fragment bundle
Unit Testing: Test Case Project41OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0DependenciesJunit & EasyMockdependencyinterfaces
Unit Testing: Test Case Code42OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0createUUTcreatemock GPS
Unit Testing: Test Case Code43OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0createmock airbag
Unit Testing: Test Case Code44OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0createmock channel
Unit Testing: Test Case Code45OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0runthe test
Unit Testing: Running46OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
System Testing: OverviewTest as much of system as possibleOSGi is presentTest full system flowTest bundles coming and going47OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
UUTget locationEmergencyMonitornotifyEmergencyServletsendHTTPGPS?logChanneltest harnessLogMockLogSystem Testing: Example48OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0deployAirbagMockAirbagverifyTestCase
System Testing: Test Case Project49OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Normal Plug-in Projectdeclares 3 components
System Testing: Test Harness50OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0hook for testing
System Testing: Test Harness51OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0hook for testing
System Testing:Competing Programming ModelsPDE Junit test infrastructureuses EquinoxextensionsDeclarative Servicesuses OSGi services52OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0VS
System Testing:PDE Junit Test InfrastructureJunit instantiates the test case as usualsetup()testEmergency()Problem: no way to obtain:bundle contextmock airbagmock log53OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
System Testing:Declarative ServicesInstantiates the test case as a componentDS dependency injectionsetAirbag(<our mock airbag>)setLog(<our mock log>)startup()Problem:This instance is never used by Junit!54OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
System Testing: Test Case Code55OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0instances share theseDS invokes theseDS invokes theseDS invokes theseready to run test case
System Testing: Test Case Code56OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0wait until DS has activatednormalteststop GPS bundlestart GPS bundle
System Testing:Launch Configuration57OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
Remaining IssuesStill very trickyNot well-supported by PDE toolingValidation by logging is fragile58OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
AvailabilityGet the slides: tinyurl.com/osgiVTGet the code: wiki.eclipse.org/ToastGet the book: equinoxosgi.org59OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Questions?
Sample Application:Emergency Scenario60OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0EmergencyMonitorEmergencyServletGPSChannelAirbagLog
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

More Related Content

PDF
Riena onrap econ-2011
PDF
Swt qt econ-2010
PDF
Riena on-e4-ese2010
PDF
Swt qt ese-2009
PDF
Orion RESTful git API
PPTX
Experiences from porting a commercial RCP application to Eclipse 4.x
KEY
What's New in Plug-in Development (Galileo)
PPTX
Building Eclipse Plugins and RCP applications with Tycho
Riena onrap econ-2011
Swt qt econ-2010
Riena on-e4-ese2010
Swt qt ese-2009
Orion RESTful git API
Experiences from porting a commercial RCP application to Eclipse 4.x
What's New in Plug-in Development (Galileo)
Building Eclipse Plugins and RCP applications with Tycho

What's hot (20)

PPTX
Tycho Tutorial EclipseCon 2013
PPTX
Tycho Tutorial (EclipseCon 2012)
PDF
P2 Introduction
PPT
Eclipse 3.7 : Tips and tricks
PDF
15 EMF projects in 25 minutes
PDF
Maven 3 / Tycho
KEY
Tycho - Building plug-ins with Maven
PPTX
Google ART (Android RunTime)
PDF
Appcelerator: iOS 10, Titanium SDK & Hyperloop
PDF
What the heck is Eclipse Modeling and why should you care !
PDF
Composing Music in the Cloud
PDF
Android and OSGi Can They Work Together - BJ Hargrave & Neil Bartlett
PDF
Docker for Software Development
PDF
GEF SVG export in JWT: a newcomer’s rocky ride to Eclipse
PDF
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
PPT
Compare framework
PDF
Appcelerator Hyperloop: Overview, Architecture & Demo
PDF
Cross-Platform App Development with Flutter, Xamarin, React Native
PPTX
How to Game a Geocoding API on Amazon and achieve High-Scores with FME
PDF
Python on Android with Delphi FMX - The Cross Platform GUI Framework
Tycho Tutorial EclipseCon 2013
Tycho Tutorial (EclipseCon 2012)
P2 Introduction
Eclipse 3.7 : Tips and tricks
15 EMF projects in 25 minutes
Maven 3 / Tycho
Tycho - Building plug-ins with Maven
Google ART (Android RunTime)
Appcelerator: iOS 10, Titanium SDK & Hyperloop
What the heck is Eclipse Modeling and why should you care !
Composing Music in the Cloud
Android and OSGi Can They Work Together - BJ Hargrave & Neil Bartlett
Docker for Software Development
GEF SVG export in JWT: a newcomer’s rocky ride to Eclipse
Android on Windows 11 - A Developer's Perspective (Windows Subsystem For Andr...
Compare framework
Appcelerator Hyperloop: Overview, Architecture & Demo
Cross-Platform App Development with Flutter, Xamarin, React Native
How to Game a Geocoding API on Amazon and achieve High-Scores with FME
Python on Android with Delphi FMX - The Cross Platform GUI Framework
Ad

Viewers also liked (16)

PPT
Cronologia Tdt
PPTX
Econ775PP1
PDF
Week5
PPT
Tallet Fem
PDF
Week12 Pre
PPT
Mid Term Unfront Analysis
PDF
Week7
PDF
Week9.Pre
PPT
Final Presentation
PDF
Week6
PDF
Week11.Pre
PPT
PPT
PPTX
Np Project Deliverable
PDF
Week10
PPT
Mid Term Unfront Analysis
Cronologia Tdt
Econ775PP1
Week5
Tallet Fem
Week12 Pre
Mid Term Unfront Analysis
Week7
Week9.Pre
Final Presentation
Week6
Week11.Pre
Np Project Deliverable
Week10
Mid Term Unfront Analysis
Ad

Similar to OSGi Versioning And Testing (20)

PPT
OSGi Versioning & Testing
ODP
OSGi Sticker Shock Eclipse Con 2010
KEY
Introduction to EclipseRT (JAX 2010)
KEY
OSGi, Eclipse and API Tooling
PDF
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
PPTX
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
PPTX
Automated Versioning In OSGi
PDF
Safe Bundle Updates
PPT
Managing Change
PPTX
EclipseCON2012 - Enterprise OSGi for Earthlings: Meet Eclipse Libra
PPTX
Introduction to OSGGi
PDF
JavaOne 2012, OSGi for the Earthlings: Meet Eclipse Libra
PDF
Eclipse_Building_Blocks
PDF
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
PDF
Jax london 2011
PDF
Create *real* modular Java applications - a brief introduction -
PDF
Enterprise OSGi at eBay
PDF
Best Practices for (Enterprise) OSGi applications - Tim Ward
PDF
Introduction to OSGi
PDF
OSGi for outsiders - Milen Dyankov
OSGi Versioning & Testing
OSGi Sticker Shock Eclipse Con 2010
Introduction to EclipseRT (JAX 2010)
OSGi, Eclipse and API Tooling
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
Java 9 Modules: The Duke Yet Lives That OSGi Shall Depose
Automated Versioning In OSGi
Safe Bundle Updates
Managing Change
EclipseCON2012 - Enterprise OSGi for Earthlings: Meet Eclipse Libra
Introduction to OSGGi
JavaOne 2012, OSGi for the Earthlings: Meet Eclipse Libra
Eclipse_Building_Blocks
Java Core | Java 8 and OSGi Modularisation | Tim Ellison & Neil Bartlett
Jax london 2011
Create *real* modular Java applications - a brief introduction -
Enterprise OSGi at eBay
Best Practices for (Enterprise) OSGi applications - Tim Ward
Introduction to OSGi
OSGi for outsiders - Milen Dyankov

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Electronic commerce courselecture one. Pdf
PDF
Approach and Philosophy of On baking technology
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
KodekX | Application Modernization Development
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
cuic standard and advanced reporting.pdf
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPT
Teaching material agriculture food technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Modernizing your data center with Dell and AMD
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PPTX
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Electronic commerce courselecture one. Pdf
Approach and Philosophy of On baking technology
20250228 LYD VKU AI Blended-Learning.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KodekX | Application Modernization Development
Chapter 3 Spatial Domain Image Processing.pdf
cuic standard and advanced reporting.pdf
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Teaching material agriculture food technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Modernizing your data center with Dell and AMD
Digital-Transformation-Roadmap-for-Companies.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
The Rise and Fall of 3GPP – Time for a Sabbatical?
Big Data Technologies - Introduction.pptx

OSGi Versioning And Testing

  • 1. OSGi Versioning and TestingChris AniszczykEclipseSourcehttp://aniszczyk.orgPaul VanderLeiBand XI International
  • 2. Sample Application: ToastTelematics-On-A-STickSample from upcoming bookequinoxosgi.orgExample project in EclipseRTwiki.eclipse.org/Toast2OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 3. Toast Dependencies3OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0EmergencyMonitorEmergencyServletGPSChannelAirbagLog
  • 4. get locationEmergencyMonitornotifyEmergencyServletsendHTTPGPSlogChannelLogToast: Emergency Scenario4OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Airbag
  • 5. Versioning: OverviewVersioningEvolving APIToolsIssuesSummary5OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 6. Define Versioning“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…6OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 7. Versioning: User Perspective7OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Versioning 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., UbuntuFeisty Fawn – 7.04Gutsy Gibbon – 7.10Hardy Heron – 8.04
  • 8. Versioning: Dev Perspective8OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Version numbers are like dog tags*Primarily used in an event of emergency…*http://www.codinghorror.com/blog/archives/000793.html
  • 9. OSGi VersionsDependencies are defined on the module and package levelImport-PackageRequire-BundleRanges allow for flexibilityImport-Package: org.easymock;version=[2.4.0,3.0.0)9OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 10. OSGi Versioning Schememajor.minor.micro.qualifiermajor – An incompatible update; breaking APIminor – A backward compatible update; API stablemicro – A bug fix; no API changesqualifier – build date; lexigraphicVersions should encode compatibility* at the bundle and package level10OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0*http://wiki.eclipse.org/Version_Numbering
  • 11. Bundle Versions in Eclipse11OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Notice how the version numbers don’t necessarily match the 3.6 release?
  • 12. Evolving API: GPS 1.012OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Let’s evolve our GPS API…Evolving API: GPS 1.113OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Toast on a plane… we add height…Evolving API: GPS 1.2?14OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Management now wants an altimeter!Evolving API: GPS 2.015OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0We broke API, need to fix versions!Managing VersionsManaging versions is important and painfulAt Eclipse, we learned this quickly…Other projects eventually learn this…16OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 13. Log4j…17OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 14. Commons Collections !@#$18OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0“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.”http://commons.apache.org/collections/compatibility.html
  • 15. Developer Reaction…19OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 16. Contracts are ImportantGood fences make for good neighbors!Binary compatibility* is important20OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 17. ToolsBinary compatibility is importantMaintaining binary compatibility is complexEclipse puts API on an altar…Since Eclipse 3.4, Eclipse uses tools to manage and evolve API…21OSGi 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
  • 18. PDE API ToolsAssists developers in API maintenance by reporting API defects such as binary incompatibilities, incorrect bundle version numbers and API usage.Let’s see an example…22OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 19. GPS Example using API Tools23OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0We need height!
  • 20. Version Scheme Compliance24OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Version number problems and quickfixes…Binary Compatibility Compliance25OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Let’s unknowingly break API…Version Compliance Checking26OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Never break API again unless you want to!API Comparison27OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 21. API Comparison28OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Understand API changes…API Usage Scan29OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Understand who uses your API given a set of bundles
  • 22. API Usage Report30OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.022 GPS API References
  • 23. API Usage Report31OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0API Reference Details
  • 24. IssuesGetting proper version ranges correct is difficult if there’s no consistent semanticse.g., log4j caseNot all bundles are versioned properly in repositoriesTooling doesn’t cover packages yet…32OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 25. SummaryOSGi versions encode compatibility!Don’t treat bundle versions like a marketing numberScope your version ranges properly33OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 26. Testing: OverviewGood PracticesSample ApplicationUnit TestingSystem TestingRemaining Issues34OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 27. Good Practices: TestabilityWrite your application as POJOs(plain-old-java-objects)No Service Trackers!Whiteboard Pattern is trickyPay attention to dependenciesUnit testing depends on getting this right35OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 28. Good Practices: TestingUse JunitUse mock objects (EasyMock, jMock...)Minimize delaysNo human interactionDo TDD36OSGi 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…”
  • 29. Unit Testing: OverviewTerminologyUnit under test (UUT)Test harnessTest each POJO on its own (no OSGi)Mock each dependency37OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 30. get locationEmergencyMonitornotifyEmergencyServletsendHTTPGPSlogChannelLogToast: Emergency Scenario38OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Airbag
  • 31. UUTtest harnessUnit Testing: Example39OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0get locationEmergencyMonitornotifyEmergencyServletsendGPSMockGPSChannelMockChannelAirbagMockAirbagLog
  • 32. Unit Testing: Test Case ProjectKeep the test case in a separate projectBut POJO is not visibleSolution:40OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0fragment bundle
  • 33. Unit Testing: Test Case Project41OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0DependenciesJunit & EasyMockdependencyinterfaces
  • 34. Unit Testing: Test Case Code42OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0createUUTcreatemock GPS
  • 35. Unit Testing: Test Case Code43OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0createmock airbag
  • 36. Unit Testing: Test Case Code44OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0createmock channel
  • 37. Unit Testing: Test Case Code45OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0runthe test
  • 38. Unit Testing: Running46OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 39. System Testing: OverviewTest as much of system as possibleOSGi is presentTest full system flowTest bundles coming and going47OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 40. UUTget locationEmergencyMonitornotifyEmergencyServletsendHTTPGPS?logChanneltest harnessLogMockLogSystem Testing: Example48OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0deployAirbagMockAirbagverifyTestCase
  • 41. System Testing: Test Case Project49OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Normal Plug-in Projectdeclares 3 components
  • 42. System Testing: Test Harness50OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0hook for testing
  • 43. System Testing: Test Harness51OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0hook for testing
  • 44. System Testing:Competing Programming ModelsPDE Junit test infrastructureuses EquinoxextensionsDeclarative Servicesuses OSGi services52OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0VS
  • 45. System Testing:PDE Junit Test InfrastructureJunit instantiates the test case as usualsetup()testEmergency()Problem: no way to obtain:bundle contextmock airbagmock log53OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 46. System Testing:Declarative ServicesInstantiates the test case as a componentDS dependency injectionsetAirbag(<our mock airbag>)setLog(<our mock log>)startup()Problem:This instance is never used by Junit!54OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 47. System Testing: Test Case Code55OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0instances share theseDS invokes theseDS invokes theseDS invokes theseready to run test case
  • 48. System Testing: Test Case Code56OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0wait until DS has activatednormalteststop GPS bundlestart GPS bundle
  • 49. System Testing:Launch Configuration57OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 50. Remaining IssuesStill very trickyNot well-supported by PDE toolingValidation by logging is fragile58OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0
  • 51. AvailabilityGet the slides: tinyurl.com/osgiVTGet the code: wiki.eclipse.org/ToastGet the book: equinoxosgi.org59OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0Questions?
  • 52. Sample Application:Emergency Scenario60OSGi Versioning and Testing | © Copyright 2009 EclipseSource & Band XI International; made available under EPL v1.0EmergencyMonitorEmergencyServletGPSChannelAirbagLog