1 23 package com.sun.enterprise.tools.verifier.tests.wsclients; 24 25 import com.sun.enterprise.deployment.*; 26 import com.sun.enterprise.tools.verifier.*; 27 import java.util.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import java.lang.reflect.*; 30 31 34 35 42 43 public class HandlerPortNameCheck extends WSClientTest implements WSClientCheck { 45 46 50 public Result check (ServiceReferenceDescriptor descriptor) { 51 52 Result result = getInitializedResult(); 53 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 54 55 if (descriptor.hasHandlers()) { 56 Collection allPortNames = getAllPortNamesInService(descriptor); 57 List handlerChain = descriptor.getHandlerChain(); 58 for (Iterator it = handlerChain.iterator(); it.hasNext();) { 59 Collection c = ((WebServiceHandler)it.next()).getPortNames(); 60 Collection invalid = getInvalidHandlerPortNames(c,allPortNames); 61 if (invalid.size() > 0) { 62 result.addErrorDetails(smh.getLocalString ("tests.componentNameConstructor", 64 "For [ {0} ]", new Object [] {compName.toString()})); 65 result.failed(smh.getLocalString 66 (getClass().getName() + ".failed", 67 "The Port Name(s) in the Handler Chain are invalid.")); 68 } 69 else { 70 result.addGoodDetails(smh.getLocalString ("tests.componentNameConstructor", 72 "For [ {0} ]", new Object [] {compName.toString()})); 73 result.passed(smh.getLocalString (getClass().getName()+ ".passed", 74 "Port Name(s) in the Handler-Chain are valid.")); 75 76 } 77 } 78 } 79 else { 80 result.addNaDetails(smh.getLocalString 82 ("tests.componentNameConstructor", "For [ {0} ]", new Object [] {compName.toString()})); 83 result.notApplicable(smh.getLocalString (getClass().getName() + ".notapp", 84 "Not Applicable since No handlers defined in this WebService.")); 85 } 86 87 return result; 88 } 89 90 private Collection getAllPortNamesInService(ServiceReferenceDescriptor descriptor) { 91 92 Collection endPoints = descriptor.getPortsInfo(); 93 Vector<String > ret = new Vector<String >(); 94 for (Iterator it = endPoints.iterator(); it.hasNext();) { 95 ret.add(((ServiceRefPortInfo)it.next()).getPortComponentLinkName()); 96 } 97 return ret; 98 } 99 100 private Collection getInvalidHandlerPortNames(Collection hpNames, Collection allPortNames) { 101 102 Vector<String > ret = new Vector<String >(); 103 for (Iterator it = hpNames.iterator(); it.hasNext();) { 104 String currName = (String )it.next(); 105 if (!allPortNames.contains(currName)) 106 ret.add(currName); 107 } 108 return ret; 109 } 110 } 111 112 | Popular Tags |