Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 340661

Summary: [Tooling] TargetSwitcher_Test fails
Product: [RT] RAP Reporter: Rüdiger Herrmann <ruediger.herrmann>
Component: DemoAssignee: Project Inbox <rap-inbox>
Status: RESOLVED INVALID QA Contact:
Severity: normal    
Priority: P3 CC: beyhan.veliev
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Rüdiger Herrmann CLA 2011-03-22 10:13:32 EDT
All test cases from the TargetSwitcher_Test fail. I tried to run them aginst a 3.6.1 target as well as 3.7M6 - same result.
Note: I am using a launch config with manually selected plug-ins as I had problems with junit4 when running with all plug-ins from workspace and target. The launch config is valid according to the the 'Validate Plug-ins' button.
What's wrong?

Stacktrace from the testSwitchTarget test case:
java.lang.NullPointerException
	at org.eclipse.pde.internal.core.target.P2TargetUtils.getAgent(P2TargetUtils.java:296)
	at org.eclipse.pde.internal.core.target.P2TargetUtils.getProfileRegistry(P2TargetUtils.java:787)
	at org.eclipse.pde.internal.core.target.P2TargetUtils.deleteProfile(P2TargetUtils.java:199)
	at org.eclipse.pde.internal.core.target.LocalTargetHandle.delete(LocalTargetHandle.java:176)
	at org.eclipse.pde.internal.core.target.TargetPlatformService.deleteTarget(TargetPlatformService.java:85)
	at org.eclipse.rap.ui.internal.intro.target.TargetSwitcher_Test.tearDown(TargetSwitcher_Test.java:58)
	at junit.framework.TestCase.runBare(TestCase.java:136)
	at junit.framework.TestResult$1.protect(TestResult.java:106)
	at junit.framework.TestResult.runProtected(TestResult.java:124)
	at junit.framework.TestResult.run(TestResult.java:109)
	at junit.framework.TestCase.run(TestCase.java:120)
	at junit.framework.TestSuite.runTest(TestSuite.java:230)
	at junit.framework.TestSuite.run(TestSuite.java:225)
	at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
	at org.eclipse.pde.internal.junit.runtime.RemotePluginTestRunner.main(RemotePluginTestRunner.java:62)
	at org.eclipse.pde.internal.junit.runtime.UITestApplication$1.run(UITestApplication.java:56)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4125)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3742)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
	at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.runApp(NonUIThreadTestApplication.java:43)
	at org.eclipse.pde.internal.junit.runtime.UITestApplication.runApp(UITestApplication.java:44)
	at org.eclipse.pde.internal.junit.runtime.NonUIThreadTestApplication.start(NonUIThreadTestApplication.java:37)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1410)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
