1 23 24 package com.sun.enterprise.admin.verifier.tests; 25 26 33 34 import java.net.*; 35 36 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 53 import java.util.logging.*; 55 import com.sun.logging.*; 56 57 public class IiopListenerTest extends ServerXmlTest implements ServerCheck { 58 59 static Logger _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER); 61 62 public IiopListenerTest() { 63 } 64 65 public Result check(ConfigContext context) 67 { 68 Result result; 69 result = super.getInitializedResult(); 70 82 90 94 121 return result; 122 } 123 124 public Result check(ConfigContextEvent ccce) { 126 Result result = new Result(); 127 Object value = ccce.getObject(); 128 String choice = ccce.getChoice(); 129 ConfigContext context = ccce.getConfigContext(); 130 String beanName = ccce.getBeanName(); 131 if(beanName!=null) 132 return testSave(ccce.getName(), ccce.getObject()); 133 134 IiopListener listener = (IiopListener)value; 135 136 String id = listener.getId(); 138 if(StaticTest.checkObjectName(id, result)) 139 result.passed("Valid Object Name"); 140 else { 141 result.failed("IIOP Listener ID Invalid "); 142 return result; 143 } 144 146 String hostIP = listener.getAddress(); 147 String hostPort = listener.getPort(); 148 149 if(choice.equals("ADD")) { 150 try { 151 Config config = StaticTest.getConfig(context); 155 if(config!=null) { 156 IiopService service = config.getIiopService(); 157 IiopListener[] listeners = service.getIiopListener(); 158 int count=0; 160 for(int i=0;i<listeners.length;i++) { 161 if(listeners[i].isEnabled()) 162 count++; 163 } 164 172 178 } 179 } catch(Exception e) { 180 result.failed("Exception occured " + e.getMessage()); 181 } 182 } 183 184 try { 185 if(hostPort != null && !hostPort.equals("") ) { 186 if(!StaticTest.isPortValid(Integer.parseInt(hostPort))) { 187 result.failed("Invalid IIOP Listener Port - " + hostPort); 188 return result; 190 } 191 else 192 result.passed("valid IIOP Listener Port"); 193 } 194 } catch(NumberFormatException e) { 195 result.failed("Port Number - " + hostPort + " : Invalid"); 196 return result; 197 } 198 try{ 199 InetAddress.getByName(hostIP).getHostName(); 200 result.passed("Valid IIOP Listener IP"); 201 }catch(UnknownHostException e){ 202 result.failed("Host name not resolvable - " + hostIP); 203 return result; 204 } 205 return result; 206 } 207 208 public Result testSave(String name, Object value) { 209 Result result = new Result(); 210 result.passed("Passed **"); 211 if(name.equals(ServerTags.ADDRESS)) { 212 try{ 213 InetAddress.getByName((String )value).getHostName(); 214 result.passed("Valid Http Listener IP Address"); 215 }catch(UnknownHostException e){ 216 result.failed("Host name not resolvable - " + (String )value); 217 } 218 } 219 String hostPort = (String ) value; 220 if(name.equals(ServerTags.PORT)){ 221 try { 222 if(hostPort != null && !hostPort.equals("")) { 223 if(!StaticTest.isPortValid(Integer.parseInt(hostPort))) { 224 result.failed("Invalid IIOP Listener Port - " + hostPort); 225 } 226 else { 227 result.passed("valid IIOP Listener Port"); 228 } 229 } 230 } catch(NumberFormatException e) { 231 result.failed("Port Number - " + hostPort + " : Invalid"); 232 } 233 } 234 return result; 235 } 236 } 237 | Popular Tags |