Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Workspace closed Exception with JUnitTests
Workspace closed Exception with JUnitTests [message #774273] Tue, 03 January 2012 16:12 Go to next message
Nepomuk Seiler is currently offline Nepomuk SeilerFriend
Messages: 88
Registered: December 2010
Member
I wanted to write some JUnitTest for my model and ran into an interesting problem.

When I add to the import package "org.eclipse.sapphire.workspace" the following exception is thrown
and I need org.eclipse.resource and org.eclipse.runtime plugins imported.

ERROR : Workspace is closed.
java.lang.IllegalStateException: Workspace is closed.
	at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:399)
	at org.eclipse.sapphire.workspace.internal.WorkspaceRelativePathService.roots(WorkspaceRelativePathService.java:35)
	at org.eclipse.sapphire.services.RelativePathService.convertToAbsolute(RelativePathService.java:176)
	at org.eclipse.sapphire.services.internal.RelativePathValidationService.validate(RelativePathValidationService.java:44)
	at org.eclipse.sapphire.modeling.Value.initValidation(Value.java:76)
	at org.eclipse.sapphire.modeling.Value.init(Value.java:62)
	at de.lmu.ifi.dbs.knowing.core.model.internal.Configuration.refreshProperty(Configuration.java:304)
	at org.eclipse.sapphire.modeling.ModelElement.refresh(ModelElement.java:463)
	at org.eclipse.sapphire.modeling.ModelElement.refresh(ModelElement.java:456)
	at de.lmu.ifi.dbs.knowing.core.model.internal.Configuration.getOutput(Configuration.java:155)
	at de.lmu.ifi.dbs.knowing.core.model.internal.Configuration.read(Configuration.java:347)
	at org.eclipse.sapphire.modeling.ModelElement.read(ModelElement.java:239)
	at org.eclipse.sapphire.modeling.ModelElement.refreshValidationResult(ModelElement.java:707)
	at org.eclipse.sapphire.modeling.ModelElement.validate(ModelElement.java:689)
	at org.eclipse.sapphire.modeling.ModelElementHandle.refreshValidationState(ModelElementHandle.java:290)
	at org.eclipse.sapphire.modeling.ModelElementHandle.refreshInternal(ModelElementHandle.java:254)
	at org.eclipse.sapphire.modeling.ModelElementHandle.init(ModelElementHandle.java:55)
	at de.lmu.ifi.dbs.knowing.core.model.internal.DataProcessingUnit.refreshProperty(DataProcessingUnit.java:211)
	at org.eclipse.sapphire.modeling.ModelElement.refresh(ModelElement.java:463)
	at org.eclipse.sapphire.modeling.ModelElement.refresh(ModelElement.java:456)
	at de.lmu.ifi.dbs.knowing.core.model.internal.DataProcessingUnit.getConfiguration(DataProcessingUnit.java:52)
	at de.lmu.ifi.dbs.knowing.core.model.internal.DataProcessingUnit.read(DataProcessingUnit.java:362)
	at org.eclipse.sapphire.modeling.ModelElement.read(ModelElement.java:253)
	at org.eclipse.sapphire.modeling.ModelElement.copy(ModelElement.java:520)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest$$anonfun$1.apply$mcV$sp(DPUUtilTest.scala:26)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest$$anonfun$1.apply(DPUUtilTest.scala:20)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest$$anonfun$1.apply(DPUUtilTest.scala:20)
	at org.scalatest.BeforeAndAfter$class.runTest(BeforeAndAfter.scala:166)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest.runTest(DPUUtilTest.scala:16)
	at org.scalatest.FunSuite$$anonfun$runTests$1.apply(FunSuite.scala:1304)
	at org.scalatest.FunSuite$$anonfun$runTests$1.apply(FunSuite.scala:1304)
	at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:226)
	at org.scalatest.SuperEngine$$anonfun$org$scalatest$SuperEngine$$runTestsInBranch$1.apply(Engine.scala:215)
	at scala.collection.LinearSeqOptimized$class.foreach(LinearSeqOptimized.scala:59)
	at scala.collection.immutable.List.foreach(List.scala:45)
	at org.scalatest.SuperEngine.org$scalatest$SuperEngine$$runTestsInBranch(Engine.scala:215)
	at org.scalatest.SuperEngine.runTestsImpl(Engine.scala:282)
	at org.scalatest.FunSuite$class.runTests(FunSuite.scala:1304)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest.runTests(DPUUtilTest.scala:16)
	at org.scalatest.Suite$class.run(Suite.scala:2286)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest.org$scalatest$FunSuite$$super$run(DPUUtilTest.scala:16)
	at org.scalatest.FunSuite$$anonfun$run$1.apply(FunSuite.scala:1310)
	at org.scalatest.FunSuite$$anonfun$run$1.apply(FunSuite.scala:1310)
	at org.scalatest.SuperEngine.runImpl(Engine.scala:318)
	at org.scalatest.FunSuite$class.run(FunSuite.scala:1310)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest.org$scalatest$BeforeAndAfter$$super$run(DPUUtilTest.scala:16)
	at org.scalatest.BeforeAndAfter$class.run(BeforeAndAfter.scala:208)
	at de.lmu.ifi.dbs.knowing.core.util.DPUUtilTest.run(DPUUtilTest.scala:16)
	at org.scalatest.junit.JUnitRunner.run(JUnitRunner.scala:94)
	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
	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.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


I'm using org.scalatest but the tests are executed with JUnit 4, so IMHO this is not the point of failure.
When I remove "org.eclipse.sapphire.workspace" the test runs without any problem.

Is this a bug or a feature?
Re: Workspace closed Exception with JUnitTests [message #774289 is a reply to message #774273] Tue, 03 January 2012 16:30 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Use "Run As -> JUnit Plug-in Test" as opposed to "Run As -> JUnit Test". This will ensure that OSGi container is started.

- Konstantin
Re: Workspace closed Exception with JUnitTests [message #774302 is a reply to message #774289] Tue, 03 January 2012 16:54 Go to previous messageGo to next message
Nepomuk Seiler is currently offline Nepomuk SeilerFriend
Messages: 88
Registered: December 2010
Member
thx for the quick answer. Tests run a lot slower with this setting and
I can only test within in Eclipse. There is no way to use normal JUnitTests
while using org.eclipse.sapphire.workspace?
Re: Workspace closed Exception with JUnitTests [message #774469 is a reply to message #774302] Wed, 04 January 2012 01:01 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
You have to use this method of running tests if you need access to features that depend on OSGi. Eclipse workspace facility depends on OSGi. My guess is that the slowness you are experiencing is the initial startup of OSGi/Eclipse environment. As you add more tests, the cost of the initial startup will be less of an issue.

You can certainly run tests in this manner from command line build. See how to do that in Sapphire's build.xml file (in the root of the repo).

- Konstantin
Previous Topic:Using @{} params in Sapphire expressions
Next Topic:Transient properties as property editors
Goto Forum:
  


Current Time: Wed Nov 30 04:24:56 GMT 2022

Powered by FUDForum. Page generated in 0.02881 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top