Comment 1 Beyhan Veliev CLA 2011-03-22 13:08:58 EDT
(In reply to comment #0)
> All test cases from the TargetSwitcher_Test fail. I tried to run them aginst a
> 3.6.1 target as well as 3.7M6 - same result.
> Note: I am using a launch config with manually selected plug-ins as I had
> problems with junit4 when running with all plug-ins from workspace and target.
> The launch config is valid according to the the 'Validate Plug-ins' button.
> What's wrong?
> 

Hi Rüdiger,

are you using the launch configuration available with the tests? The launch configuration for 3.6.1 available with the test should work for 3.6 and 3.7. You just need to select the right SWT fragment. P2 provides its APIs as OSGi services and I suppose that the org.eclipse.equinox.ds is not selected in your launch configuration that is why the NullPointerExceptin happens.
Comment 2 Rüdiger Herrmann CLA 2011-03-22 13:18:14 EDT
Thanks for the tip, Equinox DS was missing. Now the testSwitchTagret test succeeds but all remaining test cases from TargetSwitcher_Test still fail.
Any idea?

org.eclipse.core.runtime.CoreException: Problems occurred while resolving the target contents
	at org.eclipse.rap.ui.internal.intro.target.TargetSwitcher.downloadTarget(TargetSwitcher.java:167)
	at org.eclipse.rap.ui.internal.intro.target.TargetSwitcher.install(TargetSwitcher.java:97)
	at org.eclipse.rap.ui.internal.intro.target.TargetSwitcher_Test.testInstallTargetAvailable(TargetSwitcher_Test.java:95)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at junit.framework.TestCase.runTest(TestCase.java:164)
[ ... ]
Contains: An error occurred while collecting items to be installed
Contains: session context was:(profile=TARGET_DEFINITION:local:1300814044994.target, phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
Contains: 
java.lang.NullPointerException
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.downloadArtifact(SimpleArtifactRepository.java:582)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.downloadArtifact(SimpleArtifactRepository.java:565)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifact(SimpleArtifactRepository.java:637)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.getArtifact(MirrorRequest.java:249)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.transferSingle(MirrorRequest.java:224)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.transfer(MirrorRequest.java:180)
	at org.eclipse.equinox.internal.p2.artifact.repository.MirrorRequest.perform(MirrorRequest.java:116)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifact(SimpleArtifactRepository.java:621)
	at org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.getArtifacts(SimpleArtifactRepository.java:692)
	at org.eclipse.equinox.internal.p2.engine.DownloadManager.fetch(DownloadManager.java:110)
	at org.eclipse.equinox.internal.p2.engine.DownloadManager.start(DownloadManager.java:99)
	at org.eclipse.equinox.internal.p2.engine.phases.Collect.completePhase(Collect.java:76)
	at org.eclipse.equinox.internal.p2.engine.Phase.postPerform(Phase.java:216)
[ ... ]
Comment 3 Beyhan Veliev CLA 2011-03-22 17:34:30 EDT
(In reply to comment #2)
> Thanks for the tip, Equinox DS was missing. Now the testSwitchTagret test
> succeeds but all remaining test cases from TargetSwitcher_Test still fail.
> Any idea?

The bundle o.e.e.p2.transport.ecf is missing which provides the Trasport/Download mechanism of P2. Also make sure that o.e.ecf. o.e.ecf.filetransfer and o.e.ecf.provider.filetransfer are selected. I just verified that "RAP Tooling Tests 3.6" launch configuration available in CVS doesn't select all bundles. Just the required. Does this launch configuration not work for you? It uses junit 3.
Comment 4 Rüdiger Herrmann CLA 2011-03-22 17:56:04 EDT
Since the "RAP Tooling Tests 3.6" launch config didn't work out of the box I must have ruined it completely while trying to bring it to work. Replacing with HEAD and adding the right SWT fragment brought it back to work. Thanks for your assistance!

Though there is one other thing I noticed: some of the tests write "[Fatal Error] :1:1: Premature end of file." to System.err. Can we do anything about this or is it is written by p2?
Comment 5 Beyhan Veliev CLA 2011-03-22 18:43:28 EDT
(In reply to comment #4)
> 
> Though there is one other thing I noticed: some of the tests write "[Fatal
> Error] :1:1: Premature end of file." to System.err. Can we do anything about
> this or is it is written by p2?
It is written by p2 but I don't get these error messages when I run the tests on Windows. I'm creating on the fly p2 repositories for the tests and jarring artifacts using an ant script. I suppose that the jars created by the script are corrupted on Linux and that is why p2 logs such an error message. But I don't know exactly where the problem is. If you have an idea let me know.
Comment 6 Rüdiger Herrmann CLA 2011-03-23 06:29:50 EDT
(In reply to comment #5)
> (In reply to comment #4)
> >
> > Though there is one other thing I noticed: some of the tests write "[Fatal
> > Error] :1:1: Premature end of file." to System.err. Can we do anything about
> > this or is it is written by p2?
> It is written by p2 but I don't get these error messages when I run the tests on
> Windows. I'm creating on the fly p2 repositories for the tests and jarring
> artifacts using an ant script. I suppose that the jars created by the script are
> corrupted on Linux and that is why p2 logs such an error message. But I don't
> know exactly where the problem is. If you have an idea let me know.
I do run the tests on Windows (Vista 32), too.
I opened bug 340737 to track this issue,