EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.trmk.vcloud_0_8]

COVERAGE SUMMARY FOR SOURCE FILE [TerremarkVCloudPropertiesBuilder.java]

nameclass, %method, %block, %line, %
TerremarkVCloudPropertiesBuilder.java100% (1/1)75%  (6/8)84%  (124/147)83%  (25/30)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TerremarkVCloudPropertiesBuilder100% (1/1)75%  (6/8)84%  (124/147)83%  (25/30)
withApiVersion (String): TerremarkVCloudPropertiesBuilder 0%   (0/1)0%   (0/8)0%   (0/2)
withSchemaVersion (String): TerremarkVCloudPropertiesBuilder 0%   (0/1)0%   (0/8)0%   (0/2)
setFenceMode (): void 100% (1/1)74%  (20/27)80%  (4/5)
TerremarkVCloudPropertiesBuilder (Properties): void 100% (1/1)100% (4/4)100% (2/2)
build (): Properties 100% (1/1)100% (9/9)100% (4/4)
defaultProperties (): Properties 100% (1/1)100% (40/40)100% (9/9)
setExtensions (): void 100% (1/1)100% (29/29)100% (3/3)
setNs (): void 100% (1/1)100% (22/22)100% (3/3)

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.trmk.vcloud_0_8;
20 
21import static org.jclouds.Constants.PROPERTY_API_VERSION;
22import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
23import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NAME;
24import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_NS;
25import static org.jclouds.trmk.vcloud_0_8.reference.TerremarkConstants.PROPERTY_TERREMARK_EXTENSION_VERSION;
26import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_DEFAULT_FENCEMODE;
27import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED;
28import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_VERSION_SCHEMA;
29import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_NAMESPACE;
30import static org.jclouds.trmk.vcloud_0_8.reference.VCloudConstants.PROPERTY_VCLOUD_XML_SCHEMA;
31 
32import java.util.Properties;
33 
34import org.jclouds.PropertiesBuilder;
35import org.jclouds.trmk.vcloud_0_8.domain.FenceMode;
36 
37/**
38 * Builds properties used in Terremark VCloud Clients
39 * 
40 * @author Adrian Cole
41 */
42public class TerremarkVCloudPropertiesBuilder extends PropertiesBuilder {
43   @Override
44   protected Properties defaultProperties() {
45      Properties properties = super.defaultProperties();
46      properties.setProperty(PROPERTY_API_VERSION, "0.8");
47      properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
48      properties.setProperty(PROPERTY_SESSION_INTERVAL, 8 * 60 + "");
49      properties.setProperty(PROPERTY_VCLOUD_XML_SCHEMA, "http://vcloud.safesecureweb.com/ns/vcloud.xsd");
50      properties.setProperty("jclouds.dns_name_length_min", "1");
51      properties.setProperty("jclouds.dns_name_length_max", "15");
52      // with ssh key injection comes another reboot. allowing more time
53      properties.setProperty(PROPERTY_VCLOUD_TIMEOUT_TASK_COMPLETED, 420l * 1000l + "");
54      return properties;
55   }
56 
57   public TerremarkVCloudPropertiesBuilder(Properties properties) {
58      super(properties);
59   }
60 
61   void setExtensions() {
62      if (properties.getProperty(PROPERTY_TERREMARK_EXTENSION_NS) == null) {
63         properties.setProperty(
64               PROPERTY_TERREMARK_EXTENSION_NS,
65               String.format("urn:tmrk:%s-%s", properties.getProperty(PROPERTY_TERREMARK_EXTENSION_NAME),
66                     properties.getProperty(PROPERTY_TERREMARK_EXTENSION_VERSION)));
67      }
68   }
69 
70   protected void setNs() {
71      if (properties.getProperty(PROPERTY_VCLOUD_XML_NAMESPACE) == null)
72         properties.setProperty(PROPERTY_VCLOUD_XML_NAMESPACE,
73               "http://www.vmware.com/vcloud/v" + properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA));
74   }
75 
76   protected void setFenceMode() {
77      if (properties.getProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE) == null) {
78         if (properties.getProperty(PROPERTY_VCLOUD_VERSION_SCHEMA).startsWith("0.8"))
79            properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, "allowInOut");
80         else
81            properties.setProperty(PROPERTY_VCLOUD_DEFAULT_FENCEMODE, FenceMode.ALLOW_IN_OUT.toString());
82      }
83   }
84 
85   public TerremarkVCloudPropertiesBuilder withApiVersion(String version) {
86      properties.setProperty(PROPERTY_API_VERSION, "0.8");
87      return this;
88   }
89 
90   public TerremarkVCloudPropertiesBuilder withSchemaVersion(String version) {
91      properties.setProperty(PROPERTY_VCLOUD_VERSION_SCHEMA, "0.8");
92      return this;
93   }
94 
95   @Override
96   public Properties build() {
97      setNs();
98      setFenceMode();
99      setExtensions();
100      return super.build();
101   }
102}

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