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

COVERAGE SUMMARY FOR SOURCE FILE [TerremarkECloudParseOsFromVAppTemplateName.java]

nameclass, %method, %block, %line, %
TerremarkECloudParseOsFromVAppTemplateName.java100% (1/1)100% (3/3)94%  (101/108)90%  (18/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TerremarkECloudParseOsFromVAppTemplateName100% (1/1)100% (3/3)94%  (101/108)90%  (18/20)
apply (String): OperatingSystem 100% (1/1)93%  (93/100)88%  (15/17)
<static initializer> 100% (1/1)100% (4/4)100% (1/1)
TerremarkECloudParseOsFromVAppTemplateName (Map): void 100% (1/1)100% (4/4)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.trmk.ecloud.compute.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.compute.util.ComputeServiceUtils.parseOsFamilyOrUnrecognized;
23 
24import java.util.Map;
25import java.util.regex.Matcher;
26import java.util.regex.Pattern;
27 
28import javax.inject.Inject;
29import javax.inject.Singleton;
30 
31import org.jclouds.compute.domain.OperatingSystem;
32import org.jclouds.compute.domain.OperatingSystem.Builder;
33import org.jclouds.compute.domain.OsFamily;
34import org.jclouds.compute.util.ComputeServiceUtils;
35import org.jclouds.trmk.vcloud_0_8.compute.functions.ParseOsFromVAppTemplateName;
36 
37/**
38 * @author Adrian Cole
39 */
40@Singleton
41public class TerremarkECloudParseOsFromVAppTemplateName extends ParseOsFromVAppTemplateName {
42   // CentOS 5 (x64)
43   public static final Pattern OS_PATTERN = Pattern.compile("^-?([^ ]*) ([0-9.]+)( R[1-9])? ?.*");
44 
45   @Inject
46   protected TerremarkECloudParseOsFromVAppTemplateName(Map<OsFamily, Map<String, String>> osVersionMap) {
47      super(osVersionMap);
48   }
49 
50   @Override
51   public OperatingSystem apply(String from) {
52      checkNotNull(from, "vapp template name");
53      Builder builder = new OperatingSystem.Builder();
54      builder.description(from);
55      if (from.equals("-Windows 2003 Std. R2 SQL 2005 Std. (x64)"))
56         System.out.print(';');
57      builder.is64Bit(from.indexOf("64") != -1);
58      from = from.replace("Red Hat Enterprise Linux", "RHEL").replace("Sun Solaris", "SOLARIS").replace(
59               " Server", "").replace("Std. ", "");
60      Matcher matcher = OS_PATTERN.matcher(from);
61      if (matcher.find()) {
62         OsFamily osFamily = parseOsFamilyOrUnrecognized(matcher.group(1));
63         builder.family(osFamily);
64         String version = (matcher.group(3) != null) ? matcher.group(2) + matcher.group(3) : matcher.group(2);
65         builder.version(ComputeServiceUtils.parseVersionOrReturnEmptyString(osFamily, version, osVersionMap));
66      } else {
67         OsFamily osFamily = parseOsFamilyOrUnrecognized(from);
68         builder.family(osFamily);
69      }
70      return builder.build();
71   }
72}

[all classes][org.jclouds.trmk.ecloud.compute.functions]
EMMA 2.0.5312 (C) Vladimir Roubtsov