SlideShare uma empresa Scribd logo
1 de 18
Baixar para ler offline
OSGi Applications
Testing
AndrAndréé AssadAssad
System EngineerSystem Engineer
AgendaAgenda
•• Introduction: What Testing Is NotIntroduction: What Testing Is Not
•• OSGi Test Harness OverviewOSGi Test Harness Overview
•• OSGi Test Framework andOSGi Test Framework and JUnitJUnit
•• User Oriented xUser Oriented x OSGiOSGi Service OrientedService Oriented
•• Guidelines for Writing OSGi Test CasesGuidelines for Writing OSGi Test Cases
•• OSGiOSGi Testing PatternsTesting Patterns
Introduction: What Testing Is NotIntroduction: What Testing Is Not
•• Demonstrating the Lack of BugsDemonstrating the Lack of Bugs
–– ““it is impossible to specify any algorithm which, given anit is impossible to specify any algorithm which, given an
arbitrary input (computer program), can decide whether or notarbitrary input (computer program), can decide whether or not
the system will eventually haltthe system will eventually halt””, (Allan Turing), (Allan Turing)
•• DebuggingDebugging
–– This is a pair programming and peer reviewing activityThis is a pair programming and peer reviewing activity
•• Quality Assurance JobQuality Assurance Job
–– It is also the engineer responsibilityIt is also the engineer responsibility
•• The Final Hurdle to Release the CodeThe Final Hurdle to Release the Code
–– Testing must be treated as a continuous activityTesting must be treated as a continuous activity
–– E.g.: OSGi Compliance ProgramE.g.: OSGi Compliance Program
•• OSGi Test Director BundleOSGi Test Director Bundle
–– Manage test suites; register targets; set testing propertiesManage test suites; register targets; set testing properties
–– Provides a HTTP serverProvides a HTTP server
•• Target test bundleTarget test bundle
–– RunsRuns on theon the device under testdevice under test
–– ControlledControlled by the directorby the director
–– InstallInstall the Test bundles (tbcN.jar) /the Test bundles (tbcN.jar) / runrun the tests /the tests / postpost the resultsthe results
PC / Workstation
OSGi
Test
Director
Test
JARs.
OSGi Device
CVM
FP/PP
OSGi + MEG/VEG
Target Bundle
“P2P Protocol”
OSGi Test Harness OverviewOSGi Test Harness Overview
a1
Slide 5
a1 Adicionar o componente web server no director
Andre, 9/16/2005
OSGi Test Framework and JUnitOSGi Test Framework and JUnit
•• Does OSGi Test Framework use JUnit?Does OSGi Test Framework use JUnit?
–– Yes and NoYes and No
–– It can do much more than evaluate the execution of a singleIt can do much more than evaluate the execution of a single
classclass
•• In Common:In Common:
–– Assertion PatternsAssertion Patterns
–– Both can be run inside EclipseBoth can be run inside Eclipse
•• OSGi:OSGi:
–– Test Control has AllPermissions over the FrameworkTest Control has AllPermissions over the Framework
–– Test Control has access to the BundleContextTest Control has access to the BundleContext
–– Test Case itself is an OSGi BundleTest Case itself is an OSGi Bundle
–– Service drivenService driven
•• JUnit:JUnit:
–– Class drivenClass driven
User Oriented x OSGi Service Oriented TestingUser Oriented x OSGi Service Oriented Testing
User Oriented:User Oriented:
1.1. Bases tests onBases tests on
requirementsrequirements
2.2. Tested API is neverTested API is never
changedchanged
3.3. Business process isBusiness process is
usually an entityusually an entity
4.4. AssumesAssumes
Components will beComponents will be
always presentalways present
OSGi Service Oriented:OSGi Service Oriented:
1.1. Bases tests onBases tests on
services contractsservices contracts
2.2. Normally extendsNormally extends
service interfaces forservice interfaces for
testingtesting
3.3. Business process is aBusiness process is a
set of servicesset of services
4.4. Assumes ComponentsAssumes Components
have a dynamichave a dynamic
availabilityavailability
Writing OSGi Test Cases GuidelinesWriting OSGi Test Cases Guidelines
•• RobustnessRobustness
–– Perform automatic testing when possiblePerform automatic testing when possible
–– Sharing static variables is not badSharing static variables is not bad
–– Avoid Checked Exception handlingAvoid Checked Exception handling
•• PerformancePerformance
–– Do care about cleaning up a Test CaseDo care about cleaning up a Test Case
state, before execution of another teststate, before execution of another test
casecase
Writing OSGi Test Cases GuidelinesWriting OSGi Test Cases Guidelines
•• CodingCoding
–– Test the interfaces and not the implementationTest the interfaces and not the implementation
–– Write as many assertions per test cases asWrite as many assertions per test cases as
necessarynecessary
–– Do care about the test suite jar sizeDo care about the test suite jar size
•• Ease of UseEase of Use
–– Do not bother waiting forever for asynchronousDo not bother waiting forever for asynchronous
events, yet another definition for don't handleevents, yet another definition for don't handle
specificspecific TIMEOUTTIMEOUT
OSGi Test PatternsOSGi Test Patterns
•• Unit Test PatternUnit Test Pattern
–– Test Framework automatically finds and invokesTest Framework automatically finds and invokes TestControlTestControl
methodsmethods
–– In each test method of test control, call Test ClassesIn each test method of test control, call Test Classes’’ runrun
methodmethod
–– Remember doing Cleanup after test case executionRemember doing Cleanup after test case execution
OSGi Test PatternsOSGi Test Patterns
•• Unit Test ImplementationUnit Test Implementation
public classpublic class TestControlTestControl extendsextends
DefaultTestBundleControlDefaultTestBundleControl {{
public voidpublic void
testtestClassUnderTestMethodAClassUnderTestMethodA() {() {
newnew
TestMethodA(this).runTestMethodA(this).run();();
}}
public classpublic class TestMethodATestMethodA {{
privateprivate TestControlTestControl tbctbc;;
publicpublic TestMethodA(TestControlTestMethodA(TestControl tbctbc) {) {
this.tbcthis.tbc == tbctbc;;
}}
public void run() {public void run() {
testMethodA001();testMethodA001();
}}
private void testMethodA001() {private void testMethodA001() {
StringString paramparam = "test";= "test";
try {try {
ClassUnderTestClassUnderTest cut = newcut = new
ClassUnderTest(ClassUnderTest(paramparam););
tbc.assertEquals("Paramtbc.assertEquals("Param was correctlywas correctly
set",set", paramparam,, cut.getParamcut.getParam());());
} catch (Exception e) {} catch (Exception e) {
tbc.fail("Unexpectedtbc.fail("Unexpected Exception"+Exception"+
e.getClass().getNamee.getClass().getName());());
}}
}}
}}
OSGi Test PatternsOSGi Test Patterns
•• Bundles Test PatternBundles Test Pattern
•• In the Test Control prepare method:In the Test Control prepare method:
–– Install TB1 bundleInstall TB1 bundle
–– Set bundle PermissionsSet bundle Permissions
–– Get registeredGet registered TestFactoryTestFactory
OSGi Test PatternsOSGi Test Patterns
•• Bundles Test ImplementationBundles Test Implementation
public classpublic class TestControlTestControl extendsextends
DefaultTestBundleControlDefaultTestBundleControl {{
privateprivate TestFactoryTestFactory tftf;;
public void prepare() {public void prepare() {
Bundle b = null;Bundle b = null;
try {try {
b =b = installBundle("tb1.jar")installBundle("tb1.jar");;
tftf = (= (TestFactoryTestFactory))
getService(TestFactory.classgetService(TestFactory.class));;
} catch (Exception e) {} catch (Exception e) {
log("Failedlog("Failed to prepare the test");to prepare the test");
}}
setBundlePermission(b.getLocationsetBundlePermission(b.getLocation());());
}}
public voidpublic void
testBundleUnderTestPrivilegedActionAtestBundleUnderTestPrivilegedActionA() {() {
TestServiceTestService[][] tsts ==
tf.getInstances(thistf.getInstances(this););
ts[0].run();ts[0].run();
}}
public class TB1Activator implementspublic class TB1Activator implements
BundleActivatorBundleActivator,, TestFactoryTestFactory {{
privateprivate ServiceRegistrationServiceRegistration srsr;;
public voidpublic void start(BundleContextstart(BundleContext bcbc))
throws Exception {throws Exception {
srsr ==
bc.registerService(TestFactory.class.getNabc.registerService(TestFactory.class.getNa
meme(), this, null);(), this, null);
}}
public voidpublic void stop(BundleContextstop(BundleContext context)context)
throws Exception {throws Exception {
sr.unregistersr.unregister();();
}}
publicpublic TestServiceTestService[][]
getInstances(DefaultTestBundleControlgetInstances(DefaultTestBundleControl tbctbc))
{{
return newreturn new TestServiceTestService[] {[] {
newnew
TestPrivilegedActionA((TestControlTestPrivilegedActionA((TestControl)) tbctbc))
};};
}}
OSGi Test PatternsOSGi Test Patterns
•• Service Contracts Pattern:Service Contracts Pattern:
–– Register as ServiceInterface instanceRegister as ServiceInterface instance
–– Get Service as ServiceInterfaceTest instanceGet Service as ServiceInterfaceTest instance
OSGi Test PatternsOSGi Test Patterns
•• Service Contracts ImplementationService Contracts Implementation
public classpublic class TestControlTestControl extendsextends DefaultTestBundleControlDefaultTestBundleControl {{
public void prepare() {public void prepare() {
ServiceInterfaceTestServiceInterfaceTest sit = newsit = new ServiceInterfaceTestImplServiceInterfaceTestImpl();();
getContext().registerService(getContext().registerService(ServiceInterface.class.getNameServiceInterface.class.getName()(), sit, null);, sit, null);
}}
public voidpublic void testServiceContracttestServiceContract() {() {
newnew TestServiceContract(this).runTestServiceContract(this).run();();
}}
public classpublic class TestServiceContractTestServiceContract {{
public void run() {public void run() {
testServiceContract001();testServiceContract001();
}}
public void testServiceContract001() {public void testServiceContract001() {
//action that calls//action that calls doSomeThingdoSomeThing inin ServiceInterfaceServiceInterface
ImplementationImplementation
ServiceInterfaceTestServiceInterfaceTest sit = null;sit = null;
try {try {
sit = (sit = (ServiceInterfaceTestServiceInterfaceTest)) tbc.getServicetbc.getService
((ServiceInterface.classServiceInterface.class););
String[] values =String[] values = sit.getValuessit.getValues();();
tbc.assertEquals("doSomethingtbc.assertEquals("doSomething method called",method called",
"true", values[0]);"true", values[0]);
} catch (Exception e) {} catch (Exception e) {
tbc.fail("Unexpectedtbc.fail("Unexpected
Exception"+e.getClass().getNameException"+e.getClass().getName());());
}}
public classpublic class ServiceInterfaceTestImplServiceInterfaceTestImpl implementsimplements
ServiceInterfaceTestServiceInterfaceTest {{
private Stringprivate String someThingCalledsomeThingCalled;;
public String[]public String[] getValuesgetValues() {() {
return newreturn new String[]{someThingCalledString[]{someThingCalled};};
}}
public void reset() {public void reset() {
someThingCalledsomeThingCalled = "false";= "false";
}}
public voidpublic void doSomeThingdoSomeThing()() {{
someThingCalledsomeThingCalled = "true";= "true";
}}
}}
ConclusionsConclusions
•• Compliance programs will neverCompliance programs will never
mathematically cover 100% of themathematically cover 100% of the
specificationsspecifications
•• Robustness, Performance and Ease of UseRobustness, Performance and Ease of Use
are not main requirements of test casesare not main requirements of test cases
•• OSGiOSGi Test Framework can be extended for:Test Framework can be extended for:
–– Unit testingUnit testing
–– Bundle privileged actions testingBundle privileged actions testing
–– For services contracts testingFor services contracts testing
Questions?Questions?
Andre.Assad@cesar.org.brAndre.Assad@cesar.org.br

Mais conteúdo relacionado

Mais procurados

Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTest
Raihan Masud
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
nickokiss
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
Will Shen
 

Mais procurados (20)

Google test training
Google test trainingGoogle test training
Google test training
 
Presentation_C++UnitTest
Presentation_C++UnitTestPresentation_C++UnitTest
Presentation_C++UnitTest
 
Unit testing best practices
Unit testing best practicesUnit testing best practices
Unit testing best practices
 
Automated testing in Python and beyond
Automated testing in Python and beyondAutomated testing in Python and beyond
Automated testing in Python and beyond
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practices
 
Qtp-training A presentation for beginers
Qtp-training  A presentation for beginersQtp-training  A presentation for beginers
Qtp-training A presentation for beginers
 
Groovy Testing
Groovy TestingGroovy Testing
Groovy Testing
 
20111018 boost and gtest
20111018 boost and gtest20111018 boost and gtest
20111018 boost and gtest
 
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
[Webinar] Qt Test-Driven Development Using Google Test and Google Mock
 
Junit
JunitJunit
Junit
 
TDD in Python With Pytest
TDD in Python With PytestTDD in Python With Pytest
TDD in Python With Pytest
 
Clean Unit Test Patterns
Clean Unit Test PatternsClean Unit Test Patterns
Clean Unit Test Patterns
 
Unit testing best practices with JUnit
Unit testing best practices with JUnitUnit testing best practices with JUnit
Unit testing best practices with JUnit
 
QA Meetup at Signavio (Berlin, 06.06.19)
QA Meetup at Signavio (Berlin, 06.06.19)QA Meetup at Signavio (Berlin, 06.06.19)
QA Meetup at Signavio (Berlin, 06.06.19)
 
Python Testing Fundamentals
Python Testing FundamentalsPython Testing Fundamentals
Python Testing Fundamentals
 
Simple Unit Testing With Netbeans 6.1
Simple Unit Testing With Netbeans 6.1Simple Unit Testing With Netbeans 6.1
Simple Unit Testing With Netbeans 6.1
 
Unit testing with JUnit
Unit testing with JUnitUnit testing with JUnit
Unit testing with JUnit
 
Unit test
Unit testUnit test
Unit test
 
What is new in JUnit5
What is new in JUnit5What is new in JUnit5
What is new in JUnit5
 
Unit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and HowsUnit Testing - The Whys, Whens and Hows
Unit Testing - The Whys, Whens and Hows
 

Destaque

OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.
OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.
OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.
mfrancis
 
Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...
Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...
Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...
mfrancis
 
Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...
Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...
Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...
mfrancis
 
OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...
OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...
OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...
mfrancis
 
OSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigital
OSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigitalOSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigital
OSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigital
mfrancis
 
Using OSGi for the Realization of Complex Building Management Systems - Peter...
Using OSGi for the Realization of Complex Building Management Systems - Peter...Using OSGi for the Realization of Complex Building Management Systems - Peter...
Using OSGi for the Realization of Complex Building Management Systems - Peter...
mfrancis
 
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBMOSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
mfrancis
 
Why Have The Specifications Been Based On Java™ Technology? - P Kriens
Why Have The Specifications Been Based On Java™ Technology? - P KriensWhy Have The Specifications Been Based On Java™ Technology? - P Kriens
Why Have The Specifications Been Based On Java™ Technology? - P Kriens
mfrancis
 
OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...
OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...
OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...
mfrancis
 
iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...
iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...
iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...
mfrancis
 
Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...
Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...
Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...
mfrancis
 
Introduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B ZsoldosIntroduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B Zsoldos
mfrancis
 
Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...
Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...
Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...
mfrancis
 
Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...
Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...
Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...
mfrancis
 

Destaque (20)

OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.
OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.
OSGi Users’ Forum Korea - Haejun Yi, ProSyst Technology Korea, Inc.
 
Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...
Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...
Building Global Telematics System by Using OSGi Technology - Dimitar Valtchev...
 
OSGi - Four Years and Forward - J Barr
OSGi - Four Years and Forward - J BarrOSGi - Four Years and Forward - J Barr
OSGi - Four Years and Forward - J Barr
 
Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...
Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...
Enabling the Enterprise with Next-Generation Mobile Architectures - Mark Vand...
 
OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...
OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...
OSGi Technology Based In-vehicle Computing Platforms- The Embedded Systems Pe...
 
OSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigital
OSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigitalOSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigital
OSGi Residential Gateways Experience in Spain - Andrés Manso, HogarDigital
 
Using OSGi for the Realization of Complex Building Management Systems - Peter...
Using OSGi for the Realization of Complex Building Management Systems - Peter...Using OSGi for the Realization of Complex Building Management Systems - Peter...
Using OSGi for the Realization of Complex Building Management Systems - Peter...
 
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBMOSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
OSGi Technology, Eclipse and Convergence - Jeff McAffer, IBM
 
Opensugar - Enabling pervasive services - P Scokaert
Opensugar - Enabling pervasive services - P ScokaertOpensugar - Enabling pervasive services - P Scokaert
Opensugar - Enabling pervasive services - P Scokaert
 
Delivering Services Using an OSGi Gateway - C Nycander
Delivering Services Using an OSGi Gateway - C NycanderDelivering Services Using an OSGi Gateway - C Nycander
Delivering Services Using an OSGi Gateway - C Nycander
 
Why Have The Specifications Been Based On Java™ Technology? - P Kriens
Why Have The Specifications Been Based On Java™ Technology? - P KriensWhy Have The Specifications Been Based On Java™ Technology? - P Kriens
Why Have The Specifications Been Based On Java™ Technology? - P Kriens
 
Experiences from Building the Fastest OSGi Container on the Planet - Jaroslav...
Experiences from Building the Fastest OSGi Container on the Planet - Jaroslav...Experiences from Building the Fastest OSGi Container on the Planet - Jaroslav...
Experiences from Building the Fastest OSGi Container on the Planet - Jaroslav...
 
Massive Enterprise Product Migration to OSG - Raymond Auge
Massive Enterprise Product Migration to OSG - Raymond AugeMassive Enterprise Product Migration to OSG - Raymond Auge
Massive Enterprise Product Migration to OSG - Raymond Auge
 
OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...
OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...
OSGi Technology as it relates to Java, Smartcards, and the Automotive Industr...
 
E2 Home - P Ljunggren
E2 Home - P LjunggrenE2 Home - P Ljunggren
E2 Home - P Ljunggren
 
iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...
iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...
iPOJO - The Simple Life - Richard Hall, Visiting Assistant Professor at Tufts...
 
Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...
Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...
Making the Home Gateway an Operator Control Point - Andreas Sayegh, Deutsche ...
 
Introduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B ZsoldosIntroduction to Everit Component Registry - B Zsoldos
Introduction to Everit Component Registry - B Zsoldos
 
Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...
Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...
Keynote - OSGi Service Enabler - Peter Möckel, Managing Director T-Labs, Deu...
 
Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...
Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...
Available OSGi Service Platforms - What distinguishes ProSyst’s offering? - D...
 

Semelhante a OSGi Applications Testing - André Elia Assad, System Engineer, Cesar

AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...
AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...
AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...
jamieayre
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
Peter Kofler
 
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
mfrancis
 

Semelhante a OSGi Applications Testing - André Elia Assad, System Engineer, Cesar (20)

Qt test framework
Qt test frameworkQt test framework
Qt test framework
 
Lecture (Software Testing).pptx
Lecture (Software Testing).pptxLecture (Software Testing).pptx
Lecture (Software Testing).pptx
 
AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...
AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...
AdaCore Paris Tech Day 2016: Elie Richa - Integrated Unit Testing for a Trust...
 
Test ng
Test ngTest ng
Test ng
 
Unit testing
Unit testingUnit testing
Unit testing
 
Agile Software Testing the Agilogy Way
Agile Software Testing the Agilogy WayAgile Software Testing the Agilogy Way
Agile Software Testing the Agilogy Way
 
Intro to junit
Intro to junitIntro to junit
Intro to junit
 
A la découverte des google/test (aka gtest)
A la découverte des google/test (aka gtest)A la découverte des google/test (aka gtest)
A la découverte des google/test (aka gtest)
 
Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)Practical (J)Unit Testing (2009)
Practical (J)Unit Testing (2009)
 
Guidelines to Improve the Robustness of the OSGi Framework and Its Services A...
Guidelines to Improve the Robustness of the OSGi Framework and Its Services A...Guidelines to Improve the Robustness of the OSGi Framework and Its Services A...
Guidelines to Improve the Robustness of the OSGi Framework and Its Services A...
 
Microsoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable CodeMicrosoft Fakes, Unit Testing the (almost) Untestable Code
Microsoft Fakes, Unit Testing the (almost) Untestable Code
 
Unit Tests with Microsoft Fakes
Unit Tests with Microsoft FakesUnit Tests with Microsoft Fakes
Unit Tests with Microsoft Fakes
 
Make Your Testing Groovy
Make Your Testing GroovyMake Your Testing Groovy
Make Your Testing Groovy
 
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
Using the OSGi Application Model on Mobile Devices with CLDC JVM - Dimitar Va...
 
Unit testing for Cocoa developers
Unit testing for Cocoa developersUnit testing for Cocoa developers
Unit testing for Cocoa developers
 
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit TutorialJAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
JAVASCRIPT TDD(Test driven Development) & Qunit Tutorial
 
Test automation principles, terminologies and implementations
Test automation principles, terminologies and implementationsTest automation principles, terminologies and implementations
Test automation principles, terminologies and implementations
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran Janardhana
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
Throwing complexity over the wall: Rapid development for enterprise Java (Jav...
 

Mais de mfrancis

Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
mfrancis
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
mfrancis
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
mfrancis
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
mfrancis
 

Mais de mfrancis (20)

Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
Eclipse Modeling Framework and plain OSGi the easy way - Mark Hoffman (Data I...
 
OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)OSGi and Java 9+ - BJ Hargrave (IBM)
OSGi and Java 9+ - BJ Hargrave (IBM)
 
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
Simplify Web UX Coding using OSGi Modularity Magic - Paul Fraser (A2Z Living)
 
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank LyaruuOSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
OSGi for the data centre - Connecting OSGi to Kubernetes - Frank Lyaruu
 
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
Remote Management and Monitoring of Distributed OSGi Applications - Tim Verbe...
 
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
OSGi with Docker - a powerful way to develop Java systems - Udo Hafermann (So...
 
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
A real world use case with OSGi R7 - Jurgen Albert (Data In Motion Consulting...
 
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
OSGi Feature Model - Where Art Thou - David Bosschaert (Adobe)
 
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
Migrating from PDE to Bndtools in Practice - Amit Kumar Mondal (Deutsche Tele...
 
OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)OSGi CDI Integration Specification - Ray Augé (Liferay)
OSGi CDI Integration Specification - Ray Augé (Liferay)
 
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
How OSGi drives cross-sector energy management - Jörn Tümmler (SMA Solar Tech...
 
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
Improved developer productivity thanks to Maven and OSGi - Lukasz Dywicki (Co...
 
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
It Was Twenty Years Ago Today - Building an OSGi based Smart Home System - Ch...
 
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)Popular patterns revisited on OSGi - Christian Schneider (Adobe)
Popular patterns revisited on OSGi - Christian Schneider (Adobe)
 
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
Integrating SLF4J and the new OSGi LogService 1.4 - BJ Hargrave (IBM)
 
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
OSG(a)i: because AI needs a runtime - Tim Verbelen (imec)
 
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
Flying to Jupiter with OSGi - Tony Walsh (ESA) & Hristo Indzhov (Telespazio V...
 
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
MicroProfile, OSGi was meant for this - Ray Auge (Liferay)
 
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
Prototyping IoT systems with a hybrid OSGi & Node-RED platform - Bruce Jackso...
 
How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)How to connect your OSGi application - Dirk Fauth (Bosch)
How to connect your OSGi application - Dirk Fauth (Bosch)
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

OSGi Applications Testing - André Elia Assad, System Engineer, Cesar

  • 1.
  • 3. AgendaAgenda •• Introduction: What Testing Is NotIntroduction: What Testing Is Not •• OSGi Test Harness OverviewOSGi Test Harness Overview •• OSGi Test Framework andOSGi Test Framework and JUnitJUnit •• User Oriented xUser Oriented x OSGiOSGi Service OrientedService Oriented •• Guidelines for Writing OSGi Test CasesGuidelines for Writing OSGi Test Cases •• OSGiOSGi Testing PatternsTesting Patterns
  • 4. Introduction: What Testing Is NotIntroduction: What Testing Is Not •• Demonstrating the Lack of BugsDemonstrating the Lack of Bugs –– ““it is impossible to specify any algorithm which, given anit is impossible to specify any algorithm which, given an arbitrary input (computer program), can decide whether or notarbitrary input (computer program), can decide whether or not the system will eventually haltthe system will eventually halt””, (Allan Turing), (Allan Turing) •• DebuggingDebugging –– This is a pair programming and peer reviewing activityThis is a pair programming and peer reviewing activity •• Quality Assurance JobQuality Assurance Job –– It is also the engineer responsibilityIt is also the engineer responsibility •• The Final Hurdle to Release the CodeThe Final Hurdle to Release the Code –– Testing must be treated as a continuous activityTesting must be treated as a continuous activity –– E.g.: OSGi Compliance ProgramE.g.: OSGi Compliance Program
  • 5. •• OSGi Test Director BundleOSGi Test Director Bundle –– Manage test suites; register targets; set testing propertiesManage test suites; register targets; set testing properties –– Provides a HTTP serverProvides a HTTP server •• Target test bundleTarget test bundle –– RunsRuns on theon the device under testdevice under test –– ControlledControlled by the directorby the director –– InstallInstall the Test bundles (tbcN.jar) /the Test bundles (tbcN.jar) / runrun the tests /the tests / postpost the resultsthe results PC / Workstation OSGi Test Director Test JARs. OSGi Device CVM FP/PP OSGi + MEG/VEG Target Bundle “P2P Protocol” OSGi Test Harness OverviewOSGi Test Harness Overview a1
  • 6. Slide 5 a1 Adicionar o componente web server no director Andre, 9/16/2005
  • 7. OSGi Test Framework and JUnitOSGi Test Framework and JUnit •• Does OSGi Test Framework use JUnit?Does OSGi Test Framework use JUnit? –– Yes and NoYes and No –– It can do much more than evaluate the execution of a singleIt can do much more than evaluate the execution of a single classclass •• In Common:In Common: –– Assertion PatternsAssertion Patterns –– Both can be run inside EclipseBoth can be run inside Eclipse •• OSGi:OSGi: –– Test Control has AllPermissions over the FrameworkTest Control has AllPermissions over the Framework –– Test Control has access to the BundleContextTest Control has access to the BundleContext –– Test Case itself is an OSGi BundleTest Case itself is an OSGi Bundle –– Service drivenService driven •• JUnit:JUnit: –– Class drivenClass driven
  • 8. User Oriented x OSGi Service Oriented TestingUser Oriented x OSGi Service Oriented Testing User Oriented:User Oriented: 1.1. Bases tests onBases tests on requirementsrequirements 2.2. Tested API is neverTested API is never changedchanged 3.3. Business process isBusiness process is usually an entityusually an entity 4.4. AssumesAssumes Components will beComponents will be always presentalways present OSGi Service Oriented:OSGi Service Oriented: 1.1. Bases tests onBases tests on services contractsservices contracts 2.2. Normally extendsNormally extends service interfaces forservice interfaces for testingtesting 3.3. Business process is aBusiness process is a set of servicesset of services 4.4. Assumes ComponentsAssumes Components have a dynamichave a dynamic availabilityavailability
  • 9. Writing OSGi Test Cases GuidelinesWriting OSGi Test Cases Guidelines •• RobustnessRobustness –– Perform automatic testing when possiblePerform automatic testing when possible –– Sharing static variables is not badSharing static variables is not bad –– Avoid Checked Exception handlingAvoid Checked Exception handling •• PerformancePerformance –– Do care about cleaning up a Test CaseDo care about cleaning up a Test Case state, before execution of another teststate, before execution of another test casecase
  • 10. Writing OSGi Test Cases GuidelinesWriting OSGi Test Cases Guidelines •• CodingCoding –– Test the interfaces and not the implementationTest the interfaces and not the implementation –– Write as many assertions per test cases asWrite as many assertions per test cases as necessarynecessary –– Do care about the test suite jar sizeDo care about the test suite jar size •• Ease of UseEase of Use –– Do not bother waiting forever for asynchronousDo not bother waiting forever for asynchronous events, yet another definition for don't handleevents, yet another definition for don't handle specificspecific TIMEOUTTIMEOUT
  • 11. OSGi Test PatternsOSGi Test Patterns •• Unit Test PatternUnit Test Pattern –– Test Framework automatically finds and invokesTest Framework automatically finds and invokes TestControlTestControl methodsmethods –– In each test method of test control, call Test ClassesIn each test method of test control, call Test Classes’’ runrun methodmethod –– Remember doing Cleanup after test case executionRemember doing Cleanup after test case execution
  • 12. OSGi Test PatternsOSGi Test Patterns •• Unit Test ImplementationUnit Test Implementation public classpublic class TestControlTestControl extendsextends DefaultTestBundleControlDefaultTestBundleControl {{ public voidpublic void testtestClassUnderTestMethodAClassUnderTestMethodA() {() { newnew TestMethodA(this).runTestMethodA(this).run();(); }} public classpublic class TestMethodATestMethodA {{ privateprivate TestControlTestControl tbctbc;; publicpublic TestMethodA(TestControlTestMethodA(TestControl tbctbc) {) { this.tbcthis.tbc == tbctbc;; }} public void run() {public void run() { testMethodA001();testMethodA001(); }} private void testMethodA001() {private void testMethodA001() { StringString paramparam = "test";= "test"; try {try { ClassUnderTestClassUnderTest cut = newcut = new ClassUnderTest(ClassUnderTest(paramparam);); tbc.assertEquals("Paramtbc.assertEquals("Param was correctlywas correctly set",set", paramparam,, cut.getParamcut.getParam());()); } catch (Exception e) {} catch (Exception e) { tbc.fail("Unexpectedtbc.fail("Unexpected Exception"+Exception"+ e.getClass().getNamee.getClass().getName());()); }} }} }}
  • 13. OSGi Test PatternsOSGi Test Patterns •• Bundles Test PatternBundles Test Pattern •• In the Test Control prepare method:In the Test Control prepare method: –– Install TB1 bundleInstall TB1 bundle –– Set bundle PermissionsSet bundle Permissions –– Get registeredGet registered TestFactoryTestFactory
  • 14. OSGi Test PatternsOSGi Test Patterns •• Bundles Test ImplementationBundles Test Implementation public classpublic class TestControlTestControl extendsextends DefaultTestBundleControlDefaultTestBundleControl {{ privateprivate TestFactoryTestFactory tftf;; public void prepare() {public void prepare() { Bundle b = null;Bundle b = null; try {try { b =b = installBundle("tb1.jar")installBundle("tb1.jar");; tftf = (= (TestFactoryTestFactory)) getService(TestFactory.classgetService(TestFactory.class));; } catch (Exception e) {} catch (Exception e) { log("Failedlog("Failed to prepare the test");to prepare the test"); }} setBundlePermission(b.getLocationsetBundlePermission(b.getLocation());()); }} public voidpublic void testBundleUnderTestPrivilegedActionAtestBundleUnderTestPrivilegedActionA() {() { TestServiceTestService[][] tsts == tf.getInstances(thistf.getInstances(this);); ts[0].run();ts[0].run(); }} public class TB1Activator implementspublic class TB1Activator implements BundleActivatorBundleActivator,, TestFactoryTestFactory {{ privateprivate ServiceRegistrationServiceRegistration srsr;; public voidpublic void start(BundleContextstart(BundleContext bcbc)) throws Exception {throws Exception { srsr == bc.registerService(TestFactory.class.getNabc.registerService(TestFactory.class.getNa meme(), this, null);(), this, null); }} public voidpublic void stop(BundleContextstop(BundleContext context)context) throws Exception {throws Exception { sr.unregistersr.unregister();(); }} publicpublic TestServiceTestService[][] getInstances(DefaultTestBundleControlgetInstances(DefaultTestBundleControl tbctbc)) {{ return newreturn new TestServiceTestService[] {[] { newnew TestPrivilegedActionA((TestControlTestPrivilegedActionA((TestControl)) tbctbc)) };}; }}
  • 15. OSGi Test PatternsOSGi Test Patterns •• Service Contracts Pattern:Service Contracts Pattern: –– Register as ServiceInterface instanceRegister as ServiceInterface instance –– Get Service as ServiceInterfaceTest instanceGet Service as ServiceInterfaceTest instance
  • 16. OSGi Test PatternsOSGi Test Patterns •• Service Contracts ImplementationService Contracts Implementation public classpublic class TestControlTestControl extendsextends DefaultTestBundleControlDefaultTestBundleControl {{ public void prepare() {public void prepare() { ServiceInterfaceTestServiceInterfaceTest sit = newsit = new ServiceInterfaceTestImplServiceInterfaceTestImpl();(); getContext().registerService(getContext().registerService(ServiceInterface.class.getNameServiceInterface.class.getName()(), sit, null);, sit, null); }} public voidpublic void testServiceContracttestServiceContract() {() { newnew TestServiceContract(this).runTestServiceContract(this).run();(); }} public classpublic class TestServiceContractTestServiceContract {{ public void run() {public void run() { testServiceContract001();testServiceContract001(); }} public void testServiceContract001() {public void testServiceContract001() { //action that calls//action that calls doSomeThingdoSomeThing inin ServiceInterfaceServiceInterface ImplementationImplementation ServiceInterfaceTestServiceInterfaceTest sit = null;sit = null; try {try { sit = (sit = (ServiceInterfaceTestServiceInterfaceTest)) tbc.getServicetbc.getService ((ServiceInterface.classServiceInterface.class);); String[] values =String[] values = sit.getValuessit.getValues();(); tbc.assertEquals("doSomethingtbc.assertEquals("doSomething method called",method called", "true", values[0]);"true", values[0]); } catch (Exception e) {} catch (Exception e) { tbc.fail("Unexpectedtbc.fail("Unexpected Exception"+e.getClass().getNameException"+e.getClass().getName());()); }} public classpublic class ServiceInterfaceTestImplServiceInterfaceTestImpl implementsimplements ServiceInterfaceTestServiceInterfaceTest {{ private Stringprivate String someThingCalledsomeThingCalled;; public String[]public String[] getValuesgetValues() {() { return newreturn new String[]{someThingCalledString[]{someThingCalled};}; }} public void reset() {public void reset() { someThingCalledsomeThingCalled = "false";= "false"; }} public voidpublic void doSomeThingdoSomeThing()() {{ someThingCalledsomeThingCalled = "true";= "true"; }} }}
  • 17. ConclusionsConclusions •• Compliance programs will neverCompliance programs will never mathematically cover 100% of themathematically cover 100% of the specificationsspecifications •• Robustness, Performance and Ease of UseRobustness, Performance and Ease of Use are not main requirements of test casesare not main requirements of test cases •• OSGiOSGi Test Framework can be extended for:Test Framework can be extended for: –– Unit testingUnit testing –– Bundle privileged actions testingBundle privileged actions testing –– For services contracts testingFor services contracts testing