EMMA Coverage Report (generated Wed Oct 26 13:47:17 EDT 2011)
[all classes][org.jclouds]

COVERAGE SUMMARY FOR SOURCE FILE [PropertiesBuilder.java]

nameclass, %method, %block, %line, %
PropertiesBuilder.java100% (1/1)50%  (14/28)53%  (169/316)59%  (41/69)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class PropertiesBuilder100% (1/1)50%  (14/28)53%  (169/316)59%  (41/69)
limitConnectionsTo (int): PropertiesBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
limitUserThreadsTo (int): PropertiesBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
relaxSSLHostname (boolean): PropertiesBuilder 0%   (0/1)0%   (0/15)0%   (0/2)
sessionInterval (long): PropertiesBuilder 0%   (0/1)0%   (0/15)0%   (0/2)
trustAllCerts (boolean): PropertiesBuilder 0%   (0/1)0%   (0/15)0%   (0/2)
useSystemProxies (boolean): PropertiesBuilder 0%   (0/1)0%   (0/15)0%   (0/2)
withConnectionTimeout (long): PropertiesBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
withMaxRedirects (int): PropertiesBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
withProxyHost (String): PropertiesBuilder 0%   (0/1)0%   (0/8)0%   (0/2)
withProxyPassword (String): PropertiesBuilder 0%   (0/1)0%   (0/8)0%   (0/2)
withProxyPort (int): PropertiesBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
withProxyUser (String): PropertiesBuilder 0%   (0/1)0%   (0/8)0%   (0/2)
withRetriesDelayStart (long): PropertiesBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
withSOTimeout (long): PropertiesBuilder 0%   (0/1)0%   (0/9)0%   (0/2)
PropertiesBuilder (): void 100% (1/1)100% (7/7)100% (3/3)
PropertiesBuilder (Properties): void 100% (1/1)100% (7/7)100% (3/3)
apiVersion (String): PropertiesBuilder 100% (1/1)100% (8/8)100% (2/2)
build (): Properties 100% (1/1)100% (3/3)100% (1/1)
credentials (String, String): PropertiesBuilder 100% (1/1)100% (16/16)100% (4/4)
defaultProperties (): Properties 100% (1/1)100% (56/56)100% (12/12)
endpoint (String): PropertiesBuilder 100% (1/1)100% (8/8)100% (2/2)
iso3166Codes (Iterable): PropertiesBuilder 100% (1/1)100% (11/11)100% (2/2)
limitConnectionsPerHostTo (int): PropertiesBuilder 100% (1/1)100% (9/9)100% (2/2)
limitIoWorkerThreadsTo (int): PropertiesBuilder 100% (1/1)100% (9/9)100% (2/2)
provider (String): PropertiesBuilder 100% (1/1)100% (8/8)100% (2/2)
withMaxClientReuse (int): PropertiesBuilder 100% (1/1)100% (9/9)100% (2/2)
withMaxRetries (int): PropertiesBuilder 100% (1/1)100% (9/9)100% (2/2)
withMaxSessionFailures (int): PropertiesBuilder 100% (1/1)100% (9/9)100% (2/2)

