• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Beware - Testing RCP Applications in Tycho can cause Serious Harm to your Brain.
 

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

on

  • 1,876 views

Presented at EclipseCon Europe 2012: ...

Presented at EclipseCon Europe 2012:

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..

Statistics

Views

Total Views
1,876
Views on SlideShare
1,069
Embed Views
807

Actions

Likes
2
Downloads
5
Comments
2

35 Embeds 807

http://tonnymadsen.blogspot.de 226
http://tonnymadsen.blogspot.com 163
http://tonnymadsen.blogspot.dk 75
http://tonnymadsen.blogspot.fr 59
http://tonnymadsen.blogspot.co.at 32
http://tonnymadsen.blogspot.co.uk 32
http://tonnymadsen.blogspot.ru 24
http://tonnymadsen.blogspot.in 23
http://tonnymadsen.blogspot.ch 23
http://tonnymadsen.blogspot.ca 14
http://tonnymadsen.blogspot.com.br 13
http://tonnymadsen.blogspot.cz 12
http://tonnymadsen.blogspot.com.es 12
http://tonnymadsen.blogspot.jp 12
http://tonnymadsen.blogspot.nl 11
http://tonnymadsen.blogspot.hu 10
http://tonnymadsen.blogspot.ro 10
http://tonnymadsen.blogspot.kr 6
http://tonnymadsen.blogspot.pt 6
http://tonnymadsen.blogspot.se 5
http://tonnymadsen.blogspot.it 5
http://tonnymadsen.blogspot.tw 5
http://tonnymadsen.blogspot.sk 5
http://tonnymadsen.blogspot.sg 4
http://tonnymadsen.blogspot.com.ar 4
http://tonnymadsen.blogspot.mx 3
http://tonnymadsen.blogspot.ie 3
http://tonnymadsen.blogspot.fi 2
http://tonnymadsen.blogspot.com.au 2
http://webcache.googleusercontent.com 1
http://news.google.com 1
http://tonnymadsen.blogspot.gr 1
http://tonnymadsen.blogspot.hk 1
http://tonnymadsen.blogspot.be 1
http://tonnymadsen.blogspot.com.tr 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

12 of 2 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • 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
  • Me: I’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
  • 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
  • Some of the things that are more difficult with Tycho/Surefire tests\n
  • \n
  • \n
  • What if you want to test how your application behaves with limited resources?\n
  • 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
  • \n
  • Mock services - not rally the OSGi way...\n
  • As we must specify certain dependencies to Tycho...\n
  • This type of dependencies is used when you want to test \n
  • \n
  • \n
  • Is based on JVM, but JVM is sometimes wrong!! \n\nEx jdk1.7.0_05 installed under "Windows Server 2008 R2 (64-bit)" reports arch x86, not x86_64\n\n
  • \n
  • And require less brain power!\n
  • \n
  • \n

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

  • Beware: Testing RCP Applications in Tycho can cause Serious Harm to your Brain Debugging Dependencies SurefireJUnit OSGi p2Mac 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 toyour BrainFor our Business Integration product - AGETOR -, we have built an IDE based onEclipse. Until recently this product has been build using PDE Build and simple JUnittesting.As we anticipate a lot of new features in this IDE over the next year, we haverefactored the compete code base and moved from PDE Build to Tycho. And withthat we also need to move our various tests to Tycho.Where the move from PDE Build to Tycho wasnt too difficult (once you have studiedthe various examples on the web and the Tycho sessions from the previousEclipseCons), moving the tests was an entirely different story!In the "old" days, to test an RCP application, you traditionally "just" added a numberof JUnit related plug-ins and fragments and ran all your tests in the same basicenvironment as the original application. Not so when you use Tycho as the buildsystem. Here each test usually is run in a much smaller environment that justincludes 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 OSGidependencies.In this session, I will show some of the problems we ran into and illustrate how wesolved the problems. As it turns out, you can actually test a lot more when usingTycho 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 dependenciesEach Maven module is basically aseparate testbed Tycho/SurefireMore can be tested with Tycho thanwith the usual PDE/JUnit approach  Update sites  Different configurations of extensions and services PDE/JUnit  Mocked OSGi services and APIs  Specific Environment for Specific Failures3
  • Some Sources for Harm to Your Brain...UI or notSystem Software Dependencies  Mac OS X  32 versus 64 bit  JavaDependencies outside OSGi  Declarative Services  Extension Registry  Update SitesSpecifying DependenciesOSGi Boot Loader ArgumentsWhen Tests Fail Inconsistently4
  • 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 testTypical Problems  Most services - e.g. the ICommandService, IHandlerService  Help System  Expressions  Resources in your bundle6
  • System Software DependenciesIn theory Maven and Tycho should factor outall the architectural dependencies, but that isnot always the case  Mac OS X  32 versus 64 bit  Memory and options 7
  • Additional “Hidden” Dependencies Manifest-Version: 1.0 Bundle-ManifestVersion: 2Tycho detects OSGi/Java based Bundle-Name: AGETOR 5 Workbench: Base Modeldependencies Bundle-SymbolicName: com.agetor.wb.model;singleton:=true Bundle-Version: 1.1.0.qualifier Bundle-ClassPath: . Bundle-Vendor: Bording Data A/S Bundle-Localization: pluginOptional 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.xmlBuddy Class Loading Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 8
  • Declarative ServicesOSGi Declarative services does not play well with Tychos dependencyresolution!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-810
  • 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=unknownjava.version=1.7.0_05 OS=win32, ARCH=x86, WS=win32java.vendor=Oracle CorporationBootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_USFramework arguments: -application org.eclipse.tycho.surefire.osgibooter.uitest -testproperties C:BuildAgentwork8810fc500e9bd9f8com.agetor.wb.support.teststargetsurefire.propertiesCommand-line arguments: -data C:BuildAgentwork8810fc500e9bd9f8com.agetor.wb.support.teststargetworkdata -dev file:/C:/BuildAgent/work/8810fc500e9bd9f8/com.agetor.wb.support.tests/target/dev.properties -applicationorg.eclipse.tycho.surefire.osgibooter.uitest -testproperties C:BuildAgentwork org.eclipse.swt.cocoa.macosx.x86_64-3.100.0.v4233d.jar was not8810fc500e9bd9f8com.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 notresolved:!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 1java.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 number16
  • Testing will never be a no-brainer, but it could be easier... Debugging Dependencies SurefireJUnit OSGi p2 Mac OS X Update Site Tycho17
  • More Informationhttp://www.eclipse.org/tycho/  The Home of Tychohttp://wiki.eclipse.org/Tycho/FAQ  Tycho FAQ - with many interesting pieces on testinghttps://dev.eclipse.org/mailman/listinfo/tycho-user  The Tycho User Mailing Listhttps://dev.eclipse.org/mailman/listinfo/tycho-dev  The Tycho Developers Mailing List18
  • Questions ?If you want to talk more about Tycho, tests and the various properties of thecombination, meet me at our booth near Bürgersaal 119