Program: 114838
Project: 114838
Buggy source:
@Test(groups={"String_Node_Str"},description="String_Node_Str",enabled=false) public void testAPIAccessWhenJWTCachingEnabledTestCase() throws APIManagerIntegrationTestException, XPathExpressionException, IOException, JSONException, InterruptedException {
  String applicationName="String_Node_Str";
  String apiName="String_Node_Str";
  String apiContext="String_Node_Str";
  String apiVersion="String_Node_Str";
  String description="String_Node_Str";
  String endpointURL=gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str";
  String apiTier=APIMIntegrationConstants.API_TIER.GOLD;
  String tags="String_Node_Str";
  int waitingSecs=900;
  addAPI(apiName,apiVersion,apiContext,description,endpointURL,tags,providerName);
  APIStoreRestClient apiStoreRestClient=new APIStoreRestClient(storeURLHttp);
  apiStoreRestClient.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  apiStoreRestClient.addApplication(applicationName,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,storeContext.getContextTenant().getContextUser().getUserName());
  subscriptionRequest.setApplicationName(applicationName);
  apiStoreRestClient.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(applicationName);
  String responseString=apiStoreRestClient.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject response=new JSONObject(responseString);
  String accessToken=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").get("String_Node_Str").toString();
  String url=gatewayUrlsWrk.getWebAppURLNhttp() + apiContext + "String_Node_Str"+ apiVersion;
  Map<String,String> headers=new HashMap<String,String>();
  headers.put("String_Node_Str","String_Node_Str" + accessToken);
  HttpResponse httpResponse=HttpRequestUtil.doGet(url,headers);
  assertEquals("String_Node_Str" + url,200,httpResponse.getResponseCode());
  log.info("String_Node_Str" + waitingSecs + "String_Node_Str");
  Thread.sleep(waitingSecs * 1000);
  httpResponse=HttpRequestUtil.doGet(url,headers);
  assertEquals("String_Node_Str" + url + "String_Node_Str",200,httpResponse.getResponseCode());
}

Fixed version (ground truth):
/** 
 * This test case is a test for the fix fix for APIMANAGER-3912, where jwt claims are attempted to retrieve from an invalidated cache and hence failed. In carbon 4.2 products cache invalidation timeout is not configurable and is hardcoded to 15 mins. So the test case will take approximately 15mins to complete and it will delay the product build unnecessarily, hence the test case is disabled.
 */
@Test(groups={"String_Node_Str"},description="String_Node_Str",enabled=false) public void testAPIAccessWhenJWTCachingEnabledTestCase() throws APIManagerIntegrationTestException, XPathExpressionException, IOException, JSONException, InterruptedException {
  String applicationName="String_Node_Str";
  String apiName="String_Node_Str";
  String apiContext="String_Node_Str";
  String apiVersion="String_Node_Str";
  String description="String_Node_Str";
  String endpointURL=gatewayUrlsWrk.getWebAppURLNhttp() + "String_Node_Str";
  String apiTier=APIMIntegrationConstants.API_TIER.GOLD;
  String tags="String_Node_Str";
  int waitingSecs=900;
  addAPI(apiName,apiVersion,apiContext,description,endpointURL,tags,providerName);
  APIStoreRestClient apiStoreRestClient=new APIStoreRestClient(storeURLHttp);
  apiStoreRestClient.login(storeContext.getContextTenant().getContextUser().getUserName(),storeContext.getContextTenant().getContextUser().getPassword());
  apiStoreRestClient.addApplication(applicationName,APIMIntegrationConstants.APPLICATION_TIER.LARGE,"String_Node_Str","String_Node_Str");
  SubscriptionRequest subscriptionRequest=new SubscriptionRequest(apiName,storeContext.getContextTenant().getContextUser().getUserName());
  subscriptionRequest.setApplicationName(applicationName);
  apiStoreRestClient.subscribe(subscriptionRequest);
  APPKeyRequestGenerator generateAppKeyRequest=new APPKeyRequestGenerator(applicationName);
  String responseString=apiStoreRestClient.generateApplicationKey(generateAppKeyRequest).getData();
  JSONObject response=new JSONObject(responseString);
  String accessToken=response.getJSONObject("String_Node_Str").getJSONObject("String_Node_Str").get("String_Node_Str").toString();
  String url=gatewayUrlsWrk.getWebAppURLNhttp() + apiContext + "String_Node_Str"+ apiVersion;
  Map<String,String> headers=new HashMap<String,String>();
  headers.put("String_Node_Str","String_Node_Str" + accessToken);
  HttpResponse httpResponse=HttpRequestUtil.doGet(url,headers);
  assertEquals("String_Node_Str" + url,200,httpResponse.getResponseCode());
  log.info("String_Node_Str" + waitingSecs + "String_Node_Str");
  Thread.sleep(waitingSecs * 1000);
  httpResponse=HttpRequestUtil.doGet(url,headers);
  assertEquals("String_Node_Str" + url + "String_Node_Str",200,httpResponse.getResponseCode());
}