Hi,
I am running into below error [1] while using below code snippet.
> AuthorizationGrantCacheEntry cacheEntry =
> AuthorizationGrantCache.getInstance().getValueFromCacheByToken(cacheKey);
> if (cacheEntry == null) {
> return new HashMap<String, String>();
> }
> Map<ClaimMapping, String> userAttributes = cacheEntry.getUserAttributes();
> Map<String, String> userClaims = new HashMap<String, String>();
> for (Map.Entry<ClaimMapping, String> entry : userAttributes.entrySet()) {
> userClaims.put(entry.getKey().getRemoteClaim().getClaimUri(),
> entry.getValue());
> }
>
>
Because It fails to access PrivilegedCarbonContext at
* PrivilegedCarbonContext.endTenantFlow();*
This looks to me a concurrency access issue. *Does anyone has an idea of
fixing this without using powermock?*
If i use power mock , *it also fails Prepare classes for test at *
@PrepareForTest()
PrivilegedCarbonContext.endTenantFlow();
public V getValueFromCache(K key) {
> if (!isEnabled()) {
> return null;
> }
>
> if(key == null) {
> return null;
> }
>
> try {
> PrivilegedCarbonContext.startTenantFlow();
> PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext
> .getThreadLocalCarbonContext();
> carbonContext.setTenantId(MultitenantConstants.SUPER_TENANT_ID);
>
> carbonContext.setTenantDomain(MultitenantConstants.SUPER_TENANT_DOMAIN_NAME);
> Cache<K, V> cache = getBaseCache();
> if (cache != null && cache.get(key) != null) {
> return (V) cache.get(key);
> }
> return null;
> } finally {
> PrivilegedCarbonContext.endTenantFlow();
> }
> }
>
> Need to fix the test case without using powermock.
[1]
testAbstractJWTGenerator(org.wso2.carbon.apimgt.keymgt.token.TokenGenTest)
Time elapsed: 0 sec <<< ERROR!
java.lang.NoClassDefFoundError: Could not initialize class
org.wso2.carbon.context.PrivilegedCarbonContext
at
org.wso2.carbon.identity.application.common.cache.BaseCache.getValueFromCache(BaseCache.java:158)
at
org.wso2.carbon.identity.oauth.cache.AuthorizationGrantCache.getValueFromCacheByToken(AuthorizationGrantCache.java:86)
at
org.wso2.carbon.apimgt.keymgt.token.JWTGenerator.getClaimsFromCache(JWTGenerator.java:129)
at
org.wso2.carbon.apimgt.keymgt.token.JWTGenerator.populateCustomClaims(JWTGenerator.java:98)
at
org.wso2.carbon.apimgt.keymgt.token.AbstractJWTGenerator.buildBody(AbstractJWTGenerator.java:190)
at
org.wso2.carbon.apimgt.keymgt.token.AbstractJWTGenerator.generateToken(AbstractJWTGenerator.java:143)
at
org.wso2.carbon.apimgt.keymgt.token.TokenGenTest.testAbstractJWTGenerator(TokenGenTest.java:81)
Thanks & Regards,
Ishara Cooray
Senior Software Engineer
Mobile : +9477 262 9512
WSO2, Inc. | http://wso2.com/
Lean . Enterprise . Middleware
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev