Test Driven Development with OSGi

Balázs Zsoldos
Original motivation

Deployment time
2 minutes

Internet time
10 minutes
Coding time
Deployment time

Facebook time
“What was I doing?” time
Reduce
deployment
time

v3
“mvn package”
+

copy file

Iteration is faster, but not fast enough (compile + copy)
drop JAR

OR
Drop project

process
“target/classes”
Eclipse
+
maven-bundle-plugin
=
up-to-date “target/classes”
Richconsole deployment
OSGi container

StartLevel 10

Bundle A (startLevel=4)
Bundle B (startLevel=2)

A

StartLevel 2
B
Deployment time reduced

How can we have better quality?
The Three Laws of TDD
1.You are not allowed to write any production code until you have
2.You are not allowed to write mor...
External Blockers

External Test Engines
Framework Startup
Blocker

Blueprint
Blocker

JUnit4
TestEngine

Test runner
Blueprint / DS / creation from Acvtivator / ...
Test service
service.id=MyTest
service.testEngine=junit4

Test runner
JUni...
I do not want to re-run all tests during
development
In development mode only tests with
@TestMethodInDevelopmentMode or
@...
Test Code

Deploy / Run tests

Production code
Test Code

Deploy / Run tests

Production code

What will run the tests on Jenkins?
Maven repository

Get the dist package

eosgi-maven-plugin:dist
- Unpack dist package
- Parse with velocity
- Add the depe...
Maven repository

Get the dist package

eosgi-maven-plugin:integration-test
- Unpack dist package
- Parse with velocity
- ...
Maven plugin configuration
<plugin>
<groupId>org.everit.osgi.dev</groupId>
<artifactId>eosgi-maven-plugin</artifactId>
<ve...
Maven plugin configuration
<plugin>
<groupId>org.everit.osgi.dev</groupId>
<artifactId>eosgi-maven-plugin</artifactId>
<ve...
Maven plugin configuration
<plugin>
<groupId>org.everit.osgi.dev</groupId>
<artifactId>eosgi-maven-plugin</artifactId>
<ve...
Maven plugin configuration
<plugin>
<groupId>org.everit.osgi.dev</groupId>
<artifactId>eosgi-maven-plugin</artifactId>
<ve...
100% coverage
Let's see it in practice
Creating your own dist package
●

Look at the sample equinox package

●

Look at the .eosgi.dist.xml file

Look for the XS...
Thank you

balazs.zsoldos@everit.biz
E-mail:
http://github.com/everit-org
Source:
Maven repo: http://repository.everit.biz...
Test Driven Development with OSGi - Balázs Zsoldos
Upcoming SlideShare
Loading in...5
×

Test Driven Development with OSGi - Balázs Zsoldos

533

Published on

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

ABSTRACT

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

  • Be the first to like this

