1 23 28 29 package com.sun.enterprise.tools.verifier.tests.connector.managed; 30 31 import java.io.File ; 32 import java.lang.reflect.Method ; 33 import com.sun.enterprise.tools.verifier.Result; 34 import com.sun.enterprise.tools.verifier.Verifier; 35 import com.sun.enterprise.deployment.ConnectorDescriptor; 36 import com.sun.enterprise.tools.verifier.tests.*; 37 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest; 38 import com.sun.enterprise.tools.verifier.tests.connector.ConnectorCheck; 39 40 48 public class ManagedConnectionGetMetaData 49 extends ConnectorTest 50 implements ConnectorCheck 51 { 52 62 public Result check(ConnectorDescriptor descriptor) { 63 64 Result result = getInitializedResult(); 65 ComponentNameConstructor compName = 66 getVerifierContext().getComponentNameConstructor(); 67 if(!descriptor.getOutBoundDefined()) 69 { 70 result.addNaDetails(smh.getLocalString 71 ("tests.componentNameConstructor", 72 "For [ {0} ]", 73 new Object [] {compName.toString()})); 74 result.notApplicable(smh.getLocalString 75 ("com.sun.enterprise.tools.verifier.tests.connector.managed.notApplicableForInboundRA", 76 "Resource Adapter does not provide outbound communication")); 77 return result; 78 } 79 Class c = findImplementorOf(descriptor, "javax.resource.spi.ManagedConnection"); 82 if(c == null) 83 { 84 result.addErrorDetails(smh.getLocalString 85 ("tests.componentNameConstructor", 86 "For [ {0} ]", 87 new Object [] {compName.toString()})); 88 result.failed(smh.getLocalString 89 ("com.sun.enterprise.tools.verifier.tests.connector.ConnectorTest.findImplementor.failed", 90 "Error: There is no implementation of the [ {0} ] provided", 91 new Object [] {"javax.resource.spi.ManagedConnection"})); 92 return result; 93 } 94 Method m = null; 96 do { 97 try { 98 m = c.getMethod("getMetaData", (Class [])null); 99 } catch(NoSuchMethodException nsme) { 100 } catch(SecurityException se) { 101 } 102 c = c.getSuperclass(); 103 } while (m != null && c != Object .class); 104 if(m == null) 105 { 106 result.addErrorDetails(smh.getLocalString 107 ("tests.componentNameConstructor", 108 "For [ {0} ]", 109 new Object [] {compName.toString()})); 110 result.failed(smh.getLocalString 111 ("com.sun.enterprise.tools.verifier.tests.connector.managed.ManagedConnectionGetMetaData.failed", 112 "Error: There is no implementation of getMetaData() provided")); 113 return result; 114 } 115 Class returnType = m.getReturnType(); 116 if(VerifierTest.isImplementorOf(returnType, 117 "javax.resource.spi.ManagedConnectionMetaData")) 118 { 119 result.addGoodDetails(smh.getLocalString 120 ("tests.componentNameConstructor", 121 "For [ {0} ]", 122 new Object [] {compName.toString()})); 123 result.passed(smh.getLocalString 124 ("com.sun.enterprise.tools.verifier.tests.connector.managed.ManagedConnectionGetMetaData.passed", 125 "ManagedConnection.getMetaData() returns an instance of the" + 126 "javax.resource.spi.ManagedConnectionMetaData interface")); 127 } 128 else 129 { 130 result.addErrorDetails(smh.getLocalString 131 ("tests.componentNameConstructor", 132 "For [ {0} ]", 133 new Object [] {compName.toString()})); 134 result.failed(smh.getLocalString 135 ("com.sun.enterprise.tools.verifier.tests.connector.managed.ManagedConnectionGetMetaData.failed1", 136 "Error: getMetaData() does not return an instance of the" + 137 "javax.resource.spi.ManagedConnectionMetaData interface")); 138 } 139 return result; 140 } 141 } 142 | Popular Tags |