Coverage details for com.topcoder.testframework.CredentialsElement

LineHitsSource
1 /*
2  * Copyright (C) 2006 TopCoder Inc., All Rights Reserved.
3  */
4 package com.topcoder.testframework;
5  
6 import org.apache.tools.ant.DynamicElement;
7  
8 import java.util.HashMap;
9 import java.util.Map;
10  
11  
12 /**
13  * This class represents a "credentials" XML element to be used in the Ant build file. The credentials can include user
14  * name, password and other information needed to authenticate to the server. A particular Server implementation
15  * should require the specific credentials. This element represents some kind of a property map, each property is
16  * described by one nested element. The name of nested element represents the property key, the "value" attribute -
17  * property value.
18  * <p/>
19  * <p>Example of the element:<p>
20  * <pre>
21  * &lt;credentials&gt;
22  * &lt;user_name value="topcoder" /&gt;
23  * &lt;password value="some_password" /&gt;
24  * &lt;some_other_property="some_value"/&gt;
25  * &lt;/credentials&gt;
26  * </pre>
27  * <p/>
28  * This class is mutable, i.e. not thread-safe.
29  *
30  * @author real_vg, TCSDEVELOPER
31  * @version 1.0
32  */
33 public class CredentialsElement implements DynamicElement {
34  
35     /**
36      * Stores the property map represented by the "credentials" element. Keys are String instances, values are also
37      * String instances. They are set with call to the {@link CredentialProperty#setValue()}.
38      */
3914    private Map propertyMap = new HashMap();
40  
41     /**
42      * Creates a CredentialsElement instance.
43      */
4414    public CredentialsElement() {
45         //this constructor is intentionally empty
4614    }
47  
48     /**
49      * This method creates a nested element with a specified name. Nested elements are of type {@link
50      * CredentialProperty}.
51      *
52      * @param name the name of nested element to create
53      *
54      * @return the created CredentialProperty instance
55      *
56      * @throws org.apache.tools.ant.BuildException
57      * when fails to create nested element
58      * @throws IllegalArgumentException if name is <tt>null</tt> or empty (trim'd) string
59      */
60     public Object createDynamicElement(final String name) {
614        if (name == null) {
621            throw new IllegalArgumentException("The parameter named [name] was null.");
63         }
643        if (name.trim().length() == 0) {
651            throw new IllegalArgumentException("The parameter named [name] was an empty String.");
66         }
67  
682        return new CredentialProperty(name, getPropertyMap());
69     }
70  
71     /**
72      * This method returns the property map represented by the <tt>credentials</tt> element.
73      *
74      * @return the property map represented by the "credentials" element, which is not a disconnected copy, as proper
75      * usage of the map is expected
76      */
77     public Map getPropertyMap() {
786        return propertyMap;
79     }
80 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.