EMMA Coverage Report (generated Wed Jun 22 19:47:49 EDT 2011)
[all classes][org.jclouds.vcloud]

COVERAGE SUMMARY FOR SOURCE FILE [VCloudExpressPropertiesBuilder.java]

nameclass, %method, %block, %line, %
VCloudExpressPropertiesBuilder.java100% (1/1)71%  (5/7)80%  (93/116)81%  (21/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VCloudExpressPropertiesBuilder100% (1/1)71%  (5/7)80%  (93/116)81%  (21/26)
withApiVersion (String): VCloudExpressPropertiesBuilder 0%   (0/1)0%   (0/8)0%   (0/2)
withSchemaVersion (String): VCloudExpressPropertiesBuilder 0%   (0/1)0%   (0/8)0%   (0/2)
setFenceMode (): void 100% (1/1)74%  (20/27)80%  (4/5)
VCloudExpressPropertiesBuilder (Properties): void 100% (1/1)100% (4/4)100% (2/2)
build (): Properties 100% (1/1)100% (7/7)100% (3/3)
defaultProperties (): Properties 100% (1/1)100% (40/40)100% (9/9)
setNs (): void 100% (1/1)100% (22/22)100% (3/3)

1/**
2 *
3 * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com>
4 *
5 * ====================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * 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, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 * ====================================================================
18 */
19package org.jclouds.vcloud;
20 
21import static org.jclouds.Constants.PROPERTY_API_VERSION;
22import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
23import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
24import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
25import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
26import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
27import static org.jclouds.vcloud.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
28 
29import java.util.Properties;
30 
31import org.jclouds.PropertiesBuilder;
32import org.jclouds.vcloud.domain.network.FenceMode;
33 
34/**
35 * Builds properties used in VCloud Clients
36 * 
37 * @author Adrian Cole
38 */
39public class VCloudExpressPropertiesBuilder extends PropertiesBuilder {
40   @Override
41   protected Properties defaultProperties() {
42      Properties properties = super.defaultProperties();
43      properties.setProperty(PROPERTY_API_VERSION, "0.8");
44      properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
45      properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + "");
46      properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA,
47               "http://vcloud.safesecureweb.com/ns/vcloud.xsd");
48      properties.setProperty("jclouds.dns_name_length_min", "1");
49      properties.setProperty("jclouds.dns_name_length_max", "80");
50      properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 180l * 1000l + "");
51      return properties;
52   }
53 
54   public VCloudExpressPropertiesBuilder(Properties properties) {
55      super(properties);
56   }
57 
58   protected void setNs() {
59      if (properties.getProperty(PROPERTY_VCLOUD_XML_NAMESPACE) == null)
60         properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE, "http://www.vmware.com/vcloud/v"
61                  + properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA));
62   }
63 
64   protected void setFenceMode() {
65      if (properties.getProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) == null) {
66         if (properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA).startsWith("0.8"))
67            properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut");
68         else
69            properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.BRIDGED.toString());
70      }
71   }
72 
73   public VCloudExpressPropertiesBuilder withApiVersion(String version) {
74      properties.setProperty(PROPERTY_API_VERSION, "0.8");
75      return this;
76   }
77 
78   public VCloudExpressPropertiesBuilder withSchemaVersion(String version) {
79      properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
80      return this;
81   }
82 
83   @Override
84   public Properties build() {
85      setNs();
86      setFenceMode();
87      return super.build();
88   }
89}

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