SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Beware: Testing RCP Applications in Tycho can
               cause Serious Harm to your Brain
                                                                                                Debugging
                                     Dependencies
                                                                                                                    Surefire

JUnit




  OSGi
                                                                                                                       p2


Mac OS X

                                         Update Site                                                        Tycho
 Redistribution and other use of this material requires written permission from Bording Data.
Beware: Testing RCP Applications in Tycho can cause Serious Harm to
your Brain

For our Business Integration product - AGETOR -, we have built an IDE based on
Eclipse. Until recently this product has been build using PDE Build and simple JUnit
testing.
As we anticipate a lot of new features in this IDE over the next year, we have
refactored the compete code base and moved from PDE Build to Tycho. And with
that we also need to move our various tests to Tycho.

Where the move from PDE Build to Tycho wasn't too difficult (once you have studied
the various examples on the web and the Tycho sessions from the previous
EclipseCons), moving the tests was an entirely different story!

In the "old" days, to test an RCP application, you traditionally "just" added a number
of JUnit related plug-ins and fragments and ran all your tests in the same basic
environment as the original application. Not so when you use Tycho as the build
system. Here each test usually is run in a much smaller environment that just
includes the plug-in or bundle to test and not everything else. As we found out,
this can give you some unexpected problems when you want to test OSGi services,
extension points, update sites and other "things" that are not based on pure OSGi
dependencies.

In this session, I will show some of the problems we ran into and illustrate how we
solved the problems. As it turns out, you can actually test a lot more when using
Tycho than when using PDE Build, but it does take some getting used to..

 2
Why Tycho/Surefire for Tests? Less is More...




Only the needed environment is present
     Based on OSGi dependencies

Each Maven module is basically a
separate testbed                        Tycho/Surefire
More can be tested with Tycho than
with the usual PDE/JUnit approach
     Update sites
     Different configurations of
      extensions and services                  PDE/JUnit
     Mocked OSGi services and APIs
     Specific Environment for Specific
      Failures




3
Some Sources for Harm to Your Brain...




UI or not

System Software Dependencies
     Mac OS X
     32 versus 64 bit
     Java

Dependencies outside OSGi
     Declarative Services
     Extension Registry
     Update Sites

Specifying Dependencies

OSGi Boot Loader Arguments

When Tests Fail Inconsistently


4
UI Testing or not...




                                              <project>
                                               <packaging>eclipse-test-plugin</packaging>

                                               <parent>
                                                <groupId>com.agetor.v5</groupId>
                                                <artifactId>com.agetor.wb.parent</artifactId>
                                                <version>1-SNAPSHOT</version>
                                                <relativePath>../com.agetor.wb.parent</relativePath>
                                               </parent>
Simple on the surface:
                                               <build>
      If you test UI stuff just add            <plugins>
       “<useUIHarness>true</                      <plugin>
                                                    <groupId>org.eclipse.tycho</groupId>
       useUIHarness>” to the test                   <artifactId>tycho-surefire-plugin</artifactId>
       configuration                                 <version>${tycho.version}</version>
                                                    <configuration>
                                                      <useUIHarness>true</useUIHarness>
      But the test sequence also gets much          </configuration>
       slower                                     </plugin>
                                                </plugins>
                                               </build>

                                              </project>




 5
UI Testing or not...


But it quickly gets more complicated:
     If any part of the bundles under test - directly or indirectly - depends on
      IWorkbench, then it is a UI test



Typical Problems
     Most services - e.g. the ICommandService, IHandlerService
     Help System
     Expressions
     Resources in your bundle




6
System Software Dependencies




In theory Maven and Tycho should factor out
all the architectural dependencies, but that is
not always the case


      Mac OS X
      32 versus 64 bit
      Memory and options




 7
Additional “Hidden” Dependencies




                                Manifest-Version: 1.0
                                Bundle-ManifestVersion: 2
Tycho detects OSGi/Java based   Bundle-Name: AGETOR 5 Workbench: Base Model
dependencies                    Bundle-SymbolicName: com.agetor.wb.model;singleton:=true
                                Bundle-Version: 1.1.0.qualifier
                                Bundle-ClassPath: .
                                Bundle-Vendor: Bording Data A/S
                                Bundle-Localization: plugin
