KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > verifier > tests > HttpServiceTest


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /**
25  * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
26  *
27  * Copyright 2001-2002 by iPlanet/Sun Microsystems, Inc.,
28  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
29  * All rights reserved.
30  */

31
32 package com.sun.enterprise.admin.verifier.tests;
33
34 /* Test case for checking the validity of HTTP Service
35  * Author : srini@sun.com
36  */

37
38 import java.io.File JavaDoc;
39
40 //import com.sun.enterprise.tools.verifier.Result;
41
import com.sun.enterprise.config.serverbeans.Server;
42 import com.sun.enterprise.config.serverbeans.*;
43 import com.sun.enterprise.config.serverbeans.Resources;
44 import com.sun.enterprise.config.serverbeans.Applications;
45 import com.sun.enterprise.config.ConfigContext;
46 import com.sun.enterprise.config.ConfigContextEvent;
47 import com.sun.enterprise.config.ConfigException;
48 import com.sun.enterprise.config.serverbeans.*;
49
50 import com.sun.enterprise.admin.verifier.*;
51
52 // Logging
53
import java.util.logging.Logger JavaDoc;
54 import java.util.logging.Level JavaDoc;
55 import com.sun.logging.LogDomains;
56
57 public class HttpServiceTest extends ServerXmlTest implements ServerCheck {
58     
59     // Logging
60
static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
61     
62     public HttpServiceTest() {
63     }
64  
65     // check method called from command line verifier
66
public Result check(ConfigContext context)
67     {
68         Result result;
69         result = super.getInitializedResult();
70         /*try {
71             Server server = (Server)context.getRootConfigBean();
72             HttpService http = server.getHttpService();
73             String qos = http.getQosMetricsIntervalInSeconds();
74             String qosRecompute = http.getQosRecomputeTimeIntervalInMillis();
75             try {
76                 // <addition> srini@sun.com Bug : 4698904
77                 if(qos!=null)
78                 // </addition>
79                     Long.parseLong(qos);
80                 result.passed("Http Service QOS Metric Interval in Seconds Valid " + qos);
81             } catch(NumberFormatException e) {
82                 result.failed("Http Service QOS Metric Interval in Seconds invalid number - " + qos );
83             }
84             try {
85                // <addition> srini@sun.com Bug : 4698904
86                if(qosRecompute!=null)
87                // </addition>
88                     Long.parseLong(qosRecompute);
89                result.passed("Http Service QOS Recompute time interval in millis Valid ");
90             } catch(NumberFormatException e) {
91                 result.failed("Http Service QOS Recompute time Interval in millis Invalid - " + qosRecompute );
92             }
93             Acl[] aclList = http.getAcl();
94             for(int i=0;i<aclList.length;i++){
95                 String file = aclList[i].getFile();
96                 File f = new File(file);
97                 try {
98                     if(f.exists())
99                         result.passed("Acl File Valid - " + file);
100                     else
101                         result.failed("Acl File Invalid - " + file);
102                 }catch(SecurityException e){
103                     result.failed("Acl File Not able to access"+ file);
104                 }
105             }
106         }
107         catch(Exception ex) {
108             // Logging
109             _logger.log(Level.FINE, "serverxmlverifier.exception", ex);
110             result.failed("Exception : " + ex.getMessage());
111         }*/

112         return result;
113     }
114     
115     // check method called from iasadmin and admin GUI
116
public Result check(ConfigContextEvent ccce)
117     {
118         Result result;
119         Object JavaDoc value = ccce.getObject();
120         result = new Result();
121         String JavaDoc beanName = ccce.getBeanName();
122         result.passed("Passed***");
123         if(beanName!=null) {
124                String JavaDoc name = ccce.getName();
125                result = testSave(name,(String JavaDoc)value);
126                return result;
127         }
128 /*
129         HttpService http = (HttpService)value;
130         String qos = http.getQosMetricsIntervalInSeconds();
131         String qosRecompute = http.getQosRecomputeTimeIntervalInMillis();
132         try {
133             // <addition> srini@sun.com Bug : 4698904
134             if(qos!=null)
135             // </addition>
136                 Long.parseLong(qos);
137             result.passed("QOS Metric Interval Valid Number : Passed");
138         } catch(NumberFormatException e) {
139             result.failed("QOS Metric Interval Invalid Number " + qos);
140         }
141         try {
142            // <addition> srini@sun.com Bug : 4698904
143            if(qosRecompute!=null)
144            // <addition>
145                 Long.parseLong(qosRecompute);
146            result.passed("QOS Recompute Interval Valid : Passed");
147         } catch(NumberFormatException e) {
148             result.failed(" QOS Recompute time Interval Invalid Number " + qosRecompute);
149         }
150         Acl[] aclList = http.getAcl();
151         for(int i=0;i<aclList.length;i++){
152             String file = aclList[i].getFile();
153             File f = new File(file);
154             try {
155                 if(f.exists())
156                     result.passed("Acl File Valid - " + file + ": Passed");
157                 else
158                     result.failed("Acl File Invalid - " + file + ": Failed");
159             }catch(SecurityException e){
160                 result.failed("Acl File Not able to access "+ file + ": Failed");
161             }
162         }
163 */

164         return result;
165     }
166     
167     public Result testSave(String JavaDoc name, String JavaDoc value) {
168         Result result = new Result();
169         result.passed("passed ** ");
170 /*
171         if(name.equals(ServerTags.QOS_METRICS_INTERVAL_IN_SECONDS)) {
172             try {
173                 // <addition> srini@sun.com Bug : 4698904
174                 if(value!=null)
175                 // </addition>
176                     Long.parseLong(value);
177                 result.passed("QOS Metrics Interval Valid Number ");
178             } catch(NumberFormatException e) {
179                 result.failed("QOS Metrics Interval Invalid Number " + value);
180             }
181         }
182         if(name.equals(ServerTags.QOS_RECOMPUTE_TIME_INTERVAL_IN_MILLIS)){
183             try {
184                 // <addition> srini@sun.com Bug : 4698904
185                 if(value!=null)
186                 // <addition>
187                      Long.parseLong(value);
188                 result.passed("QOS Recompute Time Interval Valid Number");
189             } catch(NumberFormatException e){
190                 result.failed("QOS Recompute Time Interval Invalid Number " + value);
191             }
192         }
193 */

194         return result;
195     }
196     
197 }
198
Popular Tags