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 java.lang.ClassLoader ; 28 import java.util.*; 29 import java.lang.reflect.*; 30 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 31 import com.sun.enterprise.tools.verifier.*; 32 import com.sun.enterprise.tools.verifier.tests.*; 33 34 53 public class ContainerTransactionStyle2 extends EjbTest implements EjbCheck { 54 55 78 public Result check(EjbDescriptor descriptor) { 79 80 Result result = getInitializedResult(); 81 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 82 83 try { 89 boolean oneFailed = false; 90 if (!descriptor.getMethodContainerTransactions().isEmpty()) { 91 int na = 0; 92 for (Enumeration ee = descriptor.getMethodContainerTransactions().keys(); ee.hasMoreElements();) { 93 MethodDescriptor methodDescriptor = (MethodDescriptor) ee.nextElement(); 94 if (methodDescriptor.getParameterClassNames() == null) { 96 int foundIt = 0; 97 98 for (Enumeration eee = descriptor.getMethodContainerTransactions().keys(); eee.hasMoreElements();) { 101 102 MethodDescriptor matchingMethodDescriptor = (MethodDescriptor) eee.nextElement(); 103 if (matchingMethodDescriptor.getParameterClassNames() == null) { 105 if (methodDescriptor.getName().equals(matchingMethodDescriptor.getName())) { 108 foundIt++; 109 } 110 } 111 } 113 114 if (foundIt == 1) { 117 result.addGoodDetails(smh.getLocalString 118 ("tests.componentNameConstructor", 119 "For [ {0} ]", 120 new Object [] {compName.toString()})); 121 result.passed(smh.getLocalString 122 (getClass().getName() + ".passed", 123 "Container Transaction method name [ {0} ] defined only once in [ {1} ] bean.", 124 new Object [] {methodDescriptor.getName(), descriptor.getName()})); 125 } else if (foundIt > 1) { 126 if (!oneFailed) { 127 oneFailed = false; 128 } 129 result.addErrorDetails(smh.getLocalString 130 ("tests.componentNameConstructor", 131 "For [ {0} ]", 132 new Object [] {compName.toString()})); 133 result.failed(smh.getLocalString 134 (getClass().getName() + ".failed", 135 "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.", 136 new Object [] {methodDescriptor.getName(), new Integer (foundIt), descriptor.getName(),new Integer (2)})); 137 } else { 138 na++; 139 result.addNaDetails(smh.getLocalString 140 ("tests.componentNameConstructor", 141 "For [ {0} ]", 142 new Object [] {compName.toString()})); 143 result.notApplicable(smh.getLocalString 144 (getClass().getName() + ".notApplicable1", 145 "Container Transaction method name [ {0} ] not defined in [ {1} ] bean.", 146 new Object [] {methodDescriptor.getName(), descriptor.getName()})); 147 } 148 } else { na++; 150 result.addNaDetails(smh.getLocalString 151 ("tests.componentNameConstructor", 152 "For [ {0} ]", 153 new Object [] {compName.toString()})); 154 result.notApplicable(smh.getLocalString 155 (getClass().getName() + ".notApplicable2", 156 "Container Transaction method name [ {0} ] not defined as style{1} container transaction within [ {2} ].", 157 new Object [] {methodDescriptor.getName(), new Integer (2), descriptor.getName()})); 158 } 159 160 } 162 if (oneFailed) { 163 result.setStatus(result.FAILED); 164 } else if (na == descriptor.getMethodContainerTransactions().size()){ 165 result.setStatus(result.NOT_APPLICABLE); 166 } else { 167 result.setStatus(result.PASSED); 168 } 169 return result; 170 } else { result.addNaDetails(smh.getLocalString 172 ("tests.componentNameConstructor", 173 "For [ {0} ]", 174 new Object [] {compName.toString()})); 175 result.notApplicable(smh.getLocalString 176 (getClass().getName() + ".notApplicable", 177 "There are no container transactions within this bean [ {0} ]", 178 new Object [] {descriptor.getName()})); 179 return result; 180 } 181 } catch (Throwable t) { 182 result.addErrorDetails(smh.getLocalString 183 ("tests.componentNameConstructor", 184 "For [ {0} ]", 185 new Object [] {compName.toString()})); 186 result.failed(smh.getLocalString 187 (getClass().getName() + ".failedException2", 188 "Error: [ {0} ] does not contain class [ {1} ] within bean [ {2} ]", 189 new Object [] {descriptor.getName(), t.getMessage(), descriptor.getName()})); 190 return result; 191 } 192 } 193 } 194 | Popular Tags |