Optional Dependencies?          Export-Package: ...
                                Require-Bundle: org.eclipse.core.runtime,
                                 org.eclipse.emf.ecore;visibility:=reexport,
RAP versus RCP?                  org.eclipse.xtext.xbase.lib;visibility:=reexport,
                                 com.rcpcompany.uibindings.moao;bundle-version="[1.2.0,2.0.0)",
                                 org.eclipse.equinox.ds;bundle-version="[1.4.0,2.0.0)"
Declarative Services            Import-Package: com.agetor.wb.ui.preferences;version="1.0.0",
                                 com.rcpcompany.uibindings.model.utils,
                                 com.rcpcompany.utils.logging;version="[1.5.0,2.0.0)",
Extension Registry               org.eclipse.emf.ecore.xmi.impl,
                                 org.eclipse.jdt.annotation,
Update Sites                     org.eclipse.jface.preference,
                                 org.eclipse.jface.util,
                                 org.eclipse.ui.preferences,
JSR 223                          org.osgi.service.component.annotations
                                Service-Component: OSGI-INF/com.agetor.wb.model.GlobalSettings.xml,
                                 OSGI-INF/com.agetor.wb.model.internal.SettingsService.xml
Buddy Class Loading             Bundle-ActivationPolicy: lazy
                                Bundle-RequiredExecutionEnvironment: JavaSE-1.6




 8
Declarative Services


OSGi Declarative services does not play well with Tychos dependency
resolution!



Services not discovered at all???
      Add “org.eclipse.equinox.ds” to Require-Bundle for all providers
       and users of declarative services
      Have you remembered to set “Bundle-ActivationPolicy: lazy” in
       MANIFEST.MF? (also known as “Activate this plug-in when one of
       its classes is loaded” )


Still not working?!!??
      Re-run the tests with the Eclipse flags “-Dequinox.ds.print=true -
       Dequinox.ds.debug=true” and be prepared for a lot of output




 9
Declarative Services




                                    <component name="com.agetor.server.mail.mock.internal.MockMailFactory">
                                     <property value="10" name="service.ranking" />
Mock services not loaded             <service>
                                         <provide interface="com.agetor.server.mail.IMailFactory"/>
      Use service.ranking=10        </service>
                                     ...
                                    <component>




                                                       source.. = src/
                                                       output.. = target/classes/
It works in the IDE, but not in Tycho                  bin.includes = META-INF/,
                                                                 .,
      Remember to add OSGI-INF/ in                              OSGI-INF/
       build.properties                                javacDefaultEncoding.. = UTF-8




10
Specifying Dependencies to Surefire


                                        <project>
                                         <packaging>eclipse-test-plugin</packaging>

                                         <parent>
                                          <groupId>com.agetor.v5</groupId>
                                          <artifactId>com.agetor.wb.parent</artifactId>
                                          <version>1-SNAPSHOT</version>
                                          <relativePath>../com.agetor.wb.parent</relativePath>
                                         </parent>

                                         <dependencies>
                                          <dependency>
                                            ...
                                          </dependency>
Dependencies can be specified in three    </dependencies>

different places                         <build>
                                           <plugins>
      At the POM level                      <plugin>
                                               <groupId>org.eclipse.tycho</groupId>
                                               <artifactId>tycho-surefire-plugin</artifactId>
      At the plugin level                     <version>${tycho.version}</version>
                                               <configuration>
      At the configuration level                 <dependencies>
                                                   <dependency>
                                                       ...
                                                   </dependency>
                                                 </dependencies>
                                               </configuration>
                                               <dependencies>
                                                 <dependency>
                                                   ...
                                                 </dependency>
                                               </dependencies>
                                             </plugin>
                                           </plugins>
                                         </build>
                                        </project>




