Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Eclipse Process Manager (Stardust) » Deployed models are cached during unit tests
Deployed models are cached during unit tests [message #1703291] Thu, 30 July 2015 11:05 Go to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
I am using Stardust 2.1.1, and currently I am writing unit tests with JUnit, Spring and an in-memory Derby database. I would like to create a clean state for each of the unit tests, so I create and initialize the database before every test method and drop it after method executions. I also dispose of the Spring application context and initialize it between test methods with the @DirtiesContext(classMode = ClassMode.AFTER_EACH_TEST_METHOD) annotation.

My problem is that despite dropping the database and reinitializing the Spring context after every test method my previously deployed models are still cached and I get an authorization-related exception:

org.eclipse.stardust.common.error.AccessForbiddenException: AUTHx01000 - The user 'motu' does not have the permission 'model.deployProcessModel'.
	at org.eclipse.stardust.engine.core.runtime.utils.Authorization2.checkPermission(Authorization2.java:332) ~[carnot-engine-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.core.runtime.beans.interceptors.GuardingInterceptor.invoke(GuardingInterceptor.java:52) ~[carnot-engine-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.core.runtime.interceptor.MethodInvocationImpl.proceed(MethodInvocationImpl.java:130) [carnot-engine-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.core.runtime.beans.interceptors.AbstractLoginInterceptor.performCall(AbstractLoginInterceptor.java:201) ~[carnot-engine-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.core.runtime.beans.interceptors.AbstractLoginInterceptor.invoke(AbstractLoginInterceptor.java:131) ~[carnot-engine-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.api.spring.SpringBeanLoginInterceptor.invoke(SpringBeanLoginInterceptor.java:79) ~[carnot-spring-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.core.runtime.interceptor.MethodInvocationImpl.proceed(MethodInvocationImpl.java:130) [carnot-engine-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.api.spring.SpringSessionInterceptor.doWithDataSource(SpringSessionInterceptor.java:142) ~[carnot-spring-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.api.spring.SpringSessionInterceptor.access$000(SpringSessionInterceptor.java:48) ~[carnot-spring-2.1.1.jar:2.1.1]
	at org.eclipse.stardust.engine.api.spring.SpringSessionInterceptor$1.doInConnection(SpringSessionInterceptor.java:87) ~[carnot-spring-2.1.1.jar:2.1.1]
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:350) ~[spring-jdbc-4.1.6.RELEASE.jar:4.1.6.RELEASE]

...


I looked into the code and found out that the ModelManagerBean and ModelMananagerBeanPartition classes cache my test model. I set the Infinity.Engine.Caching property to false in my carnot.properties as per the online documentation but the model is still getting cached.

What is the proper way to disable caching in Stardust or how can I ensure that it disposes of everything that is cached?

Thank you.
Re: Deployed models are cached during unit tests [message #1703307 is a reply to message #1703291] Thu, 30 July 2015 13:23 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
If I don't drop the database but wrap the test methods in transactions and roll them back instead, the problem still occurs. If I don't roll back the database modifications, I can deploy the same model again in a different test method, despite a previous deployment of the same model being there (which is totally normal behaviour).
Re: Deployed models are cached during unit tests [message #1703311 is a reply to message #1703307] Thu, 30 July 2015 13:40 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
In the Authorization2.checkPermission(...) method there's the following call:

List<IModel> models = ModelManagerFactory.getCurrent().findActiveModels();


This is a call to the ModelManagerPartition.findActiveModels() method. This class also has a deleleAllModels() method. If I try to call either of them manually after deploying the model in the first test, I get a NullPointerException.
Re: Deployed models are cached during unit tests [message #1703331 is a reply to message #1703311] Thu, 30 July 2015 16:53 Go to previous messageGo to next message
Tam Gom is currently offline Tam GomFriend
Messages: 36
Registered: July 2011
Member
I found out that the AdministrationService interface has the cleanupRuntime(boolean) and cleanupRuntimeAndModels() methods. These flush the deployed models and users from memory, but do not make changes in the database itself.
Re: Deployed models are cached during unit tests [message #1704621 is a reply to message #1703291] Mon, 10 August 2015 08:21 Go to previous message
Amol Chandurkar is currently offline Amol ChandurkarFriend
Messages: 3
Registered: December 2011
Junior Member
Looking into the exception it looks like motu user don't have model deployment permission. So it may be failing to deploy your model Are you deleting users and recreating it and providing appropriate access rights.
Previous Topic:JBoss EAP 6.2 and UserService
Next Topic:How to access transitions programmatically
Goto Forum:
  


Current Time: Tue Sep 18 16:22:16 GMT 2018

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

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

Back to the top