1 23 package com.sun.enterprise.tools.verifier.tests.appclient; 24 25 import java.util.*; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 30 36 public class AppClientEnvEntryValue extends AppClientTest implements AppClientCheck { 37 38 39 49 public Result check(ApplicationClientDescriptor descriptor) { 50 Result result = getInitializedResult(); 51 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 52 53 boolean oneFailed = false; 54 if (!descriptor.getEnvironmentProperties().isEmpty()) { 55 int oneEnvValue = 0; 56 int oneNA = 0; 57 for (Iterator itr2 = descriptor.getEnvironmentProperties().iterator(); 60 itr2.hasNext();) { 61 oneEnvValue++; 62 EnvironmentProperty nextEnvironmentProperty = 63 (EnvironmentProperty) itr2.next(); 64 if ((nextEnvironmentProperty.getValue() != null) && (nextEnvironmentProperty.getValue().length() > 0)) { 65 if (nextEnvironmentProperty.getType().equals("java.lang.String")) { 66 try { 69 new String (nextEnvironmentProperty.getValue()); 70 } catch (Exception e) { 71 if (debug) { 72 e.printStackTrace(); 73 } 74 oneFailed = true; 75 } 76 } else if (nextEnvironmentProperty.getType().equals("java.lang.Character")) { 77 try { 78 if (nextEnvironmentProperty.getValue().length() == 1) { 79 char c = (nextEnvironmentProperty.getValue()).charAt(0); 80 new Character (c); 81 } 82 else oneFailed = true; 83 } catch (Exception e) { 84 if (debug) { 85 e.printStackTrace(); 86 } 87 oneFailed = true; 88 } 89 } else if (nextEnvironmentProperty.getType().equals("java.lang.Integer")) { 90 try { 91 new Integer (nextEnvironmentProperty.getValue()); 92 } catch (NumberFormatException e) { 93 if (debug) { 94 e.printStackTrace(); 95 } 96 oneFailed = true; 97 } 98 } else if (nextEnvironmentProperty.getType().equals("java.lang.Boolean")) { 99 try { 102 new Boolean (nextEnvironmentProperty.getValue()); 103 } catch (Exception e) { 104 if (debug) { 105 e.printStackTrace(); 106 } 107 oneFailed = true; 108 } 109 } else if (nextEnvironmentProperty.getType().equals("java.lang.Double")) { 110 try { 111 new Double (nextEnvironmentProperty.getValue()); 112 } catch (NumberFormatException e) { 113 if (debug) { 114 e.printStackTrace(); 115 } 116 oneFailed = true; 117 } 118 } else if (nextEnvironmentProperty.getType().equals("java.lang.Byte")) { 119 try { 120 new Byte (nextEnvironmentProperty.getValue()); 121 } catch (NumberFormatException e) { 122 if (debug) { 123 e.printStackTrace(); 124 } 125 oneFailed = true; 126 } 127 } else if (nextEnvironmentProperty.getType().equals("java.lang.Short")) { 128 try { 129 new Short (nextEnvironmentProperty.getValue()); 130 } catch (NumberFormatException e) { 131 if (debug) { 132 e.printStackTrace(); 133 } 134 oneFailed = true; 135 } 136 } else if (nextEnvironmentProperty.getType().equals("java.lang.Long")) { 137 try { 138 new Long (nextEnvironmentProperty.getValue()); 139 } catch (NumberFormatException e) { 140 if (debug) { 141 e.printStackTrace(); 142 } 143 oneFailed = true; 144 } 145 } else if (nextEnvironmentProperty.getType().equals("java.lang.Float")) { 146 try { 147 new Float (nextEnvironmentProperty.getValue()); 148 } catch (NumberFormatException e) { 149 if (debug) { 150 e.printStackTrace(); 151 } 152 oneFailed = true; 153 } 154 } else { 155 oneFailed = true; 156 } 157 if (oneFailed) { 158 result.addErrorDetails(smh.getLocalString 159 ("tests.componentNameConstructor", 160 "For [ {0} ]", 161 new Object [] {compName.toString()})); 162 result.addErrorDetails 163 (smh.getLocalString 164 (getClass().getName() + ".failed", 165 "Error: Environment entry value [ {0} ] does not have valid value [ {1} ] for constructor of the specified type [ {2} ] that takes a single String parameter within application client [ {3} ]", 166 new Object [] {nextEnvironmentProperty.getName(),nextEnvironmentProperty.getValue(),nextEnvironmentProperty.getType(),descriptor.getName()})); 167 } else { 168 result.addGoodDetails(smh.getLocalString 169 ("tests.componentNameConstructor", 170 "For [ {0} ]", 171 new Object [] {compName.toString()})); 172 result.addGoodDetails 173 (smh.getLocalString 174 (getClass().getName() + ".passed", 175 "Environment entry value [ {0} ] has valid value [ {1} ] for constructor of the specified type [ {2} ] that takes a single String parameter within application client [ {3} ]", 176 new Object [] {nextEnvironmentProperty.getName(),nextEnvironmentProperty.getValue(),nextEnvironmentProperty.getType(),descriptor.getName()})); 177 } 178 } else { 179 result.addNaDetails(smh.getLocalString 183 ("tests.componentNameConstructor", 184 "For [ {0} ]", 185 new Object [] {compName.toString()})); 186 result.addNaDetails(smh.getLocalString 187 (getClass().getName() + ".notApplicable1", 188 "Environment entry [ {0} ] initial value is not defined within application client [ {1} ]", 189 new Object [] {nextEnvironmentProperty.getName(), descriptor.getName()})); 190 oneNA++; 191 } 192 } 193 if (oneFailed){ 194 result.setStatus(Result.FAILED); 195 } else if (oneNA == oneEnvValue) { 196 result.setStatus(Result.NOT_APPLICABLE); 197 } else { 198 result.setStatus(Result.PASSED); 199 } 200 } else { 201 result.addNaDetails(smh.getLocalString 202 ("tests.componentNameConstructor", 203 "For [ {0} ]", 204 new Object [] {compName.toString()})); 205 result.notApplicable(smh.getLocalString 206 (getClass().getName() + ".notApplicable", 207 "There are no environment entry elements defined within this application client [ {0} ]", 208 new Object [] {descriptor.getName()})); 209 } 210 211 212 return result; 213 } 214 215 } 216 | Popular Tags |