11
Specifying Dependencies to Surefire

     <project>
      <packaging>eclipse-test-plugin</packaging>

      <parent>
       <groupId>com.agetor.v5</groupId>
       <artifactId>com.agetor.wb.parent</artifactId>
       <version>1-SNAPSHOT</version>
       <relativePath>../com.agetor.wb.parent</relativePath>
      </parent>

      <dependencies>
       <dependency>
         <groupId>com.agetor.v5</groupId>
         <artifactId>com.agetor.server.site</artifactId>
         <version>5.0.1-SNAPSHOT</version>
         <type>eclipse-repository</type>
       </dependency>
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-surefire-plugin</artifactId>
            <version>${tycho.version}</version>
            <configuration>
              <dependencies>
                ...
              </dependencies>
            </configuration>
          </plugin>
        </plugins>
      </build>
     </project>




12
Specifying Dependencies to Surefire

     <project>
      <packaging>eclipse-test-plugin</packaging>

      <parent>
       <groupId>com.agetor.v5</groupId>
       <artifactId>com.agetor.wb.parent</artifactId>
       <version>1-SNAPSHOT</version>
       <relativePath>../com.agetor.wb.parent</relativePath>
      </parent>

      <dependencies>
       ...
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-surefire-plugin</artifactId>
            <version>${tycho.version}</version>
            <configuration>
              <dependencies>
                <dependency>
                    <type>eclipse-plugin</type>
                    <artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId>
                    <version>0.0.0</version>
                 </dependency>
                ...
              </dependencies>
            </configuration>
          </plugin>
        </plugins>
      </build>
     </project>




13
Specifying Dependencies to Surefire

     <project>
      <packaging>eclipse-test-plugin</packaging>

      <parent>
       <groupId>com.agetor.v5</groupId>
       <artifactId>com.agetor.wb.parent</artifactId>
       <version>1-SNAPSHOT</version>
       <relativePath>../com.agetor.wb.parent</relativePath>
      </parent>

      <dependencies>
       ...
      </dependencies>

      <build>                                      Missing <configuration>
        <plugins>
          <plugin>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-surefire-plugin</artifactId>
            <version>${tycho.version}</version>
            <dependencies>
              <dependency>
                  <type>eclipse-plugin</type>
                  <artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId>
                  <version>0.0.0</version>
               </dependency>
              ...
            </dependencies>
          </plugin>
        </plugins>
      </build>
     </project>




14
OSGi Bootloader Arguments

!SESSION 2012-08-24 15:21:43.019 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.7.0_05                              OS=win32, ARCH=x86, WS=win32
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US
Framework arguments: -application org.eclipse.tycho.surefire.osgibooter.uitest -
testproperties C:BuildAgentwork8810fc500e9bd9f8com.agetor.wb.support.teststarget
surefire.properties
Command-line arguments: -data C:BuildAgentwork
8810fc500e9bd9f8com.agetor.wb.support.teststargetworkdata -dev file:/C:/BuildAgent/
work/8810fc500e9bd9f8/com.agetor.wb.support.tests/target/dev.properties -application
org.eclipse.tycho.surefire.osgibooter.uitest -testproperties C:BuildAgentwork
                        org.eclipse.swt.cocoa.macosx.x86_64-3.100.0.v4233d.jar was not
8810fc500e9bd9f8com.agetor.wb.support.teststargetsurefire.properties
                        resolved
!ENTRY org.eclipse.osgi 2 0 2012-08-24 15:21:47.309
!MESSAGE One or more bundles are not resolved because the following root constraints are not
resolved:
!SUBENTRY 1 org.eclipse.osgi 2 0 2012-08-24 15:21:47.310
!MESSAGE Bundle initial@reference:file:../../../../common-m2-repository/p2/osgi/bundle/
org.eclipse.swt.cocoa.macosx.x86_64/3.100.0.v4233d/
org.eclipse.swt.cocoa.macosx.x86_64-3.100.0.v4233d.jar was not resolved.

!ENTRY org.eclipse.osgi 4 0 2012-08-24 15:21:47.983
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM

             at org.eclipse.swt.internal.Library.loadLibrary(Library.java:263)

             at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)

             at org.eclipse.swt.internal.C.<clinit>(C.java:21)

             at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)

             at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:654)
                                                            Cannot load 32-bit SWT libraries on
                                                            64-bit JVM


   15
