mirror of https://github.com/apache/jclouds.git
switched to new naming conventions
This commit is contained in:
parent
85ce1bd659
commit
4c1f8f8414
|
@ -45,12 +45,12 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
* Provides synchronous access to Chef.
|
||||
* <p/>
|
||||
*
|
||||
* @see ChefAsyncClient
|
||||
* @see ChefAsyncApi
|
||||
* @see <a href="TODO: insert URL of Chef documentation" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
|
||||
public interface ChefClient {
|
||||
public interface ChefApi {
|
||||
/**
|
||||
*
|
||||
* Creates a new sandbox. It accepts a list of checksums as input and returns
|
||||
|
@ -105,7 +105,7 @@ public interface ChefClient {
|
|||
/**
|
||||
* deletes an existing cookbook.
|
||||
*
|
||||
* @return last state of the client you deleted or null, if not found
|
||||
* @return last state of the api you deleted or null, if not found
|
||||
* @throws AuthorizationException
|
||||
* <p/>
|
||||
* "401 Unauthorized" if you are not a recognized user.
|
||||
|
@ -387,7 +387,7 @@ public interface ChefClient {
|
|||
Role getRole(String name);
|
||||
|
||||
/**
|
||||
* lists databags available to the client
|
||||
* lists databags available to the api
|
||||
*
|
||||
* @throws AuthorizationException
|
||||
* <p/>
|
||||
|
@ -503,7 +503,7 @@ public interface ChefClient {
|
|||
/**
|
||||
* Show indexes you can search on
|
||||
* <p/>
|
||||
* By default, the "role", "node" and "client" indexes will always be
|
||||
* By default, the "role", "node" and "api" indexes will always be
|
||||
* available.
|
||||
* <p/>
|
||||
* Note that the search indexes may lag behind the most current data by at
|
||||
|
@ -532,7 +532,7 @@ public interface ChefClient {
|
|||
SearchResult<? extends Role> searchRoles();
|
||||
|
||||
/**
|
||||
* search all clients.
|
||||
* search all apis.
|
||||
* <p/>
|
||||
* Note that without any request parameters this will return all of the data
|
||||
* within the index.
|
|
@ -50,7 +50,7 @@ public class ChefApiMetadata extends BaseRestApiMetadata {
|
|||
}
|
||||
|
||||
public ChefApiMetadata() {
|
||||
this(new Builder(ChefClient.class, ChefAsyncClient.class));
|
||||
this(new Builder(ChefApi.class, ChefAsyncApi.class));
|
||||
}
|
||||
|
||||
protected ChefApiMetadata(Builder builder) {
|
||||
|
@ -66,13 +66,13 @@ public class ChefApiMetadata extends BaseRestApiMetadata {
|
|||
|
||||
public static class Builder extends BaseRestApiMetadata.Builder {
|
||||
|
||||
protected Builder(Class<?> client, Class<?> asyncClient) {
|
||||
super(client, asyncClient);
|
||||
protected Builder(Class<?> api, Class<?> asyncApi) {
|
||||
super(api, asyncApi);
|
||||
id("chef")
|
||||
.name("OpsCode Chef Api")
|
||||
.identityName("User")
|
||||
.credentialName("Certificate")
|
||||
.version(ChefAsyncClient.VERSION)
|
||||
.version(ChefAsyncApi.VERSION)
|
||||
.documentation(URI.create("http://wiki.opscode.com/display/chef/Server+API"))
|
||||
.defaultEndpoint("http://localhost:4000")
|
||||
.defaultProperties(ChefApiMetadata.defaultProperties())
|
||||
|
@ -92,4 +92,4 @@ public class ChefApiMetadata extends BaseRestApiMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,18 +84,18 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* Provides asynchronous access to Chef via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see ChefClient
|
||||
* @see ChefApi
|
||||
* @see <a href="TODO: insert URL of provider documentation" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@RequestFilters(SignedHeaderAuth.class)
|
||||
@Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface ChefAsyncClient {
|
||||
public interface ChefAsyncApi {
|
||||
public static final String VERSION = "0.10.8";
|
||||
|
||||
/**
|
||||
* @see ChefClient#getUploadSandboxForChecksums(Set)
|
||||
* @see ChefApi#getUploadSandboxForChecksums(Set)
|
||||
*/
|
||||
@POST
|
||||
@Path("/sandboxes")
|
||||
|
@ -103,14 +103,14 @@ public interface ChefAsyncClient {
|
|||
@BinderParam(BindChecksumsToJsonPayload.class) Set<List<Byte>> md5s);
|
||||
|
||||
/**
|
||||
* @see ChefClient#uploadContent(URI, Payload)
|
||||
* @see ChefApi#uploadContent(URI, Payload)
|
||||
*/
|
||||
@PUT
|
||||
@Produces("application/x-binary")
|
||||
ListenableFuture<Void> uploadContent(@EndpointParam URI location, Payload content);
|
||||
|
||||
/**
|
||||
* @see ChefClient#commitSandbox(String, boolean)
|
||||
* @see ChefApi#commitSandbox(String, boolean)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/sandboxes/{id}")
|
||||
|
@ -118,7 +118,7 @@ public interface ChefAsyncClient {
|
|||
@BinderParam(BindIsCompletedToJsonPayload.class) boolean isCompleted);
|
||||
|
||||
/**
|
||||
* @see ChefClient#listCookbooks()
|
||||
* @see ChefApi#listCookbooks()
|
||||
*/
|
||||
@GET
|
||||
@Path("/cookbooks")
|
||||
|
@ -127,7 +127,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> listCookbooks();
|
||||
|
||||
/**
|
||||
* @see ChefClient#updateCookbook(String, String, CookbookVersion)
|
||||
* @see ChefApi#updateCookbook(String, String, CookbookVersion)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/cookbooks/{cookbookname}/{version}")
|
||||
|
@ -135,7 +135,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("version") String version, @BinderParam(BindToJsonPayload.class) CookbookVersion cookbook);
|
||||
|
||||
/**
|
||||
* @see ChefClient#deleteCookbook(String, String)
|
||||
* @see ChefApi#deleteCookbook(String, String)
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/cookbooks/{cookbookname}/{version}")
|
||||
|
@ -144,7 +144,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("version") String version);
|
||||
|
||||
/**
|
||||
* @see ChefClient#getVersionsOfCookbook(String)
|
||||
* @see ChefApi#getVersionsOfCookbook(String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/cookbooks/{cookbookname}")
|
||||
|
@ -153,7 +153,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> getVersionsOfCookbook(@PathParam("cookbookname") String cookbookName);
|
||||
|
||||
/**
|
||||
* @see ChefClient#getCookbook(String, String)
|
||||
* @see ChefApi#getCookbook(String, String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/cookbooks/{cookbookname}/{version}")
|
||||
|
@ -162,7 +162,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("version") String version);
|
||||
|
||||
/**
|
||||
* @see ChefClient#createClient(String)
|
||||
* @see ChefApi#createClient(String)
|
||||
*/
|
||||
@POST
|
||||
@Path("/clients")
|
||||
|
@ -170,7 +170,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Client> createClient(@PayloadParam("name") String clientname);
|
||||
|
||||
/**
|
||||
* @see ChefClient#createClient(String, CreateClientOptions)
|
||||
* @see ChefApi#createClient(String, CreateApiOptions)
|
||||
*/
|
||||
@POST
|
||||
@Path("/clients")
|
||||
|
@ -178,7 +178,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Client> createClient(@PayloadParam("name") String clientname, CreateClientOptions options);
|
||||
|
||||
/**
|
||||
* @see ChefClient#generateKeyForClient(String)
|
||||
* @see ChefApi#generateKeyForClient(String)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/clients/{clientname}")
|
||||
|
@ -186,7 +186,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("clientname") @BinderParam(BindGenerateKeyForClientToJsonPayload.class) String clientname);
|
||||
|
||||
/**
|
||||
* @see ChefClient#clientExists(String)
|
||||
* @see ChefApi#clientExists(String)
|
||||
*/
|
||||
@HEAD
|
||||
@Path("/clients/{clientname}")
|
||||
|
@ -194,7 +194,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Boolean> clientExists(@PathParam("clientname") String clientname);
|
||||
|
||||
/**
|
||||
* @see ChefClient#getClient(String)
|
||||
* @see ChefApi#getClient(String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/clients/{clientname}")
|
||||
|
@ -202,7 +202,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Client> getClient(@PathParam("clientname") String clientname);
|
||||
|
||||
/**
|
||||
* @see ChefClient#deleteClient(String)
|
||||
* @see ChefApi#deleteClient(String)
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/clients/{clientname}")
|
||||
|
@ -210,7 +210,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Client> deleteClient(@PathParam("clientname") String clientname);
|
||||
|
||||
/**
|
||||
* @see ChefClient#listClients()
|
||||
* @see ChefApi#listClients()
|
||||
*/
|
||||
@GET
|
||||
@Path("/clients")
|
||||
|
@ -219,14 +219,14 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> listClients();
|
||||
|
||||
/**
|
||||
* @see ChefClient#createNode(Node)
|
||||
* @see ChefApi#createNode(Node)
|
||||
*/
|
||||
@POST
|
||||
@Path("/nodes")
|
||||
ListenableFuture<Void> createNode(@BinderParam(BindToJsonPayload.class) Node node);
|
||||
|
||||
/**
|
||||
* @see ChefClient#updateNode(Node)
|
||||
* @see ChefApi#updateNode(Node)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/nodes/{nodename}")
|
||||
|
@ -234,7 +234,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("nodename") @ParamParser(NodeName.class) @BinderParam(BindToJsonPayload.class) Node node);
|
||||
|
||||
/**
|
||||
* @see ChefClient#nodeExists(String)
|
||||
* @see ChefApi#nodeExists(String)
|
||||
*/
|
||||
@HEAD
|
||||
@Path("/nodes/{nodename}")
|
||||
|
@ -242,7 +242,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Boolean> nodeExists(@PathParam("nodename") String nodename);
|
||||
|
||||
/**
|
||||
* @see ChefClient#getNode(String)
|
||||
* @see ChefApi#getNode(String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/nodes/{nodename}")
|
||||
|
@ -258,7 +258,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Node> deleteNode(@PathParam("nodename") String nodename);
|
||||
|
||||
/**
|
||||
* @see ChefClient#listNodes()
|
||||
* @see ChefApi#listNodes()
|
||||
*/
|
||||
@GET
|
||||
@Path("/nodes")
|
||||
|
@ -267,14 +267,14 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> listNodes();
|
||||
|
||||
/**
|
||||
* @see ChefClient#createRole(Role)
|
||||
* @see ChefApi#createRole(Role)
|
||||
*/
|
||||
@POST
|
||||
@Path("/roles")
|
||||
ListenableFuture<Void> createRole(@BinderParam(BindToJsonPayload.class) Role role);
|
||||
|
||||
/**
|
||||
* @see ChefClient#updateRole(Role)
|
||||
* @see ChefApi#updateRole(Role)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/roles/{rolename}")
|
||||
|
@ -282,7 +282,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("rolename") @ParamParser(RoleName.class) @BinderParam(BindToJsonPayload.class) Role role);
|
||||
|
||||
/**
|
||||
* @see ChefClient#roleExists(String)
|
||||
* @see ChefApi#roleExists(String)
|
||||
*/
|
||||
@HEAD
|
||||
@Path("/roles/{rolename}")
|
||||
|
@ -290,7 +290,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Boolean> roleExists(@PathParam("rolename") String rolename);
|
||||
|
||||
/**
|
||||
* @see ChefClient#getRole(String)
|
||||
* @see ChefApi#getRole(String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/roles/{rolename}")
|
||||
|
@ -298,7 +298,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Role> getRole(@PathParam("rolename") String rolename);
|
||||
|
||||
/**
|
||||
* @see ChefClient#deleteRole(String)
|
||||
* @see ChefApi#deleteRole(String)
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/roles/{rolename}")
|
||||
|
@ -306,7 +306,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Role> deleteRole(@PathParam("rolename") String rolename);
|
||||
|
||||
/**
|
||||
* @see ChefClient#listRoles()
|
||||
* @see ChefApi#listRoles()
|
||||
*/
|
||||
@GET
|
||||
@Path("/roles")
|
||||
|
@ -315,7 +315,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> listRoles();
|
||||
|
||||
/**
|
||||
* @see ChefClient#listDatabags()
|
||||
* @see ChefApi#listDatabags()
|
||||
*/
|
||||
@GET
|
||||
@Path("/data")
|
||||
|
@ -324,14 +324,14 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> listDatabags();
|
||||
|
||||
/**
|
||||
* @see ChefClient#createDatabag(String)
|
||||
* @see ChefApi#createDatabag(String)
|
||||
*/
|
||||
@POST
|
||||
@Path("/data")
|
||||
ListenableFuture<Void> createDatabag(@BinderParam(BindNameToJsonPayload.class) String databagName);
|
||||
|
||||
/**
|
||||
* @see ChefClient#databagExists(String)
|
||||
* @see ChefApi#databagExists(String)
|
||||
*/
|
||||
@HEAD
|
||||
@Path("/data/{name}")
|
||||
|
@ -339,7 +339,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Boolean> databagExists(@PathParam("name") String databagName);
|
||||
|
||||
/**
|
||||
* @see ChefClient#deleteDatabag(String)
|
||||
* @see ChefApi#deleteDatabag(String)
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/data/{name}")
|
||||
|
@ -347,7 +347,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Void> deleteDatabag(@PathParam("name") String databagName);
|
||||
|
||||
/**
|
||||
* @see ChefClient#listDatabagItems(String)
|
||||
* @see ChefApi#listDatabagItems(String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/data/{name}")
|
||||
|
@ -356,7 +356,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> listDatabagItems(@PathParam("name") String databagName);
|
||||
|
||||
/**
|
||||
* @see ChefClient#createDatabagItem(String, DatabagItem)
|
||||
* @see ChefApi#createDatabagItem(String, DatabagItem)
|
||||
*/
|
||||
@POST
|
||||
@Path("/data/{databagName}")
|
||||
|
@ -364,7 +364,7 @@ public interface ChefAsyncClient {
|
|||
@BinderParam(BindToJsonPayload.class) DatabagItem databagItem);
|
||||
|
||||
/**
|
||||
* @see ChefClient#updateDatabagItem(String, DatabagItem)
|
||||
* @see ChefApi#updateDatabagItem(String, DatabagItem)
|
||||
*/
|
||||
@PUT
|
||||
@Path("/data/{databagName}/{databagItemId}")
|
||||
|
@ -373,7 +373,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("databagItemId") @ParamParser(DatabagItemId.class) @BinderParam(BindToJsonPayload.class) DatabagItem item);
|
||||
|
||||
/**
|
||||
* @see ChefClient#databagItemExists(String, String)
|
||||
* @see ChefApi#databagItemExists(String, String)
|
||||
*/
|
||||
@HEAD
|
||||
@Path("/data/{databagName}/{databagItemId}")
|
||||
|
@ -382,7 +382,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("databagItemId") String databagItemId);
|
||||
|
||||
/**
|
||||
* @see ChefClient#getDatabagItem(String, String)
|
||||
* @see ChefApi#getDatabagItem(String, String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/data/{databagName}/{databagItemId}")
|
||||
|
@ -391,7 +391,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("databagItemId") String databagItemId);
|
||||
|
||||
/**
|
||||
* @see ChefClient#deleteDatabagItem(String, String)
|
||||
* @see ChefApi#deleteDatabagItem(String, String)
|
||||
*/
|
||||
@DELETE
|
||||
@Path("/data/{databagName}/{databagItemId}")
|
||||
|
@ -400,7 +400,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("databagItemId") String databagItemId);
|
||||
|
||||
/**
|
||||
* @see ChefClient#listSearchIndexes()
|
||||
* @see ChefApi#listSearchIndexes()
|
||||
*/
|
||||
@GET
|
||||
@Path("/search")
|
||||
|
@ -409,7 +409,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<Set<String>> listSearchIndexes();
|
||||
|
||||
/**
|
||||
* @see ChefClient#searchRoles()
|
||||
* @see ChefApi#searchRoles()
|
||||
*/
|
||||
@GET
|
||||
@Path("/search/role")
|
||||
|
@ -417,7 +417,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<? extends SearchResult<? extends Role>> searchRoles();
|
||||
|
||||
/**
|
||||
* @see ChefClient#searchClients()
|
||||
* @see ChefApi#searchClients()
|
||||
*/
|
||||
@GET
|
||||
@Path("/search/client")
|
||||
|
@ -425,7 +425,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<? extends SearchResult<? extends Client>> searchClients();
|
||||
|
||||
/**
|
||||
* @see ChefClient#searchNodes()
|
||||
* @see ChefApi#searchNodes()
|
||||
*/
|
||||
@GET
|
||||
@Path("/search/node")
|
||||
|
@ -433,7 +433,7 @@ public interface ChefAsyncClient {
|
|||
ListenableFuture<? extends SearchResult<? extends Node>> searchNodes();
|
||||
|
||||
/**
|
||||
* @see ChefClient#searchDatabag(String)
|
||||
* @see ChefApi#searchDatabag(String)
|
||||
*/
|
||||
@GET
|
||||
@Path("/search/{databagName}")
|
||||
|
@ -442,7 +442,7 @@ public interface ChefAsyncClient {
|
|||
@PathParam("databagName") String databagName);
|
||||
|
||||
/**
|
||||
* @see ChefClient#getResourceContents(Resource)
|
||||
* @see ChefApi#getResourceContents(Resource)
|
||||
*/
|
||||
@GET
|
||||
@ExceptionParser(ReturnNullOnNotFoundOr404.class)
|
|
@ -30,8 +30,8 @@ import com.google.inject.ImplementedBy;
|
|||
*
|
||||
*/
|
||||
@ImplementedBy(ChefContextImpl.class)
|
||||
public interface ChefContext extends RestContext<ChefClient, ChefAsyncClient>{
|
||||
public interface ChefContext extends RestContext<ChefApi, ChefAsyncApi>{
|
||||
|
||||
ChefService getChefService();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public interface ChefService {
|
|||
Node createNodeAndPopulateAutomaticAttributes(String nodeName, Iterable<String> runList);
|
||||
|
||||
/**
|
||||
* Creates all steps necessary to bootstrap and run the chef client.
|
||||
* Creates all steps necessary to bootstrap and run the chef api.
|
||||
*
|
||||
* @param tag
|
||||
* corresponds to a configured
|
||||
|
@ -81,7 +81,7 @@ public interface ChefService {
|
|||
* corresponds to a configured
|
||||
* {@link org.jclouds.chef.reference.ChefConstants#CHEF_BOOTSTRAP_DATABAG databag}
|
||||
* where run_list and other information are stored
|
||||
* @see #makeChefClientBootstrapScriptForTag
|
||||
* @see #makeChefApiBootstrapScriptForTag
|
||||
*/
|
||||
void updateRunListForTag(Iterable<String> runList, String tag);
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ public class BindCreateClientOptionsToJsonPayload extends BindToJsonPayload
|
|||
|
||||
@Override
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
|
||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest<?>,
|
||||
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
|
||||
"this binder is only valid for GeneratedHttpRequests");
|
||||
GeneratedHttpRequest<?> gRequest = (GeneratedHttpRequest<?>) request;
|
||||
GeneratedHttpRequest gRequest = (GeneratedHttpRequest) request;
|
||||
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
|
||||
|
||||
String name = checkNotNull(postParams.remove("name"), "name").toString();
|
||||
|
|
|
@ -35,4 +35,4 @@ public class DatabagItemId implements Function<Object, String> {
|
|||
return ((DatabagItem) from).getId();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,4 +35,4 @@ public class NodeName implements Function<Object, String> {
|
|||
return ((Node) from).getName();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,4 +35,4 @@ public class RoleName implements Function<Object, String> {
|
|||
return ((Role) from).getName();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.concurrent.TimeUnit;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.chef.handlers.ChefClientErrorRetryHandler;
|
||||
import org.jclouds.chef.handlers.ChefApiErrorRetryHandler;
|
||||
import org.jclouds.chef.handlers.ChefErrorHandler;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
import org.jclouds.crypto.Pems;
|
||||
|
@ -58,13 +58,13 @@ import com.google.inject.Provides;
|
|||
@ConfiguresRestClient
|
||||
public class BaseChefRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
|
||||
protected BaseChefRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
protected BaseChefRestClientModule(TypeToken<S> syncApiType, TypeToken<A> asyncApiType) {
|
||||
super(syncApiType, asyncApiType);
|
||||
}
|
||||
|
||||
protected BaseChefRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||
protected BaseChefRestClientModule(TypeToken<S> syncApiType, TypeToken<A> asyncApiType,
|
||||
Map<Class<?>, Class<?>> delegates) {
|
||||
super(syncClientType, asyncClientType, delegates);
|
||||
super(syncApiType, asyncApiType, delegates);
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -102,7 +102,7 @@ public class BaseChefRestClientModule<S, A> extends RestClientModule<S, A> {
|
|||
|
||||
@Override
|
||||
protected void bindRetryHandlers() {
|
||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(ChefClientErrorRetryHandler.class);
|
||||
bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(ChefApiErrorRetryHandler.class);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -250,4 +250,4 @@ public class ChefParserModule extends AbstractModule {
|
|||
protected void configure() {
|
||||
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,8 +23,8 @@ import java.util.Map;
|
|||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.functions.ClientForTag;
|
||||
import org.jclouds.chef.functions.RunListForTag;
|
||||
|
@ -43,10 +43,10 @@ import com.google.inject.name.Names;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class ChefRestClientModule extends BaseChefRestClientModule<ChefClient, ChefAsyncClient> {
|
||||
public class ChefRestClientModule extends BaseChefRestClientModule<ChefApi, ChefAsyncApi> {
|
||||
|
||||
public ChefRestClientModule() {
|
||||
super(TypeToken.of(ChefClient.class), TypeToken.of(ChefAsyncClient.class));
|
||||
super(TypeToken.of(ChefApi.class), TypeToken.of(ChefAsyncApi.class));
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -67,4 +67,4 @@ public class ChefRestClientModule extends BaseChefRestClientModule<ChefClient, C
|
|||
super.configure();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.HttpRequestFilter;
|
||||
import org.jclouds.http.HttpUtils;
|
||||
import org.jclouds.http.internal.SignatureWire;
|
||||
import org.jclouds.http.utils.ModifyRequest;
|
||||
import org.jclouds.io.InputSuppliers;
|
||||
import org.jclouds.io.Payload;
|
||||
import org.jclouds.io.Payloads;
|
||||
|
@ -107,7 +106,7 @@ public class SignedHeaderAuth implements HttpRequestFilter {
|
|||
headers.put( "X-Ops-Timestamp", timestamp );
|
||||
utils.logRequest( signatureLog, request, "<<" );
|
||||
|
||||
return ModifyRequest.putHeaders(request, headers);
|
||||
return request.toBuilder().replaceHeaders(headers).build();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
|
@ -121,7 +120,7 @@ public class SignedHeaderAuth implements HttpRequestFilter {
|
|||
for (int i = 0; i < signatureLines.length; i++) {
|
||||
headers.put("X-Ops-Authorization-" + (i + 1), signatureLines[i]);
|
||||
}
|
||||
return ModifyRequest.putHeaders( request, headers );
|
||||
return request.toBuilder().replaceHeaders(headers).build();
|
||||
}
|
||||
|
||||
public String createStringToSign(String request, String hashedPath, String contentHash, String timestamp) {
|
||||
|
@ -196,4 +195,4 @@ public class SignedHeaderAuth implements HttpRequestFilter {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import java.util.Set;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
@ -39,17 +39,17 @@ import com.google.common.base.Function;
|
|||
*/
|
||||
@Singleton
|
||||
public class ClientForTag implements Function<String, Client> {
|
||||
private final ChefClient chefClient;
|
||||
private final ChefApi chefApi;
|
||||
|
||||
@Inject
|
||||
public ClientForTag(ChefClient chefClient) {
|
||||
this.chefClient = checkNotNull(chefClient, "chefClient");
|
||||
public ClientForTag(ChefApi chefApi) {
|
||||
this.chefApi = checkNotNull(chefApi, "chefApi");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Client apply(String from) {
|
||||
String clientName = findNextClientName(chefClient.listClients(), from + "-validator-%02d");
|
||||
Client client = chefClient.createClient(clientName);
|
||||
String clientName = findNextClientName(chefApi.listClients(), from + "-validator-%02d");
|
||||
Client client = chefApi.createClient(clientName);
|
||||
// response from create only includes the key
|
||||
return new Client(null, null, clientName, clientName, false, client.getPrivateKey());
|
||||
}
|
||||
|
@ -65,4 +65,4 @@ public class ClientForTag implements Function<String, Client> {
|
|||
}
|
||||
return clientName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class GroupToBootScript implements Function<String, Payload> {
|
|||
checkNotNull(tag, "tag");
|
||||
|
||||
Client client = tagToClient.get(tag);
|
||||
checkState(client != null, "could not get a client for tag %s", tag);
|
||||
checkState(client != null, "could not get a api for tag %s", tag);
|
||||
checkState(client.getClientname() != null, "clientname null for %s", client);
|
||||
checkState(client.getPrivateKey() != null, "privatekey null for %s", client);
|
||||
|
||||
|
@ -115,4 +115,4 @@ public class GroupToBootScript implements Function<String, Payload> {
|
|||
return newStringPayload(runScript);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,4 @@ public class ParseCookbookDefinitionCheckingChefVersion implements Function<Http
|
|||
public Set<String> apply(HttpResponse response) {
|
||||
return parser.apply(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,4 @@ public class ParseCookbookDefinitionFromJson implements Function<HttpResponse, S
|
|||
public Set<String> apply(HttpResponse response) {
|
||||
return parser.apply(response).keySet();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,4 +50,4 @@ public class ParseCookbookVersionsCheckingChefVersion implements Function<HttpRe
|
|||
public Set<String> apply(HttpResponse response) {
|
||||
return parser.apply(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,4 +49,4 @@ public class ParseCookbookVersionsV09FromJson implements Function<HttpResponse,
|
|||
return Iterables.getFirst(json.apply(arg0).values(), null);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,4 +59,4 @@ public class ParseCookbookVersionsV10FromJson implements Function<HttpResponse,
|
|||
}})
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,4 +59,4 @@ public class ParseErrorFromJsonOrReturnBody implements Function<HttpResponse, St
|
|||
}
|
||||
return in;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,4 +47,4 @@ public class ParseKeySetFromJson implements Function<HttpResponse, Set<String>>
|
|||
return json.apply(arg0).keySet();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,4 @@ public class ParseSearchClientsFromJson extends ParseSearchResultFromJson<Client
|
|||
super(json);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,4 @@ public class ParseSearchDatabagFromJson extends ParseSearchResultFromJson<Databa
|
|||
super(json);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,4 @@ public class ParseSearchNodesFromJson extends ParseSearchResultFromJson<Node> {
|
|||
super(json);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,4 +52,4 @@ public class ParseSearchResultFromJson<T> implements Function<HttpResponse, Sear
|
|||
Response<T> returnVal = json.apply(arg0);
|
||||
return new SearchResult<T>(returnVal.start, returnVal.rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,4 +38,4 @@ public class ParseSearchRolesFromJson extends ParseSearchResultFromJson<Role> {
|
|||
super(json);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
import org.jclouds.json.Json;
|
||||
|
||||
|
@ -48,23 +48,23 @@ import com.google.inject.TypeLiteral;
|
|||
public class RunListForTag implements Function<String, List<String>> {
|
||||
public static final Type RUN_LIST_TYPE = new TypeLiteral<Map<String, List<String>>>() {
|
||||
}.getType();
|
||||
private final ChefClient client;
|
||||
private final ChefApi api;
|
||||
private final Json json;
|
||||
private final String databag;
|
||||
|
||||
@Inject
|
||||
public RunListForTag(@Named(CHEF_BOOTSTRAP_DATABAG) String databag, ChefClient client, Json json) {
|
||||
public RunListForTag(@Named(CHEF_BOOTSTRAP_DATABAG) String databag, ChefApi api, Json json) {
|
||||
this.databag = checkNotNull(databag, "databag");
|
||||
this.client = checkNotNull(client, "client");
|
||||
this.api = checkNotNull(api, "api");
|
||||
this.json = checkNotNull(json, "json");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public List<String> apply(String from) {
|
||||
DatabagItem list = client.getDatabagItem(databag, from);
|
||||
DatabagItem list = api.getDatabagItem(databag, from);
|
||||
checkState(list != null, "databag item %s/%s not found", databag, from);
|
||||
return ((Map<String, List<String>>) json.fromJson(list.toString(), RUN_LIST_TYPE)).get("run_list");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.google.inject.Inject;
|
|||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
public class ChefClientErrorRetryHandler implements HttpRetryHandler {
|
||||
public class ChefApiErrorRetryHandler implements HttpRetryHandler {
|
||||
|
||||
@Inject(optional = true)
|
||||
@Named(Constants.PROPERTY_MAX_RETRIES)
|
||||
|
@ -49,7 +49,7 @@ public class ChefClientErrorRetryHandler implements HttpRetryHandler {
|
|||
private final BackoffLimitedRetryHandler backoffLimitedRetryHandler;
|
||||
|
||||
@Inject
|
||||
ChefClientErrorRetryHandler(BackoffLimitedRetryHandler backoffLimitedRetryHandler) {
|
||||
ChefApiErrorRetryHandler(BackoffLimitedRetryHandler backoffLimitedRetryHandler) {
|
||||
this.backoffLimitedRetryHandler = backoffLimitedRetryHandler;
|
||||
}
|
||||
|
|
@ -74,4 +74,4 @@ public class ChefErrorHandler implements HttpErrorHandler {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,8 @@ import org.jclouds.chef.domain.Client;
|
|||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.chef.functions.RunListForTag;
|
||||
import org.jclouds.chef.functions.GroupToBootScript;
|
||||
import org.jclouds.chef.functions.RunListForTag;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.CleanupStaleNodesAndClients;
|
||||
import org.jclouds.chef.strategy.CreateNodeAndPopulateAutomaticAttributes;
|
||||
|
@ -223,4 +223,4 @@ public class BaseChefService implements ChefService {
|
|||
.get()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ package org.jclouds.chef.internal;
|
|||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.ChefService;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
|
@ -38,14 +38,14 @@ import com.google.inject.TypeLiteral;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Singleton
|
||||
public class ChefContextImpl extends RestContextImpl<ChefClient, ChefAsyncClient> implements ChefContext {
|
||||
public class ChefContextImpl extends RestContextImpl<ChefApi, ChefAsyncApi> implements ChefContext {
|
||||
private final ChefService chefService;
|
||||
|
||||
@Inject
|
||||
protected ChefContextImpl(ProviderMetadata providerMetadata, @Identity String identity, Utils utils, Closer closer,
|
||||
Injector injector, ChefService chefService) {
|
||||
super(providerMetadata, identity, utils, closer, injector, TypeLiteral.get(ChefClient.class), TypeLiteral
|
||||
.get(ChefAsyncClient.class));
|
||||
super(providerMetadata, identity, utils, closer, injector, TypeLiteral.get(ChefApi.class), TypeLiteral
|
||||
.get(ChefAsyncApi.class));
|
||||
this.chefService = chefService;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ public interface ChefConstants {
|
|||
/**
|
||||
* There are generally 3 types of identities
|
||||
* <ul>
|
||||
* <li>validator - used to create clients within an organization; {@code orgname}-validator</li>
|
||||
* <li>client - scoped to an organization, used on nodes to run chef</li>
|
||||
* <li>validator - used to create apis within an organization; {@code orgname}-validator</li>
|
||||
* <li>api - scoped to an organization, used on nodes to run chef</li>
|
||||
* <li>user - used to run commands like knife and access cookbook sites</li>
|
||||
* </ul>
|
||||
*
|
||||
|
@ -43,7 +43,7 @@ public interface ChefConstants {
|
|||
*/
|
||||
|
||||
public static final String CHEF_LOGGER = "jclouds.chef";
|
||||
public static final String CHEF_SERVICE_CLIENT = "chef.service-client";
|
||||
public static final String CHEF_SERVICE_CLIENT = "chef.service-api";
|
||||
public static final String CHEF_NODE = "chef.node";
|
||||
public static final String CHEF_NODE_PATTERN = "chef.node-pattern";
|
||||
public static final String CHEF_RUN_LIST = "chef.run-list";
|
||||
|
|
|
@ -33,4 +33,4 @@ public interface CleanupStaleNodesAndClients {
|
|||
|
||||
void execute(String prefix, int secondsStale);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,4 +34,4 @@ public interface CreateNodeAndPopulateAutomaticAttributes {
|
|||
Node execute(Node node);
|
||||
|
||||
Node execute(String nodeName, Iterable<String> runList);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,4 @@ public interface DeleteAllClientsInList {
|
|||
|
||||
public void execute(Iterable<String> names);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,4 @@ public interface DeleteAllNodesInList {
|
|||
|
||||
public void execute(Iterable<String> names);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,4 +37,4 @@ public interface ListClients {
|
|||
Iterable<? extends Client> execute(Predicate<String> clientNameSelector);
|
||||
|
||||
Iterable<? extends Client> execute(Iterable<String> toGet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,4 +37,4 @@ public interface ListCookbookVersions {
|
|||
Iterable<? extends CookbookVersion> execute(Predicate<String> cookbookNameSelector);
|
||||
|
||||
Iterable<? extends CookbookVersion> execute(Iterable<String> cookbookNames);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,4 +37,4 @@ public interface ListNodes {
|
|||
Iterable<? extends Node> execute(Predicate<String> nodeNameSelector);
|
||||
|
||||
Iterable<? extends Node> execute(Iterable<String> toGet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,4 +32,4 @@ import com.google.inject.ImplementedBy;
|
|||
public interface UpdateAutomaticAttributesOnNode {
|
||||
|
||||
public void execute(String nodeName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ import com.google.common.base.Predicate;
|
|||
|
||||
/**
|
||||
*
|
||||
* Cleans up nodes and clients who have been hanging around too long.
|
||||
* Cleans up nodes and apis who have been hanging around too long.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
|
@ -104,4 +104,4 @@ public class CleanupStaleNodesAndClientsImpl implements CleanupStaleNodesAndClie
|
|||
nodeDeleter.execute(nodeNames);
|
||||
clientDeleter.execute(nodeNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.CreateNodeAndPopulateAutomaticAttributes;
|
||||
|
@ -50,11 +50,11 @@ public class CreateNodeAndPopulateAutomaticAttributesImpl implements CreateNodeA
|
|||
@Named(ChefConstants.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final ChefClient chef;
|
||||
private final ChefApi chef;
|
||||
private final Supplier<Map<String, JsonBall>> automaticSupplier;
|
||||
|
||||
@Inject
|
||||
public CreateNodeAndPopulateAutomaticAttributesImpl(ChefClient chef,
|
||||
public CreateNodeAndPopulateAutomaticAttributesImpl(ChefApi chef,
|
||||
@Automatic Supplier<Map<String, JsonBall>> automaticSupplier) {
|
||||
this.chef = checkNotNull(chef, "chef");
|
||||
this.automaticSupplier = checkNotNull(automaticSupplier, "automaticSupplier");
|
||||
|
@ -73,4 +73,4 @@ public class CreateNodeAndPopulateAutomaticAttributesImpl implements CreateNodeA
|
|||
public Node execute(String nodeName, Iterable<String> runList) {
|
||||
return execute(new Node(nodeName, runList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.DeleteAllClientsInList;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -46,8 +46,8 @@ import com.google.inject.Inject;
|
|||
@Singleton
|
||||
public class DeleteAllClientsInListImpl implements DeleteAllClientsInList {
|
||||
|
||||
protected final ChefClient chefClient;
|
||||
protected final ChefAsyncClient chefAsyncClient;
|
||||
protected final ChefApi chefApi;
|
||||
protected final ChefAsyncApi chefAsyncApi;
|
||||
protected final ExecutorService userExecutor;
|
||||
@Resource
|
||||
@Named(ChefConstants.CHEF_LOGGER)
|
||||
|
@ -59,10 +59,10 @@ public class DeleteAllClientsInListImpl implements DeleteAllClientsInList {
|
|||
|
||||
@Inject
|
||||
DeleteAllClientsInListImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor,
|
||||
ChefClient getAllClient, ChefAsyncClient ablobstore) {
|
||||
ChefApi getAllApi, ChefAsyncApi ablobstore) {
|
||||
this.userExecutor = userExecutor;
|
||||
this.chefAsyncClient = ablobstore;
|
||||
this.chefClient = getAllClient;
|
||||
this.chefAsyncApi = ablobstore;
|
||||
this.chefApi = getAllApi;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,11 +70,11 @@ public class DeleteAllClientsInListImpl implements DeleteAllClientsInList {
|
|||
Map<String, Exception> exceptions = newHashMap();
|
||||
Map<String, Future<?>> responses = newHashMap();
|
||||
for (String name : names) {
|
||||
responses.put(name, chefAsyncClient.deleteClient(name));
|
||||
responses.put(name, chefAsyncApi.deleteClient(name));
|
||||
}
|
||||
exceptions = awaitCompletion(responses, userExecutor, maxTime, logger, String.format(
|
||||
"deleting clients: %s", names));
|
||||
"deleting apis: %s", names));
|
||||
if (exceptions.size() > 0)
|
||||
throw new RuntimeException(String.format("errors deleting clients: %s: %s", names, exceptions));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,8 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.DeleteAllNodesInList;
|
||||
import org.jclouds.logging.Logger;
|
||||
|
@ -46,8 +46,8 @@ import com.google.inject.Inject;
|
|||
@Singleton
|
||||
public class DeleteAllNodesInListImpl implements DeleteAllNodesInList {
|
||||
|
||||
protected final ChefClient chefClient;
|
||||
protected final ChefAsyncClient chefAsyncClient;
|
||||
protected final ChefApi chefApi;
|
||||
protected final ChefAsyncApi chefAsyncApi;
|
||||
protected final ExecutorService userExecutor;
|
||||
@Resource
|
||||
@Named(ChefConstants.CHEF_LOGGER)
|
||||
|
@ -59,10 +59,10 @@ public class DeleteAllNodesInListImpl implements DeleteAllNodesInList {
|
|||
|
||||
@Inject
|
||||
DeleteAllNodesInListImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor,
|
||||
ChefClient getAllNode, ChefAsyncClient ablobstore) {
|
||||
ChefApi getAllNode, ChefAsyncApi ablobstore) {
|
||||
this.userExecutor = userExecutor;
|
||||
this.chefAsyncClient = ablobstore;
|
||||
this.chefClient = getAllNode;
|
||||
this.chefAsyncApi = ablobstore;
|
||||
this.chefApi = getAllNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,11 +70,11 @@ public class DeleteAllNodesInListImpl implements DeleteAllNodesInList {
|
|||
Map<String, Exception> exceptions = newHashMap();
|
||||
Map<String, Future<?>> responses = newHashMap();
|
||||
for (String name : names) {
|
||||
responses.put(name, chefAsyncClient.deleteNode(name));
|
||||
responses.put(name, chefAsyncApi.deleteNode(name));
|
||||
}
|
||||
exceptions = awaitCompletion(responses, userExecutor, maxTime, logger, String.format(
|
||||
"deleting nodes: %s", names));
|
||||
if (exceptions.size() > 0)
|
||||
throw new RuntimeException(String.format("errors deleting nodes: %s: %s", names, exceptions));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.ListClients;
|
||||
|
@ -48,8 +48,8 @@ import com.google.inject.Inject;
|
|||
@Singleton
|
||||
public class ListClientsImpl implements ListClients {
|
||||
|
||||
protected final ChefClient chefClient;
|
||||
protected final ChefAsyncClient chefAsyncClient;
|
||||
protected final ChefApi chefApi;
|
||||
protected final ChefAsyncApi chefAsyncApi;
|
||||
protected final ExecutorService userExecutor;
|
||||
@Resource
|
||||
@Named(ChefConstants.CHEF_LOGGER)
|
||||
|
@ -60,21 +60,21 @@ public class ListClientsImpl implements ListClients {
|
|||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListClientsImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor, ChefClient getAllClient,
|
||||
ChefAsyncClient ablobstore) {
|
||||
ListClientsImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor, ChefApi getAllApi,
|
||||
ChefAsyncApi ablobstore) {
|
||||
this.userExecutor = userExecutor;
|
||||
this.chefAsyncClient = ablobstore;
|
||||
this.chefClient = getAllClient;
|
||||
this.chefAsyncApi = ablobstore;
|
||||
this.chefApi = getAllApi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Client> execute() {
|
||||
return execute(chefClient.listClients());
|
||||
return execute(chefApi.listClients());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Client> execute(Predicate<String> clientNameSelector) {
|
||||
return execute(filter(chefClient.listClients(), clientNameSelector));
|
||||
return execute(filter(chefApi.listClients(), clientNameSelector));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,11 +83,11 @@ public class ListClientsImpl implements ListClients {
|
|||
|
||||
@Override
|
||||
public Future<Client> apply(String from) {
|
||||
return chefAsyncClient.getClient(from);
|
||||
return chefAsyncApi.getClient(from);
|
||||
}
|
||||
|
||||
}, userExecutor, maxTime, logger, "getting clients");
|
||||
}, userExecutor, maxTime, logger, "getting apis");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,8 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.ListCookbookVersions;
|
||||
|
@ -50,8 +50,8 @@ import com.google.inject.Inject;
|
|||
@Singleton
|
||||
public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
||||
|
||||
protected final ChefClient chefClient;
|
||||
protected final ChefAsyncClient chefAsyncClient;
|
||||
protected final ChefApi chefApi;
|
||||
protected final ChefAsyncApi chefAsyncApi;
|
||||
protected final ExecutorService userExecutor;
|
||||
@Resource
|
||||
@Named(ChefConstants.CHEF_LOGGER)
|
||||
|
@ -63,20 +63,20 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
|||
|
||||
@Inject
|
||||
ListCookbookVersionsImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor,
|
||||
ChefClient getAllCookbookVersion, ChefAsyncClient ablobstore) {
|
||||
ChefApi getAllCookbookVersion, ChefAsyncApi ablobstore) {
|
||||
this.userExecutor = userExecutor;
|
||||
this.chefAsyncClient = ablobstore;
|
||||
this.chefClient = getAllCookbookVersion;
|
||||
this.chefAsyncApi = ablobstore;
|
||||
this.chefApi = getAllCookbookVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends CookbookVersion> execute() {
|
||||
return execute(chefClient.listCookbooks());
|
||||
return execute(chefApi.listCookbooks());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends CookbookVersion> execute(Predicate<String> cookbookNameSelector) {
|
||||
return execute(filter(chefClient.listCookbooks(), cookbookNameSelector));
|
||||
return execute(filter(chefApi.listCookbooks(), cookbookNameSelector));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,12 +86,12 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
|||
@Override
|
||||
public Iterable<? extends CookbookVersion> apply(final String cookbook) {
|
||||
// TODO getting each version could also go parallel
|
||||
return transformParallel(chefClient.getVersionsOfCookbook(cookbook),
|
||||
return transformParallel(chefApi.getVersionsOfCookbook(cookbook),
|
||||
new Function<String, Future<? extends CookbookVersion>>() {
|
||||
|
||||
@Override
|
||||
public Future<CookbookVersion> apply(String version) {
|
||||
return chefAsyncClient.getCookbook(cookbook, version);
|
||||
return chefAsyncApi.getCookbook(cookbook, version);
|
||||
}
|
||||
|
||||
}, userExecutor, maxTime, logger, "getting versions of cookbook " + cookbook);
|
||||
|
@ -100,4 +100,4 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
|||
}));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ import javax.inject.Named;
|
|||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.Constants;
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.ListNodes;
|
||||
|
@ -48,8 +48,8 @@ import com.google.inject.Inject;
|
|||
@Singleton
|
||||
public class ListNodesImpl implements ListNodes {
|
||||
|
||||
protected final ChefClient chefClient;
|
||||
protected final ChefAsyncClient chefAsyncClient;
|
||||
protected final ChefApi chefApi;
|
||||
protected final ChefAsyncApi chefAsyncApi;
|
||||
protected final ExecutorService userExecutor;
|
||||
@Resource
|
||||
@Named(ChefConstants.CHEF_LOGGER)
|
||||
|
@ -60,21 +60,21 @@ public class ListNodesImpl implements ListNodes {
|
|||
protected Long maxTime;
|
||||
|
||||
@Inject
|
||||
ListNodesImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor, ChefClient getAllNode,
|
||||
ChefAsyncClient ablobstore) {
|
||||
ListNodesImpl(@Named(Constants.PROPERTY_USER_THREADS) ExecutorService userExecutor, ChefApi getAllNode,
|
||||
ChefAsyncApi ablobstore) {
|
||||
this.userExecutor = userExecutor;
|
||||
this.chefAsyncClient = ablobstore;
|
||||
this.chefClient = getAllNode;
|
||||
this.chefAsyncApi = ablobstore;
|
||||
this.chefApi = getAllNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> execute() {
|
||||
return execute(chefClient.listNodes());
|
||||
return execute(chefApi.listNodes());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> execute(Predicate<String> nodeNameSelector) {
|
||||
return execute(filter(chefClient.listNodes(), nodeNameSelector));
|
||||
return execute(filter(chefApi.listNodes(), nodeNameSelector));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -83,11 +83,11 @@ public class ListNodesImpl implements ListNodes {
|
|||
|
||||
@Override
|
||||
public Future<Node> apply(String from) {
|
||||
return chefAsyncClient.getNode(from);
|
||||
return chefAsyncApi.getNode(from);
|
||||
}
|
||||
|
||||
}, userExecutor, maxTime, logger, "getting nodes");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import javax.inject.Inject;
|
|||
import javax.inject.Named;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.chef.reference.ChefConstants;
|
||||
import org.jclouds.chef.strategy.UpdateAutomaticAttributesOnNode;
|
||||
|
@ -50,11 +50,11 @@ public class UpdateAutomaticAttributesOnNodeImpl implements UpdateAutomaticAttri
|
|||
@Named(ChefConstants.CHEF_LOGGER)
|
||||
protected Logger logger = Logger.NULL;
|
||||
|
||||
private final ChefClient chef;
|
||||
private final ChefApi chef;
|
||||
private final Supplier<Map<String, JsonBall>> automaticSupplier;
|
||||
|
||||
@Inject
|
||||
public UpdateAutomaticAttributesOnNodeImpl(ChefClient chef,
|
||||
public UpdateAutomaticAttributesOnNodeImpl(ChefApi chef,
|
||||
@Automatic Supplier<Map<String, JsonBall>> automaticSupplier) {
|
||||
this.chef = checkNotNull(chef, "chef");
|
||||
this.automaticSupplier = checkNotNull(automaticSupplier, "automaticSupplier");
|
||||
|
@ -68,4 +68,4 @@ public class UpdateAutomaticAttributesOnNodeImpl implements UpdateAutomaticAttri
|
|||
chef.updateNode(node);
|
||||
logger.debug("updated node %s", nodeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,19 +20,19 @@ package org.jclouds.chef.test;
|
|||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.concurrent.Timeout;
|
||||
|
||||
/**
|
||||
* In-memory chef simulator.
|
||||
* <p/>
|
||||
*
|
||||
* @see ChefAsyncClient
|
||||
* @see ChefAsyncApi
|
||||
* @see <a href="TODO: insert URL of Chef documentation" />
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Timeout(duration = 30, timeUnit = TimeUnit.MILLISECONDS)
|
||||
public interface TransientChefClient extends ChefClient {
|
||||
public interface TransientChefApi extends ChefApi {
|
||||
|
||||
}
|
|
@ -21,7 +21,7 @@ package org.jclouds.chef.test;
|
|||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.test.config.TransientChefClientModule;
|
||||
import org.jclouds.chef.test.config.TransientChefApiModule;
|
||||
import org.jclouds.ohai.config.JMXOhaiModule;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
@ -56,15 +56,15 @@ public class TransientChefApiMetadata extends ChefApiMetadata {
|
|||
|
||||
public static class Builder extends ChefApiMetadata.Builder {
|
||||
protected Builder() {
|
||||
super(TransientChefClient.class, TransientChefAsyncClient.class);
|
||||
super(TransientChefApi.class, TransientChefAsyncApi.class);
|
||||
id("transientchef")
|
||||
.name("In-memory Chef API")
|
||||
.identityName("unused")
|
||||
.defaultIdentity("client")
|
||||
.defaultIdentity("api")
|
||||
.defaultCredential(
|
||||
"-----BEGIN RSA PRIVATE KEY-----\nMIIEpQIBAAKCAQEAyb2ZJJqGm0KKR+8nfQJNsSd+F9tXNMV7CfOcW6jsqs8EZgiV\nR09hD1IYOj4YqM0qJONlgyg4xRWewdSG7QTPj1lJpVAida9sXy2+kzyagZA1Am0O\nZcbqb5hoeIDgcX+eDa79s0u0DomjcfO9EKhvHLBz+zM+3QqPRkPV8nYTbfs+HjVz\nzOU6D1B0XR3+IPZZl2AnWs2d0qhnStHcDUvnRVQ0P482YwN9VgceOZtpPz0DCKEJ\n5Tx5STub8k0/zt/VAMHQafLSuQMLd2s4ZLuOZptN//uAsTmxireqd37z+8ZTdBbJ\n8LEpJ+iCXuSfm5aUh7iw6oxvToY2AL53+jK2UQIDAQABAoIBAQDA88B3i/xWn0vX\nBVxFamCYoecuNjGwXXkSyZew616A+EOCu47bh4aTurdFbYL0YFaAtaWvzlaN2eHg\nDb+HDuTefE29+WkcGk6SshPmiz5T0XOCAICWw6wSVDkHmGwS4jZvbAFm7W8nwGk9\nYhxgxFiRngswJZFopOLoF5WXs2td8guIYNslMpo7tu50iFnBHwKO2ZsPAk8t9nnS\nxlDavKruymEmqHCr3+dtio5eaenJcp3fjoXBQOKUk3ipII29XRB8NqeCVV/7Kxwq\nckqOBEbRwBclckyIbD+RiAgKvOelORjEiE9R42vuqvxRA6k9kd9o7utlX0AUtpEn\n3gZc6LepAoGBAP9ael5Y75+sK2JJUNOOhO8ae45cdsilp2yI0X+UBaSuQs2+dyPp\nkpEHAxd4pmmSvn/8c9TlEZhr+qYbABXVPlDncxpIuw2Ajbk7s/S4XaSKsRqpXL57\nzj/QOqLkRk8+OVV9q6lMeQNqLtEj1u6JPviX70Ro+FQtRttNOYbfdP/fAoGBAMpA\nXjR5woV5sUb+REg9vEuYo8RSyOarxqKFCIXVUNsLOx+22+AK4+CQpbueWN7jotrl\nYD6uT6svWi3AAC7kiY0UI/fjVPRCUi8tVoQUE0TaU5VLITaYOB+W/bBaDE4M9560\n1NuDWO90baA5dfU44iuzva02rGJXK9+nS3o8nk/PAoGBALOL6djnDe4mwAaG6Jco\ncd4xr8jkyPzCRZuyBCSBbwphIUXLc7hDprPky064ncJD1UDmwIdkXd/fpMkg2QmA\n/CUk6LEFjMisqHojOaCL9gQZJPhLN5QUN2x1PJWGjs1vQh8Tkx0iUUCOa8bQPXNR\n+34OTsW6TUna4CSZAycLfhffAoGBAIggVsefBCvuQkF0NeUhmDCRZfhnd8y55RHR\n1HCvqKIlpv+rhcX/zmyBLuteopYyRJRsOiE2FW00i8+rIPRu4Z3Q5nybx7w3PzV9\noHN5R5baE9OyI4KpZWztpYYitZF67NcnAvVULHHOvVJQGnKYfLHJYmrJF7GA1ojM\nAuMdFbjFAoGAPxUhxwFy8gaqBahKUEZn4F81HFP5ihGhkT4QL6AFPO2e+JhIGjuR\n27+85hcFqQ+HHVtFsm81b/a+R7P4UuCRgc8eCjxQMoJ1Xl4n7VbjPbHMnIN0Ryvd\nO4ZpWDWYnCO021JTOUUOJ4J/y0416Bvkw0z59y7sNX7wDBBHHbK/XCc=\n-----END RSA PRIVATE KEY-----\n")
|
||||
.defaultEndpoint("transientchef").defaultModules(
|
||||
ImmutableSet.<Class<? extends Module>> of(TransientChefClientModule.class,
|
||||
ImmutableSet.<Class<? extends Module>> of(TransientChefApiModule.class,
|
||||
ChefParserModule.class, JMXOhaiModule.class));
|
||||
}
|
||||
|
||||
|
@ -80,4 +80,4 @@ public class TransientChefApiMetadata extends ChefApiMetadata {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.jclouds.blobstore.TransientAsyncBlobStore;
|
|||
import org.jclouds.blobstore.domain.Blob;
|
||||
import org.jclouds.blobstore.domain.PageSet;
|
||||
import org.jclouds.blobstore.domain.StorageMetadata;
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
|
@ -64,7 +64,7 @@ import com.google.common.util.concurrent.ListenableFuture;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
|
||||
public class TransientChefAsyncClient implements ChefAsyncClient {
|
||||
public class TransientChefAsyncApi implements ChefAsyncApi {
|
||||
@Singleton
|
||||
private static class StorageMetadataToName implements Function<PageSet<? extends StorageMetadata>, Set<String>> {
|
||||
@Override
|
||||
|
@ -99,7 +99,7 @@ public class TransientChefAsyncClient implements ChefAsyncClient {
|
|||
private final StorageMetadataToName storageMetadataToName;
|
||||
|
||||
@Inject
|
||||
TransientChefAsyncClient(@Named("databags") TransientAsyncBlobStore databags,
|
||||
TransientChefAsyncApi(@Named("databags") TransientAsyncBlobStore databags,
|
||||
StorageMetadataToName storageMetadataToName, BlobToDatabagItem blobToDatabagItem,
|
||||
@Named(Constants.PROPERTY_USER_THREADS) ExecutorService executor) {
|
||||
this.databags = checkNotNull(databags, "databags");
|
|
@ -29,14 +29,14 @@ import javax.inject.Singleton;
|
|||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.blobstore.TransientApiMetadata;
|
||||
import org.jclouds.blobstore.TransientAsyncBlobStore;
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.functions.ClientForTag;
|
||||
import org.jclouds.chef.functions.RunListForTag;
|
||||
import org.jclouds.chef.statements.InstallChefGems;
|
||||
import org.jclouds.chef.test.TransientChefAsyncClient;
|
||||
import org.jclouds.chef.test.TransientChefClient;
|
||||
import org.jclouds.chef.test.TransientChefApi;
|
||||
import org.jclouds.chef.test.TransientChefAsyncApi;
|
||||
import org.jclouds.concurrent.MoreExecutors;
|
||||
import org.jclouds.concurrent.config.ExecutorServiceModule;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
|
@ -61,15 +61,15 @@ import com.google.inject.name.Names;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@ConfiguresRestClient
|
||||
public class TransientChefClientModule extends AbstractModule {
|
||||
public class TransientChefApiModule extends AbstractModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
install(new RestModule());
|
||||
bind(ChefAsyncClient.class).to(TransientChefAsyncClient.class).asEagerSingleton();
|
||||
// forward all requests from TransientChefClient to ChefAsyncClient. needs above binding as cannot proxy a class
|
||||
BinderUtils.bindClient(binder(), TransientChefClient.class, ChefAsyncClient.class, ImmutableMap.<Class<?>, Class<?>>of());
|
||||
bind(ChefClient.class).to(TransientChefClient.class);
|
||||
bind(ChefAsyncApi.class).to(TransientChefAsyncApi.class).asEagerSingleton();
|
||||
// forward all requests from TransientChefApi to ChefAsyncApi. needs above binding as cannot proxy a class
|
||||
BinderUtils.bindClient(binder(), TransientChefApi.class, ChefAsyncApi.class, ImmutableMap.<Class<?>, Class<?>>of());
|
||||
bind(ChefApi.class).to(TransientChefApi.class);
|
||||
|
||||
bind(TransientAsyncBlobStore.class).annotatedWith(Names.named("databags")).toInstance(
|
||||
ContextBuilder.newBuilder(new TransientApiMetadata()).modules(
|
||||
|
@ -100,4 +100,4 @@ public class TransientChefClientModule extends AbstractModule {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -75,4 +75,4 @@ public class ChefUtils {
|
|||
matcher.find();
|
||||
return matcher.group(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,4 +84,4 @@ public class RunListBuilder {
|
|||
public List<String> build() {
|
||||
return ImmutableList.copyOf(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,4 +52,4 @@ public class AutomaticSupplier implements Supplier<Map<String, JsonBall>> {
|
|||
return nester.apply(autoAttrs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,4 +49,4 @@ public class JMXOhaiModule extends OhaiModule {
|
|||
mapBinder.addBinding("uptime_seconds").to(UptimeSecondsSupplier.class);
|
||||
return mapBinder;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -184,4 +184,4 @@ public class OhaiModule extends AbstractModule {
|
|||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,4 +53,4 @@ public class ByteArrayToMacAddress implements Function<byte[], String> {
|
|||
}));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,4 +45,4 @@ public class MapSetToMultimap<K, V> implements Function<Map<K, Set<V>>, Multimap
|
|||
return returnV;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,4 +157,4 @@ public class NestSlashKeys implements Function<Multimap<String, Supplier<JsonBal
|
|||
}.getType();
|
||||
final Type listLiteral = new TypeLiteral<List<JsonBall>>() {
|
||||
}.getType();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,4 +47,4 @@ public class UptimeSecondsSupplier implements Supplier<JsonBall> {
|
|||
return new JsonBall(uptimeInSeconds);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,18 +21,18 @@ package org.jclouds.chef;
|
|||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
import org.jclouds.chef.internal.BaseChefClientLiveTest;
|
||||
import org.jclouds.chef.internal.BaseChefApiLiveTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code ChefClient} against a Chef Server <= 0.9.8.
|
||||
* Tests behavior of {@code ChefApi} against a Chef Server <= 0.9.8.
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "live" })
|
||||
public class ChefClientLiveTest extends BaseChefClientLiveTest<ChefContext> {
|
||||
public class ChefApiLiveTest extends BaseChefApiLiveTest<ChefContext> {
|
||||
|
||||
@Test
|
||||
public void testListCookbookVersionsWithChefService() throws Exception {
|
||||
|
@ -41,7 +41,7 @@ public class ChefClientLiveTest extends BaseChefClientLiveTest<ChefContext> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
|
@ -59,7 +59,7 @@ import org.jclouds.rest.functions.ReturnEmptySetOnNotFoundOr404;
|
|||
import org.jclouds.rest.functions.ReturnFalseOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnNullOnNotFoundOr404;
|
||||
import org.jclouds.rest.functions.ReturnVoidOnNotFoundOr404;
|
||||
import org.jclouds.rest.internal.BaseAsyncClientTest;
|
||||
import org.jclouds.rest.internal.BaseAsyncApiTest;
|
||||
import org.jclouds.rest.internal.GeneratedHttpRequest;
|
||||
import org.jclouds.rest.internal.RestAnnotationProcessor;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -71,21 +71,21 @@ import com.google.inject.Module;
|
|||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* Tests annotation parsing of {@code ChefAsyncClient}
|
||||
* Tests annotation parsing of {@code ChefAsyncApi}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "unit" })
|
||||
public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
||||
public class ChefAsyncApiTest extends BaseAsyncApiTest<ChefAsyncApi> {
|
||||
|
||||
public void testCommitSandbox() throws SecurityException, NoSuchMethodException, IOException {
|
||||
|
||||
Method method = ChefAsyncClient.class.getMethod("commitSandbox", String.class, boolean.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method,
|
||||
Method method = ChefAsyncApi.class.getMethod("commitSandbox", String.class, boolean.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method,
|
||||
"0189e76ccc476701d6b374e5a1a27347", true);
|
||||
assertRequestLineEquals(httpRequest,
|
||||
"PUT http://localhost:4000/sandboxes/0189e76ccc476701d6b374e5a1a27347 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"is_completed\":true}", "application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -97,13 +97,13 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testGetUploadSandboxForChecksums() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("getUploadSandboxForChecksums", Set.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, ImmutableSet.of(Bytes
|
||||
Method method = ChefAsyncApi.class.getMethod("getUploadSandboxForChecksums", Set.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, ImmutableSet.of(Bytes
|
||||
.asList(CryptoStreams.hex("0189e76ccc476701d6b374e5a1a27347")), Bytes.asList(CryptoStreams
|
||||
.hex("0c5ecd7788cf4f6c7de2a57193897a6c")), Bytes.asList(CryptoStreams
|
||||
.hex("1dda05ed139664f1f89b9dec482b77c0"))));
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/sandboxes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"checksums\":{\"0189e76ccc476701d6b374e5a1a27347\":null,\"0c5ecd7788cf4f6c7de2a57193897a6c\":null,\"1dda05ed139664f1f89b9dec482b77c0\":null}}",
|
||||
|
@ -118,11 +118,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testUploadContent() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("uploadContent", URI.class, Payload.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, URI.create("http://foo/bar"),
|
||||
Method method = ChefAsyncApi.class.getMethod("uploadContent", URI.class, Payload.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, URI.create("http://foo/bar"),
|
||||
new StringPayload("{\"foo\": \"bar\"}"));
|
||||
assertRequestLineEquals(httpRequest, "PUT http://foo/bar HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"foo\": \"bar\"}", "application/x-binary", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
|
||||
|
@ -134,10 +134,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testGetCookbook() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("getCookbook", String.class, String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "cookbook", "1.0.0");
|
||||
Method method = ChefAsyncApi.class.getMethod("getCookbook", String.class, String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "cookbook", "1.0.0");
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/cookbooks/cookbook/1.0.0 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -149,10 +149,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDeleteCookbook() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("deleteCookbook", String.class, String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "cookbook", "1.0.0");
|
||||
Method method = ChefAsyncApi.class.getMethod("deleteCookbook", String.class, String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "cookbook", "1.0.0");
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/cookbooks/cookbook/1.0.0 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -164,13 +164,13 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testUpdateCookbook() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("updateCookbook", String.class, String.class,
|
||||
Method method = ChefAsyncApi.class.getMethod("updateCookbook", String.class, String.class,
|
||||
CookbookVersion.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "cookbook", "1.0.1",
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "cookbook", "1.0.1",
|
||||
new CookbookVersion("cookbook", "1.0.1"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/cookbooks/cookbook/1.0.1 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"name\":\"cookbook-1.0.1\",\"definitions\":[],\"attributes\":[],\"files\":[],\"metadata\":{\"suggestions\":{},\"dependencies\":{},\"conflicting\":{},\"providing\":{},\"platforms\":{},\"recipes\":{},\"replacing\":{},\"groupings\":{},\"attributes\":{},\"recommendations\":{}},\"providers\":[],\"cookbook_name\":\"cookbook\",\"resources\":[],\"templates\":[],\"libraries\":[],\"version\":\"1.0.1\",\"recipes\":[],\"root_files\":[],\"json_class\":\"Chef::CookbookVersion\",\"chef_type\":\"cookbook_version\"}",
|
||||
|
@ -184,11 +184,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testListCookbooks() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("listCookbooks");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("listCookbooks");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/cookbooks HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseCookbookDefinitionCheckingChefVersion.class);
|
||||
|
@ -200,11 +200,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testGetVersionsOfCookbook() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("getVersionsOfCookbook", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "apache2");
|
||||
Method method = ChefAsyncApi.class.getMethod("getVersionsOfCookbook", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "apache2");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/cookbooks/apache2 HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseCookbookVersionsCheckingChefVersion.class);
|
||||
|
@ -215,11 +215,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
|
||||
}
|
||||
|
||||
public void testClientExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("clientExists", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "client");
|
||||
assertRequestLineEquals(httpRequest, "HEAD http://localhost:4000/clients/client HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
public void testApiExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncApi.class.getMethod("clientExists", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "api");
|
||||
assertRequestLineEquals(httpRequest, "HEAD http://localhost:4000/clients/api HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
|
||||
|
@ -231,10 +231,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDeleteClient() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("deleteClient", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "client");
|
||||
Method method = ChefAsyncApi.class.getMethod("deleteClient", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "client");
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/clients/client HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -245,13 +245,13 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
|
||||
}
|
||||
|
||||
public void testCreateClient() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createClient", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "client");
|
||||
public void testCreateApi() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncApi.class.getMethod("createClient", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "api");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/clients HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"client\"}", "application/json", false);
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"api\"}", "application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
@ -261,13 +261,13 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
|
||||
}
|
||||
|
||||
public void testCreateAdminClient() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createClient", String.class, CreateClientOptions.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "client", CreateClientOptions.Builder.admin());
|
||||
public void testCreateAdminApi() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncApi.class.getMethod("createClient", String.class, CreateClientOptions.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "api", CreateClientOptions.Builder.admin());
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/clients HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"client\",\"admin\":true}", "application/json", false);
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"api\",\"admin\":true}", "application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
assertSaxResponseParserClassEquals(method, null);
|
||||
|
@ -278,11 +278,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testListClients() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("listClients");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("listClients");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/clients HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseKeySetFromJson.class);
|
||||
|
@ -294,10 +294,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testGenerateKeyForClient() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("generateKeyForClient", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "client");
|
||||
Method method = ChefAsyncApi.class.getMethod("generateKeyForClient", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "client");
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/clients/client HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"client\", \"private_key\": true}", "application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -309,10 +309,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testNodeExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("nodeExists", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "node");
|
||||
Method method = ChefAsyncApi.class.getMethod("nodeExists", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "node");
|
||||
assertRequestLineEquals(httpRequest, "HEAD http://localhost:4000/nodes/node HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
|
||||
|
@ -324,10 +324,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDeleteNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("deleteNode", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "node");
|
||||
Method method = ChefAsyncApi.class.getMethod("deleteNode", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "node");
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/nodes/node HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -339,12 +339,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testCreateNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createNode", Node.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, new Node("testnode",
|
||||
Method method = ChefAsyncApi.class.getMethod("createNode", Node.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, new Node("testnode",
|
||||
ImmutableSet.of("recipe[java]")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/nodes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"name\":\"testnode\",\"normal\":{},\"override\":{},\"default\":{},\"automatic\":{},\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::Node\",\"chef_type\":\"node\"}",
|
||||
|
@ -359,12 +359,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testUpdateNode() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("updateNode", Node.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, new Node("testnode",
|
||||
Method method = ChefAsyncApi.class.getMethod("updateNode", Node.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, new Node("testnode",
|
||||
ImmutableSet.of("recipe[java]")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/nodes/testnode HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"name\":\"testnode\",\"normal\":{},\"override\":{},\"default\":{},\"automatic\":{},\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::Node\",\"chef_type\":\"node\"}",
|
||||
|
@ -379,11 +379,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testListNodes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("listNodes");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("listNodes");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/nodes HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseKeySetFromJson.class);
|
||||
|
@ -395,10 +395,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testRoleExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("roleExists", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "role");
|
||||
Method method = ChefAsyncApi.class.getMethod("roleExists", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "role");
|
||||
assertRequestLineEquals(httpRequest, "HEAD http://localhost:4000/roles/role HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
|
||||
|
@ -410,10 +410,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDeleteRole() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("deleteRole", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "role");
|
||||
Method method = ChefAsyncApi.class.getMethod("deleteRole", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "role");
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/roles/role HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -425,12 +425,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testCreateRole() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createRole", Role.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, new Role("testrole",
|
||||
Method method = ChefAsyncApi.class.getMethod("createRole", Role.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, new Role("testrole",
|
||||
ImmutableSet.of("recipe[java]")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/roles HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"name\":\"testrole\",\"override_attributes\":{},\"default_attributes\":{},\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"}",
|
||||
|
@ -445,12 +445,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testUpdateRole() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("updateRole", Role.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, new Role("testrole",
|
||||
Method method = ChefAsyncApi.class.getMethod("updateRole", Role.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, new Role("testrole",
|
||||
ImmutableSet.of("recipe[java]")));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/roles/testrole HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"name\":\"testrole\",\"override_attributes\":{},\"default_attributes\":{},\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::Role\",\"chef_type\":\"role\"}",
|
||||
|
@ -465,11 +465,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testListRoles() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("listRoles");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("listRoles");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/roles HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseKeySetFromJson.class);
|
||||
|
@ -481,10 +481,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDatabagExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("databagExists", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "databag");
|
||||
Method method = ChefAsyncApi.class.getMethod("databagExists", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "databag");
|
||||
assertRequestLineEquals(httpRequest, "HEAD http://localhost:4000/data/databag HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
|
||||
|
@ -496,10 +496,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDeleteDatabag() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("deleteDatabag", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "databag");
|
||||
Method method = ChefAsyncApi.class.getMethod("deleteDatabag", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "databag");
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/data/databag HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
|
||||
|
@ -511,11 +511,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testCreateDatabag() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createDatabag", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name");
|
||||
Method method = ChefAsyncApi.class.getMethod("createDatabag", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"name\":\"name\"}", "application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReleasePayloadAndReturn.class);
|
||||
|
@ -527,11 +527,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testListDatabags() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("listDatabags");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("listDatabags");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/data HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseKeySetFromJson.class);
|
||||
|
@ -543,10 +543,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDatabagItemExists() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("databagItemExists", String.class, String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name", "databagItem");
|
||||
Method method = ChefAsyncApi.class.getMethod("databagItemExists", String.class, String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name", "databagItem");
|
||||
assertRequestLineEquals(httpRequest, "HEAD http://localhost:4000/data/name/databagItem HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReturnTrueIf2xx.class);
|
||||
|
@ -558,10 +558,10 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testDeleteDatabagItem() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("deleteDatabagItem", String.class, String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name", "databagItem");
|
||||
Method method = ChefAsyncApi.class.getMethod("deleteDatabagItem", String.class, String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name", "databagItem");
|
||||
assertRequestLineEquals(httpRequest, "DELETE http://localhost:4000/data/name/databagItem HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -575,12 +575,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testCreateDatabagItemThrowsIllegalArgumentOnPrimitive() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
Method method = ChefAsyncApi.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
"100"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"name\":\"testdatabagItem\",\"override_attributes\":{},\"default_attributes\":{},\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::DatabagItem\",\"chef_type\":\"databagItem\"}",
|
||||
|
@ -597,12 +597,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testCreateDatabagItemThrowsIllegalArgumentOnWrongId() throws SecurityException, NoSuchMethodException,
|
||||
IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
Method method = ChefAsyncApi.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
"{\"id\": \"item1\",\"my_key\": \"my_data\"}"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(
|
||||
httpRequest,
|
||||
"{\"name\":\"testdatabagItem\",\"override_attributes\":{},\"default_attributes\":{},\"run_list\":[\"recipe[java]\"],\"json_class\":\"Chef::DatabagItem\",\"chef_type\":\"databagItem\"}",
|
||||
|
@ -617,12 +617,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testCreateDatabagItem() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
Method method = ChefAsyncApi.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
"{\"id\": \"id\",\"my_key\": \"my_data\"}"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"id\": \"id\",\"my_key\": \"my_data\"}", "application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -634,12 +634,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testCreateDatabagItemEvenWhenUserForgotId() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
Method method = ChefAsyncApi.class.getMethod("createDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
"{\"my_key\": \"my_data\"}"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "POST http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, "{\"id\":\"id\",\"my_key\": \"my_data\"}", "application/json", false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseJson.class);
|
||||
|
@ -651,12 +651,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testUpdateDatabagItem() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("updateDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
Method method = ChefAsyncApi.class.getMethod("updateDatabagItem", String.class, DatabagItem.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name", new DatabagItem("id",
|
||||
"{\"my_key\": \"my_data\"}"));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "PUT http://localhost:4000/data/name/id HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
|
||||
assertPayloadEquals(httpRequest, "{\"id\":\"id\",\"my_key\": \"my_data\"}", "application/json", false);
|
||||
|
||||
|
@ -669,11 +669,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testListDatabagItems() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("listDatabagItems", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "name");
|
||||
Method method = ChefAsyncApi.class.getMethod("listDatabagItems", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "name");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/data/name HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseKeySetFromJson.class);
|
||||
|
@ -685,11 +685,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testListSearchIndexes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("listSearchIndexes");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("listSearchIndexes");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseKeySetFromJson.class);
|
||||
|
@ -701,11 +701,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testSearchRoles() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("searchRoles");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("searchRoles");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/role HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseSearchRolesFromJson.class);
|
||||
|
@ -717,11 +717,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testSearchClients() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("searchClients");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("searchClients");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/client HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseSearchClientsFromJson.class);
|
||||
|
@ -733,11 +733,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testSearchNodes() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("searchNodes");
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method);
|
||||
Method method = ChefAsyncApi.class.getMethod("searchNodes");
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method);
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/node HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseSearchNodesFromJson.class);
|
||||
|
@ -749,11 +749,11 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testSearchDatabag() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("searchDatabag", String.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method, "foo");
|
||||
Method method = ChefAsyncApi.class.getMethod("searchDatabag", String.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method, "foo");
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://localhost:4000/search/foo HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ParseSearchDatabagFromJson.class);
|
||||
|
@ -765,12 +765,12 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
public void testGetResourceContents() throws SecurityException, NoSuchMethodException, IOException {
|
||||
Method method = ChefAsyncClient.class.getMethod("getResourceContents", Resource.class);
|
||||
GeneratedHttpRequest<ChefAsyncClient> httpRequest = processor.createRequest(method,
|
||||
Method method = ChefAsyncApi.class.getMethod("getResourceContents", Resource.class);
|
||||
GeneratedHttpRequest httpRequest = processor.createRequest(method,
|
||||
new Resource("test", URI.create("http://foo/bar"), new byte[]{}, null, null));
|
||||
|
||||
assertRequestLineEquals(httpRequest, "GET http://foo/bar HTTP/1.1");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncClient.VERSION + "-test\n");
|
||||
assertNonPayloadHeadersEqual(httpRequest, "Accept: application/json\nX-Chef-Version: " + ChefAsyncApi.VERSION + "-test\n");
|
||||
assertPayloadEquals(httpRequest, null, null, false);
|
||||
|
||||
assertResponseParserClassEquals(method, httpRequest, ReturnInputStream.class);
|
||||
|
@ -788,8 +788,8 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected TypeLiteral<RestAnnotationProcessor<ChefAsyncClient>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<ChefAsyncClient>>() {
|
||||
protected TypeLiteral<RestAnnotationProcessor<ChefAsyncApi>> createTypeLiteral() {
|
||||
return new TypeLiteral<RestAnnotationProcessor<ChefAsyncApi>>() {
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -801,7 +801,7 @@ public class ChefAsyncClientTest extends BaseAsyncClientTest<ChefAsyncClient> {
|
|||
@Override
|
||||
protected Properties setupProperties() {
|
||||
Properties props = super.setupProperties();
|
||||
props.put(Constants.PROPERTY_API_VERSION, ChefAsyncClient.VERSION + "-test");
|
||||
props.put(Constants.PROPERTY_API_VERSION, ChefAsyncApi.VERSION + "-test");
|
||||
return props;
|
||||
}
|
||||
|
|
@ -21,11 +21,10 @@ package org.jclouds.chef.binders;
|
|||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.HttpMethod;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.crypto.CryptoStreams;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
|
@ -48,7 +47,7 @@ public class BindHexEncodedMD5sToJsonPayloadTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -56,20 +55,20 @@ public class BindHexEncodedMD5sToJsonPayloadTest {
|
|||
|
||||
@Test(expectedExceptions = IllegalArgumentException.class)
|
||||
public void testMustBeIterable() {
|
||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
||||
HttpRequest request = HttpRequest.builder().method(HttpMethod.POST).endpoint("http://localhost").build();
|
||||
binder.bindToRequest(request, new File("foo"));
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testCorrect() {
|
||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
||||
HttpRequest request = HttpRequest.builder().method(HttpMethod.POST).endpoint("http://localhost").build();
|
||||
binder.bindToRequest(request, ImmutableSet.of(CryptoStreams.hex("abddef"), CryptoStreams.hex("1234")));
|
||||
assertEquals(request.getPayload().getRawContent(), "{\"checksums\":{\"abddef\":null,\"1234\":null}}");
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
|
||||
public void testNullIsBad() {
|
||||
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
|
||||
HttpRequest request = HttpRequest.builder().method(HttpMethod.POST).endpoint("http://localhost").build();
|
||||
binder.bindToRequest(request, null);
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
|
|||
import static org.testng.Assert.assertEqualsNoOrder;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.security.PrivateKey;
|
||||
|
||||
import javax.inject.Provider;
|
||||
|
@ -36,7 +35,7 @@ import org.jclouds.http.HttpRequest;
|
|||
import org.jclouds.http.HttpUtils;
|
||||
import org.jclouds.http.internal.SignatureWire;
|
||||
import org.jclouds.logging.config.NullLoggingModule;
|
||||
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
|
||||
import org.jclouds.rest.internal.BaseRestApiTest.MockModule;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -128,9 +127,9 @@ public class SignedHeaderAuthTest {
|
|||
@Test
|
||||
void shouldGenerateTheCorrectStringToSignAndSignature() {
|
||||
|
||||
URI host = URI.create("http://localhost/" + PATH);
|
||||
HttpRequest request = new HttpRequest(HttpMethod.POST, host);
|
||||
request.setPayload(BODY);
|
||||
HttpRequest request = HttpRequest.builder().method(HttpMethod.POST)
|
||||
.endpoint("http://localhost/" + PATH)
|
||||
.payload(BODY).build();
|
||||
|
||||
String expected_string_to_sign = new StringBuilder().append("Method:POST").append("\n").append("Hashed Path:")
|
||||
.append(HASHED_CANONICAL_PATH).append("\n").append("X-Ops-Content-Hash:").append(HASHED_BODY).append("\n")
|
||||
|
@ -150,8 +149,8 @@ public class SignedHeaderAuthTest {
|
|||
@Test
|
||||
void shouldGenerateTheCorrectStringToSignAndSignatureWithNoBody() {
|
||||
|
||||
URI host = URI.create("http://localhost/" + PATH);
|
||||
HttpRequest request = new HttpRequest(HttpMethod.DELETE, host);
|
||||
HttpRequest request = HttpRequest.builder().method(HttpMethod.DELETE)
|
||||
.endpoint("http://localhost/" + PATH).build();
|
||||
|
||||
request = signing_obj.filter(request);
|
||||
Multimap<String, String> headersWithoutContentLength = LinkedHashMultimap.create(request.getHeaders());
|
||||
|
@ -163,9 +162,10 @@ public class SignedHeaderAuthTest {
|
|||
StringBuilder path = new StringBuilder("nodes/");
|
||||
for (int i = 0; i < 100; i++)
|
||||
path.append('A');
|
||||
URI host = URI.create("http://localhost/" + path.toString());
|
||||
HttpRequest request = new HttpRequest(HttpMethod.PUT, host);
|
||||
request.setPayload(BODY);
|
||||
HttpRequest request = HttpRequest.builder().method(HttpMethod.PUT)
|
||||
.endpoint("http://localhost/" + path.toString())
|
||||
.payload(BODY).build();
|
||||
|
||||
signing_obj.filter(request);
|
||||
}
|
||||
|
||||
|
@ -199,4 +199,4 @@ public class SignedHeaderAuthTest {
|
|||
}, crypto, utils);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
*/
|
||||
package org.jclouds.chef.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.PrivateKey;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -40,18 +40,18 @@ import com.google.common.collect.ImmutableSet;
|
|||
public class ClientForTagTest {
|
||||
|
||||
public void testWhenNoClientsInList() throws IOException {
|
||||
ChefClient chefClient = createMock(ChefClient.class);
|
||||
ChefApi chefApi = createMock(ChefApi.class);
|
||||
Client client = createMock(Client.class);
|
||||
PrivateKey privateKey = createMock(PrivateKey.class);
|
||||
|
||||
ClientForTag fn = new ClientForTag(chefClient);
|
||||
ClientForTag fn = new ClientForTag(chefApi);
|
||||
|
||||
expect(chefClient.listClients()).andReturn(ImmutableSet.<String> of());
|
||||
expect(chefClient.createClient("foo-validator-00")).andReturn(client);
|
||||
expect(chefApi.listClients()).andReturn(ImmutableSet.<String> of());
|
||||
expect(chefApi.createClient("foo-validator-00")).andReturn(client);
|
||||
expect(client.getPrivateKey()).andReturn(privateKey);
|
||||
|
||||
replay(client);
|
||||
replay(chefClient);
|
||||
replay(chefApi);
|
||||
|
||||
Client compare = fn.apply("foo");
|
||||
assertEquals(compare.getClientname(), "foo-validator-00");
|
||||
|
@ -59,23 +59,23 @@ public class ClientForTagTest {
|
|||
assertEquals(compare.getPrivateKey(), privateKey);
|
||||
|
||||
verify(client);
|
||||
verify(chefClient);
|
||||
verify(chefApi);
|
||||
}
|
||||
|
||||
public void testWhenClientsInListAddsToEnd() throws IOException {
|
||||
ChefClient chefClient = createMock(ChefClient.class);
|
||||
ChefApi chefApi = createMock(ChefApi.class);
|
||||
Client client = createMock(Client.class);
|
||||
PrivateKey privateKey = createMock(PrivateKey.class);
|
||||
|
||||
ClientForTag fn = new ClientForTag(chefClient);
|
||||
ClientForTag fn = new ClientForTag(chefApi);
|
||||
|
||||
expect(chefClient.listClients()).andReturn(
|
||||
expect(chefApi.listClients()).andReturn(
|
||||
ImmutableSet.<String> of("foo-validator-00", "foo-validator-01", "foo-validator-02"));
|
||||
expect(chefClient.createClient("foo-validator-03")).andReturn(client);
|
||||
expect(chefApi.createClient("foo-validator-03")).andReturn(client);
|
||||
expect(client.getPrivateKey()).andReturn(privateKey);
|
||||
|
||||
replay(client);
|
||||
replay(chefClient);
|
||||
replay(chefApi);
|
||||
|
||||
Client compare = fn.apply("foo");
|
||||
assertEquals(compare.getClientname(), "foo-validator-03");
|
||||
|
@ -83,22 +83,22 @@ public class ClientForTagTest {
|
|||
assertEquals(compare.getPrivateKey(), privateKey);
|
||||
|
||||
verify(client);
|
||||
verify(chefClient);
|
||||
verify(chefApi);
|
||||
}
|
||||
|
||||
public void testWhenClientsInListReplacesMissing() throws IOException {
|
||||
ChefClient chefClient = createMock(ChefClient.class);
|
||||
ChefApi chefApi = createMock(ChefApi.class);
|
||||
Client client = createMock(Client.class);
|
||||
PrivateKey privateKey = createMock(PrivateKey.class);
|
||||
|
||||
ClientForTag fn = new ClientForTag(chefClient);
|
||||
ClientForTag fn = new ClientForTag(chefApi);
|
||||
|
||||
expect(chefClient.listClients()).andReturn(ImmutableSet.<String> of("foo-validator-00", "foo-validator-02"));
|
||||
expect(chefClient.createClient("foo-validator-01")).andReturn(client);
|
||||
expect(chefApi.listClients()).andReturn(ImmutableSet.<String> of("foo-validator-00", "foo-validator-02"));
|
||||
expect(chefApi.createClient("foo-validator-01")).andReturn(client);
|
||||
expect(client.getPrivateKey()).andReturn(privateKey);
|
||||
|
||||
replay(client);
|
||||
replay(chefClient);
|
||||
replay(chefApi);
|
||||
|
||||
Client compare = fn.apply("foo");
|
||||
assertEquals(compare.getClientname(), "foo-validator-01");
|
||||
|
@ -106,6 +106,6 @@ public class ClientForTagTest {
|
|||
assertEquals(compare.getPrivateKey(), privateKey);
|
||||
|
||||
verify(client);
|
||||
verify(chefClient);
|
||||
verify(chefApi);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.chef.functions;
|
||||
|
||||
import static org.jclouds.io.Payloads.newInputStreamPayload;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -27,7 +26,7 @@ import java.security.cert.CertificateException;
|
|||
import java.security.cert.X509Certificate;
|
||||
import java.security.spec.InvalidKeySpecException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.crypto.Crypto;
|
||||
|
@ -70,7 +69,7 @@ public class ParseClientFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -92,7 +91,7 @@ public class ParseClientFromJsonTest {
|
|||
assertEquals(ByteStreams.toByteArray(new RSADecryptingPayload(Payloads.newPayload(encrypted), user
|
||||
.getPrivateKey())), "fooya".getBytes());
|
||||
|
||||
assertEquals(handler.apply(new HttpResponse(200, "ok", newInputStreamPayload(ParseClientFromJsonTest.class
|
||||
.getResourceAsStream("/client.json")))), user);
|
||||
assertEquals(handler.apply(HttpResponse.builder().statusCode(200).message("ok").payload(ParseClientFromJsonTest.class
|
||||
.getResourceAsStream("/client.json")).build()), user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,9 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -52,7 +51,7 @@ public class ParseCookbookDefinitionFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -62,11 +61,10 @@ public class ParseCookbookDefinitionFromJsonTest {
|
|||
public void testParse010Response() {
|
||||
assertEquals(
|
||||
handler
|
||||
.apply(new HttpResponse(
|
||||
200,
|
||||
"ok",
|
||||
Payloads
|
||||
.newStringPayload("{" +
|
||||
.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload("{" +
|
||||
"\"apache2\" => {" +
|
||||
"\"url\" => \"http://localhost:4000/cookbooks/apache2\"," +
|
||||
"\"versions\" => [" +
|
||||
|
@ -85,7 +83,7 @@ public class ParseCookbookDefinitionFromJsonTest {
|
|||
"\"version\" => \"0.3.0\"}" +
|
||||
"]" +
|
||||
"}" +
|
||||
"}"))),
|
||||
"}").build()),
|
||||
ImmutableSet.of("apache2", "nginx"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Attribute;
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
|
@ -32,11 +32,9 @@ import org.jclouds.chef.domain.Resource;
|
|||
import org.jclouds.crypto.CryptoStreams;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.Json;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -66,7 +64,7 @@ public class ParseCookbookVersionFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -77,37 +75,55 @@ public class ParseCookbookVersionFromJsonTest {
|
|||
|
||||
@Test(enabled = false)
|
||||
public void testBrew() throws IOException {
|
||||
CookbookVersion cookbook = handler.apply(new HttpResponse(200, "ok", Payloads
|
||||
.newPayload(ParseCookbookVersionFromJsonTest.class.getResourceAsStream("/brew-cookbook.json"))));
|
||||
CookbookVersion cookbook = handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(ParseCookbookVersionFromJsonTest.class.getResourceAsStream("/brew-cookbook.json")).build());
|
||||
|
||||
assertEquals(cookbook, handler.apply(new HttpResponse(200, "ok", Payloads.newPayload(Strings2.toInputStream(json
|
||||
.toJson(cookbook))))));
|
||||
assertEquals(cookbook, handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(json
|
||||
.toJson(cookbook)).build()));
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testTomcat() {
|
||||
CookbookVersion cookbook = handler.apply(new HttpResponse(200, "ok", Payloads
|
||||
.newPayload(ParseCookbookVersionFromJsonTest.class.getResourceAsStream("/tomcat-cookbook.json"))));
|
||||
CookbookVersion cookbook = handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(ParseCookbookVersionFromJsonTest.class.getResourceAsStream("/tomcat-cookbook.json")).build());
|
||||
|
||||
assertEquals(cookbook, handler.apply(new HttpResponse(200, "ok", Payloads.newPayload(Strings2.toInputStream(json
|
||||
.toJson(cookbook))))));
|
||||
assertEquals(cookbook, handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(json
|
||||
.toJson(cookbook)).build()));
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testMysql() throws IOException {
|
||||
CookbookVersion cookbook = handler.apply(new HttpResponse(200, "ok", Payloads
|
||||
.newPayload(ParseCookbookVersionFromJsonTest.class.getResourceAsStream("/mysql-cookbook.json"))));
|
||||
CookbookVersion cookbook = handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(ParseCookbookVersionFromJsonTest.class.getResourceAsStream("/mysql-cookbook.json")).build());
|
||||
|
||||
assertEquals(cookbook, handler.apply(new HttpResponse(200, "ok", Payloads.newPayload(Strings2.toInputStream(json
|
||||
.toJson(cookbook))))));
|
||||
assertEquals(cookbook, handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(json
|
||||
.toJson(cookbook)).build()));
|
||||
}
|
||||
|
||||
@Test(enabled = false)
|
||||
public void testApache() {
|
||||
|
||||
assertEquals(
|
||||
handler.apply(new HttpResponse(200, "ok", Payloads.newPayload(ParseCookbookVersionFromJsonTest.class
|
||||
.getResourceAsStream("/apache-chef-demo-cookbook.json")))),
|
||||
handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(ParseCookbookVersionFromJsonTest.class
|
||||
.getResourceAsStream("/apache-chef-demo-cookbook.json")).build()),
|
||||
new CookbookVersion(
|
||||
"apache-chef-demo-0.0.0",
|
||||
ImmutableSet.<Resource> of(),
|
||||
|
|
|
@ -22,10 +22,9 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -52,7 +51,7 @@ public class ParseCookbookVersionsV09FromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -62,11 +61,10 @@ public class ParseCookbookVersionsV09FromJsonTest {
|
|||
public void testRegex() {
|
||||
assertEquals(
|
||||
handler
|
||||
.apply(new HttpResponse(
|
||||
200,
|
||||
"ok",
|
||||
Payloads
|
||||
.newStringPayload("{\"apache2\": [\"0.1.8\", \"0.2\"]}"))),
|
||||
.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload("{\"apache2\": [\"0.1.8\", \"0.2\"]}").build()),
|
||||
ImmutableSet.of("0.1.8", "0.2"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,10 +22,9 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -52,7 +51,7 @@ public class ParseCookbookVersionsV10FromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -62,11 +61,10 @@ public class ParseCookbookVersionsV10FromJsonTest {
|
|||
public void testRegex() {
|
||||
assertEquals(
|
||||
handler
|
||||
.apply(new HttpResponse(
|
||||
200,
|
||||
"ok",
|
||||
Payloads
|
||||
.newStringPayload("{" +
|
||||
.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload("{" +
|
||||
"\"apache2\" => {" +
|
||||
"\"url\" => \"http://localhost:4000/cookbooks/apache2\"," +
|
||||
"\"versions\" => [" +
|
||||
|
@ -76,7 +74,7 @@ public class ParseCookbookVersionsV10FromJsonTest {
|
|||
"\"version\" => \"4.2.0\"}" +
|
||||
"]" +
|
||||
"}" +
|
||||
"}"))),
|
||||
"}").build()),
|
||||
ImmutableSet.of("5.1.0", "4.2.0"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,11 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.Json;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
|
@ -54,7 +53,7 @@ public class ParseDataBagItemFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -66,7 +65,10 @@ public class ParseDataBagItemFromJsonTest {
|
|||
public void test1() {
|
||||
String json = "{\"my_key\":\"my_data\",\"id\":\"item1\"}";
|
||||
DatabagItem item = new DatabagItem("item1", json);
|
||||
assertEquals(handler.apply(new HttpResponse(200, "ok", Payloads.newStringPayload(json))), item);
|
||||
assertEquals(handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(json).build()), item);
|
||||
assertEquals(mapper.toJson(item), json);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import java.net.UnknownHostException;
|
|||
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ReturnStringIf2xx;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.util.Strings2;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -42,7 +41,10 @@ public class ParseErrorFromJsonOrReturnBodyTest {
|
|||
|
||||
ParseErrorFromJsonOrReturnBody parser = new ParseErrorFromJsonOrReturnBody(
|
||||
new ReturnStringIf2xx());
|
||||
String response = parser.apply(new HttpResponse(200, "ok", Payloads.newPayload(is)));
|
||||
String response = parser.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(is).build());
|
||||
assertEquals(response, "invalid tarball: tarball root must contain java-bytearray");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,9 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -52,7 +51,7 @@ public class ParseKeySetFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -62,11 +61,10 @@ public class ParseKeySetFromJsonTest {
|
|||
public void testRegex() {
|
||||
assertEquals(
|
||||
handler
|
||||
.apply(new HttpResponse(
|
||||
200,
|
||||
"ok",
|
||||
Payloads
|
||||
.newStringPayload("{\n\"opscode-validator\": \"https://api.opscode.com/...\", \"pimp-validator\": \"https://api.opscode.com/...\"}"))),
|
||||
.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload("{\n\"opscode-validator\": \"https://api.opscode.com/...\", \"pimp-validator\": \"https://api.opscode.com/...\"}").build()),
|
||||
ImmutableSet.of("opscode-validator", "pimp-validator"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,12 @@ import static org.testng.Assert.assertEquals;
|
|||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -58,7 +57,7 @@ public class ParseNodeFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -72,7 +71,10 @@ public class ParseNodeFromJsonTest {
|
|||
"{\"ssl_port\":8433}")), ImmutableMap.<String, JsonBall> of(), ImmutableMap.<String, JsonBall> of(),
|
||||
ImmutableMap.<String, JsonBall> of(), Collections.singleton("recipe[java]"));
|
||||
|
||||
assertEquals(handler.apply(new HttpResponse(200, "ok", Payloads.newPayload(ParseCookbookVersionFromJsonTest.class
|
||||
.getResourceAsStream("/node.json")))), node);
|
||||
assertEquals(handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(ParseCookbookVersionFromJsonTest.class
|
||||
.getResourceAsStream("/node.json")).build()), node);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,13 +22,12 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Sandbox;
|
||||
import org.jclouds.date.DateService;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -58,7 +57,7 @@ public class ParseSandboxFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -68,8 +67,11 @@ public class ParseSandboxFromJsonTest {
|
|||
}
|
||||
|
||||
public void test() {
|
||||
assertEquals(handler.apply(new HttpResponse(200, "ok", Payloads.newPayload(ParseSandboxFromJsonTest.class
|
||||
.getResourceAsStream("/sandbox.json")))), new Sandbox("1-8c27b0ea4c2b7aaedbb44cfbdfcc11b2", false,
|
||||
assertEquals(handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(ParseSandboxFromJsonTest.class
|
||||
.getResourceAsStream("/sandbox.json")).build()), new Sandbox("1-8c27b0ea4c2b7aaedbb44cfbdfcc11b2", false,
|
||||
dateService.iso8601SecondsDateParse("2010-07-07T03:36:00+00:00"), ImmutableSet.<String> of(),
|
||||
"f9d6d9b72bae465890aae87969f98a9c", "f9d6d9b72bae465890aae87969f98a9c"));
|
||||
}
|
||||
|
|
|
@ -24,14 +24,13 @@ import java.io.IOException;
|
|||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.ChecksumStatus;
|
||||
import org.jclouds.chef.domain.UploadSandbox;
|
||||
import org.jclouds.crypto.CryptoStreams;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
|
@ -62,7 +61,7 @@ public class ParseUploadSandboxFromJsonTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -72,8 +71,11 @@ public class ParseUploadSandboxFromJsonTest {
|
|||
|
||||
public void test() {
|
||||
assertEquals(
|
||||
handler.apply(new HttpResponse(200, "ok", Payloads.newPayload(ParseUploadSandboxFromJsonTest.class
|
||||
.getResourceAsStream("/upload-site.json")))),
|
||||
handler.apply(HttpResponse.builder()
|
||||
.statusCode(200)
|
||||
.message("ok")
|
||||
.payload(ParseUploadSandboxFromJsonTest.class
|
||||
.getResourceAsStream("/upload-site.json")).build()),
|
||||
new UploadSandbox(
|
||||
URI
|
||||
.create("https://api.opscode.com/organizations/jclouds/sandboxes/d454f71e2a5f400c808d0c5d04c2c88c"),
|
||||
|
|
|
@ -18,21 +18,22 @@
|
|||
*/
|
||||
package org.jclouds.chef.functions;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
import org.jclouds.json.Json;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.rest.annotations.Api;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
@ -50,7 +51,7 @@ public class RunListForTagTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -58,58 +59,58 @@ public class RunListForTagTest {
|
|||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testWhenNoDatabagItem() throws IOException {
|
||||
ChefClient chefClient = createMock(ChefClient.class);
|
||||
ChefApi chefApi = createMock(ChefApi.class);
|
||||
Client client = createMock(Client.class);
|
||||
|
||||
RunListForTag fn = new RunListForTag("jclouds", chefClient, json);
|
||||
RunListForTag fn = new RunListForTag("jclouds", chefApi, json);
|
||||
|
||||
expect(chefClient.getDatabagItem("jclouds", "foo")).andReturn(null);
|
||||
expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(null);
|
||||
|
||||
replay(client);
|
||||
replay(chefClient);
|
||||
replay(chefApi);
|
||||
|
||||
fn.apply("foo");
|
||||
|
||||
verify(client);
|
||||
verify(chefClient);
|
||||
verify(chefApi);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneRecipe() throws IOException {
|
||||
ChefClient chefClient = createMock(ChefClient.class);
|
||||
Client client = createMock(Client.class);
|
||||
ChefApi chefApi = createMock(ChefApi.class);
|
||||
Api api = createMock(Api.class);
|
||||
|
||||
RunListForTag fn = new RunListForTag("jclouds", chefClient, json);
|
||||
RunListForTag fn = new RunListForTag("jclouds", chefApi, json);
|
||||
|
||||
expect(chefClient.getDatabagItem("jclouds", "foo")).andReturn(
|
||||
expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(
|
||||
new DatabagItem("foo", "{\"run_list\":[\"recipe[apache2]\"]}"));
|
||||
|
||||
replay(client);
|
||||
replay(chefClient);
|
||||
replay(api);
|
||||
replay(chefApi);
|
||||
|
||||
assertEquals(fn.apply("foo"), ImmutableList.of("recipe[apache2]"));
|
||||
|
||||
verify(client);
|
||||
verify(chefClient);
|
||||
verify(api);
|
||||
verify(chefApi);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoRecipes() throws IOException {
|
||||
ChefClient chefClient = createMock(ChefClient.class);
|
||||
Client client = createMock(Client.class);
|
||||
ChefApi chefApi = createMock(ChefApi.class);
|
||||
Api api = createMock(Api.class);
|
||||
|
||||
RunListForTag fn = new RunListForTag("jclouds", chefClient, json);
|
||||
RunListForTag fn = new RunListForTag("jclouds", chefApi, json);
|
||||
|
||||
expect(chefClient.getDatabagItem("jclouds", "foo")).andReturn(
|
||||
expect(chefApi.getDatabagItem("jclouds", "foo")).andReturn(
|
||||
new DatabagItem("foo", "{\"run_list\":[\"recipe[apache2]\",\"recipe[mysql]\"]}"));
|
||||
|
||||
replay(client);
|
||||
replay(chefClient);
|
||||
replay(api);
|
||||
replay(chefApi);
|
||||
|
||||
assertEquals(fn.apply("foo"), ImmutableList.of("recipe[apache2]", "recipe[mysql]"));
|
||||
|
||||
verify(client);
|
||||
verify(chefClient);
|
||||
verify(api);
|
||||
verify(chefApi);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.net.URI;
|
|||
import java.security.PrivateKey;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.statements.InstallChefGems;
|
||||
|
@ -60,7 +60,7 @@ public class TagToBootScriptTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class TagToBootScriptTest {
|
|||
Statement installChefGems = new InstallChefGems();
|
||||
|
||||
@Test(expectedExceptions = IllegalStateException.class)
|
||||
public void testMustHaveClients() {
|
||||
public void testMustHaveApis() {
|
||||
GroupToBootScript fn = new GroupToBootScript(Suppliers.ofInstance(URI.create("http://localhost:4000")), json, ImmutableMap
|
||||
.<String, Client> of(), ImmutableMap.<String, List<String>> of("foo", ImmutableList
|
||||
.of("recipe[apache2]")), installChefGems);
|
||||
|
|
|
@ -18,18 +18,15 @@
|
|||
*/
|
||||
package org.jclouds.chef.handlers;
|
||||
|
||||
import static org.easymock.EasyMock.createMock;
|
||||
import static org.easymock.EasyMock.expect;
|
||||
import static org.easymock.classextension.EasyMock.createMock;
|
||||
import static org.easymock.classextension.EasyMock.replay;
|
||||
import static org.easymock.classextension.EasyMock.verify;
|
||||
|
||||
import java.net.URI;
|
||||
import static org.easymock.EasyMock.replay;
|
||||
import static org.easymock.EasyMock.verify;
|
||||
|
||||
import org.jclouds.http.HttpCommand;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
|
||||
import org.jclouds.io.Payloads;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +35,7 @@ import org.testng.annotations.Test;
|
|||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "unit" })
|
||||
public class ChefClientErrorRetryHandlerTest {
|
||||
public class ChefApiErrorRetryHandlerTest {
|
||||
@Test
|
||||
public void test401DoesNotRetry() {
|
||||
|
||||
|
@ -53,7 +50,7 @@ public class ChefClientErrorRetryHandlerTest {
|
|||
replay(retry);
|
||||
replay(command);
|
||||
|
||||
ChefClientErrorRetryHandler handler = new ChefClientErrorRetryHandler(retry);
|
||||
ChefApiErrorRetryHandler handler = new ChefApiErrorRetryHandler(retry);
|
||||
|
||||
assert !handler.shouldRetryRequest(command, response);
|
||||
|
||||
|
@ -77,7 +74,7 @@ public class ChefClientErrorRetryHandlerTest {
|
|||
replay(retry);
|
||||
replay(command);
|
||||
|
||||
ChefClientErrorRetryHandler handler = new ChefClientErrorRetryHandler(retry);
|
||||
ChefApiErrorRetryHandler handler = new ChefApiErrorRetryHandler(retry);
|
||||
|
||||
assert !handler.shouldRetryRequest(command, response);
|
||||
|
||||
|
@ -93,13 +90,12 @@ public class ChefClientErrorRetryHandlerTest {
|
|||
HttpCommand command = createMock(HttpCommand.class);
|
||||
BackoffLimitedRetryHandler retry = createMock(BackoffLimitedRetryHandler.class);
|
||||
|
||||
HttpRequest request = new HttpRequest("PUT", URI
|
||||
.create("https://api.opscode.com/organizations/jclouds/sandboxes/bfd68d4052f44053b2e593a33b5e1cd5"));
|
||||
HttpResponse response = new HttpResponse(
|
||||
400,
|
||||
"400 Bad Request",
|
||||
Payloads
|
||||
.newStringPayload("{\"error\":[\"Cannot update sandbox bfd68d4052f44053b2e593a33b5e1cd5: checksum 9b7c23369f4b576451216c39f214af6c was not uploaded\"]}"));
|
||||
HttpRequest request = HttpRequest.builder().method("PUT")
|
||||
.endpoint("https://api.opscode.com/organizations/jclouds/sandboxes/bfd68d4052f44053b2e593a33b5e1cd5").build();
|
||||
HttpResponse response = HttpResponse.builder()
|
||||
.statusCode(400)
|
||||
.message("400 Bad Request")
|
||||
.payload("{\"error\":[\"Cannot update sandbox bfd68d4052f44053b2e593a33b5e1cd5: checksum 9b7c23369f4b576451216c39f214af6c was not uploaded\"]}").build();
|
||||
|
||||
expect(command.getFailureCount()).andReturn(0);
|
||||
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();
|
||||
|
@ -108,7 +104,7 @@ public class ChefClientErrorRetryHandlerTest {
|
|||
replay(retry);
|
||||
replay(command);
|
||||
|
||||
ChefClientErrorRetryHandler handler = new ChefClientErrorRetryHandler(retry);
|
||||
ChefApiErrorRetryHandler handler = new ChefApiErrorRetryHandler(retry);
|
||||
|
||||
assert handler.shouldRetryRequest(command, response);
|
||||
|
|
@ -31,7 +31,7 @@ import java.util.Properties;
|
|||
import java.util.Set;
|
||||
|
||||
import org.jclouds.Context;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.ChecksumStatus;
|
||||
import org.jclouds.chef.domain.Client;
|
||||
import org.jclouds.chef.domain.CookbookVersion;
|
||||
|
@ -58,12 +58,12 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.io.Closeables;
|
||||
import com.google.common.primitives.Bytes;
|
||||
/**
|
||||
* Tests behavior of {@code ChefClient}
|
||||
* Tests behavior of {@code ChefApi}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "live", "integration" })
|
||||
public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChefContextLiveTest<C> {
|
||||
public abstract class BaseChefApiLiveTest<C extends Context> extends BaseChefContextLiveTest<C> {
|
||||
public static final String PREFIX = System.getProperty("user.name") + "-jcloudstest";
|
||||
public static final String ADMIN_PREFIX = System.getProperty("user.name") + "-jcloudstest-adm";
|
||||
public static final String VALIDATOR_PREFIX = System.getProperty("user.name") + "-jcloudstest-val";
|
||||
|
@ -71,9 +71,9 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
private String validatorIdentity;
|
||||
private String validatorCredential;
|
||||
private C validatorContext;
|
||||
private ChefClient validatorClient;
|
||||
private ChefApi validatorClient;
|
||||
|
||||
protected ChefClient chefClient;
|
||||
protected ChefApi chefApi;
|
||||
|
||||
protected Properties setupValidatorProperties() {
|
||||
Properties overrides = setupProperties();
|
||||
|
@ -89,8 +89,8 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
public void setupContext() {
|
||||
super.setupContext();
|
||||
validatorContext = createContext(setupValidatorProperties(), setupModules());
|
||||
chefClient = getChefClient(context);
|
||||
validatorClient = getChefClient(validatorContext);
|
||||
chefApi = getChefApi(context);
|
||||
validatorClient = getChefApi(validatorContext);
|
||||
}
|
||||
|
||||
private Node node;
|
||||
|
@ -112,7 +112,7 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
List<Byte> md5 = Bytes.asList(content.getContentMetadata().getContentMD5());
|
||||
|
||||
// request an upload site for this file
|
||||
UploadSandbox site = chefClient.getUploadSandboxForChecksums(ImmutableSet.of(md5));
|
||||
UploadSandbox site = chefApi.getUploadSandboxForChecksums(ImmutableSet.of(md5));
|
||||
|
||||
try {
|
||||
assert site.getChecksums().containsKey(md5) : md5 + " not in " + site.getChecksums();
|
||||
|
@ -120,13 +120,13 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
ChecksumStatus status = site.getChecksums().get(md5);
|
||||
if (status.needsUpload()) {
|
||||
//context.utils().http().put(status.getUrl(), content);
|
||||
chefClient.uploadContent(status.getUrl(), content);
|
||||
chefApi.uploadContent(status.getUrl(), content);
|
||||
}
|
||||
|
||||
chefClient.commitSandbox(site.getSandboxId(), true);
|
||||
chefApi.commitSandbox(site.getSandboxId(), true);
|
||||
|
||||
} catch (RuntimeException e) {
|
||||
chefClient.commitSandbox(site.getSandboxId(), false);
|
||||
chefApi.commitSandbox(site.getSandboxId(), false);
|
||||
}
|
||||
|
||||
// create a new cookbook
|
||||
|
@ -134,29 +134,29 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
cookbook.getRootFiles().add(new Resource(content));
|
||||
|
||||
// upload the cookbook to the remote server
|
||||
chefClient.updateCookbook(PREFIX, "0.0.0", cookbook);
|
||||
chefApi.updateCookbook(PREFIX, "0.0.0", cookbook);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateClient")
|
||||
public void testGenerateKeyForClient() throws Exception {
|
||||
String credential = Pems.pem(chefClient.generateKeyForClient(PREFIX).getPrivateKey());
|
||||
String credential = Pems.pem(chefApi.generateKeyForClient(PREFIX).getPrivateKey());
|
||||
assertClientCreated(PREFIX, credential);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListCookbooks() throws Exception {
|
||||
Set<String> cookbookNames = chefClient.listCookbooks();
|
||||
Set<String> cookbookNames = chefApi.listCookbooks();
|
||||
assertFalse(cookbookNames.isEmpty());
|
||||
|
||||
for (String cookbook : cookbookNames)
|
||||
for (String version : chefClient.getVersionsOfCookbook(cookbook)) {
|
||||
CookbookVersion cookbookO = chefClient.getCookbook(cookbook, version);
|
||||
for (String version : chefApi.getVersionsOfCookbook(cookbook)) {
|
||||
CookbookVersion cookbookO = chefApi.getCookbook(cookbook, version);
|
||||
for (Resource resource : ImmutableList.<Resource> builder().addAll(cookbookO.getDefinitions()).addAll(
|
||||
cookbookO.getFiles()).addAll(cookbookO.getLibraries()).addAll(cookbookO.getSuppliers()).addAll(
|
||||
cookbookO.getRecipes()).addAll(cookbookO.getResources()).addAll(cookbookO.getRootFiles()).addAll(
|
||||
cookbookO.getTemplates()).build()) {
|
||||
try {
|
||||
InputStream stream = chefClient.getResourceContents(resource);
|
||||
InputStream stream = chefApi.getResourceContents(resource);
|
||||
byte[] md5 = CryptoStreams.md5(InputSuppliers.of(stream));
|
||||
assertEquals(md5, resource.getChecksum());
|
||||
} catch (NullPointerException e) {
|
||||
|
@ -168,13 +168,13 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
|
||||
@Test(dependsOnMethods = "testCreateNewCookbook")
|
||||
public void testUpdateCookbook() throws Exception {
|
||||
CookbookVersion cookbook = chefClient.getCookbook(PREFIX, "0.0.0");
|
||||
assertNotNull(chefClient.updateCookbook(PREFIX, "0.0.0", cookbook));
|
||||
CookbookVersion cookbook = chefApi.getCookbook(PREFIX, "0.0.0");
|
||||
assertNotNull(chefApi.updateCookbook(PREFIX, "0.0.0", cookbook));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = {"testCreateNewCookbook", "testUpdateCookbook"})
|
||||
public void testDeleteCookbook() throws Exception {
|
||||
assertNotNull(chefClient.deleteCookbook(PREFIX, "0.0.0"));
|
||||
assertNotNull(chefApi.deleteCookbook(PREFIX, "0.0.0"));
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = AuthorizationException.class)
|
||||
|
@ -196,63 +196,63 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
|
||||
@Test
|
||||
public void testCreateClient() throws Exception {
|
||||
String credential = Pems.pem(chefClient.createClient(PREFIX).getPrivateKey());
|
||||
String credential = Pems.pem(chefApi.createClient(PREFIX).getPrivateKey());
|
||||
assertClientCreated(PREFIX, credential);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAdminClient() throws Exception {
|
||||
String credential = Pems.pem(chefClient.createClient(ADMIN_PREFIX, CreateClientOptions.Builder.admin())
|
||||
String credential = Pems.pem(chefApi.createClient(ADMIN_PREFIX, CreateClientOptions.Builder.admin())
|
||||
.getPrivateKey());
|
||||
assertClientCreated(ADMIN_PREFIX, credential);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientExists() throws Exception {
|
||||
assertNotNull(chefClient.clientExists(validatorIdentity));
|
||||
assertNotNull(chefApi.clientExists(validatorIdentity));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListNodes() throws Exception {
|
||||
Set<String> nodes = chefClient.listNodes();
|
||||
Set<String> nodes = chefApi.listNodes();
|
||||
assertNotNull(nodes);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateRole")
|
||||
public void testCreateNode() throws Exception {
|
||||
chefClient.deleteNode(PREFIX);
|
||||
chefClient.createNode(new Node(PREFIX, Collections.singleton("role[" + PREFIX + "]")));
|
||||
node = chefClient.getNode(PREFIX);
|
||||
chefApi.deleteNode(PREFIX);
|
||||
chefApi.createNode(new Node(PREFIX, Collections.singleton("role[" + PREFIX + "]")));
|
||||
node = chefApi.getNode(PREFIX);
|
||||
// TODO check recipes
|
||||
assertNotNull(node);
|
||||
Set<String> nodes = chefClient.listNodes();
|
||||
Set<String> nodes = chefApi.listNodes();
|
||||
assert nodes.contains(PREFIX) : String.format("node %s not in %s", PREFIX, nodes);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateNode")
|
||||
public void testNodeExists() throws Exception {
|
||||
assertNotNull(chefClient.nodeExists(PREFIX));
|
||||
assertNotNull(chefApi.nodeExists(PREFIX));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testNodeExists")
|
||||
public void testUpdateNode() throws Exception {
|
||||
for (String nodename : chefClient.listNodes()) {
|
||||
Node node = chefClient.getNode(nodename);
|
||||
chefClient.updateNode(node);
|
||||
for (String nodename : chefApi.listNodes()) {
|
||||
Node node = chefApi.getNode(nodename);
|
||||
chefApi.updateNode(node);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListRoles() throws Exception {
|
||||
Set<String> roles = chefClient.listRoles();
|
||||
Set<String> roles = chefApi.listRoles();
|
||||
assertNotNull(roles);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateRole() throws Exception {
|
||||
chefClient.deleteRole(PREFIX);
|
||||
chefClient.createRole(new Role(PREFIX, Collections.singleton("recipe[java]")));
|
||||
role = chefClient.getRole(PREFIX);
|
||||
chefApi.deleteRole(PREFIX);
|
||||
chefApi.createRole(new Role(PREFIX, Collections.singleton("recipe[java]")));
|
||||
role = chefApi.getRole(PREFIX);
|
||||
assertNotNull(role);
|
||||
assertEquals(role.getName(), PREFIX);
|
||||
assertEquals(role.getRunList(), Collections.singleton("recipe[java]"));
|
||||
|
@ -260,37 +260,37 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
|
||||
@Test(dependsOnMethods = "testCreateRole")
|
||||
public void testRoleExists() throws Exception {
|
||||
assertNotNull(chefClient.roleExists(PREFIX));
|
||||
assertNotNull(chefApi.roleExists(PREFIX));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testRoleExists")
|
||||
public void testUpdateRole() throws Exception {
|
||||
for (String rolename : chefClient.listRoles()) {
|
||||
Role role = chefClient.getRole(rolename);
|
||||
chefClient.updateRole(role);
|
||||
for (String rolename : chefApi.listRoles()) {
|
||||
Role role = chefApi.getRole(rolename);
|
||||
chefApi.updateRole(role);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListDatabags() throws Exception {
|
||||
Set<String> databags = chefClient.listDatabags();
|
||||
Set<String> databags = chefApi.listDatabags();
|
||||
assertNotNull(databags);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateDatabag() throws Exception {
|
||||
chefClient.deleteDatabag(PREFIX);
|
||||
chefClient.createDatabag(PREFIX);
|
||||
chefApi.deleteDatabag(PREFIX);
|
||||
chefApi.createDatabag(PREFIX);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateDatabag")
|
||||
public void testDatabagExists() throws Exception {
|
||||
assertNotNull(chefClient.databagExists(PREFIX));
|
||||
assertNotNull(chefApi.databagExists(PREFIX));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testCreateDatabagItem")
|
||||
public void testListDatabagItems() throws Exception {
|
||||
Set<String> databagItems = chefClient.listDatabagItems(PREFIX);
|
||||
Set<String> databagItems = chefApi.listDatabagItems(PREFIX);
|
||||
assertNotNull(databagItems);
|
||||
}
|
||||
|
||||
|
@ -298,8 +298,8 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
public void testCreateDatabagItem() throws Exception {
|
||||
Properties config = new Properties();
|
||||
config.setProperty("foo", "bar");
|
||||
chefClient.deleteDatabagItem(PREFIX, PREFIX);
|
||||
databagItem = chefClient.createDatabagItem(PREFIX,
|
||||
chefApi.deleteDatabagItem(PREFIX, PREFIX);
|
||||
databagItem = chefApi.createDatabagItem(PREFIX,
|
||||
new DatabagItem("config", context.utils().json().toJson(config)));
|
||||
assertNotNull(databagItem);
|
||||
assertEquals(databagItem.getId(), "config");
|
||||
|
@ -314,20 +314,20 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
|
||||
@Test(dependsOnMethods = "testCreateDatabagItem")
|
||||
public void testDatabagItemExists() throws Exception {
|
||||
assertNotNull(chefClient.databagItemExists(PREFIX, PREFIX));
|
||||
assertNotNull(chefApi.databagItemExists(PREFIX, PREFIX));
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testDatabagItemExists")
|
||||
public void testUpdateDatabagItem() throws Exception {
|
||||
for (String databagItemId : chefClient.listDatabagItems(PREFIX)) {
|
||||
DatabagItem databagItem = chefClient.getDatabagItem(PREFIX, databagItemId);
|
||||
chefClient.updateDatabagItem(PREFIX, databagItem);
|
||||
for (String databagItemId : chefApi.listDatabagItems(PREFIX)) {
|
||||
DatabagItem databagItem = chefApi.getDatabagItem(PREFIX, databagItemId);
|
||||
chefApi.updateDatabagItem(PREFIX, databagItem);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testListSearchIndexes() throws Exception {
|
||||
Set<String> indexes = chefClient.listSearchIndexes();
|
||||
Set<String> indexes = chefApi.listSearchIndexes();
|
||||
assertNotNull(indexes);
|
||||
assert indexes.contains("node") : indexes;
|
||||
assert indexes.contains("client") : indexes;
|
||||
|
@ -336,31 +336,31 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
|
||||
@Test
|
||||
public void testSearchNodes() throws Exception {
|
||||
SearchResult<? extends Node> results = chefClient.searchNodes();
|
||||
SearchResult<? extends Node> results = chefApi.searchNodes();
|
||||
assertNotNull(results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchClients() throws Exception {
|
||||
SearchResult<? extends Client> results = chefClient.searchClients();
|
||||
SearchResult<? extends Client> results = chefApi.searchClients();
|
||||
assertNotNull(results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSearchRoles() throws Exception {
|
||||
SearchResult<? extends Role> results = chefClient.searchRoles();
|
||||
SearchResult<? extends Role> results = chefApi.searchRoles();
|
||||
assertNotNull(results);
|
||||
}
|
||||
|
||||
@Test(dependsOnMethods = "testDatabagItemExists")
|
||||
public void testSearchDatabag() throws Exception {
|
||||
SearchResult<? extends DatabagItem> results = chefClient.searchDatabag(PREFIX);
|
||||
SearchResult<? extends DatabagItem> results = chefApi.searchDatabag(PREFIX);
|
||||
assertNotNull(results);
|
||||
}
|
||||
|
||||
@Test(expectedExceptions = ResourceNotFoundException.class)
|
||||
public void testSearchDatabagNotFound() throws Exception {
|
||||
SearchResult<? extends DatabagItem> results = chefClient.searchDatabag("whoopie");
|
||||
SearchResult<? extends DatabagItem> results = chefApi.searchDatabag("whoopie");
|
||||
assertNotNull(results);
|
||||
}
|
||||
|
||||
|
@ -368,12 +368,12 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
@Override
|
||||
public void tearDownContext() {
|
||||
Closeables.closeQuietly(validatorContext);
|
||||
chefClient.deleteClient(PREFIX);
|
||||
chefClient.deleteClient(ADMIN_PREFIX);
|
||||
chefClient.deleteClient(VALIDATOR_PREFIX);
|
||||
chefClient.deleteNode(PREFIX);
|
||||
chefClient.deleteRole(PREFIX);
|
||||
chefClient.deleteDatabag(PREFIX);
|
||||
chefApi.deleteClient(PREFIX);
|
||||
chefApi.deleteClient(ADMIN_PREFIX);
|
||||
chefApi.deleteClient(VALIDATOR_PREFIX);
|
||||
chefApi.deleteNode(PREFIX);
|
||||
chefApi.deleteRole(PREFIX);
|
||||
chefApi.deleteDatabag(PREFIX);
|
||||
super.tearDownContext();
|
||||
}
|
||||
|
||||
|
@ -385,7 +385,7 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
C clientContext = createContext(overrides, setupModules());
|
||||
|
||||
try {
|
||||
Client client = getChefClient(clientContext).getClient(identity);
|
||||
Client client = getChefApi(clientContext).getClient(identity);
|
||||
assertNotNull(client);
|
||||
} finally {
|
||||
Closeables.closeQuietly(clientContext);
|
||||
|
@ -394,4 +394,4 @@ public abstract class BaseChefClientLiveTest<C extends Context> extends BaseChef
|
|||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import java.util.Properties;
|
|||
|
||||
import org.jclouds.Context;
|
||||
import org.jclouds.apis.BaseContextLiveTest;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
@ -42,7 +42,7 @@ public abstract class BaseChefContextLiveTest<C extends Context> extends BaseCon
|
|||
provider = "chef";
|
||||
}
|
||||
|
||||
protected abstract ChefClient getChefClient(C context);
|
||||
protected abstract ChefApi getChefApi(C context);
|
||||
|
||||
/**
|
||||
* the credential is a path to the pem file.
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Map;
|
|||
|
||||
import org.jclouds.apis.ApiMetadata;
|
||||
import org.jclouds.chef.ChefApiMetadata;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.chef.config.ChefRestClientModule;
|
||||
|
@ -63,7 +63,7 @@ public class BaseStubbedOhaiLiveTest extends BaseChefContextLiveTest<ChefContext
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
@ -64,7 +64,7 @@ public class CleanupStaleNodesAndClientsImplLiveTest extends BaseChefContextLive
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
|
@ -66,7 +66,7 @@ public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseCh
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import static org.easymock.classextension.EasyMock.verify;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -44,7 +44,7 @@ public class CreateNodeAndPopulateAutomaticAttributesImplTest {
|
|||
|
||||
@Test
|
||||
public void testWithNoRunlist() {
|
||||
ChefClient chef = createMock(ChefClient.class);
|
||||
ChefApi chef = createMock(ChefApi.class);
|
||||
|
||||
Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
package org.jclouds.chef.strategy.internal;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
|
@ -28,16 +28,16 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code DeleteAllClientsAndNodesInListImpl} strategies
|
||||
* Tests behavior of {@code DeleteAllApisAndNodesInListImpl} strategies
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = "live", testName = "DeleteAllClientsAndNodesInListImplLiveTest")
|
||||
public class DeleteAllClientsAndNodesInListImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
|
||||
@Test(groups = "live", testName = "DeleteAllApisAndNodesInListImplLiveTest")
|
||||
public class DeleteAllApisAndNodesInListImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
|
||||
|
||||
private DeleteAllNodesInListImpl strategy;
|
||||
private CreateNodeAndPopulateAutomaticAttributesImpl creater;
|
||||
private ChefClient chef;
|
||||
private ChefApi chef;
|
||||
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
@Override
|
||||
|
@ -69,7 +69,7 @@ public class DeleteAllClientsAndNodesInListImplLiveTest extends BaseChefContextL
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
|
@ -21,7 +21,7 @@ package org.jclouds.chef.strategy.internal;
|
|||
import static com.google.common.collect.Iterables.size;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
import org.testng.annotations.AfterClass;
|
||||
|
@ -42,7 +42,7 @@ public class GetNodesImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
|
|||
|
||||
private ListNodesImpl strategy;
|
||||
private CreateNodeAndPopulateAutomaticAttributesImpl creater;
|
||||
private ChefClient chef;
|
||||
private ChefApi chef;
|
||||
|
||||
@BeforeClass(groups = { "integration", "live" })
|
||||
@Override
|
||||
|
@ -86,7 +86,7 @@ public class GetNodesImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.util.Set;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
|
@ -65,7 +65,7 @@ public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefContext
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import static org.easymock.classextension.EasyMock.verify;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.domain.Node;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.testng.annotations.Test;
|
||||
|
@ -45,7 +45,7 @@ public class UpdateAutomaticAttributesOnNodeImplTest {
|
|||
|
||||
@Test
|
||||
public void test() {
|
||||
ChefClient chef = createMock(ChefClient.class);
|
||||
ChefApi chef = createMock(ChefApi.class);
|
||||
|
||||
Map<String, JsonBall> automatic = ImmutableMap.<String, JsonBall> of();
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ import static org.testng.Assert.assertNotNull;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefApi;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.domain.DatabagItem;
|
||||
import org.jclouds.chef.internal.BaseChefContextLiveTest;
|
||||
|
@ -34,16 +34,16 @@ import com.google.common.io.Closeables;
|
|||
import com.google.common.reflect.TypeToken;
|
||||
|
||||
/**
|
||||
* Tests behavior of {@code TransientChefClient}
|
||||
* Tests behavior of {@code TransientChefApi}
|
||||
*
|
||||
* @author Adrian Cole
|
||||
*/
|
||||
@Test(groups = { "integration" })
|
||||
public class TransientChefClientIntegrationTest extends BaseChefContextLiveTest<ChefContext> {
|
||||
public class TransientChefApiIntegrationTest extends BaseChefContextLiveTest<ChefContext> {
|
||||
public static final String PREFIX = System.getProperty("user.name") + "-jcloudstest";
|
||||
private DatabagItem databagItem;
|
||||
|
||||
public TransientChefClientIntegrationTest() {
|
||||
public TransientChefApiIntegrationTest() {
|
||||
provider = "transientchef";
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ public class TransientChefClientIntegrationTest extends BaseChefContextLiveTest<
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ChefClient getChefClient(ChefContext context)
|
||||
protected ChefApi getChefApi(ChefContext context)
|
||||
{
|
||||
return context.getApi();
|
||||
}
|
|
@ -28,7 +28,7 @@ import java.util.Map;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.json.Json;
|
||||
|
@ -64,7 +64,7 @@ public class JMXTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule(), new JMXOhaiModule() {
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Properties;
|
|||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.json.Json;
|
||||
|
@ -66,7 +66,7 @@ public class OhaiModuleTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule(), new OhaiModule() {
|
||||
@Override
|
||||
|
@ -101,7 +101,7 @@ public class OhaiModuleTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule(), new OhaiModule() {
|
||||
@Override
|
||||
|
|
|
@ -22,7 +22,7 @@ import static org.testng.Assert.assertEquals;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefAsyncApi;
|
||||
import org.jclouds.chef.config.ChefParserModule;
|
||||
import org.jclouds.domain.JsonBall;
|
||||
import org.jclouds.json.Json;
|
||||
|
@ -55,7 +55,7 @@ public class NestSlashKeysTest {
|
|||
@Override
|
||||
protected void configure()
|
||||
{
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncClient.VERSION);
|
||||
bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefAsyncApi.VERSION);
|
||||
}
|
||||
}, new ChefParserModule(), new GsonModule());
|
||||
converter = injector.getInstance(NestSlashKeys.class);
|
||||
|
|
Loading…
Reference in New Issue