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

COVERAGE SUMMARY FOR SOURCE FILE [TerremarkECloudRestClientModule.java]

nameclass, %method, %block, %line, %
TerremarkECloudRestClientModule.java33%  (1/3)33%  (3/9)19%  (18/96)29%  (4/14)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class TerremarkECloudRestClientModule$10%   (0/1)0%   (0/2)0%   (0/11)0%   (0/2)
TerremarkECloudRestClientModule$1 (TerremarkECloudRestClientModule): void 0%   (0/1)0%   (0/6)0%   (0/1)
provideDefaultNetworkSelector (Injector): Predicate 0%   (0/1)0%   (0/5)0%   (0/1)
     
class TerremarkECloudRestClientModule$IsDMZNetwork0%   (0/1)0%   (0/2)0%   (0/58)0%   (0/6)
TerremarkECloudRestClientModule$IsDMZNetwork (TerremarkECloudClient): void 0%   (0/1)0%   (0/6)0%   (0/3)
apply (ReferenceType): boolean 0%   (0/1)0%   (0/52)0%   (0/3)
     
class TerremarkECloudRestClientModule100% (1/1)60%  (3/5)67%  (18/27)57%  (4/7)
installDefaultVCloudEndpointsModule (): void 0%   (0/1)0%   (0/7)0%   (0/2)
provideTerremarkClient (TerremarkECloudClient): TerremarkVCloudClient 0%   (0/1)0%   (0/2)0%   (0/1)
<static initializer> 100% (1/1)100% (10/10)100% (1/1)
TerremarkECloudRestClientModule (): void 100% (1/1)100% (6/6)100% (2/2)
provideTerremarkAsyncClient (TerremarkECloudAsyncClient): TerremarkVCloudAsyn... 100% (1/1)100% (2/2)100% (1/1)

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.config;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import java.util.Map;
24 
25import javax.inject.Inject;
26import javax.inject.Singleton;
27 
28import org.jclouds.http.RequiresHttp;
29import org.jclouds.rest.ConfiguresRestClient;
30import org.jclouds.trmk.ecloud.TerremarkECloudAsyncClient;
31import org.jclouds.trmk.ecloud.TerremarkECloudClient;
32import org.jclouds.trmk.ecloud.features.DataCenterOperationsAsyncClient;
33import org.jclouds.trmk.ecloud.features.DataCenterOperationsClient;
34import org.jclouds.trmk.ecloud.features.TagOperationsAsyncClient;
35import org.jclouds.trmk.ecloud.features.TagOperationsClient;
36import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudAsyncClient;
37import org.jclouds.trmk.vcloud_0_8.TerremarkVCloudClient;
38import org.jclouds.trmk.vcloud_0_8.config.DefaultVCloudReferencesModule;
39import org.jclouds.trmk.vcloud_0_8.config.TerremarkVCloudRestClientModule;
40import org.jclouds.trmk.vcloud_0_8.domain.Network;
41import org.jclouds.trmk.vcloud_0_8.domain.NetworkExtendedInfo;
42import org.jclouds.trmk.vcloud_0_8.domain.ReferenceType;
43 
44import com.google.common.base.Predicate;
45import com.google.common.collect.ImmutableMap;
46import com.google.inject.Injector;
47import com.google.inject.Provides;
48 
49/**
50 * Configures the VCloud authentication service connection, including logging
51 * and http transport.
52 * 
53 * @author Adrian Cole
54 */
55@RequiresHttp
56@ConfiguresRestClient
57public class TerremarkECloudRestClientModule extends
58      TerremarkVCloudRestClientModule<TerremarkECloudClient, TerremarkECloudAsyncClient> {
59 
60   public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
61         .put(DataCenterOperationsClient.class, DataCenterOperationsAsyncClient.class)//
62         .put(TagOperationsClient.class, TagOperationsAsyncClient.class)//
63         .build();
64 
65   public TerremarkECloudRestClientModule() {
66      super(TerremarkECloudClient.class, TerremarkECloudAsyncClient.class, DELEGATE_MAP);
67   }
68 
69   @Provides
70   @Singleton
71   protected TerremarkVCloudAsyncClient provideTerremarkAsyncClient(TerremarkECloudAsyncClient in) {
72      return in;
73   }
74 
75   @Provides
76   @Singleton
77   protected TerremarkVCloudClient provideTerremarkClient(TerremarkECloudClient in) {
78      return in;
79   }
80 
81   @Singleton
82   public static class IsDMZNetwork implements Predicate<ReferenceType> {
83      private final TerremarkECloudClient client;
84 
85      @Inject
86      public IsDMZNetwork(TerremarkECloudClient client) {
87         this.client = client;
88      }
89 
90      @Override
91      public boolean apply(ReferenceType arg0) {
92         // TODO FIXME XXX: In Terremark Enterprise environment with multiple
93         // VDC's
94         // this does not
95         // work well.
96         // Each VDC will have differnt network subnets. So we cannot assume the
97         // default VDC's
98         // networks will
99         // work with non-default VDC's. So make PROPERTY_VCLOUD_DEFAULT_NETWORK
100         // optional. If
101         // this property
102         // is not set, they are expected to add NetworkConfig to the options
103         // when
104         // launching a
105         // server.
106         Network orgNetwork = client.getNetwork(arg0.getHref());
107         NetworkExtendedInfo terremarkNetwork = client.getNetworkExtendedInfo(checkNotNull(
108               checkNotNull(orgNetwork, "network at: " + arg0).getNetworkExtension(), "network extension for: " + arg0)
109               .getHref());
110         return checkNotNull(terremarkNetwork, "terremark network extension at: " + orgNetwork.getNetworkExtension())
111               .getNetworkType() == NetworkExtendedInfo.Type.DMZ;
112      }
113   }
114 
115   @Override
116   protected void installDefaultVCloudEndpointsModule() {
117      install(new DefaultVCloudReferencesModule() {
118 
119         @Override
120         protected Predicate<ReferenceType> provideDefaultNetworkSelector(Injector i) {
121            return i.getInstance(IsDMZNetwork.class);
122         }
123 
124      });
125 
126   }
127 
128}

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