When Tests Fail Inconsistently...


                                              <project>
                                               <packaging>eclipse-test-plugin</packaging>

                                               <build>
                                                 <plugins>
                                                   <plugin>
                                                     <groupId>org.eclipse.tycho</groupId>
                                                     <artifactId>tycho-surefire-plugin</artifactId>
                                                     <version>${tycho.version}</version>
                                                     <configuration>
                                                       <debugPort>5005</debugPort>
Works in Tycho/Surefire or in PDE/JUnit...            </configuration>
but not in both...                                 </plugin>
                                                 </plugins>
                                               </build>
... so you really, really want to debug the   </project>

test in Tycho/Surefire...


      use the debugPort parameter to
       tycho-surefire-plugin
      use Remote Java Application launch
       configuration with same port number




16
Testing will never be a no-brainer, but it could be easier...


                                             Debugging
                 Dependencies
                                                                    Surefire

JUnit




     OSGi
                                                                       p2


 Mac OS X

                   Update Site                              Tycho

17
More Information


http://www.eclipse.org/tycho/
      The Home of Tycho

http://wiki.eclipse.org/Tycho/FAQ
      Tycho FAQ - with many interesting pieces on testing


https://dev.eclipse.org/mailman/listinfo/tycho-user
      The Tycho User Mailing List

https://dev.eclipse.org/mailman/listinfo/tycho-dev
      The Tycho Developers Mailing List




18
Questions ?




If you want to talk more about Tycho, tests and the various properties of the
combination, meet me at our booth near Bürgersaal 1



19

Weitere ähnliche Inhalte

Mehr von Tonny Madsen

EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user group
Tonny Madsen
 

Mehr von Tonny Madsen (20)

L0018 - SWT - The Standard Widget Toolkit
L0018 - SWT - The Standard Widget ToolkitL0018 - SWT - The Standard Widget Toolkit
L0018 - SWT - The Standard Widget Toolkit
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-in
 
L0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformL0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse Platform
 
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
 
PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
 
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionEclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
 
ITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model Transformations
 
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)
 
IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)
 
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
 
ITU - MDD - EMF
ITU - MDD - EMFITU - MDD - EMF
ITU - MDD - EMF
 
ITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-ins
 
ITU - MDD - XText
ITU - MDD - XTextITU - MDD - XText
ITU - MDD - XText
 
eclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hoodeclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hood
 
EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user group
 
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
 
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platform
 
ITU - MDD – Modeling Techniques
ITU - MDD – Modeling TechniquesITU - MDD – Modeling Techniques
ITU - MDD – Modeling Techniques
 