1/**
2 * Licensed to jclouds, Inc. (jclouds) under one or more
3 * contributor license agreements.  See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership.  jclouds licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License.  You may obtain a copy of the License at
9 *
10 *   http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied.  See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19package org.jclouds;
20 
21import static org.jclouds.Constants.PROPERTY_API_VERSION;
22import static org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT;
23import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
24import static org.jclouds.Constants.PROPERTY_ENDPOINT;
25import static org.jclouds.Constants.PROPERTY_IDENTITY;
26import static org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS;
27import static org.jclouds.Constants.PROPERTY_ISO3166_CODES;
28import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT;
29import static org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST;
30import static org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE;
31import static org.jclouds.Constants.PROPERTY_MAX_REDIRECTS;
32import static org.jclouds.Constants.PROPERTY_MAX_RETRIES;
33import static org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES;
34import static org.jclouds.Constants.PROPERTY_PROVIDER;
35import static org.jclouds.Constants.PROPERTY_PROXY_HOST;
36import static org.jclouds.Constants.PROPERTY_PROXY_PASSWORD;
37import static org.jclouds.Constants.PROPERTY_PROXY_PORT;
38import static org.jclouds.Constants.PROPERTY_PROXY_SYSTEM;
39import static org.jclouds.Constants.PROPERTY_PROXY_USER;
40import static org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME;
41import static org.jclouds.Constants.PROPERTY_RETRY_DELAY_START;
42import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
43import static org.jclouds.Constants.PROPERTY_SO_TIMEOUT;
44import static org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS;
45import static org.jclouds.Constants.PROPERTY_USER_THREADS;
46 
47import java.util.Properties;
48 
49import org.jclouds.javax.annotation.Nullable;
50 
51import com.google.common.annotations.VisibleForTesting;
52import com.google.common.base.Joiner;
53 
54/**
55 * Builds properties used in Http engines
56 * 
57 * @author Adrian Cole, Andrew Newdigate
58 */
59public class PropertiesBuilder {
60 
61   /**
62    * @see org.jclouds.Constants.PROPERTY_RELAX_HOSTNAME
63    */
64   public PropertiesBuilder relaxSSLHostname(boolean relax) {
65      properties.setProperty(PROPERTY_RELAX_HOSTNAME, relax + "");
66      return this;
67   }
68 
69   /**
70    * @see org.jclouds.Constants.PROPERTY_TRUST_ALL_CERTS
71    */
72   public PropertiesBuilder trustAllCerts(boolean trust) {
73      properties.setProperty(PROPERTY_TRUST_ALL_CERTS, trust + "");
74      return this;
75   }
76 
77   /**
78    * @see org.jclouds.Constants.PROPERTY_PROXY_SYSTEM
79    */
80   public PropertiesBuilder useSystemProxies(boolean useSystemProxies) {
81      properties.setProperty(PROPERTY_PROXY_SYSTEM, useSystemProxies + "");
82      return this;
83   }
84 
85   /**
86    * @see org.jclouds.Constants.PROPERTY_PROXY_HOST
87    */
88   public PropertiesBuilder withProxyHost(String proxyHost) {
89      properties.setProperty(PROPERTY_PROXY_HOST, proxyHost);
90      return this;
91   }
92 
93   /**
94    * @see org.jclouds.Constants.PROPERTY_PROXY_PORT
95    */
96   public PropertiesBuilder withProxyPort(int proxyPort) {
97      properties.setProperty(PROPERTY_PROXY_PORT, Integer.toString(proxyPort));
98      return this;
99   }
100 
101   /**
102    * @see org.jclouds.Constants.PROPERTY_PROXY_USER
103    */
104   public PropertiesBuilder withProxyUser(String proxyUser) {
105      properties.setProperty(PROPERTY_PROXY_USER, proxyUser);
106      return this;
107   }
108 
109   /**
110    * @see org.jclouds.Constants.PROPERTY_PROXY_PASSWORD
111    */
112   public PropertiesBuilder withProxyPassword(String proxyPassword) {
113      properties.setProperty(PROPERTY_PROXY_PASSWORD, proxyPassword);
114      return this;
115   }
116 
117   /**
118    * @see org.jclouds.Constants.PROPERTY_SO_TIMEOUT
119    */
120   public PropertiesBuilder withSOTimeout(long soTimeout) {
121      properties.setProperty(PROPERTY_SO_TIMEOUT, Long.toString(soTimeout));
122      return this;
123   }
124 
125   /**
126    * @see org.jclouds.Constants.PROPERTY_CONNECTION_TIMEOUT
127    */
128   public PropertiesBuilder withConnectionTimeout(long connectionTimeout) {
129      properties.setProperty(PROPERTY_CONNECTION_TIMEOUT, Long.toString(connectionTimeout));
130      return this;
131   }
132 
133   /**
134    * @see org.jclouds.Constants.PROPERTY_MAX_RETRIES
135    */
136   public PropertiesBuilder withMaxRetries(int httpMaxRetries) {
137      properties.setProperty(PROPERTY_MAX_RETRIES, Integer.toString(httpMaxRetries));
138      return this;
139   }
140 
141   /**
142    * @see org.jclouds.Constants.PROPERTY_RETRY_DELAY_START
143    */
144   public PropertiesBuilder withRetriesDelayStart(long delayStart) {
145      properties.setProperty(PROPERTY_RETRY_DELAY_START, Long.toString(delayStart));
146      return this;
147   }
148 
149   /**
150    * @see org.jclouds.Constants.PROPERTY_MAX_REDIRECTS
151    */
152   public PropertiesBuilder withMaxRedirects(int httpMaxRedirects) {
153      properties.setProperty(PROPERTY_MAX_REDIRECTS, Integer.toString(httpMaxRedirects));
154      return this;
155   }
156 
157   /**
158    * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTION_REUSE
159    */
160   public PropertiesBuilder withMaxClientReuse(int poolMaxClientReuse) {
161      properties.setProperty(PROPERTY_MAX_CONNECTION_REUSE, Integer.toString(poolMaxClientReuse));
162      return this;
163   }
164 
165   /**
166    * @see org.jclouds.Constants.PROPERTY_MAX_SESSION_FAILURES
167    */
168   public PropertiesBuilder withMaxSessionFailures(int poolMaxSessionFailures) {
169      properties.setProperty(PROPERTY_MAX_SESSION_FAILURES, Integer.toString(poolMaxSessionFailures));
170      return this;
171 
172   }
173 
174   /**
175    * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS
176    */
177   public PropertiesBuilder limitIoWorkerThreadsTo(int poolIoWorkerThreads) {
178      properties.setProperty(PROPERTY_IO_WORKER_THREADS, Integer.toString(poolIoWorkerThreads));
179      return this;
180   }
181 
182   /**
183    * @see org.jclouds.Constants.PROPERTY_IO_WORKER_THREADS
184    */
185   public PropertiesBuilder limitUserThreadsTo(int poolIoWorkerThreads) {
186      properties.setProperty(PROPERTY_USER_THREADS, Integer.toString(poolIoWorkerThreads));
187      return this;
188   }
189 
190   /**
191    * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_CONTEXT
192    */
193   public PropertiesBuilder limitConnectionsTo(int connectionLimit) {
194      properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, Integer.toString(connectionLimit));
195      return this;
196   }
197 
198   /**
199    * @see org.jclouds.Constants.PROPERTY_MAX_CONNECTIONS_PER_HOST
200    */
201   public PropertiesBuilder limitConnectionsPerHostTo(int connectionLimit) {
202      properties.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, Integer.toString(connectionLimit));
203      return this;
204   }
205 
206   protected final Properties properties;
207 
208   public PropertiesBuilder() {
209      this.properties = defaultProperties();
210   }
211 
212   protected Properties defaultProperties() {
213      Properties props = new Properties();
214      props.setProperty(PROPERTY_ISO3166_CODES, "");
215      props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_CONTEXT, 20 + "");
216      props.setProperty(PROPERTY_MAX_CONNECTIONS_PER_HOST, 0 + "");
217      props.setProperty(PROPERTY_SO_TIMEOUT, 60000 + "");
218      props.setProperty(PROPERTY_CONNECTION_TIMEOUT, 60000 + "");
219      props.setProperty(PROPERTY_IO_WORKER_THREADS, 20 + "");
220      props.setProperty(PROPERTY_USER_THREADS, 0 + "");
221      props.setProperty(PROPERTY_MAX_CONNECTION_REUSE, 75 + "");
222      props.setProperty(PROPERTY_MAX_SESSION_FAILURES, 2 + "");
223      props.setProperty(PROPERTY_SESSION_INTERVAL, 60 + "");
224      return props;
225   }
226 
227   public PropertiesBuilder(Properties properties) {
228      this();
229      this.properties.putAll(properties);
230   }
231 
232   public PropertiesBuilder provider(String providerName) {
233      properties.setProperty(PROPERTY_PROVIDER, providerName);
234      return this;
235   }
236 
237   public PropertiesBuilder endpoint(String endpoint) {
238      properties.setProperty(PROPERTY_ENDPOINT, endpoint);
239      return this;
240   }
241 
242   public PropertiesBuilder iso3166Codes(Iterable<String> codes) {
243      properties.setProperty(PROPERTY_ISO3166_CODES, Joiner.on(',').join(codes));
244      return this;
245   }
246 
247   public PropertiesBuilder apiVersion(String apiVersion) {
248      properties.setProperty(PROPERTY_API_VERSION, apiVersion);
249      return this;
250   }
251 
252   public PropertiesBuilder credentials(String identity, @Nullable String credential) {
253      properties.setProperty(PROPERTY_IDENTITY, identity);
254      if (credential != null)
255         properties.setProperty(PROPERTY_CREDENTIAL, credential);
256      return this;
257   }
258 
259   public PropertiesBuilder sessionInterval(long seconds) {
260      properties.setProperty(PROPERTY_SESSION_INTERVAL, seconds + "");
261      return this;
262   }
263 
264   @VisibleForTesting
265   public Properties build() {
266      return properties;
267   }
268}

[all classes][org.jclouds]
EMMA 2.0.5312 (C) Vladimir Roubtsov