You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by na...@apache.org on 2015/10/30 11:30:55 UTC
[2/3] jclouds git commit: JCLOUDS-717: Join Enterprise and OpenSource
Chef
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiExpectTest.java b/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiExpectTest.java
new file mode 100644
index 0000000..748c3c5
--- /dev/null
+++ b/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiExpectTest.java
@@ -0,0 +1,207 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.chef.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+
+import javax.ws.rs.core.MediaType;
+
+import org.jclouds.apis.ApiMetadata;
+import org.jclouds.chef.BaseChefApiExpectTest;
+import org.jclouds.chef.ChefApi;
+import org.jclouds.chef.ChefApiMetadata;
+import org.jclouds.chef.config.ChefHttpApiModule;
+import org.jclouds.chef.domain.Group;
+import org.jclouds.chef.domain.User;
+import org.jclouds.date.TimeStamp;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.rest.ConfiguresHttpApi;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.annotations.Test;
+
+import com.google.common.base.Supplier;
+import com.google.inject.Module;
+
+/**
+ * Expect tests for the {@link OrganizationApi} class.
+ */
+@Test(groups = "unit", testName = "OrganizationApiExpectTest")
+public class OrganizationApiExpectTest extends BaseChefApiExpectTest<ChefApi> {
+
+ public void testGetUserReturns2xx() {
+ ChefApi api = requestSendsResponse(
+ signed(HttpRequest.builder() //
+ .method("GET") //
+ .endpoint("http://localhost:4000/users/nacx") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON).build()), //
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResourceWithContentType("/user.json", MediaType.APPLICATION_JSON)) //
+ .build());
+
+ User user = api.organizationApi().get().getUser("nacx");
+ assertEquals(user.getUsername(), "nacx");
+ assertEquals(user.getDisplayName(), "Ignasi Barrera");
+ }
+
+ public void testGetUserReturns404() {
+ ChefApi api = requestSendsResponse(signed(HttpRequest.builder() //
+ .method("GET") //
+ .endpoint("http://localhost:4000/users/foo") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON) //
+ .build()), //
+ HttpResponse.builder().statusCode(404).build());
+
+ assertNull(api.organizationApi().get().getUser("foo"));
+ }
+
+ public void testListGroups() {
+ ChefApi api = requestSendsResponse(
+ signed(HttpRequest.builder() //
+ .method("GET") //
+ .endpoint("http://localhost:4000/groups") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON).build()), //
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResourceWithContentType("/groups.json", MediaType.APPLICATION_JSON)) //
+ .build());
+
+ Set<String> groups = api.organizationApi().get().listGroups();
+ assertEquals(groups.size(), 5);
+ assertTrue(groups.contains("admins"));
+ }
+
+ public void testGetGroupReturns2xx() {
+ ChefApi api = requestSendsResponse(
+ signed(HttpRequest.builder() //
+ .method("GET") //
+ .endpoint("http://localhost:4000/groups/admins") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON).build()), //
+ HttpResponse.builder().statusCode(200)
+ .payload(payloadFromResourceWithContentType("/group.json", MediaType.APPLICATION_JSON)) //
+ .build());
+
+ Group group = api.organizationApi().get().getGroup("admins");
+ assertEquals(group.getName(), "admins");
+ assertEquals(group.getGroupname(), "admins");
+ }
+
+ public void testGetGroupReturns404() {
+ ChefApi api = requestSendsResponse(signed(HttpRequest.builder() //
+ .method("GET") //
+ .endpoint("http://localhost:4000/groups/foo") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON) //
+ .build()), //
+ HttpResponse.builder().statusCode(404).build());
+
+ assertNull(api.organizationApi().get().getGroup("foo"));
+ }
+
+ public void testCreateGroupReturns2xx() {
+ ChefApi api = requestSendsResponse(signed(HttpRequest.builder() //
+ .method("POST") //
+ .endpoint("http://localhost:4000/groups") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON) //
+ .payload(payloadFromStringWithContentType("{\"groupname\":\"foo\"}", MediaType.APPLICATION_JSON)) //
+ .build()), //
+ HttpResponse.builder().statusCode(201).build());
+
+ api.organizationApi().get().createGroup("foo");
+ }
+
+ public void testDeleteGroupReturns2xx() {
+ ChefApi api = requestSendsResponse(signed(HttpRequest.builder() //
+ .method("DELETE") //
+ .endpoint("http://localhost:4000/groups/foo") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON) //
+ .build()), //
+ HttpResponse.builder().statusCode(200).build());
+
+ api.organizationApi().get().deleteGroup("foo");
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testDeleteGroupFailsOn404() {
+ ChefApi api = requestSendsResponse(signed(HttpRequest.builder() //
+ .method("DELETE") //
+ .endpoint("http://localhost:4000/groups/foo") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON) //
+ .build()), //
+ HttpResponse.builder().statusCode(404).build());
+
+ api.organizationApi().get().deleteGroup("foo");
+ }
+
+ public void testUpdateGroupReturns2xx() {
+ ChefApi api = requestSendsResponse(signed(HttpRequest.builder() //
+ .method("PUT") //
+ .endpoint("http://localhost:4000/groups/admins") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON) //
+ .payload(payloadFromResourceWithContentType("/group-update.json", MediaType.APPLICATION_JSON)) //
+ .build()), //
+ HttpResponse.builder().statusCode(200).build());
+
+ Group group = Group.builder("admins").client("abiquo").group("admins").user("nacx").build();
+ api.organizationApi().get().updateGroup(group);
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testUpdateGroupFailsOn404() {
+ ChefApi api = requestSendsResponse(signed(HttpRequest.builder() //
+ .method("PUT") //
+ .endpoint("http://localhost:4000/groups/admins") //
+ .addHeader("X-Chef-Version", ChefApiMetadata.DEFAULT_API_VERSION) //
+ .addHeader("Accept", MediaType.APPLICATION_JSON) //
+ .payload(payloadFromResourceWithContentType("/group-update.json", MediaType.APPLICATION_JSON)) //
+ .build()), //
+ HttpResponse.builder().statusCode(404).build());
+
+ Group group = Group.builder("admins").client("abiquo").group("admins").user("nacx").build();
+ api.organizationApi().get().updateGroup(group);
+ }
+
+ @Override
+ protected Module createModule() {
+ return new TestChefHttpApiModule();
+ }
+
+ @ConfiguresHttpApi
+ static class TestChefHttpApiModule extends ChefHttpApiModule {
+ @Override
+ protected String provideTimeStamp(@TimeStamp Supplier<String> cache) {
+ return "timestamp";
+ }
+ }
+
+ @Override
+ protected ApiMetadata createApiMetadata() {
+ return new ChefApiMetadata();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiLiveTest.java
new file mode 100644
index 0000000..7e890de
--- /dev/null
+++ b/apis/chef/src/test/java/org/jclouds/chef/features/OrganizationApiLiveTest.java
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.chef.features;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.Set;
+import java.util.UUID;
+
+import org.jclouds.chef.domain.Group;
+import org.jclouds.chef.domain.User;
+import org.jclouds.chef.internal.BaseChefLiveTest;
+import org.jclouds.rest.ResourceNotFoundException;
+import org.testng.SkipException;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests behavior of the OrganizationApi.
+ */
+@Test(groups = "live", singleThreaded = true, testName = "OrganizationApiLiveTest")
+public class OrganizationApiLiveTest extends BaseChefLiveTest {
+ private static final String GROUP_NAME = System.getProperty("user.name") + "-jcloudstest";
+
+ private OrganizationApi orgApi;
+
+ @BeforeMethod
+ public void skipIfApiNotAvailable() {
+ // Throwing SkipExceptions only works with @Test and @BeforeMethod methods
+ if (!api.organizationApi().isPresent()) {
+ throw new SkipException("Organization api not available in this Chef version");
+ }
+ orgApi = api.organizationApi().get();
+ }
+
+ public void testGetUser() {
+ User user = orgApi.getUser(identity);
+ assertEquals(user.getUsername(), identity);
+ assertNotNull(user.getPublicKey());
+ }
+
+ public void testGetUnexistingUser() {
+ User user = orgApi.getUser(UUID.randomUUID().toString());
+ assertNull(user);
+ }
+
+ public void testListGroups() {
+ Set<String> groups = orgApi.listGroups();
+ assertNotNull(groups);
+ assertFalse(groups.isEmpty());
+ }
+
+ public void testGetUnexistingGroup() {
+ Group group = orgApi.getGroup(UUID.randomUUID().toString());
+ assertNull(group);
+ }
+
+ public void testCreateGroup() {
+ orgApi.createGroup(GROUP_NAME);
+ Group group = orgApi.getGroup(GROUP_NAME);
+ assertNotNull(group);
+ assertEquals(group.getGroupname(), GROUP_NAME);
+ }
+
+ @Test(dependsOnMethods = "testCreateGroup")
+ public void testUpdateGroup() {
+ Group group = orgApi.getGroup(GROUP_NAME);
+ Group updated = Group.builder(group.getGroupname()) //
+ .actors(group.getActors()) //
+ .orgname(group.getOrgname()) //
+ .name(group.getName()) //
+ .groups(group.getGroups()) //
+ .client(group.getOrgname() + "-validator") //
+ .user(identity) //
+ .build();
+
+ orgApi.updateGroup(updated);
+ group = orgApi.getGroup(GROUP_NAME);
+
+ assertNotNull(group);
+ assertTrue(group.getUsers().contains(identity));
+ assertTrue(group.getClients().contains(group.getOrgname() + "-validator"));
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testUpdateUnexistingGroup() {
+ orgApi.updateGroup(Group.builder(UUID.randomUUID().toString()).build());
+ }
+
+ @Test(dependsOnMethods = "testUpdateGroup", alwaysRun = true)
+ public void testDeleteGroup() {
+ orgApi.deleteGroup(GROUP_NAME);
+ Group group = orgApi.getGroup(GROUP_NAME);
+ assertNull(group);
+ }
+
+ @Test(expectedExceptions = ResourceNotFoundException.class)
+ public void testDeleteUnexistingGroup() {
+ orgApi.deleteGroup(UUID.randomUUID().toString());
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseClientFromJsonTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseClientFromJsonTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseClientFromJsonTest.java
index 70a38a1..2975020 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseClientFromJsonTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseClientFromJsonTest.java
@@ -88,7 +88,6 @@ public class ParseClientFromJsonTest {
publicKey = crypto.rsaKeyFactory().generatePublic(publicKeySpec);
}
- @SuppressWarnings("resource")
public void testClientWithPubKey() throws IOException, CertificateException, NoSuchAlgorithmException {
Client user = Client.builder().certificate(certificate).orgname("jclouds").clientname("adriancole-jcloudstest")
@@ -99,7 +98,6 @@ public class ParseClientFromJsonTest {
.payload(ParseClientFromJsonTest.class.getResourceAsStream("/client.json")).build()), user);
}
- @SuppressWarnings("resource")
public void testClientWithoutPubKey() throws IOException, CertificateException, NoSuchAlgorithmException {
Client user = Client.builder().certificate(certificate).orgname("jclouds").clientname("adriancole-jcloudstest")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
deleted file mode 100644
index 42a5cc2..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
+++ /dev/null
@@ -1,542 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.internal;
-
-import static com.google.common.collect.Iterables.any;
-import static com.google.common.collect.Iterables.isEmpty;
-import static com.google.common.hash.Hashing.md5;
-import static java.util.concurrent.TimeUnit.MILLISECONDS;
-import static org.jclouds.util.Closeables2.closeQuietly;
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.fail;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.domain.ChecksumStatus;
-import org.jclouds.chef.domain.Client;
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.chef.domain.CookbookVersion;
-import org.jclouds.chef.domain.DatabagItem;
-import org.jclouds.chef.domain.Environment;
-import org.jclouds.chef.domain.Metadata;
-import org.jclouds.chef.domain.Node;
-import org.jclouds.chef.domain.Resource;
-import org.jclouds.chef.domain.Role;
-import org.jclouds.chef.domain.Sandbox;
-import org.jclouds.chef.domain.SearchResult;
-import org.jclouds.chef.domain.UploadSandbox;
-import org.jclouds.chef.options.CreateClientOptions;
-import org.jclouds.chef.options.SearchOptions;
-import org.jclouds.crypto.Pems;
-import org.jclouds.io.ByteStreams2;
-import org.jclouds.io.Payloads;
-import org.jclouds.io.payloads.FilePayload;
-import org.jclouds.rest.ResourceNotFoundException;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.hash.Hashing;
-import com.google.common.io.Files;
-import com.google.common.primitives.Bytes;
-
-/**
- * Tests behavior of {@code ChefApi}
- */
-@Test(groups = { "live", "integration" })
-public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiveTest<A> {
- public static final String PREFIX = "jcloudstest-" + System.getProperty("user.name");
- public static final String ADMIN_PREFIX = "jcloudstest-adm-" + System.getProperty("user.name");
- public static final String ENV_NODE = PREFIX + "-env-node";
-
- // It may take a bit until the search index is populated
- protected int maxWaitForIndexInMs = 60000;
-
- // The id of the data bag item used in search tests
- private String databagitemId;
-
- public void testCreateNewCookbook() throws Exception {
- // Define the file you want in the cookbook
- File file = new File(System.getProperty("user.dir"), "pom.xml");
- FilePayload content = uploadAndGetFilePayload(file);
-
- // Create the metadata of the cookbook
- Metadata metadata = Metadata.builder() //
- .name(PREFIX) //
- .version("0.0.0") //
- .description("Jclouds test uploaded cookbook") //
- .maintainer("jclouds") //
- .maintainerEmail("someone@jclouds.org") //
- .license("Apache 2.0") //
- .build();
-
- // Create a new cookbook
- CookbookVersion cookbook = CookbookVersion.builder(PREFIX, "0.0.0") //
- .metadata(metadata) //
- .rootFile(Resource.builder().fromPayload(content).build()) //
- .attribute(Resource.builder().fromPayload(content).name("default.rb").build())
- .build();
-
- // upload the cookbook to the remote server
- api.updateCookbook(PREFIX, "0.0.0", cookbook);
- }
-
- private FilePayload uploadAndGetFilePayload(File file) throws IOException {
- FilePayload content = Payloads.newFilePayload(file);
- content.getContentMetadata().setContentType("application/x-binary");
-
- // Get an md5 so that you can see if the server already has it or not
- content.getContentMetadata().setContentMD5(Files.asByteSource(file).hash(Hashing.md5()).asBytes());
-
- // Note that java collections cannot effectively do equals or hashcodes on
- // byte arrays, so let's convert to a list of bytes.
- List<Byte> md5 = Bytes.asList(content.getContentMetadata().getContentMD5());
-
- // Request an upload site for this file
- UploadSandbox site = api.createUploadSandboxForChecksums(ImmutableSet.of(md5));
- assertTrue(site.getChecksums().containsKey(md5), md5 + " not in " + site.getChecksums());
-
- try {
- // Upload the file contents, if still not uploaded
- ChecksumStatus status = site.getChecksums().get(md5);
- if (status.needsUpload()) {
- api.uploadContent(status.getUrl(), content);
- }
- Sandbox sandbox = api.commitSandbox(site.getSandboxId(), true);
- assertTrue(sandbox.isCompleted(), "Sandbox should be completed after uploading");
- } catch (RuntimeException e) {
- api.commitSandbox(site.getSandboxId(), false);
- fail("Could not upload content");
- }
- return content;
- }
-
- public void testListCookbooks() throws Exception {
- Set<String> cookbookNames = api.listCookbooks();
- assertFalse(cookbookNames.isEmpty(), "No cookbooks were found");
-
- for (String cookbookName : cookbookNames) {
- Set<String> versions = api.listVersionsOfCookbook(cookbookName);
- assertFalse(versions.isEmpty(), "There are no versions of the cookbook: " + cookbookName);
-
- for (String version : api.listVersionsOfCookbook(cookbookName)) {
- CookbookVersion cookbook = api.getCookbook(cookbookName, version);
- assertNotNull(cookbook, "Could not get cookbook: " + cookbookName);
- }
- }
- }
-
- @Test(dependsOnMethods = "testListCookbooks")
- public void testListCookbookVersionsWithChefService() throws Exception {
- Iterable<? extends CookbookVersion> cookbooks = chefService.listCookbookVersions();
- assertFalse(isEmpty(cookbooks), "No cookbooks were found");
- }
-
- @Test(dependsOnMethods = "testListCookbookVersionsWithChefService")
- public void testDownloadCookbooks() throws Exception {
- Iterable<? extends CookbookVersion> cookbooks = chefService.listCookbookVersions();
- for (CookbookVersion cookbook : cookbooks) {
- for (Resource resource : ImmutableList.<Resource> builder().addAll(cookbook.getDefinitions())
- .addAll(cookbook.getFiles()).addAll(cookbook.getLibraries()).addAll(cookbook.getSuppliers())
- .addAll(cookbook.getRecipes()).addAll(cookbook.getResources()).addAll(cookbook.getRootFiles())
- .addAll(cookbook.getTemplates()).addAll(cookbook.getAttributes()).build()) {
-
- InputStream stream = api.getResourceContents(resource);
- assertNotNull(stream, "Resource contents are null for resource: " + resource.getName());
-
- byte[] md5 = ByteStreams2.hashAndClose(stream, md5()).asBytes();
- assertEquals(md5, resource.getChecksum());
- }
- }
- }
-
- @Test(dependsOnMethods = "testCreateNewCookbook")
- public void testUpdateCookbook() throws Exception {
- CookbookVersion cookbook = api.getCookbook(PREFIX, "0.0.0");
- assertNotNull(cookbook, "Cookbook not found: " + PREFIX);
- assertNotNull(api.updateCookbook(PREFIX, "0.0.0", cookbook), "Updated cookbook was null");
- }
-
- @Test(dependsOnMethods = { "testCreateNewCookbook", "testUpdateCookbook" })
- public void testDeleteCookbook() throws Exception {
- assertNotNull(api.deleteCookbook(PREFIX, "0.0.0"), "Deleted cookbook was null");
- }
-
- @Test
- public void testCreateClient() throws Exception {
- api.deleteClient(PREFIX);
- String credential = Pems.pem(api.createClient(PREFIX).getPrivateKey());
- assertClientCreated(PREFIX, credential);
- }
-
- @Test
- public void testCreateAdminClient() throws Exception {
- api.deleteClient(ADMIN_PREFIX);
- String credential = Pems.pem(api.createClient(ADMIN_PREFIX, CreateClientOptions.Builder.admin()).getPrivateKey());
- assertClientCreated(ADMIN_PREFIX, credential);
- }
-
- @Test(dependsOnMethods = "testCreateClient")
- public void testGenerateKeyForClient() throws Exception {
- String credential = Pems.pem(api.generateKeyForClient(PREFIX).getPrivateKey());
- assertClientCreated(PREFIX, credential);
- }
-
- @Test
- public void testListNodes() throws Exception {
- Set<String> nodes = api.listNodes();
- assertNotNull(nodes, "No nodes were found");
- }
-
- @Test(dependsOnMethods = "testCreateRole")
- public void testCreateNode() throws Exception {
- api.deleteNode(PREFIX);
- api.createNode(Node.builder().name(PREFIX).runListElement("role[" + PREFIX + "]").environment("_default").build());
- Node node = api.getNode(PREFIX);
- // TODO check recipes
- assertNotNull(node, "Created node should not be null");
- Set<String> nodes = api.listNodes();
- assertTrue(nodes.contains(PREFIX), String.format("node %s not in %s", PREFIX, nodes));
- }
-
- @Test(dependsOnMethods = "testCreateNode")
- public void testUpdateNode() throws Exception {
- for (String nodename : api.listNodes()) {
- Node node = api.getNode(nodename);
- api.updateNode(node);
- }
- }
-
- @Test
- public void testListRoles() throws Exception {
- Set<String> roles = api.listRoles();
- assertNotNull(roles, "Role list was null");
- }
-
- @Test
- public void testCreateRole() throws Exception {
- api.deleteRole(PREFIX);
- api.createRole(Role.builder().name(PREFIX).runListElement("recipe[java]").build());
- Role role = api.getRole(PREFIX);
- assertNotNull(role, "Created role should not be null");
- assertEquals(role.getName(), PREFIX);
- assertEquals(role.getRunList(), Collections.singleton("recipe[java]"));
- }
-
- @Test(dependsOnMethods = "testCreateRole")
- public void testUpdateRole() throws Exception {
- for (String rolename : api.listRoles()) {
- Role role = api.getRole(rolename);
- api.updateRole(role);
- }
- }
-
- @Test
- public void testListDatabags() throws Exception {
- Set<String> databags = api.listDatabags();
- assertNotNull(databags, "Data bag list was null");
- }
-
- @Test
- public void testCreateDatabag() throws Exception {
- api.deleteDatabag(PREFIX);
- api.createDatabag(PREFIX);
- }
-
- @Test(dependsOnMethods = "testCreateDatabagItem")
- public void testListDatabagItems() throws Exception {
- Set<String> databagItems = api.listDatabagItems(PREFIX);
- assertNotNull(databagItems, "Data bag item list was null");
- }
-
- @Test(dependsOnMethods = "testCreateDatabag")
- public void testCreateDatabagItem() throws Exception {
- Properties config = new Properties();
- config.setProperty("foo", "bar");
- api.deleteDatabagItem(PREFIX, PREFIX);
- DatabagItem databagItem = api.createDatabagItem(PREFIX, new DatabagItem("config", json.toJson(config)));
- databagitemId = databagItem.getId();
- assertNotNull(databagItem, "Created data bag item should not be null");
- assertEquals(databagItem.getId(), "config");
-
- // The databagItem json contains extra keys: (the name and the type if the
- // item)
- Properties props = json.fromJson(databagItem.toString(), Properties.class);
- for (Object key : config.keySet()) {
- assertTrue(props.containsKey(key));
- assertEquals(config.get(key), props.get(key));
- }
- }
-
- @Test(dependsOnMethods = "testCreateDatabagItem")
- public void testUpdateDatabagItem() throws Exception {
- for (String databagItemId : api.listDatabagItems(PREFIX)) {
- DatabagItem databagItem = api.getDatabagItem(PREFIX, databagItemId);
- api.updateDatabagItem(PREFIX, databagItem);
- }
- }
-
- @Test(dependsOnMethods = "testSearchDatabagWithOptions")
- public void testDeleteDatabagItem() throws Exception {
- for (String databagItemId : api.listDatabagItems(PREFIX)) {
- DatabagItem databagItem = api.deleteDatabagItem(PREFIX, databagItemId);
- assertNotNull(databagItem, "Deleted data bag item should not be null");
- assertEquals(databagItem.getId(), databagItemId, "Deleted data bag item id must match the original id");
- assertNull(api.getDatabagItem(PREFIX, databagItemId), "Data bag item should not exist");
- }
- }
-
- @Test
- public void testListSearchIndexes() throws Exception {
- Set<String> indexes = api.listSearchIndexes();
- assertNotNull(indexes, "The index list should not be null");
- assertTrue(indexes.contains("node"));
- assertTrue(indexes.contains("client"));
- assertTrue(indexes.contains("role"));
- }
-
- @Test
- public void testSearchNodes() throws Exception {
- SearchResult<? extends Node> results = api.searchNodes();
- assertNotNull(results, "Node result list should not be null");
- }
-
- @Test(dependsOnMethods = { "testListSearchIndexes", "testCreateNode" })
- public void testSearchNodesWithOptions() throws Exception {
- Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
- @Override
- public boolean apply(SearchOptions input) {
- SearchResult<? extends Node> results = api.searchNodes(input);
- assertNotNull(results);
- if (results.size() > 0) {
- assertEquals(results.size(), 1);
- assertEquals(results.iterator().next().getName(), PREFIX);
- return true;
- } else {
- // The index may still not be populated
- return false;
- }
- }
- }, maxWaitForIndexInMs, 5000L, MILLISECONDS);
-
- SearchOptions options = SearchOptions.Builder.query("name:" + PREFIX);
- assertTrue(waitForIndex.apply(options));
- }
-
- @Test
- public void testSearchClients() throws Exception {
- SearchResult<? extends Client> results = api.searchClients();
- assertNotNull(results, "Client result list should not be null");
- }
-
- @Test(dependsOnMethods = { "testListSearchIndexes", "testCreateClient" })
- public void testSearchClientsWithOptions() throws Exception {
- Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
- @Override
- public boolean apply(SearchOptions input) {
- SearchResult<? extends Client> results = api.searchClients(input);
- assertNotNull(results);
- if (results.size() > 0) {
- assertEquals(results.size(), 1);
- assertEquals(results.iterator().next().getName(), PREFIX);
- return true;
- } else {
- // The index may still not be populated
- return false;
- }
- }
- }, maxWaitForIndexInMs, 5000L, MILLISECONDS);
-
- SearchOptions options = SearchOptions.Builder.query("name:" + PREFIX);
- assertTrue(waitForIndex.apply(options));
- }
-
- @Test
- public void testSearchRoles() throws Exception {
- SearchResult<? extends Role> results = api.searchRoles();
- assertNotNull(results, "Role result list should not be null");
- }
-
- @Test(dependsOnMethods = { "testListSearchIndexes", "testCreateRole" })
- public void testSearchRolesWithOptions() throws Exception {
- Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
- @Override
- public boolean apply(SearchOptions input) {
- SearchResult<? extends Role> results = api.searchRoles(input);
- assertNotNull(results);
- if (results.size() > 0) {
- assertEquals(results.size(), 1);
- assertEquals(results.iterator().next().getName(), PREFIX);
- return true;
- } else {
- // The index may still not be populated
- return false;
- }
- }
- }, maxWaitForIndexInMs, 5000L, MILLISECONDS);
-
- SearchOptions options = SearchOptions.Builder.query("name:" + PREFIX);
- assertTrue(waitForIndex.apply(options));
- }
-
- @Test(dependsOnMethods = { "testListSearchIndexes", "testCreateDatabagItem" })
- public void testSearchDatabag() throws Exception {
- SearchResult<? extends DatabagItem> results = api.searchDatabagItems(PREFIX);
- assertNotNull(results, "Data bag item result list should not be null");
- }
-
- @Test(dependsOnMethods = { "testListSearchIndexes", "testCreateDatabagItem" })
- public void testSearchDatabagWithOptions() throws Exception {
- Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
- @Override
- public boolean apply(SearchOptions input) {
- SearchResult<? extends DatabagItem> results = api.searchDatabagItems(PREFIX, input);
- assertNotNull(results);
- if (results.size() > 0) {
- assertEquals(results.size(), 1);
- assertEquals(results.iterator().next().getId(), databagitemId);
- return true;
- } else {
- // The index may still not be populated
- return false;
- }
- }
- }, maxWaitForIndexInMs, 5000L, MILLISECONDS);
-
- SearchOptions options = SearchOptions.Builder.query("id:" + databagitemId);
- assertTrue(waitForIndex.apply(options));
- }
-
- @Test(expectedExceptions = ResourceNotFoundException.class, dependsOnMethods = "testListSearchIndexes")
- public void testSearchDatabagNotFound() throws Exception {
- SearchResult<? extends DatabagItem> results = api.searchDatabagItems("whoopie");
- assertNotNull(results, "Data bag item result list should not be null");
- }
-
- @Test
- public void testCreateEnvironment() {
- api.deleteEnvironment(PREFIX);
- api.createEnvironment(Environment.builder().name(PREFIX).description(PREFIX).build());
- Environment env = api.getEnvironment(PREFIX);
- assertNotNull(env, "Created environment should not be null");
- assertEquals(env.getName(), PREFIX);
- assertEquals(env.getDescription(), PREFIX);
- }
-
- @Test(dependsOnMethods = "testCreateEnvironment")
- public void testListEnvironment() {
- Set<String> envList = api.listEnvironments();
- assertNotNull(envList, "Environment list was null");
- assertTrue(envList.contains(PREFIX));
- }
-
- @Test(dependsOnMethods = "testCreateEnvironment")
- public void testSearchEnvironments() throws Exception {
- SearchResult<? extends Environment> results = api.searchEnvironments();
- assertNotNull(results, "Environment result list was null");
- }
-
- @Test(dependsOnMethods = { "testListSearchIndexes", "testCreateEnvironment" })
- public void testSearchEnvironmentsWithOptions() throws Exception {
- Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
- @Override
- public boolean apply(SearchOptions input) {
- SearchResult<? extends Environment> results = api.searchEnvironments(input);
- assertNotNull(results);
- if (results.size() > 0) {
- assertEquals(results.size(), 1);
- assertEquals(results.iterator().next().getName(), PREFIX);
- return true;
- } else {
- // The index may still not be populated
- return false;
- }
- }
- }, maxWaitForIndexInMs, 5000L, MILLISECONDS);
-
- SearchOptions options = SearchOptions.Builder.query("name:" + PREFIX);
- assertTrue(waitForIndex.apply(options));
- }
-
- @Test(dependsOnMethods = "testCreateEnvironment")
- public void testListRecipesInEnvironment() {
- Set<String> recipeList = api.listRecipesInEnvironment(PREFIX);
- assertTrue(!recipeList.isEmpty());
- }
-
- @Test(dependsOnMethods = "testCreateEnvironment")
- public void testListNodesInEnvironment() {
- api.deleteNode(ENV_NODE);
- api.createNode(Node.builder().name(ENV_NODE).runListElement("role[" + PREFIX + "]").environment(PREFIX).build());
- Node node = api.getNode(ENV_NODE);
- assertNotNull(node, "Created node should not be null");
- Set<String> nodeList = api.listNodesInEnvironment(PREFIX);
- assertTrue(!nodeList.isEmpty());
- }
-
- @Test(dependsOnMethods = "testCreateNewCookbook")
- public void testListCookbooksInEnvironment() throws Exception {
- Set<CookbookDefinition> cookbooks = api.listCookbooksInEnvironment("_default");
- assertTrue(any(cookbooks, new Predicate<CookbookDefinition>() {
- @Override
- public boolean apply(CookbookDefinition input) {
- return PREFIX.equals(input.getName());
- }}), String.format("Cookbook %s not in %s", PREFIX, cookbooks));
- }
-
- @AfterClass(groups = { "live", "integration" })
- @Override
- public void tearDown() {
- api.deleteClient(PREFIX);
- api.deleteClient(ADMIN_PREFIX);
- api.deleteNode(PREFIX);
- api.deleteNode(ENV_NODE);
- api.deleteRole(PREFIX);
- api.deleteDatabag(PREFIX);
- api.deleteEnvironment(PREFIX);
- super.tearDown();
- }
-
- private void assertClientCreated(String identity, String credential) {
- Properties overrides = super.setupProperties();
- overrides.setProperty(provider + ".identity", identity);
- overrides.setProperty(provider + ".credential", credential);
-
- A clientApi = create(overrides, setupModules());
-
- try {
- Client client = clientApi.getClient(identity);
- assertNotNull(client, "Client not found: " + identity);
- } finally {
- closeQuietly(clientApi);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java
index e314418..2e84c67 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java
@@ -16,8 +16,6 @@
*/
package org.jclouds.chef.internal;
-import static org.jclouds.reflect.Types2.checkBound;
-
import java.io.File;
import java.io.IOException;
import java.util.Properties;
@@ -31,12 +29,11 @@ import org.testng.annotations.Test;
import com.google.common.base.Charsets;
import com.google.common.base.Throwables;
import com.google.common.io.Files;
-import com.google.common.reflect.TypeToken;
import com.google.inject.Injector;
import com.google.inject.Module;
@Test(groups = "live")
-public abstract class BaseChefLiveTest<A extends ChefApi> extends BaseApiLiveTest<A> {
+public abstract class BaseChefLiveTest extends BaseApiLiveTest<ChefApi> {
protected Injector injector;
protected ChefService chefService;
@@ -64,9 +61,9 @@ public abstract class BaseChefLiveTest<A extends ChefApi> extends BaseApiLiveTes
}
@Override
- protected A create(Properties props, Iterable<Module> modules) {
+ protected ChefApi create(Properties props, Iterable<Module> modules) {
injector = newBuilder().modules(modules).overrides(props).buildInjector();
- return injector.getInstance(resolveApiClass());
+ return injector.getInstance(ChefApi.class);
}
protected String setCredentialFromPemFile(Properties overrides, String identity, String key) {
@@ -86,11 +83,4 @@ public abstract class BaseChefLiveTest<A extends ChefApi> extends BaseApiLiveTes
return credentialFromFile;
}
- @SuppressWarnings("unchecked")
- private Class<A> resolveApiClass() {
- return Class.class.cast(checkBound(new TypeToken<A>(getClass()) {
- private static final long serialVersionUID = 1L;
- }).getRawType());
- }
-
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java
deleted file mode 100644
index 8779017..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.chef.internal;
-
-import java.util.Map;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefApiMetadata;
-import org.jclouds.chef.config.ChefBootstrapModule;
-import org.jclouds.chef.config.ChefHttpApiModule;
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.domain.JsonBall;
-import org.jclouds.ohai.AutomaticSupplier;
-import org.jclouds.ohai.config.ConfiguresOhai;
-import org.jclouds.ohai.config.OhaiModule;
-import org.testng.annotations.Test;
-
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-@Test(groups = "live")
-@Deprecated
-public class BaseStubbedOhaiLiveTest extends BaseChefLiveTest<ChefApi> {
-
- @ConfiguresOhai
- static class TestOhaiModule extends OhaiModule {
-
- @Override
- protected Supplier<Map<String, JsonBall>> provideAutomatic(AutomaticSupplier in) {
- return Suppliers.<Map<String, JsonBall>> ofInstance(ImmutableMap.of("foo", new JsonBall("bar")));
- }
- }
-
- @Override
- protected ApiMetadata createApiMetadata() {
- return new ChefApiMetadata()
- .toBuilder()
- .defaultModules(
- ImmutableSet.<Class<? extends Module>> of(ChefHttpApiModule.class, ChefParserModule.class,
- ChefBootstrapModule.class, TestOhaiModule.class)).build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java
index 0c6731b..460aecf 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java
@@ -19,7 +19,6 @@ package org.jclouds.chef.strategy.internal;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
-import org.jclouds.chef.ChefApi;
import org.jclouds.chef.internal.BaseChefLiveTest;
import org.testng.annotations.Test;
@@ -29,7 +28,7 @@ import com.google.common.collect.ImmutableSet;
* Tests behavior of {@code CleanupStaleNodesAndClientsImpl} strategies
*/
@Test(groups = "live", testName = "CleanupStaleNodesAndClientsImplLiveTest")
-public class CleanupStaleNodesAndClientsImplLiveTest extends BaseChefLiveTest<ChefApi> {
+public class CleanupStaleNodesAndClientsImplLiveTest extends BaseChefLiveTest {
private CreateNodeAndPopulateAutomaticAttributesImpl creator;
private CleanupStaleNodesAndClientsImpl strategy;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java
index c26a88c..0a32c13 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java
@@ -20,7 +20,6 @@ import static org.testng.Assert.assertEquals;
import java.util.Set;
-import org.jclouds.chef.ChefApi;
import org.jclouds.chef.domain.Node;
import org.jclouds.chef.internal.BaseChefLiveTest;
import org.jclouds.ohai.config.OhaiModule.CurrentUserProvider;
@@ -33,7 +32,7 @@ import com.google.common.collect.ImmutableSet;
* strategies
*/
@Test(groups = "live", testName = "CreateNodeAndPopulateAutomaticAttributesImplLiveTest")
-public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseChefLiveTest<ChefApi> {
+public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseChefLiveTest {
private CurrentUserProvider currentUserProvider;
private CreateNodeAndPopulateAutomaticAttributesImpl strategy;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplTest.java
index 3ba7110..9f8819c 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplTest.java
@@ -16,9 +16,9 @@
*/
package org.jclouds.chef.strategy.internal;
-import static org.easymock.classextension.EasyMock.createMock;
-import static org.easymock.classextension.EasyMock.replay;
-import static org.easymock.classextension.EasyMock.verify;
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.replay;
+import static org.easymock.EasyMock.verify;
import java.util.Map;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java
index fd8a91f..0e6ce6a 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java
@@ -19,7 +19,6 @@ package org.jclouds.chef.strategy.internal;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
-import org.jclouds.chef.ChefApi;
import org.jclouds.chef.internal.BaseChefLiveTest;
import org.testng.annotations.Test;
@@ -29,7 +28,7 @@ import com.google.common.collect.ImmutableSet;
* Tests behavior of {@code DeleteAllApisAndNodesInListImpl} strategies
*/
@Test(groups = "live", testName = "DeleteAllApisAndNodesInListImplLiveTest")
-public class DeleteAllApisAndNodesInListImplLiveTest extends BaseChefLiveTest<ChefApi> {
+public class DeleteAllApisAndNodesInListImplLiveTest extends BaseChefLiveTest {
private DeleteAllNodesInListImpl strategy;
private CreateNodeAndPopulateAutomaticAttributesImpl creator;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsInEnvironmentImplLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsInEnvironmentImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsInEnvironmentImplLiveTest.java
index f33f877..71d5152 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsInEnvironmentImplLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListCookbookVersionsInEnvironmentImplLiveTest.java
@@ -25,9 +25,6 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.jclouds.chef.ChefApi;
import org.jclouds.chef.domain.ChecksumStatus;
import org.jclouds.chef.domain.CookbookVersion;
import org.jclouds.chef.domain.Metadata;
@@ -44,12 +41,14 @@ import com.google.common.collect.ImmutableSet;
import com.google.common.hash.Hashing;
import com.google.common.io.Files;
import com.google.common.primitives.Bytes;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
/**
* Tests behavior of {@code ListCookbookVersionsInEnvironmentImpl} strategies
*/
@Test(groups = "live", testName = "ListCookbookVersionsInEnvironmentImplLiveTest")
-public class ListCookbookVersionsInEnvironmentImplLiveTest extends BaseChefLiveTest<ChefApi> {
+public class ListCookbookVersionsInEnvironmentImplLiveTest extends BaseChefLiveTest {
public static final String PREFIX = "jcloudstest-strategy-" + System.getProperty("user.name");
private ListCookbookVersionsInEnvironmentImpl strategy;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java
index 903b998..042fd60 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesImplLiveTest.java
@@ -19,23 +19,22 @@ package org.jclouds.chef.strategy.internal;
import static com.google.common.collect.Iterables.size;
import static org.testng.Assert.assertTrue;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.jclouds.chef.ChefApi;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
import org.jclouds.chef.internal.BaseChefLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
/**
* Tests behavior of {@code ListNodesImpl} strategies
*/
@Test(groups = "live", testName = "ListNodesImplLiveTest")
-public class ListNodesImplLiveTest extends BaseChefLiveTest<ChefApi> {
+public class ListNodesImplLiveTest extends BaseChefLiveTest {
private ListNodesImpl strategy;
private CreateNodeAndPopulateAutomaticAttributesImpl creator;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java
index 013b6c7..61d9471 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/ListNodesInEnvironmentImplLiveTest.java
@@ -19,23 +19,22 @@ package org.jclouds.chef.strategy.internal;
import static com.google.common.collect.Iterables.size;
import static org.testng.Assert.assertTrue;
-import com.google.common.util.concurrent.ListeningExecutorService;
-import com.google.common.util.concurrent.MoreExecutors;
-import org.jclouds.chef.ChefApi;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
import org.jclouds.chef.internal.BaseChefLiveTest;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
-
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
+import com.google.common.util.concurrent.ListeningExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
/**
* Tests behavior of {@code ListNodesInEnvironmentImpl} strategies
*/
@Test(groups = "live", testName = "ListNodesInEnvironmentImplLiveTest")
-public class ListNodesInEnvironmentImplLiveTest extends BaseChefLiveTest<ChefApi> {
+public class ListNodesInEnvironmentImplLiveTest extends BaseChefLiveTest {
private ListNodesInEnvironmentImpl strategy;
private CreateNodeAndPopulateAutomaticAttributesImpl creator;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java
index b3a3148..6a1b1fc 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java
@@ -20,7 +20,6 @@ import static org.testng.Assert.assertEquals;
import java.util.Set;
-import org.jclouds.chef.ChefApi;
import org.jclouds.chef.domain.Node;
import org.jclouds.chef.internal.BaseChefLiveTest;
import org.jclouds.ohai.config.OhaiModule.CurrentUserProvider;
@@ -32,7 +31,7 @@ import com.google.common.collect.ImmutableSet;
* Tests behavior of {@code UpdateAutomaticAttributesOnNodeImpl} strategies
*/
@Test(groups = "live", testName = "UpdateAutomaticAttributesOnNodeImplLiveTest")
-public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefLiveTest<ChefApi> {
+public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefLiveTest {
private CurrentUserProvider currentUserProvider;
private UpdateAutomaticAttributesOnNodeImpl strategy;
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/resources/group-update.json
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/resources/group-update.json b/apis/chef/src/test/resources/group-update.json
new file mode 100644
index 0000000..cc7bf6a
--- /dev/null
+++ b/apis/chef/src/test/resources/group-update.json
@@ -0,0 +1 @@
+{"groupname":"admins","actors":{"clients":["abiquo"],"groups":["admins"],"users":["nacx"]}}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/resources/group.json
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/resources/group.json b/apis/chef/src/test/resources/group.json
new file mode 100644
index 0000000..df3eb28
--- /dev/null
+++ b/apis/chef/src/test/resources/group.json
@@ -0,0 +1,14 @@
+{
+ "actors" : [ "abiquo",
+ "nacx",
+ "pivotal"
+ ],
+ "clients" : [ "abiquo" ],
+ "groupname" : "admins",
+ "groups" : [ "billing-admins" ],
+ "name" : "admins",
+ "orgname" : "nacx",
+ "users" : [ "nacx",
+ "pivotal"
+ ]
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/resources/groups.json
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/resources/groups.json b/apis/chef/src/test/resources/groups.json
new file mode 100644
index 0000000..30c8aa6
--- /dev/null
+++ b/apis/chef/src/test/resources/groups.json
@@ -0,0 +1,7 @@
+{
+ "965f2db33d302ed4625d172e0bc36920" : "https://api.opscode.com/organizations/nacx/groups/965f2db33d302ed4625d172e0bc36920",
+ "admins" : "https://api.opscode.com/organizations/nacx/groups/admins",
+ "billing-admins" : "https://api.opscode.com/organizations/nacx/groups/billing-admins",
+ "clients" : "https://api.opscode.com/organizations/nacx/groups/clients",
+ "users" : "https://api.opscode.com/organizations/nacx/groups/users"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/apis/chef/src/test/resources/user.json
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/resources/user.json b/apis/chef/src/test/resources/user.json
new file mode 100644
index 0000000..1064c51
--- /dev/null
+++ b/apis/chef/src/test/resources/user.json
@@ -0,0 +1,9 @@
+{
+ "display_name" : "Ignasi Barrera",
+ "email" : "myemail@chef.org",
+ "first_name" : "Ignasi",
+ "last_name" : "Barrera",
+ "middle_name" : "",
+ "public_key" : "-----BEGIN RSA PUBLIC KEY-----\nMIIBCgKCAQEAp0ytgXbPzqJwOOixn7bTa6VAiNvVIOn+yDPoWbyEfc0li93BHIwv\n01KW/mn55IXnSbMw86rdxisvwPHFfb7URuKuTzME6yrphBiancmNjushZZeBWb8j\nqJhnFIKbaaOqew0LZSyG9ycYODB/HDK/pWTV4Bd1OtLHBNFrnIf+r3HOjJsa4rmK\nWXgSQIQO7be/iRHysApV9tfVH8lo1ETnA08JTrQwDgo9St9YNbydb5V0CiLiQsOa\nIbY09buUK9lXthh/rrRVbGbSwQM6OYdXIEZTN2BFvQ0p5pH8AiTwFqb0ICO46a0S\njfGcXNjC/QfHljAPY3T5xyIOODM8afHCnwIDAQAB\n-----END RSA PUBLIC KEY-----\n",
+ "username" : "nacx"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/providers/enterprisechef/pom.xml
----------------------------------------------------------------------
diff --git a/providers/enterprisechef/pom.xml b/providers/enterprisechef/pom.xml
deleted file mode 100644
index 08f1c39..0000000
--- a/providers/enterprisechef/pom.xml
+++ /dev/null
@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-project</artifactId>
- <version>2.0.0-SNAPSHOT</version>
- <relativePath>../../project/pom.xml</relativePath>
- </parent>
- <groupId>org.apache.jclouds.provider</groupId>
- <artifactId>enterprisechef</artifactId>
- <name>jclouds Enterprise Chef provider</name>
- <description>jclouds components to access Enterprise Chef</description>
-
- <properties>
- <test.enterprisechef.org>YOUR_ORG</test.enterprisechef.org>
- <test.enterprisechef.endpoint>https://api.opscode.com/organizations/${test.enterprisechef.org}</test.enterprisechef.endpoint>
- <test.enterprisechef.api-version />
- <test.enterprisechef.build-version />
- <test.enterprisechef.identity>YOUR_USER</test.enterprisechef.identity>
- <test.enterprisechef.credential>${user.home}/.chef/${test.enterprisechef.org}/${test.enterprisechef.identity}.pem</test.enterprisechef.credential>
- <jclouds.osgi.export>org.jclouds.enterprisechef*;version="${project.version}"</jclouds.osgi.export>
- <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
- </properties>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>chef</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.api</groupId>
- <artifactId>chef</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds</groupId>
- <artifactId>jclouds-core</artifactId>
- <version>${project.version}</version>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.jclouds.driver</groupId>
- <artifactId>jclouds-slf4j</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>ch.qos.logback</groupId>
- <artifactId>logback-classic</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.google.auto.service</groupId>
- <artifactId>auto-service</artifactId>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <profiles>
- <profile>
- <id>live</id>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <executions>
- <execution>
- <id>integration</id>
- <phase>integration-test</phase>
- <goals>
- <goal>test</goal>
- </goals>
- <configuration>
- <systemPropertyVariables>
- <test.enterprisechef.org>${test.enterprisechef.org}</test.enterprisechef.org>
- <test.enterprisechef.endpoint>${test.enterprisechef.endpoint}</test.enterprisechef.endpoint>
- <test.enterprisechef.api-version>${test.enterprisechef.api-version}</test.enterprisechef.api-version>
- <test.enterprisechef.build-version>${test.enterprisechef.build-version}</test.enterprisechef.build-version>
- <test.enterprisechef.identity>${test.enterprisechef.identity}</test.enterprisechef.identity>
- <test.enterprisechef.credential>${test.enterprisechef.credential}</test.enterprisechef.credential>
- </systemPropertyVariables>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-</project>
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApi.java
----------------------------------------------------------------------
diff --git a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApi.java b/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApi.java
deleted file mode 100644
index 159cb1b..0000000
--- a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApi.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.enterprisechef;
-
-import java.util.Set;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Constants;
-import org.jclouds.Fallbacks.NullOnNotFoundOr404;
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.filters.SignedHeaderAuth;
-import org.jclouds.chef.functions.ParseKeySetFromJson;
-import org.jclouds.enterprisechef.binders.BindGroupToUpdateRequestJsonPayload;
-import org.jclouds.enterprisechef.binders.GroupName;
-import org.jclouds.enterprisechef.domain.Group;
-import org.jclouds.enterprisechef.domain.User;
-import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.ParamParser;
-import org.jclouds.rest.annotations.RequestFilters;
-import org.jclouds.rest.annotations.ResponseParser;
-import org.jclouds.rest.annotations.WrapWith;
-
-/**
- * Provides synchronous access to the Enterprise Chef Api.
- */
-@RequestFilters(SignedHeaderAuth.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
-public interface EnterpriseChefApi extends ChefApi {
- /**
- * Retrieves an existing user.
- *
- * @param name
- * The name of the user to get.
- * @return The details of the user or <code>null</code> if not found.
- */
- @Named("user:get")
- @GET
- @Path("/users/{name}")
- @Fallback(NullOnNotFoundOr404.class)
- User getUser(@PathParam("name") String name);
-
- /**
- * List all existing groups.
- *
- * @return The list of groups.
- */
- @Named("group:list")
- @GET
- @Path("/groups")
- @ResponseParser(ParseKeySetFromJson.class)
- Set<String> listGroups();
-
- /**
- * Retrieves an existing group.
- *
- * @param name
- * The name of the group to get.
- * @return The details of the group or <code>null</code> if not found.
- */
- @Named("group:get")
- @GET
- @Path("/groups/{name}")
- @Fallback(NullOnNotFoundOr404.class)
- Group getGroup(@PathParam("name") String name);
-
- /**
- * Creates a new group.
- *
- * @param name
- * The name of the group to create.
- */
- @Named("group:create")
- @POST
- @Path("/groups")
- void createGroup(@WrapWith("groupname") String name);
-
- /**
- * Updates a group.
- * <p>
- * This method can be used to add actors (clients, groups) to the group.
- *
- * @param group
- * The group with the updated information.
- */
- @Named("group:update")
- @PUT
- @Path("/groups/{name}")
- void updateGroup(
- @PathParam("name") @ParamParser(GroupName.class) @BinderParam(BindGroupToUpdateRequestJsonPayload.class) Group group);
-
- /**
- * Deletes a group.
- *
- * @param name
- * The name of the group to delete.
- */
- @Named("group:delete")
- @DELETE
- @Path("/groups/{name}")
- void deleteGroup(@PathParam("name") String name);
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApiMetadata.java
----------------------------------------------------------------------
diff --git a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApiMetadata.java b/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApiMetadata.java
deleted file mode 100644
index bdf45c2..0000000
--- a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApiMetadata.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.enterprisechef;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.apis.ApiMetadata;
-import org.jclouds.chef.ChefApiMetadata;
-import org.jclouds.chef.config.ChefBootstrapModule;
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.enterprisechef.config.EnterpriseChefHttpApiModule;
-import org.jclouds.ohai.config.JMXOhaiModule;
-import org.jclouds.rest.internal.BaseHttpApiMetadata;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-/**
- * Implementation of {@link ApiMetadata} for the Enterprise Chef api.
- */
-public class EnterpriseChefApiMetadata extends BaseHttpApiMetadata<EnterpriseChefApi> {
-
- @Override
- public Builder toBuilder() {
- return new Builder().fromApiMetadata(this);
- }
-
- public EnterpriseChefApiMetadata() {
- this(new Builder());
- }
-
- protected EnterpriseChefApiMetadata(final Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- return ChefApiMetadata.defaultProperties();
- }
-
- public static class Builder extends BaseHttpApiMetadata.Builder<EnterpriseChefApi, Builder> {
-
- protected Builder() {
- id("enterprisechef")
- .name("Enterprise Chef Api")
- .identityName("User")
- .credentialName("Certificate")
- .version(ChefApiMetadata.DEFAULT_API_VERSION)
- .documentation(URI.create("http://www.opscode.com/support"))
- .defaultEndpoint("https://api.opscode.com")
- .defaultProperties(EnterpriseChefApiMetadata.defaultProperties())
- .defaultModules(
- ImmutableSet.<Class<? extends Module>> of(EnterpriseChefHttpApiModule.class,
- ChefParserModule.class, ChefBootstrapModule.class, JMXOhaiModule.class));
- }
-
- @Override
- public EnterpriseChefApiMetadata build() {
- return new EnterpriseChefApiMetadata(this);
- }
-
- @Override
- protected Builder self() {
- return this;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefProviderMetadata.java
----------------------------------------------------------------------
diff --git a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefProviderMetadata.java b/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefProviderMetadata.java
deleted file mode 100644
index cf77acc..0000000
--- a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefProviderMetadata.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.enterprisechef;
-
-import java.net.URI;
-import java.util.Properties;
-
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.providers.internal.BaseProviderMetadata;
-
-import com.google.auto.service.AutoService;
-
-/**
- * Implementation of @ link ProviderMetadata} for Enterprise Chef
- */
-@AutoService(ProviderMetadata.class)
-public class EnterpriseChefProviderMetadata extends BaseProviderMetadata {
-
- public static Builder builder() {
- return new Builder();
- }
-
- @Override
- public Builder toBuilder() {
- return builder().fromProviderMetadata(this);
- }
-
- public EnterpriseChefProviderMetadata() {
- super(builder());
- }
-
- public EnterpriseChefProviderMetadata(final Builder builder) {
- super(builder);
- }
-
- public static Properties defaultProperties() {
- Properties properties = new Properties();
- return properties;
- }
-
- public static class Builder extends BaseProviderMetadata.Builder {
-
- protected Builder() {
- id("enterprisechef") //
- .name("OpsCode Enterprise Chef") //
- .endpoint("https://api.opscode.com") //
- .homepage(URI.create("https://manage.opscode.com")) //
- .console(URI.create("https://manage.opscode.com")) //
- .apiMetadata(new EnterpriseChefApiMetadata()) //
- .defaultProperties(EnterpriseChefProviderMetadata.defaultProperties());
- }
-
- @Override
- public EnterpriseChefProviderMetadata build() {
- return new EnterpriseChefProviderMetadata(this);
- }
-
- @Override
- public Builder fromProviderMetadata(final ProviderMetadata in) {
- super.fromProviderMetadata(in);
- return this;
- }
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/BindGroupToUpdateRequestJsonPayload.java
----------------------------------------------------------------------
diff --git a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/BindGroupToUpdateRequestJsonPayload.java b/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/BindGroupToUpdateRequestJsonPayload.java
deleted file mode 100644
index 2573b9d..0000000
--- a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/BindGroupToUpdateRequestJsonPayload.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.enterprisechef.binders;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.enterprisechef.domain.Group;
-import org.jclouds.http.HttpRequest;
-import org.jclouds.json.Json;
-import org.jclouds.rest.binders.BindToJsonPayload;
-
-/**
- * Binds a group to the payload expected for the Put method in the Enterprise Chef
- * Api.
- */
-@Singleton
-public class BindGroupToUpdateRequestJsonPayload extends BindToJsonPayload {
-
- @Inject
- public BindGroupToUpdateRequestJsonPayload(Json jsonBinder) {
- super(jsonBinder);
- }
-
- @Override
- public <R extends HttpRequest> R bindToRequest(R request, Object payload) {
- checkArgument(checkNotNull(payload, "payload") instanceof Group, "this binder is only valid for Group objects");
- GroupUpdateRequest updateGroup = new GroupUpdateRequest((Group) payload);
- return super.bindToRequest(request, updateGroup);
- }
-
- @SuppressWarnings("unused")
- private static class GroupUpdateRequest {
- private String name;
- private String groupname;
- private String orgname;
- private ActorConfiguration actors;
-
- public GroupUpdateRequest(Group group) {
- this.name = group.getName();
- this.groupname = group.getGroupname();
- this.orgname = group.getOrgname();
- this.actors = new ActorConfiguration(group);
- }
- }
-
- @SuppressWarnings("unused")
- private static class ActorConfiguration {
- private Set<String> clients;
- private Set<String> groups;
- private Set<String> users;
-
- public ActorConfiguration(Group group) {
- this.clients = group.getClients();
- this.groups = group.getGroups();
- this.users = group.getUsers();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/GroupName.java
----------------------------------------------------------------------
diff --git a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/GroupName.java b/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/GroupName.java
deleted file mode 100644
index 12286a6..0000000
--- a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/binders/GroupName.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.enterprisechef.binders;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import javax.inject.Singleton;
-
-import org.jclouds.enterprisechef.domain.Group;
-
-import com.google.common.base.Function;
-
-/**
- * Gets the name of a group.
- */
-@Singleton
-public class GroupName implements Function<Object, String> {
-
- @Override
- public String apply(Object from) {
- return ((Group) checkNotNull(from, "from")).getGroupname();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/9df30c5a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/config/EnterpriseChefHttpApiModule.java
----------------------------------------------------------------------
diff --git a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/config/EnterpriseChefHttpApiModule.java b/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/config/EnterpriseChefHttpApiModule.java
deleted file mode 100644
index ed0a49f..0000000
--- a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/config/EnterpriseChefHttpApiModule.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.jclouds.enterprisechef.config;
-
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.config.BaseChefHttpApiModule;
-import org.jclouds.enterprisechef.EnterpriseChefApi;
-import org.jclouds.rest.ConfiguresHttpApi;
-
-/**
- * Configures the Enterprise Chef connection.
- */
-@ConfiguresHttpApi
-public class EnterpriseChefHttpApiModule extends BaseChefHttpApiModule<EnterpriseChefApi> {
-
- @Override
- protected void configure() {
- super.configure();
- bind(ChefApi.class).to(EnterpriseChefApi.class);
- }
-
-}