Result result = getInitializedResult();
WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor);
EjbRef[] ejbRefs = descriptor.getIasWebApp().getEjbRef();
boolean oneFailed = false;
String jndiName;
String refName;
if (ejbRefs.length > 0) {
boolean isValidResRefName;
for (int rep=0; rep<ejbRefs.length; rep++ ) {
//System.out.println(">>>>>>>>>>>>>rep is " + rep);
isValidResRefName=false;
jndiName = ejbRefs[rep].getJndiName();
refName = ejbRefs[rep].getEjbRefName();
if (validEjbRefName(refName,descriptor)) {
isValidResRefName=true;
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
(getClass().getName() + ".passed",
"Proper ejb reference name [ {0} ] defined in the war file.",
new Object[] {refName}));
} else {
if (!oneFailed)
oneFailed = true;
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"Error: Ejb reference name [ {0} ] is not valid, either empty or not defined in web.xml.",
new Object[] {refName}));
}
if (isValidResRefName && validJndiName(jndiName, refName,descriptor)){
// foundIt = true;
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addGoodDetails(smh.getLocalString
(getClass().getName() + ".passed",
"Proper jndi name [ {0} ] defined in the war file.",
new Object[] {jndiName}));
} else {
if (!oneFailed)
oneFailed = true;
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.addErrorDetails(smh.getLocalString
(getClass().getName() + ".failed",
"Error: Jndi name [ {0} ] is not validis not valid, either empty or not starts with \"ejb/\".",
new Object[] {jndiName}));
}
}
} else {
result.addNaDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable",
"There is no ejb env reference element present in this web archive [ {0} ].",
new Object[] {descriptor.getName()}));
return result;
}
if (oneFailed)
{
result.setStatus(Result.FAILED);
} else {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.passed
(smh.getLocalString
(getClass().getName() + ".passed",
"All ejb env reference elements are valid within the web archive [ {0} ].",
new Object[] {descriptor.getName()} ));
}
return result;