1 23 package com.sun.enterprise.tools.verifier.tests.ejb.elements; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 27 import java.util.*; 28 import com.sun.enterprise.deployment.*; 29 import com.sun.enterprise.tools.verifier.*; 30 import com.sun.enterprise.tools.verifier.tests.*; 31 32 36 public class EjbResAuthElement extends EjbTest implements EjbCheck { 37 38 39 40 48 public Result check(EjbDescriptor descriptor) { 49 50 Result result = getInitializedResult(); 51 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 52 53 boolean oneFailed = false; 54 if (!descriptor.getResourceReferenceDescriptors().isEmpty()) { 55 for (Iterator itr = descriptor.getResourceReferenceDescriptors().iterator(); itr.hasNext();) { 56 ResourceReferenceDescriptor nextResourceReference = (ResourceReferenceDescriptor) itr.next(); 57 if ((nextResourceReference.getAuthorization().equals(ResourceReferenceDescriptor.APPLICATION_AUTHORIZATION)) || 60 (nextResourceReference.getAuthorization().equals(ResourceReferenceDescriptor.CONTAINER_AUTHORIZATION))) { 61 result.addGoodDetails(smh.getLocalString 62 ("tests.componentNameConstructor", 63 "For [ {0} ]", 64 new Object [] {compName.toString()})); 65 result.addGoodDetails 66 (smh.getLocalString 67 (getClass().getName() + ".passed", 68 "Resource-ref element res-auth sub-element value [ {0} ] is valid within bean [ {1} ]", 69 new Object [] {nextResourceReference.getAuthorization(),descriptor.getName()})); 70 } else { 71 oneFailed = true; 72 result.addErrorDetails(smh.getLocalString 73 ("tests.componentNameConstructor", 74 "For [ {0} ]", 75 new Object [] {compName.toString()})); 76 result.addErrorDetails 77 (smh.getLocalString 78 (getClass().getName() + ".failed", 79 "Error: Resource-ref element res-auth sub-element value [ {0} ] is not valid within bean [ {1} ]", 80 new Object [] {nextResourceReference.getAuthorization(),descriptor.getName()})); 81 } 82 } 83 if (!oneFailed){ 84 result.setStatus(Result.PASSED); 85 } else { 86 result.setStatus(Result.FAILED); 87 } 88 } else { 89 result.addNaDetails(smh.getLocalString 90 ("tests.componentNameConstructor", 91 "For [ {0} ]", 92 new Object [] {compName.toString()})); 93 result.notApplicable(smh.getLocalString 94 (getClass().getName() + ".notApplicable", 95 "There are no resource reference elements defined within this bean [ {0} ]", 96 new Object [] {descriptor.getName()})); 97 } 98 99 100 return result; 101 102 } 103 } 104 | Popular Tags |