KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > ias > beancache > ASEjbBCResizeQuantity


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 package com.sun.enterprise.tools.verifier.tests.ejb.ias.beancache;
25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import java.util.*;
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.deployment.EjbSessionDescriptor;
30 import com.sun.enterprise.tools.verifier.*;
31 import com.sun.enterprise.tools.verifier.tests.*;
32
33 import com.sun.enterprise.tools.common.dd.ejb.*;
34
35 /** ejb [0,n]
36  * bean-cache ?
37  * max-cache-size ? [String]
38  * resize-quantity ? [String]
39  * is-cache-overflow-allowed ? [String]
40  * cache-idle-timout-in-seconds ? [String]
41  * removal-timeout-in-seconds ? [String]
42  * victim-selection-policy ? [String]
43  *
44  * The max-cache-size specifies the maximum number of beans in the cache.
45  * Valid values are between 1 and MAX_INT
46  */

47 public class ASEjbBCResizeQuantity extends ASEjbBeanCache
48 {
49     
50     public Result check(EjbDescriptor descriptor)
51     {
52
53     Result result = getInitializedResult();
54     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
55
56         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
57         String JavaDoc ejbName = null;
58         Ejb testCase = null;
59         boolean oneFailed = false;
60         if(ejbJar!=null)
61         {
62             getBeanCache(descriptor,ejbJar);
63             if(beanCache!=null)
64             {
65                 try
66                 {
67                     String JavaDoc resizeQtyStr = beanCache.getResizeQuantity();
68                     if(resizeQtyStr!=null)
69                     {
70                         if(resizeQtyStr.length()==0)
71                         {
72                             result.failed(smh.getLocalString(getClass().getName()+".failed1",
73                                 "FAILED [AS-EJB bean-cache] : resize-quantity cannot be empty. It should be between 1 and {0}",new Object JavaDoc[]{new Integer JavaDoc(Integer.MAX_VALUE)}));
74                         }
75                         else
76                         {
77                             int resizeQty = Integer.valueOf(resizeQtyStr).intValue();
78                             if(resizeQty < 1 || resizeQty > Integer.MAX_VALUE)
79                             {
80                                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
81                                     "FAILED [AS-EJB bean-cache] : resize-quantity cannot be less than 1 or greater than {0}", new Object JavaDoc[]{new Integer JavaDoc(Integer.MAX_VALUE)}));
82                             }
83                             else
84                             {
85
86                                try{
87                                    String JavaDoc maxCacheSizeStr = beanCache.getMaxCacheSize();
88                                    if(maxCacheSizeStr != null && maxCacheSizeStr.length() >0)
89                                    {
90                                        int maxCacheSize = Integer.valueOf(beanCache.getMaxCacheSize()).intValue();
91                                        if(maxCacheSize >= 1 && maxCacheSize <= Integer.MAX_VALUE)
92                                        {
93                                            if(resizeQty <= maxCacheSize)
94                                            {
95                                                result.passed(smh.getLocalString(getClass().getName()+".passed1","PASSED [AS-EJB bean-cache] : resize-quantity is {0} and is less than max-cache-size {1}",new Object JavaDoc[]{(new Integer JavaDoc(resizeQty)),new Integer JavaDoc(maxCacheSize)}));
96                                            }
97                                            else
98                                            {
99                                                result.failed(smh.getLocalString(getClass().getName()+".failed3","FAILED [AS-EJB bean-cache] : resize-quantity {0} should be less than max-cache-size {1}",new Object JavaDoc[]{new Integer JavaDoc(resizeQty), new Integer JavaDoc(maxCacheSize)}));
100                                            }
101                                        }else
102                                        {
103                                            result.failed(smh.getLocalString(getClass().getName()+".failed4","FAILED [AS-EJB bean-cache] : resize-quantity should be less than max-cache-size and max-cache-size is not a valid integer"));
104                                        }
105                                    }
106                                    else
107                                    {
108                                        result.passed(smh.getLocalString(getClass().getName()+".passed2","PASSED [AS-EJB bean-cache] : resize-quantity is {0}",new Object JavaDoc[]{(new Integer JavaDoc(resizeQty))}));
109                                    }
110
111                                 }catch(NumberFormatException JavaDoc nfex){
112                                     result.failed(smh.getLocalString(getClass().getName()+".failed3","FAILED [AS-EJB bean-cache] : resize-quantity should be less than max-cache-size and max-cache-size is not a valid integer"));
113                                 }
114                             }
115                         }
116                     }
117                     else
118                     {
119                         result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
120                           "NOT APPLICABLE [AS-EJB bean-cache] : resize-quantity element is not defined"));
121                     }
122                 }
123                 catch(NumberFormatException JavaDoc nfex)
124                 {
125                     Verifier.debug(nfex);
126                     result.failed(smh.getLocalString(getClass().getName()+".failed5",
127                         "FAILED [AS-EJB bean-cache] : resize-quantity is invalid. It should be a valid integer"));
128                 }
129             }
130             else
131             {
132                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable2",
133                     "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
134             }
135         }
136         else
137         {
138             result.addErrorDetails(smh.getLocalString
139                                    ("tests.componentNameConstructor",
140                                     "For [ {0} ]",
141                                     new Object JavaDoc[] {compName.toString()}));
142             result.addErrorDetails(smh.getLocalString
143                  (getClass().getName() + ".notRun",
144                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
145         }
146         return result;
147     }
148 }
149
150
Popular Tags