KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > connector > CheckConfigPropertyName


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  * CheckConfigPropertyName.java
25  *
26  * Created on October 2, 2000, 11:11 AM
27  */

28
29 package com.sun.enterprise.tools.verifier.tests.connector;
30
31 import java.util.*;
32 import com.sun.enterprise.deployment.ConnectorDescriptor;
33 import com.sun.enterprise.tools.verifier.tests.*;
34 import com.sun.enterprise.deployment.EnvironmentProperty;
35 import com.sun.enterprise.tools.verifier.Result;
36
37 /**
38  *
39  * @author Jerome Dochez
40  * @version
41  */

42 public class CheckConfigPropertyName extends ConnectorTest implements ConnectorCheck {
43
44     
45     /** <p>
46      * Properties names defined in the resource adapter config-propery should
47      * be unique per resource adapter
48      * </p>
49      *
50      * @paramm descriptor deployment descriptor for the rar file
51      * @return result object containing the result of the individual test
52      * performed
53      */

54     public Result check(ConnectorDescriptor descriptor) {
55         
56         Result result = getInitializedResult();
57     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
58         Set properties = descriptor.getConfigProperties();
59         Iterator iterator = properties.iterator();
60         // let's add the propery name
61
HashSet<String JavaDoc> hs = new HashSet<String JavaDoc>();
62         while (iterator.hasNext()) {
63             EnvironmentProperty ep = (EnvironmentProperty) iterator.next();
64             if (hs.add(ep.getName())==false) {
65                 // duplicate name...
66
result.addErrorDetails(smh.getLocalString
67                        ("tests.componentNameConstructor",
68                     "For [ {0} ]",
69                     new Object JavaDoc[] {compName.toString()}));
70         result.failed(smh.getLocalString(getClass().getName() + ".failed",
71                 "Error: More than one propery has a duplicate name [ {0} ] in the deployment descriptors",
72         new Object JavaDoc[] {ep.getName()}));
73                 return result;
74             }
75         }
76         // success
77
result.addGoodDetails(smh.getLocalString
78                   ("tests.componentNameConstructor",
79                    "For [ {0} ]",
80                    new Object JavaDoc[] {compName.toString()}));
81     result.passed(smh.getLocalString(getClass().getName() + ".passed",
82                      "There are no config properties with a duplicate name"));
83         return result;
84         
85     }
86 }
87
Popular Tags