Beware - Testing RCP Applications in Tycho can cause Serious Harm to your Brain.

  • 1. Beware: Testing RCP Applications in Tycho can cause Serious Harm to your Brain Debugging Dependencies Surefire JUnit OSGi p2 Mac OS X Update Site Tycho Redistribution and other use of this material requires written permission from Bording Data.
  • 2. Beware: Testing RCP Applications in Tycho can cause Serious Harm to your Brain For our Business Integration product - AGETOR -, we have built an IDE based on Eclipse. Until recently this product has been build using PDE Build and simple JUnit testing. As we anticipate a lot of new features in this IDE over the next year, we have refactored the compete code base and moved from PDE Build to Tycho. And with that we also need to move our various tests to Tycho. Where the move from PDE Build to Tycho wasn't too difficult (once you have studied the various examples on the web and the Tycho sessions from the previous EclipseCons), moving the tests was an entirely different story! In the "old" days, to test an RCP application, you traditionally "just" added a number of JUnit related plug-ins and fragments and ran all your tests in the same basic environment as the original application. Not so when you use Tycho as the build system. Here each test usually is run in a much smaller environment that just includes the plug-in or bundle to test and not everything else. As we found out, this can give you some unexpected problems when you want to test OSGi services, extension points, update sites and other "things" that are not based on pure OSGi dependencies. In this session, I will show some of the problems we ran into and illustrate how we solved the problems. As it turns out, you can actually test a lot more when using Tycho than when using PDE Build, but it does take some getting used to.. 2
  • 3. Why Tycho/Surefire for Tests? Less is More... Only the needed environment is present  Based on OSGi dependencies Each Maven module is basically a separate testbed Tycho/Surefire More can be tested with Tycho than with the usual PDE/JUnit approach  Update sites  Different configurations of extensions and services PDE/JUnit  Mocked OSGi services and APIs  Specific Environment for Specific Failures 3
  • 4. Some Sources for Harm to Your Brain... UI or not System Software Dependencies  Mac OS X  32 versus 64 bit  Java Dependencies outside OSGi  Declarative Services  Extension Registry  Update Sites Specifying Dependencies OSGi Boot Loader Arguments When Tests Fail Inconsistently 4
  • 5. UI Testing or not... <project> <packaging>eclipse-test-plugin</packaging> <parent> <groupId>com.agetor.v5</groupId> <artifactId>com.agetor.wb.parent</artifactId> <version>1-SNAPSHOT</version> <relativePath>../com.agetor.wb.parent</relativePath> </parent> Simple on the surface: <build>  If you test UI stuff just add <plugins> “<useUIHarness>true</ <plugin> <groupId>org.eclipse.tycho</groupId> useUIHarness>” to the test <artifactId>tycho-surefire-plugin</artifactId> configuration <version>${tycho.version}</version> <configuration> <useUIHarness>true</useUIHarness>  But the test sequence also gets much </configuration> slower </plugin> </plugins> </build> </project> 5
  • 6. UI Testing or not... But it quickly gets more complicated:  If any part of the bundles under test - directly or indirectly - depends on IWorkbench, then it is a UI test Typical Problems  Most services - e.g. the ICommandService, IHandlerService  Help System  Expressions  Resources in your bundle 6
  • 7. System Software Dependencies In theory Maven and Tycho should factor out all the architectural dependencies, but that is not always the case  Mac OS X  32 versus 64 bit  Memory and options 7
  • 8. Additional “Hidden” Dependencies Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Tycho detects OSGi/Java based Bundle-Name: AGETOR 5 Workbench: Base Model dependencies Bundle-SymbolicName: com.agetor.wb.model;singleton:=true Bundle-Version: 1.1.0.qualifier Bundle-ClassPath: . Bundle-Vendor: Bording Data A/S Bundle-Localization: plugin Optional Dependencies? Export-Package: ... Require-Bundle: org.eclipse.core.runtime, org.eclipse.emf.ecore;visibility:=reexport, RAP versus RCP? org.eclipse.xtext.xbase.lib;visibility:=reexport, com.rcpcompany.uibindings.moao;bundle-version="[1.2.0,2.0.0)", org.eclipse.equinox.ds;bundle-version="[1.4.0,2.0.0)" Declarative Services Import-Package: com.agetor.wb.ui.preferences;version="1.0.0", com.rcpcompany.uibindings.model.utils, com.rcpcompany.utils.logging;version="[1.5.0,2.0.0)", Extension Registry org.eclipse.emf.ecore.xmi.impl, org.eclipse.jdt.annotation, Update Sites org.eclipse.jface.preference, org.eclipse.jface.util, org.eclipse.ui.preferences, JSR 223 org.osgi.service.component.annotations Service-Component: OSGI-INF/com.agetor.wb.model.GlobalSettings.xml, OSGI-INF/com.agetor.wb.model.internal.SettingsService.xml Buddy Class Loading Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 8
  • 9. Declarative Services OSGi Declarative services does not play well with Tychos dependency resolution! Services not discovered at all???  Add “org.eclipse.equinox.ds” to Require-Bundle for all providers and users of declarative services  Have you remembered to set “Bundle-ActivationPolicy: lazy” in MANIFEST.MF? (also known as “Activate this plug-in when one of its classes is loaded” ) Still not working?!!??  Re-run the tests with the Eclipse flags “-Dequinox.ds.print=true - Dequinox.ds.debug=true” and be prepared for a lot of output 9
  • 10. Declarative Services <component name="com.agetor.server.mail.mock.internal.MockMailFactory"> <property value="10" name="service.ranking" /> Mock services not loaded <service> <provide interface="com.agetor.server.mail.IMailFactory"/>  Use service.ranking=10 </service> ... <component> source.. = src/ output.. = target/classes/ It works in the IDE, but not in Tycho bin.includes = META-INF/, .,  Remember to add OSGI-INF/ in OSGI-INF/ build.properties javacDefaultEncoding.. = UTF-8 10
  • 11. Specifying Dependencies to Surefire <project> <packaging>eclipse-test-plugin</packaging> <parent> <groupId>com.agetor.v5</groupId> <artifactId>com.agetor.wb.parent</artifactId> <version>1-SNAPSHOT</version> <relativePath>../com.agetor.wb.parent</relativePath> </parent> <dependencies> <dependency> ... </dependency> Dependencies can be specified in three </dependencies> different places <build> <plugins>  At the POM level <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-surefire-plugin</artifactId>  At the plugin level <version>${tycho.version}</version> <configuration>  At the configuration level <dependencies> <dependency> ... </dependency> </dependencies> </configuration> <dependencies> <dependency> ... </dependency> </dependencies> </plugin> </plugins> </build> </project> 11
  • 12. Specifying Dependencies to Surefire <project> <packaging>eclipse-test-plugin</packaging> <parent> <groupId>com.agetor.v5</groupId> <artifactId>com.agetor.wb.parent</artifactId> <version>1-SNAPSHOT</version> <relativePath>../com.agetor.wb.parent</relativePath> </parent> <dependencies> <dependency> <groupId>com.agetor.v5</groupId> <artifactId>com.agetor.server.site</artifactId> <version>5.0.1-SNAPSHOT</version> <type>eclipse-repository</type> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-surefire-plugin</artifactId> <version>${tycho.version}</version> <configuration> <dependencies> ... </dependencies> </configuration> </plugin> </plugins> </build> </project> 12
  • 13. Specifying Dependencies to Surefire <project> <packaging>eclipse-test-plugin</packaging> <parent> <groupId>com.agetor.v5</groupId> <artifactId>com.agetor.wb.parent</artifactId> <version>1-SNAPSHOT</version> <relativePath>../com.agetor.wb.parent</relativePath> </parent> <dependencies> ... </dependencies> <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-surefire-plugin</artifactId> <version>${tycho.version}</version> <configuration> <dependencies> <dependency> <type>eclipse-plugin</type> <artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId> <version>0.0.0</version> </dependency> ... </dependencies> </configuration> </plugin> </plugins> </build> </project> 13
  • 14. Specifying Dependencies to Surefire <project> <packaging>eclipse-test-plugin</packaging> <parent> <groupId>com.agetor.v5</groupId> <artifactId>com.agetor.wb.parent</artifactId> <version>1-SNAPSHOT</version> <relativePath>../com.agetor.wb.parent</relativePath> </parent> <dependencies> ... </dependencies> <build> Missing <configuration> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-surefire-plugin</artifactId> <version>${tycho.version}</version> <dependencies> <dependency> <type>eclipse-plugin</type> <artifactId>org.eclipse.equinox.p2.artifact.repository</artifactId> <version>0.0.0</version> </dependency> ... </dependencies> </plugin> </plugins> </build> </project> 14
  • 15. OSGi Bootloader Arguments !SESSION 2012-08-24 15:21:43.019 ----------------------------------------------- eclipse.buildId=unknown java.version=1.7.0_05 OS=win32, ARCH=x86, WS=win32 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Framework arguments: -application org.eclipse.tycho.surefire.osgibooter.uitest - testproperties C:BuildAgentwork8810fc500e9bd9f8com.agetor.wb.support.teststarget surefire.properties Command-line arguments: -data C:BuildAgentwork 8810fc500e9bd9f8com.agetor.wb.support.teststargetworkdata -dev file:/C:/BuildAgent/ work/8810fc500e9bd9f8/com.agetor.wb.support.tests/target/dev.properties -application org.eclipse.tycho.surefire.osgibooter.uitest -testproperties C:BuildAgentwork org.eclipse.swt.cocoa.macosx.x86_64-3.100.0.v4233d.jar was not 8810fc500e9bd9f8com.agetor.wb.support.teststargetsurefire.properties resolved !ENTRY org.eclipse.osgi 2 0 2012-08-24 15:21:47.309 !MESSAGE One or more bundles are not resolved because the following root constraints are not resolved: !SUBENTRY 1 org.eclipse.osgi 2 0 2012-08-24 15:21:47.310 !MESSAGE Bundle initial@reference:file:../../../../common-m2-repository/p2/osgi/bundle/ org.eclipse.swt.cocoa.macosx.x86_64/3.100.0.v4233d/ org.eclipse.swt.cocoa.macosx.x86_64-3.100.0.v4233d.jar was not resolved. !ENTRY org.eclipse.osgi 4 0 2012-08-24 15:21:47.983 !MESSAGE Application error !STACK 1 java.lang.UnsatisfiedLinkError: Cannot load 32-bit SWT libraries on 64-bit JVM at org.eclipse.swt.internal.Library.loadLibrary(Library.java:263) at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240) at org.eclipse.swt.internal.C.<clinit>(C.java:21) at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138) at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:654) Cannot load 32-bit SWT libraries on 64-bit JVM 15
  • 16. When Tests Fail Inconsistently... <project> <packaging>eclipse-test-plugin</packaging> <build> <plugins> <plugin> <groupId>org.eclipse.tycho</groupId> <artifactId>tycho-surefire-plugin</artifactId> <version>${tycho.version}</version> <configuration> <debugPort>5005</debugPort> Works in Tycho/Surefire or in PDE/JUnit... </configuration> but not in both... </plugin> </plugins> </build> ... so you really, really want to debug the </project> test in Tycho/Surefire...  use the debugPort parameter to tycho-surefire-plugin  use Remote Java Application launch configuration with same port number 16
  • 17. Testing will never be a no-brainer, but it could be easier... Debugging Dependencies Surefire JUnit OSGi p2 Mac OS X Update Site Tycho 17
  • 18. More Information http://www.eclipse.org/tycho/  The Home of Tycho http://wiki.eclipse.org/Tycho/FAQ  Tycho FAQ - with many interesting pieces on testing https://dev.eclipse.org/mailman/listinfo/tycho-user  The Tycho User Mailing List https://dev.eclipse.org/mailman/listinfo/tycho-dev  The Tycho Developers Mailing List 18
  • 19. Questions ? If you want to talk more about Tycho, tests and the various properties of the combination, meet me at our booth near Bürgersaal 1 19

