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