KickJava   Java API By Example, From Geeks To Geeks.

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


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  * is-cache-overflow-allowed ? [String]
39  * cache-idle-timout-in-seconds ? [String]
40  * removal-timeout-in-seconds ? [String]
41  * victim-selection-policy ? [String]
42  *
43  * The max-cache-size specifies the maximum number of beans in the cache.
44  * Valid values are between 1 and MAX_INT
45  * @author Irfan Ahmed
46  */

47 public class ASEjbBCMaxCacheSize 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 maxCacheSizeStr = beanCache.getMaxCacheSize();
68                     if(maxCacheSizeStr!=null)
69                     {
70                         if(maxCacheSizeStr.length()==0)
71                         {
72                             result.failed(smh.getLocalString(getClass().getName()+".failed1",
73                                 "FAILED [AS-EJB bean-cache] : max-cache-size cannot be empty. It should be between 1 and MAX_INT"));
74                         }
75                         else
76                         {
77                             int maxCacheSize = Integer.valueOf(beanCache.getMaxCacheSize()).intValue();
78                             if(maxCacheSize < 1 || maxCacheSize > Integer.MAX_VALUE)
79                             {
80                                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
81                                     "FAILED [AS-EJB bean-cache] : max-cache-size cannot be less than 1 or greater than MAX_INT"));
82                             }
83                             else
84                                 result.passed(smh.getLocalString(getClass().getName()+".passed1",
85                                     "PASSED [AS-EJB bean-cache] : max-cache-size is {0}",new Object JavaDoc[]{(new Integer JavaDoc(maxCacheSize))}));
86                         }
87                     }
88                     else
89                     {
90                         result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
91                           "NOT APPLICABLE [AS-EJB bean-cache] : max-cache-size is element not defined"));
92                     }
93                 }
94                 catch(NumberFormatException JavaDoc nfex)
95                 {
96                     Verifier.debug(nfex);
97                     result.failed(smh.getLocalString(getClass().getName()+".failed3",
98                         "FAILED [AS-EJB bean-cache] : max-cache-size is invalid. It should be a valid integer"));
99                 }
100             }
101             else
102             {
103                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
104                     "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
105             }
106         }
107         else
108         {
109             result.addErrorDetails(smh.getLocalString
110                                    ("tests.componentNameConstructor",
111                                     "For [ {0} ]",
112                                     new Object JavaDoc[] {compName.toString()}));
113             result.addErrorDetails(smh.getLocalString
114                  (getClass().getName() + ".notRun",
115                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
116         }
117         return result;
118     }
119 }
120
121
Popular Tags