Methods Summary |
---|
public Result | check(Descriptor descriptor)
run an individual test against the deployment descriptor for the
archive the verifier is performing compliance tests against.
return check((WebServiceEndpoint) descriptor);
|
public abstract Result | check(WebServiceEndpoint descriptor)
|
protected java.lang.String | getAbstractArchiveUri(WebServiceEndpoint desc)
String archBase = getVerifierContext().getAbstractArchive().
getArchiveUri();
final ModuleDescriptor moduleDescriptor = desc.getBundleDescriptor().
getModuleDescriptor();
if (moduleDescriptor.isStandalone()) {
return archBase; // it must be a stand-alone module; no such physical dir exists
} else {
return archBase + File.separator +
FileUtils.makeFriendlyFileName(moduleDescriptor.getArchiveUri());
}
|
private static boolean | isMatching(java.lang.Class cl, java.lang.Class[] classes)
for (int i= 0; i < classes.length; i++) {
/*
if (classes[i].isAssignableFrom(cl))
return true;
if (cl.isAssignableFrom(classes[i]))
return true;
*/
if (classes[i].equals(cl))
return true;
}
return false;
|
public boolean | isSEIMethod(MethodDescriptor mdesc, EjbDescriptor desc, java.lang.Class sei, java.lang.ClassLoader cl)
Method[] seiMeths = sei.getMethods();
Method methToBeTested = null;
try {
methToBeTested = mdesc.getMethod(desc);
} catch(Exception e) {
// internal error cannot get Method for MethodDescriptor
/*
result.addErrorDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.webservices.Error",
"Error: Unexpected error occurred [ {0} ]",
new Object[] {e.getMessage()}));
*/
return false;
}
for (int i=0; i < seiMeths.length; i++) {
if (WSTest.matchesSignatureAndReturn(seiMeths[i], methToBeTested))
return true;
}
return false;
|
protected java.lang.Class | loadImplBeanClass(WebServiceEndpoint descriptor, Result result)
load the declared Service Impl Bean class from the archive
// here we could be an EJB Endpoint or a Servlet Endpoint take care of that
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
String beanClassName = null;
if (descriptor.implementedByEjbComponent()) {
beanClassName = descriptor.getEjbComponentImpl().getEjbClassName();
}
else if (descriptor.implementedByWebComponent()) {
WebComponentDescriptor wcd = descriptor.getWebComponentImpl();
if(wcd!=null)
beanClassName = wcd.getWebComponentImplementation();
}
else {
//result.fail, neither implemented by web nor EJB
result.addErrorDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.webservices.Error",
"Error: Unexpected error occurred [ {0} ]",
new Object[] {"The WebService is neither implemented by an EJB nor a Servlet"}));
}
if (beanClassName != null) {
try {
Context context = getVerifierContext();
ClassLoader jcl = context.getClassLoader();
return Class.forName(beanClassName, false, getVerifierContext().getClassLoader());
}
catch (ClassNotFoundException e) {
Verifier.debug(e);
result.failed(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.webservices.WSTest.BeanClassExists",
"Error: Service Endpoint Implementation Bean class [ {0} ] not found.",
new Object[] {beanClassName}));
return null;
}
}
//result.fail , beanclass name is NULL
result.addErrorDetails(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.webservices.Error",
"Error: Unexpected error occurred [ {0} ]",
new Object[] {"The Servlet Impl Bean class name could not be resolved"}));
return null;
|
protected java.lang.Class | loadSEIClass(WebServiceEndpoint descriptor, Result result)
load the declared SEI class from the archive
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
try {
Context context = getVerifierContext();
ClassLoader jcl = context.getClassLoader();
Class cl = Class.forName(descriptor.getServiceEndpointInterface(), false, getVerifierContext().getClassLoader());
result.passed(smh.getLocalString (
"com.sun.enterprise.tools.verifier.tests.webservices.clpassed",
"The [{0}] Class [{1}] exists and was loaded successfully.",
new Object[] {"SEI",descriptor.getServiceEndpointInterface()}));
return cl;
} catch (ClassNotFoundException e) {
Verifier.debug(e);
result.failed(smh.getLocalString
("com.sun.enterprise.tools.verifier.tests.webservices.WSTest.SEIClassExists",
"Error: Service Endpoint Interface class [ {0} ] not found.",
new Object[] {descriptor.getServiceEndpointInterface()}));
return null;
}
|
public static boolean | matchesSignatureAndReturn(java.lang.reflect.Method meth1, java.lang.reflect.Method meth2)
if (!(meth1.getName()).equals(meth2.getName()))
return false;
/*
int mod1 = meth1.getModifiers();
int mod2 = meth2.getModifiers();
if (mod1 != mod2)
return false;
*/
Class ret1 = meth1.getReturnType();
Class ret2 = meth2.getReturnType();
if (ret1 != ret2)
return false;
Class[] param1 = meth1.getParameterTypes();
Class[] param2 = meth2.getParameterTypes();
if(param1.length != param2.length)
return false;
for(int i = 0; i < param1.length; i++)
if(param1[i] != param2[i])
return false;
// for exceptions, every exception in meth2 should be defined
// in meth1
Class[] excep1 = meth1.getExceptionTypes();
Class[] excep2 = meth2.getExceptionTypes();
for(int i = 0; i < excep2.length; i++) {
if(!isMatching(excep2[i], excep1))
return false;
}
return true;
|