1 23 24 package com.sun.enterprise.tools.verifier; 25 26 import java.util.Vector ; 27 import java.util.logging.Level ; 28 import java.util.logging.Logger ; 29 30 import com.sun.enterprise.logging.LogDomains; 31 32 public class Result { 33 34 public static final int PASSED = 0; 35 public static final int FAILED = 1; 36 public static final int WARNING = 2; 37 public static final int NOT_APPLICABLE = 3; 38 public static final int NOT_RUN = 4; 39 public static final int NOT_IMPLEMENTED = 5; 40 private int status = NOT_RUN; 41 42 public static final String APP = "application"; public static final String EJB = "ejb"; public static final String WEB = "web"; public static final String APPCLIENT = "appclient"; public static final String CONNECTOR = "connector"; public static final String WEBSERVICE = "webservice"; public static final String WEBSERVICE_CLIENT = "webservice_client"; 50 private String moduleName; 51 52 private String componentName; 53 private String assertion; 54 private String testName; 55 private Vector <String > errorDetails = new Vector <String >(); 56 private Vector <String > goodDetails = new Vector <String >(); 57 private Vector <String > warningDetails = new Vector <String >(); 58 private Vector <String > naDetails = new Vector <String >(); 59 boolean debug = Verifier.isDebug(); 60 61 private Logger logger = LogDomains.getLogger( 62 LogDomains.AVK_VERIFIER_LOGGER); 63 64 67 public Result() { 68 } 69 70 71 77 public void init(Class c, String version, String compName) { 78 setComponentName(compName); 79 StringBuffer assertion = new StringBuffer ( 80 StringManagerHelper.getLocalStringsManager().getLocalString( 81 (c.getName() + ".assertion"), "")); String key = ".specMappingInfo_"+version; StringBuffer specMappingInfo = new StringBuffer ( 84 StringManagerHelper.getLocalStringsManager().getLocalString( 85 (c.getName() + key), "")); 86 if(specMappingInfo == null || specMappingInfo.length() == 0) { 88 key = c.getName() + ".specMappingInfo"; 89 specMappingInfo = new StringBuffer (StringManagerHelper.getLocalStringsManager().getLocalString(key, "")); 90 } 91 String prefix = StringManagerHelper.getLocalStringsManager().getLocalString( 92 (getClass().getName() + ".prefix"), ""); String suffix = StringManagerHelper.getLocalStringsManager().getLocalString( 94 (getClass().getName() + ".suffix"), ""); 96 if (specMappingInfo.length()!=0 && specMappingInfo!=null) 97 setAssertion(assertion.append(" ").append(prefix+" ").append(specMappingInfo).append(" "+suffix).toString()); else 99 setAssertion(assertion.toString()); 100 String this_package = "com.sun.enterprise.tools.verifier."; setTestName(c.getName().substring(this_package.length())); 102 } 103 104 109 public void passed(String detail) { 110 setStatus(PASSED); 111 addGoodDetails(detail); 112 } 113 114 119 public void warning(String detail) { 120 setStatus(WARNING); 121 addWarningDetails(detail); 122 } 123 124 129 public void notApplicable(String detail) { 130 setStatus(NOT_APPLICABLE); 131 addNaDetails(detail); 132 } 133 134 139 public void failed(String detail) { 140 setStatus(FAILED); 141 addErrorDetails(detail); 142 } 143 144 149 public Vector getNaDetails() { 150 if(naDetails.isEmpty()){ 151 Vector <String > result = new Vector <String >(); 152 result.add(StringManagerHelper.getLocalStringsManager() 153 .getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object []{getComponentName()})); 156 result.add(StringManagerHelper.getLocalStringsManager() 157 .getLocalString(getClass().getName() + ".defaultNADetails", "Test is not applicable.")); logger.fine("Returning default NADetails."); return result; 161 } 162 return naDetails; 163 } 164 165 170 public Vector getWarningDetails() { 171 return warningDetails; 172 } 173 174 179 public void addNaDetails(String s) { 180 naDetails.addElement(s); 181 logger.log(Level.FINE, s); 182 } 183 184 189 public Vector getGoodDetails() { 190 if(goodDetails.isEmpty()){ 191 Vector <String > result = new Vector <String >(); 192 result.add(StringManagerHelper.getLocalStringsManager() 193 .getLocalString("tests.componentNameConstructor", "For [ {0} ]", new Object []{getComponentName()})); 196 result.add(StringManagerHelper.getLocalStringsManager() 197 .getLocalString(getClass().getName() + ".defaultGoodDetails", "There were no errors reported.")); logger.fine("Returning default GoodDetails."); return result; 201 } 202 return goodDetails; 203 } 204 205 210 public void addGoodDetails(String s) { 211 goodDetails.addElement(s); 212 logger.log(Level.FINE, s); 213 } 214 215 220 public void addWarningDetails(String s) { 221 warningDetails.addElement(s); 222 logger.log(Level.FINE, s); 223 } 224 225 230 public Vector getErrorDetails() { 231 return errorDetails; 232 } 233 234 239 public void addErrorDetails(String s) { 240 errorDetails.addElement(s); 241 logger.log(Level.FINE, s); 242 } 243 244 249 public int getStatus() { 250 return status; 251 } 252 253 258 public void setStatus(int s) { 259 status = s; 260 } 261 262 267 public String getAssertion() { 268 return assertion; 269 } 270 271 276 public void setAssertion(String s) { 277 assertion = s; 278 } 279 280 285 public String getComponentName() { 286 return componentName; 287 } 288 289 294 public void setComponentName(String s) { 295 componentName = s; 296 } 297 298 303 public String getTestName() { 304 return testName; 305 } 306 307 312 public void setTestName(String s) { 313 testName = s; 314 } 315 316 public void setModuleName(String name) { 317 moduleName = name; 318 } 319 320 public String getModuleName() { 321 return moduleName; 322 } 323 324 } | Popular Tags |