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

Bug 366574

Summary: ServiceContext_Test.testGetApplicationContextFromSessionStore failing occasionally
Product: [RT] RAP Reporter: Ralf Sternberg <rsternberg>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 1.5   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Ralf Sternberg CLA 2011-12-13 11:19:40 EST
I've seen this test failing locally and also on the build server [1]. Note that the tycho build is configured to run tests in random order, so this might be a setup or cleanup issue. That would explain why it doesn't happen in the IDE and why it's happening occasionally.

Error Message

Failed to register resource: resource/static/html/blank.html

Stacktrace

org.eclipse.rwt.internal.resources.ResourceRegistrationException: Failed to register resource: resource/static/html/blank.html
	at org.eclipse.rwt.internal.resources.ResourceManagerImpl.internalRegister(ResourceManagerImpl.java:242)
	at org.eclipse.rwt.internal.resources.ResourceManagerImpl.register(ResourceManagerImpl.java:128)
	at org.eclipse.swt.internal.widgets.displaykit.ClientResources.registerTextResource(ClientResources.java:406)
	at org.eclipse.swt.internal.widgets.displaykit.ClientResources.registerResources(ClientResources.java:327)
	at org.eclipse.rwt.internal.application.ApplicationContext.doActivateInstances(ApplicationContext.java:278)
	at org.eclipse.rwt.internal.application.ApplicationContext.access$0(ApplicationContext.java:271)
	at org.eclipse.rwt.internal.application.ApplicationContext$1.run(ApplicationContext.java:266)
	at org.eclipse.rwt.internal.application.ApplicationContextUtil.runWith(ApplicationContextUtil.java:89)
	at org.eclipse.rwt.internal.application.ApplicationContext.activateInstances(ApplicationContext.java:264)
	at org.eclipse.rwt.internal.application.ApplicationContext.doActivate(ApplicationContext.java:260)
	at org.eclipse.rwt.internal.application.ApplicationContext.activate(ApplicationContext.java:126)
	at org.eclipse.rwt.internal.service.ServiceContext_Test.testGetApplicationContextFromSessionStore(ServiceContext_Test.java:59)
Caused by: java.io.IOException: Could not create directory structure: /rwt-resources/resource/static/html
	at org.eclipse.rwt.internal.resources.ResourceManagerImpl.createFile(ResourceManagerImpl.java:276)
	at org.eclipse.rwt.internal.resources.ResourceManagerImpl.registerContent(ResourceManagerImpl.java:267)
	at org.eclipse.rwt.internal.resources.ResourceManagerImpl.internalRegister(ResourceManagerImpl.java:240)
	... 38 more

[1] https://hudson.eclipse.org/hudson/job/rap-runtime/444/testReport/junit/org.eclipse.rwt.internal.service/ServiceContext_Test/testGetApplicationContextFromSessionStore/
Comment 1 Ivan Furnadjiev CLA 2012-02-10 09:50:26 EST
*** Bug 371216 has been marked as a duplicate of this bug. ***
Comment 2 Ralf Sternberg CLA 2012-02-10 17:14:15 EST
I had to look at it a hundred times to realize what the exception clearly states: Failed to create a directory at the absolute(!) path /rwt-resources/resource/static/html, which of course must fail. The reason is that the mocked ServletContext returns an empty string in getRealPath (see setUp() method). As an effect, ResourceManager.getDiskLocation will return this absolute path.

This only happens with the default ResourceManagerImpl, not with the TestResourceManager.
The reason this failure depended on test execution order was that the TestResourceManager was not installed in Fixture.setUp(), but not Fixture.tearDown() did not reset to the default.

Fixed the latter by resetting the TestResourceManager in Fixture.tearDown().
The failing test has been fixed by calling Fixture.setSkipResourceRegistration() in ServiceContext_Test.setUp().