1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import com.sun.enterprise.tools.verifier.tests.web.WebTest; 26 import java.util.*; 27 import java.util.logging.Level ; 28 29 import com.sun.enterprise.deployment.*; 30 import com.sun.enterprise.tools.verifier.*; 31 import com.sun.enterprise.tools.verifier.tests.*; 32 33 34 38 public class WebResourceType extends WebTest implements WebCheck { 39 40 48 public Result check(WebBundleDescriptor descriptor) { 49 50 Result result = getInitializedResult(); 51 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 52 53 if (descriptor.getResourceReferences().hasMoreElements()) { 54 boolean oneFailed = false; 55 boolean foundIt = false; 56 for (Enumeration e = descriptor.getResourceReferences() ; e.hasMoreElements() ;) { 58 foundIt = false; 59 ResourceReferenceDescriptor next = (ResourceReferenceDescriptor) e.nextElement(); 60 String resType = next.getType(); 61 logger.log(Level.FINE, "servlet resType: " + resType); 62 if ((resType.equals("javax.sql.DataSource")) || 63 (resType.equals("javax.jms.QueueConnectionFactory")) || 64 (resType.equals("javax.jms.TopicConnectionFactory")) || 65 (resType.equals("javax.mail.Session")) || 66 (resType.equals("java.net.URL"))) { 67 foundIt = true; 68 } else { 69 foundIt = false; 70 String specVerStr = descriptor.getSpecVersion(); 71 double specVer = 0; 72 specVer = (Double.valueOf(specVerStr)).doubleValue(); 73 if (Double.compare(specVer, 2.4) >= 0) { 74 foundIt = true; 76 } 77 } 78 if (foundIt) { 79 result.addGoodDetails(smh.getLocalString 80 ("tests.componentNameConstructor", 81 "For [ {0} ]", 82 new Object [] {compName.toString()})); 83 result.addGoodDetails(smh.getLocalString 84 (getClass().getName() + ".passed", 85 "The resource-type [ {0} ] element specifies the Java class type of the data source within web application [ {1} ]", 86 new Object [] {resType, descriptor.getName()})); 87 } else { 88 if (!oneFailed) { 89 oneFailed = true; 90 } 91 result.addErrorDetails(smh.getLocalString 92 ("tests.componentNameConstructor", 93 "For [ {0} ]", 94 new Object [] {compName.toString()})); 95 result.addErrorDetails(smh.getLocalString 96 (getClass().getName() + ".failed", 97 "Error: The resource-type [ {0} ] element does not specify valid Java class type of the data source within web application [ {1} ]", 98 new Object [] {resType, descriptor.getName()})); 99 } 100 } 101 if (oneFailed) { 102 result.setStatus(Result.FAILED); 103 } else { 104 result.setStatus(Result.PASSED); 105 } 106 } else { 107 result.addNaDetails(smh.getLocalString 108 ("tests.componentNameConstructor", 109 "For [ {0} ]", 110 new Object [] {compName.toString()})); 111 result.notApplicable(smh.getLocalString 112 (getClass().getName() + ".notApplicable", 113 "There are no resource-type elements within the web archive [ {0} ]", 114 new Object [] {descriptor.getName()})); 115 } 116 117 return result; 118 } 119 } 120 | Popular Tags |