1 package com.sun.enterprise.tools.verifier.tests.ejb.ias; 2 3 25 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 27 import java.util.*; 28 import com.sun.enterprise.deployment.EjbDescriptor; 29 import com.sun.enterprise.deployment.EjbSessionDescriptor; 30 import com.sun.enterprise.tools.verifier.*; 31 import com.sun.enterprise.tools.verifier.tests.*; 32 33 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 34 35 import com.sun.enterprise.tools.common.dd.*; 36 import com.sun.enterprise.tools.common.dd.ejb.*; 37 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 38 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor; 39 40 41 52 public class ASEjbMDBConnFactory extends EjbTest implements EjbCheck { 53 54 public Result check(EjbDescriptor descriptor) 55 { 56 Result result = getInitializedResult(); 57 ComponentNameConstructor compName = new ComponentNameConstructor(descriptor); 58 59 SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject(); 60 boolean oneFailed = false; 61 boolean oneWarn = false; 62 if(ejbJar!=null) 63 { 64 Ejb testCase = getEjb(descriptor.getName(),ejbJar); 65 MdbConnectionFactory mdbConnFac = testCase.getMdbConnectionFactory(); 66 if(mdbConnFac != null) 67 { 68 String jndiName = mdbConnFac.getJndiName(); 69 if(jndiName.length()==0) 70 { 71 oneFailed = true; 72 result.failed(smh.getLocalString(getClass().getName()+".failed", 73 "FAILED [AS-EJB mdb-connection-factory] : jndi-name cannot be an empty string")); 74 } 75 else 76 { 77 if(jndiName.startsWith("jms/")) 78 { 79 result.passed(smh.getLocalString(getClass().getName()+".passed", 80 "PASSED [AS-EJB mdb-connection-factory] : jndi-name is {0}",new Object []{jndiName})); 81 } 82 else 83 { 84 oneWarn = true; 85 result.warning(smh.getLocalString(getClass().getName()+".warning", 86 "WARNING [AS-EJB mdb-connection-factory] : jndi-name {0} should start with jms/", 87 new Object []{jndiName})); 88 } 89 } 90 91 DefaultResourcePrincipal defPrinci = mdbConnFac.getDefaultResourcePrincipal(); 92 if(defPrinci != null) 93 { 94 String name = defPrinci.getName(); 95 if(name.length()==0) 96 { 97 oneFailed = true; 98 result.failed(smh.getLocalString(getClass().getName()+".failed1", 99 "FAILED [AS-EJB default-resource-principal] : name cannot be an empty string")); 100 } 101 else 102 { 103 result.passed(smh.getLocalString(getClass().getName()+".passed1", 104 "PASSED [AS-EJB default-resource-principal] : name is {0}",new Object []{name})); 105 } 106 107 String password = defPrinci.getPassword(); 108 if(password.length()==0) 109 { 110 result.warning(smh.getLocalString(getClass().getName()+".warning2", 115 "WARNING [AS-EJB default-resource-principal] : password is an empty string")); 116 } 118 else 119 { 120 result.passed(smh.getLocalString(getClass().getName()+".passed2", 121 "PASSED [AS-EJB default-resource-principal] : password is {0}",new Object []{password})); 122 } 123 } 124 else 125 { 126 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", 127 "NOT APPLICABLE [AS-EJB mdb-connection-factory] : default-resource-prncipal element is not defined")); 128 } 129 } 130 else 131 { 132 if(descriptor instanceof EjbMessageBeanDescriptor) 133 { 134 EjbMessageBeanDescriptor mdbDesc = (EjbMessageBeanDescriptor)descriptor; 135 if(mdbDesc.hasTopicDest() && mdbDesc.hasDurableSubscription()) 136 { 137 oneFailed = true; 138 result.failed(smh.getLocalString(getClass().getName()+".failed3", 139 "FAILED [AS-EJB ejb] : mdb-connection-factory has to be defined for an MDB with destination-type " + 140 "as Topic and subscription-durability as Durable")); 141 } 142 else 143 { 144 oneWarn = true; 145 result.warning(smh.getLocalString(getClass().getName()+".warning1", 146 "WARNING [AS-EJB ejb] : mdb-connection-factory should be defined for a Message Driven Bean")); 147 } 148 } 149 else 150 { 151 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1", 152 "NOT APPLICABLE [AS-EJB ejb] : mdb-connection-factory element is not defined")); 153 } 154 } 155 if(oneFailed) 156 result.setStatus(Result.FAILED); 157 else if(oneWarn) 158 result.setStatus(Result.WARNING); 159 } 160 else 161 { 162 result.addErrorDetails(smh.getLocalString 163 (getClass().getName() + ".notRun", 164 "NOT RUN [AS-EJB] : Could not create an SunEjbJar object")); 165 } 166 return result; 167 } 168 } 169 | Popular Tags |