1 23 24 31 32 package com.sun.enterprise.admin.verifier.tests; 33 34 37 38 import java.io.File ; 39 40 import com.sun.enterprise.config.serverbeans.Server; 43 import com.sun.enterprise.config.serverbeans.*; 44 import com.sun.enterprise.config.serverbeans.Resources; 45 import com.sun.enterprise.config.serverbeans.Applications; 46 import com.sun.enterprise.config.ConfigContext; 47 import com.sun.enterprise.config.ConfigContextEvent; 48 import com.sun.enterprise.config.ConfigException; 49 import com.sun.enterprise.config.serverbeans.*; 50 51 import com.sun.enterprise.admin.verifier.*; 52 import java.util.logging.Logger ; 54 import java.util.logging.Level ; 55 import com.sun.logging.LogDomains; 56 57 public class TransactionServiceTest extends ServerXmlTest implements ServerCheck { 58 static Logger _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER); 60 61 public TransactionServiceTest() { 62 } 63 64 public Result check(ConfigContext context) { 66 Result result; 67 result = super.getInitializedResult(); 68 115 119 return result; 120 } 121 122 public Result check(ConfigContextEvent ccce) { 124 Result result; 125 result = new Result(); 126 Object value = ccce.getObject(); 127 String beanName = ccce.getBeanName(); 128 if(beanName!=null) { 129 String name = ccce.getName(); 130 return testSave(name,(String )value); 131 } 132 133 TransactionService txn = (TransactionService)value; 134 String file = txn.getTxLogDir(); 136 if(file==null || file.equals("")) { 137 result.failed("File Name cannot be Null"); 138 return result; 139 } 140 File f = new File (txn.getTxLogDir()); 142 if(f.exists()) 143 result.passed("Transaction Log Dir valid"); 144 else 145 result.failed("Invalid Transaction Log Directory"); 146 String heuDecision = txn.getHeuristicDecision(); 147 if(heuDecision.equals("rollback") || heuDecision.equals("commit")) 148 result.passed("Heurisitic Decision Valid"); 149 else 150 result.failed("Invalid Heuristic Decision"); 151 return result; 152 } 153 154 public Result testSave(String name, String value) { 155 Result result = new Result(); 156 result.passed("Passed **"); 157 if(name.equals(ServerTags.TX_LOG_DIR)){ 158 if(value==null || value.equals("")) { 160 result.failed("File Name cannot be Null"); 161 return result; 162 } 163 File f = new File (value); 165 if(f.exists()) 166 result.passed("Transaction Log Dir valid"); 167 else 168 result.failed("Invalid Transaction Log Directory"); 169 } 170 else if(name.equals(ServerTags.HEURISTIC_DECISION)){ 171 if(value.equals("rollback") || value.equals("commit")) 172 result.passed("Heurisitic Decision Valid"); 173 else 174 result.failed("Invalid Heuristic Decision"); 175 } 176 else if(name.equals(ServerTags.TIMEOUT_IN_SECONDS)) { 178 try { 179 if(Integer.parseInt(value) < 0) 180 result.failed(smh.getLocalString(getClass().getName()+".resTimeoutNegative","Response Timeout cannot be negative number")); 181 else 182 result.passed("Passed ***"); 183 } catch(NumberFormatException e) { 184 result.failed(smh.getLocalString(getClass().getName()+".resTimeoutInvalid","Response Timeout : invalid number")); 185 } 186 } 187 else if(name.equals(ServerTags.KEYPOINT_INTERVAL)) { 188 try { 189 if(Integer.parseInt(value) < 0) 190 result.failed(smh.getLocalString(getClass().getName()+".keyPointNegative","Key Point Interval cannot be negative number")); 191 else 192 result.passed("Passed ***"); 193 } catch(NumberFormatException e) { 194 result.failed(smh.getLocalString(getClass().getName()+".keyPointInvalid","Key Point Interval : invalid number")); 195 } 196 } 197 199 return result; 200 } 201 } 202 | Popular Tags |