No Downloads
Views
Total Views
533
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
21
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Test Driven Development with OSGi - Balázs Zsoldos

  1. 1. Test Driven Development with OSGi Balázs Zsoldos
  2. 2. Original motivation Deployment time 2 minutes Internet time 10 minutes
  3. 3. Coding time Deployment time Facebook time “What was I doing?” time
  4. 4. Reduce deployment time v3
  5. 5. “mvn package” + copy file Iteration is faster, but not fast enough (compile + copy)
  6. 6. drop JAR OR Drop project process “target/classes”
  7. 7. Eclipse + maven-bundle-plugin = up-to-date “target/classes”
  8. 8. Richconsole deployment OSGi container StartLevel 10 Bundle A (startLevel=4) Bundle B (startLevel=2) A StartLevel 2 B
  9. 9. Deployment time reduced How can we have better quality?
  10. 10. The Three Laws of TDD 1.You are not allowed to write any production code until you have 2.You are not allowed to write more of a unit test than is sufficient 3.You are not allowed to write more production code that is suffici The Clean Coder (Chapter 5)
  11. 11. External Blockers External Test Engines Framework Startup Blocker Blueprint Blocker JUnit4 TestEngine Test runner
  12. 12. Blueprint / DS / creation from Acvtivator / ... Test service service.id=MyTest service.testEngine=junit4 Test runner JUnit4 TestEngine
  13. 13. I do not want to re-run all tests during development In development mode only tests with @TestMethodInDevelopmentMode or @TestClassInDevelopmentMode runs.
  14. 14. Test Code Deploy / Run tests Production code
  15. 15. Test Code Deploy / Run tests Production code What will run the tests on Jenkins?
  16. 16. Maven repository Get the dist package eosgi-maven-plugin:dist - Unpack dist package - Parse with velocity - Add the dependencies File system
  17. 17. Maven repository Get the dist package eosgi-maven-plugin:integration-test - Unpack dist package - Parse with velocity - Add the dependencies - with testrunner - as symbolic links Start the container Collect test results File system
  18. 18. Maven plugin configuration <plugin> <groupId>org.everit.osgi.dev</groupId> <artifactId>eosgi-maven-plugin</artifactId> <version>1.1.3-SNAPSHOT</version> <configuration> <environments> <environment> <id>equinoxtest</id> <framework>equinox</framework> </environment> </environments> </configuration> </plugin> # Default environments in META-INF/eosgi-framework.properties equinox=org.everit.osgi.dist:eosgi-dist-equinox:3.7.2-v201309190021 equinox-3.7.2=org.everit.osgi.dist:eosgi-dist-equinox:3.7.2-v201309190021
  19. 19. Maven plugin configuration <plugin> <groupId>org.everit.osgi.dev</groupId> <artifactId>eosgi-maven-plugin</artifactId> <version>1.1.3-SNAPSHOT</version> <configuration> <environments> <environment> <id>equinoxtest</id> <framework>equinox</framework> <vmOptions> <vmOption>-Xdebug</vmOption> <vmOption>-Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n</vmOption> </vmOptions> </environment> </environments> </configuration> </plugin> <plugin> <groupId>org.everit.osgi.dev</groupId> <artifactId>eosgi-maven-plugin</artifactId> <version>1.1.3-SNAPSHOT</version> <configuration> <environments> <environment> <id>equinoxtest</id> <framework>equinox</framework> <systemProperties> <myProperty1>myValue1</myProperty1> <myProperty2>myValue2</myProperty2> </systemProperties> </environment> </environments> </configuration> </plugin>
  20. 20. Maven plugin configuration <plugin> <groupId>org.everit.osgi.dev</groupId> <artifactId>eosgi-maven-plugin</artifactId> <version>1.1.3-SNAPSHOT</version> <configuration> <environments> <environment> <id>equinoxtest</id> <framework>equinox</framework> <timeout>300000</timeout> <bundleStartLevel>4</bundleStartLevel> <frameworkStartLevel>4</frameworkStartLevel> <bundleSettings> <bundle> <symbolicName>myBundle</symbolicName> <version>1.0.0</version> <startLevel>3</startLevel> </bundle> </bundleSettings> </environment> </environments> </configuration> </plugin>
  21. 21. Maven plugin configuration <plugin> <groupId>org.everit.osgi.dev</groupId> <artifactId>eosgi-maven-plugin</artifactId> <version>1.1.3-SNAPSHOT</version> <executions> <execution> <id>integration-test</id> <phase>integration-test</phase> <goals> <goal>integration-test</goal> </goals> <configuration> <jacoco> <includes>org.everit.osgi.servicereference.*</includes> <excludes>org.everit.osgi.servicereference.tests.*</excludes> </jacoco> <environments> <environment> <id>equinoxtest</id> <framework>equinox</framework> <vmOptions> <vmOption>-Xdebug</vmOption> <vmOption>-Xrunjdwp:server=y,transport=dt_socket,address=4000,suspend=n</vmOption> </vmOptions> </environment> </environments> </configuration> </execution> </executions> </plugin>
  22. 22. 100% coverage
  23. 23. Let's see it in practice
  24. 24. Creating your own dist package ● Look at the sample equinox package ● Look at the .eosgi.dist.xml file Look for the XSD in eosgi-maven-plugin sources and read the documentation ● ● Velocity variables – .eosgi.dist.xml ● ● bundleArtifacts: List<DistributableBundleArtifact> environment: EnvironmentConfiguration – Parseable files
  25. 25. Thank you balazs.zsoldos@everit.biz E-mail: http://github.com/everit-org Source: Maven repo: http://repository.everit.biz/nexus/content/groups/public
  1. A particular slide catching your eye?

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

×