mirror of https://github.com/apache/jclouds.git
Problem when instantiating the SessionClient via ContextBuilder, solved by forcing the getProviderMetadata override method to be used
This commit is contained in:
parent
47cbbeef57
commit
6b10fb8f32
|
@ -18,6 +18,12 @@
|
|||
*/
|
||||
package org.jclouds.vcloud.director.v1_5;
|
||||
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.vcloud.director.v1_5.login.SessionAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.login.SessionClient;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Constants used by VCloudDirector clients
|
||||
*
|
||||
|
@ -63,4 +69,11 @@ public class VCloudDirectorConstants {
|
|||
|
||||
/** TODO javadoc */
|
||||
public static final String PROPERTY_NS_NAME_LEN_MAX = "jclouds.dns_name_length_max";
|
||||
|
||||
/** TODO javadoc */
|
||||
public static final TypeToken<RestContext<SessionClient, SessionAsyncClient>> SESSION_CONTEXT_TYPE =
|
||||
new TypeToken<RestContext<SessionClient, SessionAsyncClient>>() {
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -3625362618882122604L;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@ import org.jclouds.vcloud.director.v1_5.domain.Role.DefaultRoles;
|
|||
import org.jclouds.vcloud.director.v1_5.domain.User;
|
||||
import org.jclouds.vcloud.director.v1_5.predicates.LinkPredicates;
|
||||
import org.jclouds.vcloud.director.v1_5.predicates.ReferencePredicates;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorAsyncClient;
|
||||
import org.jclouds.vcloud.director.v1_5.user.VCloudDirectorClient;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
|
|
@ -24,11 +24,13 @@ import static org.testng.Assert.assertTrue;
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.apis.BaseContextLiveTest;
|
||||
import org.jclouds.rest.AnonymousRestApiMetadata;
|
||||
import org.jclouds.providers.AnonymousProviderMetadata;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.rest.RestContext;
|
||||
import org.jclouds.vcloud.director.testng.FormatApiResultsListener;
|
||||
import org.jclouds.vcloud.director.v1_5.VCloudDirectorConstants;
|
||||
import org.jclouds.vcloud.director.v1_5.domain.SessionWithToken;
|
||||
import org.testng.annotations.BeforeGroups;
|
||||
import org.testng.annotations.Listeners;
|
||||
|
@ -84,17 +86,22 @@ public class SessionClientLiveTest extends BaseContextLiveTest<RestContext<Sessi
|
|||
public void testLogout() {
|
||||
client.logoutSessionWithToken(sessionWithToken.getSession().getHref(), sessionWithToken.getToken());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ApiMetadata createApiMetadata() {
|
||||
return AnonymousRestApiMetadata.forClientMappedToAsyncClient(SessionClient.class, SessionAsyncClient.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected TypeToken<RestContext<SessionClient, SessionAsyncClient>> contextType() {
|
||||
return new TypeToken<RestContext<SessionClient, SessionAsyncClient>>(){
|
||||
|
||||
/** The serialVersionUID */
|
||||
private static final long serialVersionUID = -3625362618882122604L;};
|
||||
return VCloudDirectorConstants.SESSION_CONTEXT_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ProviderMetadata createProviderMetadata() {
|
||||
return AnonymousProviderMetadata.forClientMappedToAsyncClientOnEndpoint(SessionClient.class, SessionAsyncClient.class, endpoint);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ContextBuilder newBuilder() {
|
||||
ProviderMetadata pm = createProviderMetadata();
|
||||
ContextBuilder builder = ContextBuilder.newBuilder(pm);
|
||||
return builder;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue