1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 28 import com.sun.enterprise.tools.verifier.*; 29 import java.lang.ClassLoader ; 30 import java.util.*; 31 import java.lang.reflect.*; 32 import com.sun.enterprise.tools.verifier.tests.*; 33 34 50 public class ContainerTransactionStyle1 extends EjbTest implements EjbCheck { 51 52 53 73 public Result check(EjbDescriptor descriptor) { 74 75 Result result = getInitializedResult(); 76 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 77 78 try { 84 boolean oneFailed = false; 85 boolean na = false; 86 int foundWildCard = 0; 87 if (!descriptor.getMethodContainerTransactions().isEmpty()) { 88 for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) { 89 MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement(); 90 91 if (methodDescriptor.getName().equals(MethodDescriptor.ALL_EJB_METHODS)) { 92 foundWildCard++; 93 } 94 } 95 96 if (foundWildCard == 1) { 99 result.addGoodDetails(smh.getLocalString 100 ("tests.componentNameConstructor", 101 "For [ {0} ]", 102 new Object [] {compName.toString()})); 103 result.passed(smh.getLocalString 104 (getClass().getName() + ".passed", 105 "Container Transaction method name [ {0} ] defined only once in [ {1} ] bean.", 106 new Object [] {MethodDescriptor.ALL_EJB_METHODS, descriptor.getName()})); 107 } else if (foundWildCard > 1) { 108 result.addErrorDetails(smh.getLocalString 109 ("tests.componentNameConstructor", 110 "For [ {0} ]", 111 new Object [] {compName.toString()})); 112 result.failed(smh.getLocalString 113 (getClass().getName() + ".failed", 114 "Error: Container Transaction method name [ {0} ] is defined [ {1} ] times in [ {2} ] bean. Method name container transaction style [ {3} ] is allowed only once per bean.", 115 new Object [] {MethodDescriptor.ALL_EJB_METHODS, new Integer (foundWildCard), descriptor.getName(),MethodDescriptor.ALL_EJB_METHODS})); 116 } else { 117 result.addNaDetails(smh.getLocalString 118 ("tests.componentNameConstructor", 119 "For [ {0} ]", 120 new Object [] {compName.toString()})); 121 result.notApplicable(smh.getLocalString 122 (getClass().getName() + ".notApplicable1", 123 "Container Transaction method name [ {0} ] not defined in [ {1} ] bean.", 124 new Object [] {MethodDescriptor.ALL_EJB_METHODS, descriptor.getName()})); 125 } 126 127 } else { result.addNaDetails(smh.getLocalString 129 ("tests.componentNameConstructor", 130 "For [ {0} ]", 131 new Object [] {compName.toString()})); 132 result.notApplicable(smh.getLocalString 133 (getClass().getName() + ".notApplicable", 134 "There are no method permissions within this bean [ {0} ]", 135 new Object [] {descriptor.getName()})); 136 } 137 return result; 138 } catch (Throwable t) { 139 result.addErrorDetails(smh.getLocalString 140 ("tests.componentNameConstructor", 141 "For [ {0} ]", 142 new Object [] {compName.toString()})); 143 result.failed(smh.getLocalString 144 (getClass().getName() + ".failedException2", 145 "Error: [ {0} ] does not contain class [ {1} ] within bean [ {2} ]", 146 new Object [] {descriptor.getName(), t.getMessage(), descriptor.getName()})); 147 return result; 148 } 149 } 150 } 151 | Popular Tags |