Hinweis der Redaktion

  1. Writing tests for a non-trivial application can sometimes be extremely difficult. Also more difficult than should be expected.\n\nThere are many concepts involved when writing tests, some of which are non-trivial in themselves. Just take p2 and Mac OS X :-)\n\n
  2. Me: I&amp;#x2019;m a systems architect with Bording Data where I primary work with AGETOR. AGETOR is a business integration product and we are in the process of moving the server parts to OSGi...\n\nAgenda\n\nBackground: Moving the build system of an existing application from PDE Build to Tycho. Implies the tests also must be moved!\n
  3. Before I go into the problems with Tycho and test, I would like to just briefly mention the advantages...\n\nWith Tycho and Surefire we test a much smaller unit of the application. Each Maven module is essentially a separate testbed, so it is easy to test a set of different configurations for extensions and services.\n\nThis advantage is also one of the main sources of problems with Tycho/Surefire testing\n
  4. Some of the things that are more difficult with Tycho/Surefire tests\n
  5. \n
  6. \n
  7. What if you want to test how your application behaves with limited resources?\n
  8. Tycho tries to be smart about the dependencies - just sometimes, it is a little too smart...\n\nBasically Tycho collects dependencies via MANIFEST.MF\n
  9. \n
  10. Mock services - not rally the OSGi way...\n
  11. As we must specify certain dependencies to Tycho...\n
  12. This type of dependencies is used when you want to test \n
  13. \n
  14. \n
  15. Is based on JVM, but JVM is sometimes wrong!! \n\nEx jdk1.7.0_05 installed under &quot;Windows Server 2008 R2 (64-bit)&quot; reports arch x86, not x86_64\n\n
  16. \n
  17. And require less brain power!\n
  18. \n
  19. \n