Resource authority exists test. Must be Container or Servlet.
Set resourceRefs;
ResourceReferenceDescriptor resrefDes;
Iterator itr;
String resAuth;
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
boolean oneFailed = false;
if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
// get the Resource Reference Descriptors set
resourceRefs = descriptor.getResourceReferenceDescriptors();
itr = resourceRefs.iterator();
// test the Resource Reference Descriptor
while (itr.hasNext()) {
resrefDes = (ResourceReferenceDescriptor)itr.next();
resAuth = resrefDes.getAuthorization();
if (resAuth.equals("Application") || resAuth.equals("Container")) {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
(getClass().getName() + ".passed",
"Resource reference has valid authorization."));
}
else {
oneFailed = true;
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"Error: Resource reference auth has to be either Container or Application."));
}
}
} else {
result.addNaDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable",
"There are no resource references defined within the web archive [ {0} ]",
new Object[] {descriptor.getName()}));
}
if (oneFailed) {
result.setStatus(Result.FAILED);
} else {
result.setStatus(Result.PASSED);
}
return result;