KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.net.*;
35
36 /* Test Case which validates the JmsService Fields
37  * Author : srini@sun.com
38  **/

39
40 // 8.0 XML Verifier
41
//import com.sun.enterprise.tools.verifier.Result;
42
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 // Logging
53
import java.util.logging.Logger JavaDoc;
54 import java.util.logging.Level JavaDoc;
55 import com.sun.logging.LogDomains;
56
57
58 public class JmsServiceTest extends ServerXmlTest implements ServerCheck {
59     // Logging
60
static Logger JavaDoc _logger = LogDomains.getLogger(LogDomains.APPVERIFY_LOGGER);
61     
62     public JmsServiceTest() {
63     }
64  
65     // check method called by command line verifier
66
public Result check(ConfigContext context)
67     {
68         Result result;
69         result = super.getInitializedResult();
70         //<addition author="irfan@sun.com" [bug/RFE]-id="" >
71
// 8.0 XML Verifier
72
/*try {
73             Server server = (Server)context.getRootConfigBean();
74             JmsService jms = server.getJmsService();
75             String httpPort = jms.getPort();
76             try {
77                 if(StaticTest.isPortValid(Integer.parseInt(httpPort)))
78                        result.passed("Valid Port");
79                 else
80                        result.failed("Invalid JMSService Port - " + httpPort);
81             }
82             catch(NumberFormatException e) {
83                 result.failed("Invalid JMSService Port Number - " + httpPort);
84             }
85             // Bug : 4713369
86             try {
87                 String timeout = jms.getInitTimeoutInSeconds();
88                 if(Integer.parseInt(timeout) < 0)
89                     result.failed(smh.getLocalString(getClass().getName()+".initTimeoutNegative","Init Timeout cannot be negative number"));
90                 else
91                     result.passed("** Passed ** ");
92             } catch(NumberFormatException e) {
93                 result.failed(smh.getLocalString(getClass().getName()+".initTimeoutInvalid","Init Timeout : invalid number"));
94             }
95         }
96         catch(Exception ex) {
97             //<addition author="irfan@sun.com" [bug/rfe]-id="logging" >
98             /*ex.printStackTrace();
99             result.failed("Exception : " + ex.getMessage());
100             // Logging
101             _logger.log(Level.FINE, "serverxmlverifier.exception", ex);
102             result.failed("Exception : " + ex.getMessage());
103             //</addition>
104         }*/

105         //</addition>
106
return result;
107     }
108     
109     // check method called by iasadmin and admin GUI
110
public Result check(ConfigContextEvent ccce) {
111         Result result = new Result();
112         Object JavaDoc value = ccce.getObject();
113         String JavaDoc beanName = ccce.getBeanName();
114         if(beanName!=null) {
115                String JavaDoc name = ccce.getName();
116                return testSave(name, (String JavaDoc) value);
117         }
118         
119         //<addition author="irfan@sun.com" [bug/RFE]-id="" >
120
// 8.0 XML Verifier
121
//JmsService jms = (JmsService) value;
122
JmsHost jms = (JmsHost) value;
123         //</addition>
124
String JavaDoc httpPort = jms.getPort();
125         try {
126             if(StaticTest.isPortValid(Integer.parseInt(httpPort)))
127                    result.passed("Valid Port");
128             else
129                    result.failed("Invalid JMSService Port : " + httpPort);
130         }
131         catch(NumberFormatException JavaDoc e) {
132             result.failed("Invalid JMSService Port Number : " + httpPort);
133         }
134         return result;
135     }
136     
137     public Result testSave(String JavaDoc name, String JavaDoc value) {
138         Result result = new Result();
139         result.passed("Passed");
140         if(name.equals(ServerTags.PORT)) {
141             try {
142                 if(StaticTest.isPortValid(Integer.parseInt(value)))
143                     result.passed("Valid Port");
144                 else
145                     result.failed("Invalid Port");
146             } catch(NumberFormatException JavaDoc e) {
147                 result.failed("Bad Number");
148             }
149         }
150         // check if init timeout is valid
151
// Bug : 4713369
152
if(name.equals(ServerTags.INIT_TIMEOUT_IN_SECONDS)) {
153             try {
154                 if(Integer.parseInt(value) < 0)
155                     result.failed(smh.getLocalString(getClass().getName()+".initTimeoutNegative","Init Timeout cannot be negative number"));
156                 else
157                     result.passed("Passed **");
158             } catch (NumberFormatException JavaDoc e) {
159                  result.failed(smh.getLocalString(getClass().getName()+".initTimeoutInvalid","Init Timeout : invalid number"));
160             }
161         }
162         return result;
163     }
164 }
165
Popular Tags