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/05/03 23:47:51 UTC
[1/2] jclouds git commit: Remove the deprecated methods in Chef
Repository: jclouds
Updated Branches:
refs/heads/master deeebe46f -> 4863bb83a
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersionTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersionTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersionTest.java
deleted file mode 100644
index bad0edf..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersionTest.java
+++ /dev/null
@@ -1,62 +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.functions;
-
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.testng.annotations.Test;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code ParseCookbookVersionsCheckingChefVersion}.
- */
-@Test(groups = { "unit" }, singleThreaded = true)
-public class ParseCookbookVersionsCheckingChefVersionTest {
-
- public void testParserFor09() {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance("0.9.8");
- }
- }, new ChefParserModule(), new GsonModule());
-
- ParseCookbookVersionsCheckingChefVersion parser = injector
- .getInstance(ParseCookbookVersionsCheckingChefVersion.class);
- assertTrue(parser.parser instanceof ParseCookbookVersionsV09FromJson);
- }
-
- public void testParserFor010() {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance("0.10.8");
- }
- }, new ChefParserModule(), new GsonModule());
-
- ParseCookbookVersionsCheckingChefVersion parser = injector
- .getInstance(ParseCookbookVersionsCheckingChefVersion.class);
- assertTrue(parser.parser instanceof ParseCookbookVersionsV10FromJson);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJsonTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJsonTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJsonTest.java
new file mode 100644
index 0000000..dda50e0
--- /dev/null
+++ b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJsonTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.chef.ChefApiMetadata;
+import org.jclouds.chef.config.ChefParserModule;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.rest.annotations.ApiVersion;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code ParseCookbookVersionsFromJson}
+ */
+@Test(groups = { "unit" }, singleThreaded = true)
+public class ParseCookbookVersionsFromJsonTest
+{
+ private ParseCookbookVersionsFromJson handler;
+
+ @BeforeTest
+ protected void setUpInjector() throws IOException {
+ Injector injector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_API_VERSION);
+ }
+ }, new ChefParserModule(), new GsonModule());
+
+ handler = injector.getInstance(ParseCookbookVersionsFromJson.class);
+ }
+
+ public void testRegex() {
+ assertEquals(handler.apply(HttpResponse
+ .builder()
+ .statusCode(200)
+ .message("ok")
+ .payload(
+ "{" + "\"apache2\" => {" + "\"url\" => \"http://localhost:4000/cookbooks/apache2\","
+ + "\"versions\" => [" + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/5.1.0\","
+ + "\"version\" => \"5.1.0\"},"
+ + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/4.2.0\","
+ + "\"version\" => \"4.2.0\"}" + "]" + "}" + "}").build()), ImmutableSet.of("5.1.0", "4.2.0"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJsonTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJsonTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJsonTest.java
deleted file mode 100644
index 08cf1d2..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJsonTest.java
+++ /dev/null
@@ -1,61 +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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.jclouds.chef.ChefApiMetadata;
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code ParseCookbookVersionsV09FromJson}
- */
-@Test(groups = { "unit" }, singleThreaded = true)
-public class ParseCookbookVersionsV09FromJsonTest {
-
- private ParseCookbookVersionsV09FromJson handler;
-
- @BeforeTest
- protected void setUpInjector() throws IOException {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_API_VERSION);
- }
- }, new ChefParserModule(), new GsonModule());
-
- handler = injector.getInstance(ParseCookbookVersionsV09FromJson.class);
- }
-
- public void testRegex() {
- assertEquals(
- handler.apply(HttpResponse.builder().statusCode(200).message("ok")
- .payload("{\"apache2\": [\"0.1.8\", \"0.2\"]}").build()), ImmutableSet.of("0.1.8", "0.2"));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJsonTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJsonTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJsonTest.java
deleted file mode 100644
index e8b396a..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJsonTest.java
+++ /dev/null
@@ -1,68 +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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-
-import org.jclouds.chef.ChefApiMetadata;
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code ParseCookbookVersionsV10FromJson}
- */
-@Test(groups = { "unit" }, singleThreaded = true)
-public class ParseCookbookVersionsV10FromJsonTest {
-
- private ParseCookbookVersionsV10FromJson handler;
-
- @BeforeTest
- protected void setUpInjector() throws IOException {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_API_VERSION);
- }
- }, new ChefParserModule(), new GsonModule());
-
- handler = injector.getInstance(ParseCookbookVersionsV10FromJson.class);
- }
-
- public void testRegex() {
- assertEquals(handler.apply(HttpResponse
- .builder()
- .statusCode(200)
- .message("ok")
- .payload(
- "{" + "\"apache2\" => {" + "\"url\" => \"http://localhost:4000/cookbooks/apache2\","
- + "\"versions\" => [" + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/5.1.0\","
- + "\"version\" => \"5.1.0\"},"
- + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/4.2.0\","
- + "\"version\" => \"4.2.0\"}" + "]" + "}" + "}").build()), ImmutableSet.of("5.1.0", "4.2.0"));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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 e8b249b..0c6731b 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
@@ -37,6 +37,7 @@ public class CleanupStaleNodesAndClientsImplLiveTest extends BaseChefLiveTest<Ch
@Override
protected void initialize() {
super.initialize();
+ this.prefix = this.prefix + "-" + this.hashCode();
this.creator = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
this.strategy = injector.getInstance(CleanupStaleNodesAndClientsImpl.class);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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 60f2661..c26a88c 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
@@ -41,6 +41,7 @@ public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseCh
@Override
protected void initialize() {
super.initialize();
+ this.prefix = this.prefix + "-" + this.hashCode();
this.currentUserProvider = injector.getInstance(CurrentUserProvider.class);
this.strategy = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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 6f0e595..fd8a91f 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
@@ -37,6 +37,7 @@ public class DeleteAllApisAndNodesInListImplLiveTest extends BaseChefLiveTest<Ch
@Override
protected void initialize() {
super.initialize();
+ this.prefix = this.prefix + "-" + this.hashCode();
this.creator = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
this.strategy = injector.getInstance(DeleteAllNodesInListImpl.class);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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 5f68fcf..f33f877 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
@@ -53,8 +53,6 @@ public class ListCookbookVersionsInEnvironmentImplLiveTest extends BaseChefLiveT
public static final String PREFIX = "jcloudstest-strategy-" + System.getProperty("user.name");
private ListCookbookVersionsInEnvironmentImpl strategy;
- private CreateNodeAndPopulateAutomaticAttributesImpl creator;
-
private ExecutorService testExecutorService;
private ListeningExecutorService testListeningExecutorService;
@@ -174,7 +172,7 @@ public class ListCookbookVersionsInEnvironmentImplLiveTest extends BaseChefLiveT
private void createCookbooksWithMultipleVersions(String cookbookName) throws Exception {
FilePayload v0content = uploadContent("pom.xml");
- FilePayload v1content = uploadContent("../README.md");
+ FilePayload v1content = uploadContent("../../README.md");
// Create the metadata of the cookbook
Metadata metadata = Metadata.builder() //
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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 f655d52..013b6c7 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
@@ -46,6 +46,7 @@ public class ListNodesInEnvironmentImplLiveTest extends BaseChefLiveTest<ChefApi
@Override
protected void initialize() {
super.initialize();
+ this.prefix = this.prefix + "-" + this.hashCode();
this.creator = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
this.strategy = injector.getInstance(ListNodesInEnvironmentImpl.class);
creator.execute(prefix, ImmutableSet.<String>of());
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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 a8f7438..b3a3148 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
@@ -40,6 +40,7 @@ public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefLiveTes
@Override
protected void initialize() {
super.initialize();
+ this.prefix = this.prefix + "-" + this.hashCode();
this.currentUserProvider = injector.getInstance(CurrentUserProvider.class);
this.strategy = injector.getInstance(UpdateAutomaticAttributesOnNodeImpl.class);
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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
index fdccf46..bdf45c2 100644
--- a/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApiMetadata.java
+++ b/providers/enterprisechef/src/main/java/org/jclouds/enterprisechef/EnterpriseChefApiMetadata.java
@@ -19,8 +19,8 @@ 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.ChefContext;
import org.jclouds.chef.config.ChefBootstrapModule;
import org.jclouds.chef.config.ChefParserModule;
import org.jclouds.enterprisechef.config.EnterpriseChefHttpApiModule;
@@ -44,7 +44,7 @@ public class EnterpriseChefApiMetadata extends BaseHttpApiMetadata<EnterpriseChe
this(new Builder());
}
- protected EnterpriseChefApiMetadata(Builder builder) {
+ protected EnterpriseChefApiMetadata(final Builder builder) {
super(builder);
}
@@ -62,7 +62,6 @@ public class EnterpriseChefApiMetadata extends BaseHttpApiMetadata<EnterpriseChe
.version(ChefApiMetadata.DEFAULT_API_VERSION)
.documentation(URI.create("http://www.opscode.com/support"))
.defaultEndpoint("https://api.opscode.com")
- .view(ChefContext.class)
.defaultProperties(EnterpriseChefApiMetadata.defaultProperties())
.defaultModules(
ImmutableSet.<Class<? extends Module>> of(EnterpriseChefHttpApiModule.class,
[2/2] jclouds git commit: Remove the deprecated methods in Chef
Posted by na...@apache.org.
Remove the deprecated methods in Chef
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/4863bb83
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/4863bb83
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/4863bb83
Branch: refs/heads/master
Commit: 4863bb83a94084ebca446f42bf62f619f260e56e
Parents: deeebe4
Author: Ignasi Barrera <na...@apache.org>
Authored: Thu Apr 30 17:20:47 2015 +0200
Committer: Ignasi Barrera <na...@apache.org>
Committed: Sun May 3 22:22:44 2015 +0200
----------------------------------------------------------------------
.../src/main/java/org/jclouds/chef/ChefApi.java | 66 +++++++-------
.../java/org/jclouds/chef/ChefApiMetadata.java | 1 -
.../main/java/org/jclouds/chef/ChefContext.java | 42 ---------
.../main/java/org/jclouds/chef/ChefService.java | 27 +-----
.../jclouds/chef/config/ChefParserModule.java | 24 -----
.../org/jclouds/chef/config/CookbookParser.java | 43 ---------
.../chef/config/CookbookVersionsParser.java | 43 ---------
...seCookbookDefinitionCheckingChefVersion.java | 51 -----------
.../ParseCookbookDefinitionFromJson.java | 26 +++---
.../ParseCookbookDefinitionFromJsonv10.java | 52 -----------
.../ParseCookbookDefinitionListFromJson.java | 63 ++++++++++++++
.../ParseCookbookDefinitionListFromJsonv10.java | 63 --------------
.../functions/ParseCookbookNamesFromJson.java | 50 +++++++++++
...arseCookbookVersionsCheckingChefVersion.java | 51 -----------
.../ParseCookbookVersionsFromJson.java | 59 +++++++++++++
.../ParseCookbookVersionsV09FromJson.java | 51 -----------
.../ParseCookbookVersionsV10FromJson.java | 59 -------------
.../jclouds/chef/internal/BaseChefService.java | 44 +++-------
.../jclouds/chef/internal/ChefContextImpl.java | 62 -------------
.../test/java/org/jclouds/chef/ChefApiTest.java | 4 +-
.../chef/functions/ParseClientFromJsonTest.java | 1 +
...okbookDefinitionCheckingChefVersionTest.java | 62 -------------
.../ParseCookbookDefinitionFromJsonTest.java | 25 +++---
.../ParseCookbookDefinitionFromJsonv10Test.java | 74 ----------------
...ParseCookbookDefinitionListFromJsonTest.java | 92 ++++++++++++++++++++
...seCookbookDefinitionListFromJsonv10Test.java | 92 --------------------
.../ParseCookbookNamesFromJsonTest.java | 72 +++++++++++++++
...CookbookVersionsCheckingChefVersionTest.java | 62 -------------
.../ParseCookbookVersionsFromJsonTest.java | 68 +++++++++++++++
.../ParseCookbookVersionsV09FromJsonTest.java | 61 -------------
.../ParseCookbookVersionsV10FromJsonTest.java | 68 ---------------
...CleanupStaleNodesAndClientsImplLiveTest.java | 1 +
...PopulateAutomaticAttributesImplLiveTest.java | 1 +
...DeleteAllApisAndNodesInListImplLiveTest.java | 1 +
...okbookVersionsInEnvironmentImplLiveTest.java | 4 +-
.../ListNodesInEnvironmentImplLiveTest.java | 1 +
...teAutomaticAttributesOnNodeImplLiveTest.java | 1 +
.../EnterpriseChefApiMetadata.java | 5 +-
38 files changed, 490 insertions(+), 1082 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/ChefApi.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/ChefApi.java b/apis/chef/src/main/java/org/jclouds/chef/ChefApi.java
index 0c4889b..1fe0f1b 100644
--- a/apis/chef/src/main/java/org/jclouds/chef/ChefApi.java
+++ b/apis/chef/src/main/java/org/jclouds/chef/ChefApi.java
@@ -56,10 +56,10 @@ import org.jclouds.chef.domain.Sandbox;
import org.jclouds.chef.domain.SearchResult;
import org.jclouds.chef.domain.UploadSandbox;
import org.jclouds.chef.filters.SignedHeaderAuth;
-import org.jclouds.chef.functions.ParseCookbookDefinitionCheckingChefVersion;
-import org.jclouds.chef.functions.ParseCookbookDefinitionFromJsonv10;
-import org.jclouds.chef.functions.ParseCookbookDefinitionListFromJsonv10;
-import org.jclouds.chef.functions.ParseCookbookVersionsCheckingChefVersion;
+import org.jclouds.chef.functions.ParseCookbookDefinitionListFromJson;
+import org.jclouds.chef.functions.ParseCookbookNamesFromJson;
+import org.jclouds.chef.functions.ParseCookbookDefinitionFromJson;
+import org.jclouds.chef.functions.ParseCookbookVersionsFromJson;
import org.jclouds.chef.functions.ParseKeySetFromJson;
import org.jclouds.chef.functions.ParseSearchClientsFromJson;
import org.jclouds.chef.functions.ParseSearchDatabagFromJson;
@@ -118,7 +118,7 @@ public interface ChefApi extends Closeable {
/**
* Gets the details of existing client.
*
- * @param clientname The name of the client to get.
+ * @param clientName The name of the client to get.
* @return The details of the given client.
*/
@Named("client:get")
@@ -130,7 +130,7 @@ public interface ChefApi extends Closeable {
/**
* Creates a new client.
*
- * @param clientname The name of the new client
+ * @param clientName The name of the new client
* @return The client with the generated private key. This key should be
* stored so client can be properly authenticated .
*/
@@ -143,7 +143,7 @@ public interface ChefApi extends Closeable {
/**
* Creates a new client with custom options.
*
- * @param clientname The name of the new client
+ * @param clientName The name of the new client
* @param options The options to customize the client creation.
* @return The client with the generated private key. This key should be
* stored so client can be properly authenticated .
@@ -158,7 +158,7 @@ public interface ChefApi extends Closeable {
* Generates a new key-pair for this client, and return the new private key in
* the response body.
*
- * @param clientname The name of the client.
+ * @param clientName The name of the client.
* @return The details of the client with the new private key.
*/
@Named("client:generatekey")
@@ -170,7 +170,7 @@ public interface ChefApi extends Closeable {
/**
* Deletes the given client.
*
- * @param clientname The name of the client to delete.
+ * @param clientName The name of the client to delete.
* @return The deleted client.
*/
@Named("client:delete")
@@ -189,14 +189,14 @@ public interface ChefApi extends Closeable {
@Named("cookbook:list")
@GET
@Path("/cookbooks")
- @ResponseParser(ParseCookbookDefinitionCheckingChefVersion.class)
+ @ResponseParser(ParseCookbookNamesFromJson.class)
@Fallback(EmptySetOnNotFoundOr404.class)
Set<String> listCookbooks();
/**
* Lists the cookbooks that are available in the given environment.
*
- * @param environmentname The name of the environment to get the cookbooks
+ * @param environmentName The name of the environment to get the cookbooks
* from.
* @return The definitions of the cookbooks (name, URL and versions) available in
* the given environment.
@@ -204,7 +204,7 @@ public interface ChefApi extends Closeable {
@SinceApiVersion("0.10.0")
@Named("cookbook:list")
@GET
- @ResponseParser(ParseCookbookDefinitionListFromJsonv10.class)
+ @ResponseParser(ParseCookbookDefinitionListFromJson.class)
@Path("/environments/{environmentname}/cookbooks")
@Fallback(EmptySetOnNotFoundOr404.class)
Set<CookbookDefinition> listCookbooksInEnvironment(@PathParam("environmentname") String environmentName);
@@ -213,9 +213,9 @@ public interface ChefApi extends Closeable {
* Lists the cookbooks that are available in the given environment, limiting
* the number of versions returned for each cookbook.
*
- * @param environmentname The name of the environment to get the cookbooks
+ * @param environmentName The name of the environment to get the cookbooks
* from.
- * @param numversions The number of cookbook versions to include in the
+ * @param numVersions The number of cookbook versions to include in the
* response, where n is the number of cookbook versions.
* @return The definitions of the cookbooks (name, URL and versions) available in
* the given environment.
@@ -223,7 +223,7 @@ public interface ChefApi extends Closeable {
@SinceApiVersion("0.10.0")
@Named("cookbook:list")
@GET
- @ResponseParser(ParseCookbookDefinitionListFromJsonv10.class)
+ @ResponseParser(ParseCookbookDefinitionListFromJson.class)
@Path("/environments/{environmentname}/cookbooks?num_versions={numversions}")
@Fallback(EmptySetOnNotFoundOr404.class)
Set<CookbookDefinition> listCookbooksInEnvironment(@PathParam("environmentname") String environmentName,
@@ -238,7 +238,7 @@ public interface ChefApi extends Closeable {
@Named("cookbook:versions")
@GET
@Path("/cookbooks/{cookbookname}")
- @ResponseParser(ParseCookbookVersionsCheckingChefVersion.class)
+ @ResponseParser(ParseCookbookVersionsFromJson.class)
@Fallback(EmptySetOnNotFoundOr404.class)
Set<String> listVersionsOfCookbook(@PathParam("cookbookname") String cookbookName);
@@ -259,15 +259,15 @@ public interface ChefApi extends Closeable {
/**
* Gets the definition of the cookbook in the given environment.
*
- * @param environmentname The name of the environment.
- * @param cookbookname The name of the cookbook.
+ * @param environmentName The name of the environment.
+ * @param cookbookName The name of the cookbook.
* @return The definition of the cookbook (URL and versions) of the cookbook
* in the given environment.
*/
@SinceApiVersion("0.10.0")
@Named("environment:cookbook")
@GET
- @ResponseParser(ParseCookbookDefinitionFromJsonv10.class)
+ @ResponseParser(ParseCookbookDefinitionFromJson.class)
@Path("/environments/{environmentname}/cookbooks/{cookbookname}")
CookbookDefinition getCookbookInEnvironment(@PathParam("environmentname") String environmentName,
@PathParam("cookbookname") String cookbookName);
@@ -275,9 +275,9 @@ public interface ChefApi extends Closeable {
/**
* Gets the definition of the cookbook in the given environment.
*
- * @param environmentname The name of the environment.
- * @param cookbookname The name of the cookbook.
- * @param numversions The number of cookbook versions to include in the
+ * @param environmentName The name of the environment.
+ * @param cookbookName The name of the cookbook.
+ * @param numVersions The number of cookbook versions to include in the
* response, where n is the number of cookbook versions.
* @return The definition of the cookbook (URL and versions) of the cookbook
* in the given environment.
@@ -285,7 +285,7 @@ public interface ChefApi extends Closeable {
@SinceApiVersion("0.10.0")
@Named("environment:cookbook")
@GET
- @ResponseParser(ParseCookbookDefinitionFromJsonv10.class)
+ @ResponseParser(ParseCookbookDefinitionFromJson.class)
@Path("/environments/{environmentname}/cookbooks/{cookbookname}?num_versions={numversions}")
CookbookDefinition getCookbookInEnvironment(@PathParam("environmentname") String environmentName,
@PathParam("cookbookname") String cookbookName, @PathParam("numversions") String numVersions);
@@ -293,7 +293,7 @@ public interface ChefApi extends Closeable {
/**
* Lists the names of the recipes in the given environment.
*
- * @param environmentname The name of the environment.
+ * @param environmentName The name of the environment.
* @return The names of the recipes in the given environment.
*/
@SinceApiVersion("0.10.0")
@@ -396,8 +396,8 @@ public interface ChefApi extends Closeable {
* Adds an item in a data bag.
*
* @param databagName The name of the data bag.
- * @param The item to add to the data bag.
- * @param The item just added to the data bag.
+ * @param databagItem item to add to the data bag.
+ * @return The item just added to the data bag.
*/
@Named("databag:createitem")
@POST
@@ -452,7 +452,7 @@ public interface ChefApi extends Closeable {
/**
* Gets the details of an existing environment.
*
- * @param environmentname The name of the environment to get.
+ * @param environmentName The name of the environment to get.
* @return The details of the given environment.
*/
@SinceApiVersion("0.10.0")
@@ -489,7 +489,7 @@ public interface ChefApi extends Closeable {
/**
* Deletes the given environment.
*
- * @param environmentname The name of the environment to delete.
+ * @param environmentName The name of the environment to delete.
* @return The details of the deleted environment.
*/
@SinceApiVersion("0.10.0")
@@ -516,7 +516,7 @@ public interface ChefApi extends Closeable {
/**
* Lists the names of the nodes in the given environment.
*
- * @param environmentname The name of the environment.
+ * @param environmentName The name of the environment.
* @return The names of the existing nodes in the given environment.
*/
@SinceApiVersion("0.10.0")
@@ -530,7 +530,7 @@ public interface ChefApi extends Closeable {
/**
* Gets the details of the given node.
*
- * @param nodename The name of the node to get.
+ * @param nodeName The name of the node to get.
* @return The details of the given node.
*/
@Named("node:get")
@@ -563,7 +563,7 @@ public interface ChefApi extends Closeable {
/**
* Deletes the given node.
*
- * @param nodename The name of the node to delete.
+ * @param nodeName The name of the node to delete.
* @return The details of the deleted node.
*/
@Named("node:delete")
@@ -589,7 +589,7 @@ public interface ChefApi extends Closeable {
/**
* Gets the details of the given role.
*
- * @param rolename The name of the role to get.
+ * @param roleName The name of the role to get.
* @return The details of the given role.
*/
@Named("role:get")
@@ -622,7 +622,7 @@ public interface ChefApi extends Closeable {
/**
* Deletes the given role.
*
- * @param rolename The name of the role to delete.
+ * @param roleName The name of the role to delete.
* @return The details of the deleted role.
*/
@Named("role:delete")
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/ChefApiMetadata.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/ChefApiMetadata.java b/apis/chef/src/main/java/org/jclouds/chef/ChefApiMetadata.java
index d983a98..41a46df 100644
--- a/apis/chef/src/main/java/org/jclouds/chef/ChefApiMetadata.java
+++ b/apis/chef/src/main/java/org/jclouds/chef/ChefApiMetadata.java
@@ -93,7 +93,6 @@ public class ChefApiMetadata extends BaseHttpApiMetadata<ChefApi> {
.documentation(URI.create("http://wiki.opscode.com/display/chef/Server+API"))
.defaultEndpoint("http://localhost:4000")
.defaultProperties(ChefApiMetadata.defaultProperties())
- .view(ChefContext.class)
.defaultModules(
ImmutableSet.<Class<? extends Module>> of(ChefHttpApiModule.class, ChefParserModule.class,
ChefBootstrapModule.class, JMXOhaiModule.class));
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/ChefContext.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/ChefContext.java b/apis/chef/src/main/java/org/jclouds/chef/ChefContext.java
deleted file mode 100644
index 794116d..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/ChefContext.java
+++ /dev/null
@@ -1,42 +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;
-
-import java.io.Closeable;
-
-import org.jclouds.View;
-import org.jclouds.chef.internal.ChefContextImpl;
-
-import com.google.inject.ImplementedBy;
-
-/**
- * Provides an entry point to Chef features.
- *
- * @deprecated Will be removed in next version. Directly create the
- * {@link ChefApi} instead and access the {@link ChefService} from
- * it.
- */
-@ImplementedBy(ChefContextImpl.class)
-@Deprecated
-public interface ChefContext extends View, Closeable {
-
- /**
- * Provides access to high level Chef features.
- */
- ChefService getChefService();
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/ChefService.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/ChefService.java b/apis/chef/src/main/java/org/jclouds/chef/ChefService.java
index e15d00c..ff0cc5c 100644
--- a/apis/chef/src/main/java/org/jclouds/chef/ChefService.java
+++ b/apis/chef/src/main/java/org/jclouds/chef/ChefService.java
@@ -18,7 +18,6 @@ package org.jclouds.chef;
import java.io.IOException;
import java.io.InputStream;
-import java.util.List;
import java.util.concurrent.ExecutorService;
import org.jclouds.chef.config.ChefProperties;
@@ -34,7 +33,6 @@ import org.jclouds.ohai.config.OhaiModule;
import org.jclouds.rest.annotations.SinceApiVersion;
import org.jclouds.scriptbuilder.domain.Statement;
-import com.google.common.io.InputSupplier;
import com.google.inject.ImplementedBy;
/**
@@ -43,32 +41,25 @@ import com.google.inject.ImplementedBy;
@ImplementedBy(BaseChefService.class)
public interface ChefService {
- /**
- * Gets the context that created this service.
- *
- * @return The context that created the service.
- */
- ChefContext getContext();
-
// Crypto
/**
* Encrypts the given input stream.
*
- * @param supplier The input stream to encrypt.
+ * @param input The input stream to encrypt.
* @return The encrypted bytes for the given input stream.
* @throws IOException If there is an error reading from the input stream.
*/
- byte[] encrypt(InputSupplier<? extends InputStream> supplier) throws IOException;
+ byte[] encrypt(InputStream input) throws IOException;
/**
* Decrypts the given input stream.
*
- * @param supplier The input stream to decrypt.
+ * @param input The input stream to decrypt.
* @return The decrypted bytes for the given input stream.
* @throws IOException If there is an error reading from the input stream.
*/
- byte[] decrypt(InputSupplier<? extends InputStream> supplier) throws IOException;
+ byte[] decrypt(InputStream input) throws IOException;
// Bootstrap
@@ -104,16 +95,6 @@ public interface ChefService {
void updateBootstrapConfigForGroup(String group, BootstrapConfig bootstrapConfig);
/**
- * Gets the run list for the given group.
- *
- * @param The group to get the configured run list for.
- * @return run list for all nodes bootstrapped with a certain group
- * @deprecated USe {{@link #getBootstrapConfigForGroup(String)}.
- */
- @Deprecated
- List<String> getRunListForGroup(String group);
-
- /**
* Gets the bootstrap configuration for a given group.
*
* @param group The name of the group.
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/config/ChefParserModule.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/config/ChefParserModule.java b/apis/chef/src/main/java/org/jclouds/chef/config/ChefParserModule.java
index c00eda5..faa9304 100644
--- a/apis/chef/src/main/java/org/jclouds/chef/config/ChefParserModule.java
+++ b/apis/chef/src/main/java/org/jclouds/chef/config/ChefParserModule.java
@@ -30,27 +30,19 @@ import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.security.spec.InvalidKeySpecException;
import java.util.Map;
-import java.util.Set;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.chef.domain.DatabagItem;
-import org.jclouds.chef.functions.ParseCookbookDefinitionFromJson;
-import org.jclouds.chef.functions.ParseCookbookVersionsV09FromJson;
-import org.jclouds.chef.functions.ParseCookbookVersionsV10FromJson;
-import org.jclouds.chef.functions.ParseKeySetFromJson;
-import org.jclouds.chef.suppliers.ChefVersionSupplier;
import org.jclouds.crypto.Crypto;
import org.jclouds.crypto.Pems;
-import org.jclouds.http.HttpResponse;
import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
import org.jclouds.json.internal.NullFilteringTypeAdapterFactories.MapTypeAdapterFactory;
import org.jclouds.json.internal.NullHackJsonLiteralAdapter;
import com.google.common.base.Charsets;
-import com.google.common.base.Function;
import com.google.common.base.Objects;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
@@ -297,22 +289,6 @@ public class ChefParserModule extends AbstractModule {
PublicKey.class, publicAdapter, X509Certificate.class, certAdapter);
}
- @Provides
- @Singleton
- @CookbookParser
- public Function<HttpResponse, Set<String>> provideCookbookDefinitionAdapter(ChefVersionSupplier chefVersionSupplier,
- ParseCookbookDefinitionFromJson v10parser, ParseKeySetFromJson v09parser) {
- return chefVersionSupplier.get() >= 10 ? v10parser : v09parser;
- }
-
- @Provides
- @Singleton
- @CookbookVersionsParser
- public Function<HttpResponse, Set<String>> provideCookbookDefinitionAdapter(ChefVersionSupplier chefVersionSupplier,
- ParseCookbookVersionsV10FromJson v10parser, ParseCookbookVersionsV09FromJson v09parser) {
- return chefVersionSupplier.get() >= 10 ? v10parser : v09parser;
- }
-
@Override
protected void configure() {
bind(DateAdapter.class).to(Iso8601DateAdapter.class);
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/config/CookbookParser.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/config/CookbookParser.java b/apis/chef/src/main/java/org/jclouds/chef/config/CookbookParser.java
deleted file mode 100644
index 22048c5..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/config/CookbookParser.java
+++ /dev/null
@@ -1,43 +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.config;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Used to configure the cookbook Json parser.
- * <p>
- * Chef Server version 0.9 and 0.10 return a different Json when rquesting the
- * cookbook definitions. This annotation can be used to setup the cookbook
- * parser.
- * @deprecated Support for Chef 0.9 and 0.10 will be removed in upcoming versions.
- */
-@Target({ METHOD, PARAMETER, FIELD })
-@Retention(RUNTIME)
-@Qualifier
-@Deprecated
-public @interface CookbookParser {
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/config/CookbookVersionsParser.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/config/CookbookVersionsParser.java b/apis/chef/src/main/java/org/jclouds/chef/config/CookbookVersionsParser.java
deleted file mode 100644
index 5fd2ba5..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/config/CookbookVersionsParser.java
+++ /dev/null
@@ -1,43 +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.config;
-
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.ElementType.PARAMETER;
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-import javax.inject.Qualifier;
-
-/**
- * Used to configure the cookbook versions Json parser.
- * <p>
- * Chef Server version 0.9 and 0.10 return a different Json when rquesting the
- * cookbook versions. This annotation can be used to setup the cookbook versions
- * parser.
- * @deprecated Support for Chef 0.9 and 0.10 will be removed in upcoming versions.
- */
-@Target({ METHOD, PARAMETER, FIELD })
-@Retention(RUNTIME)
-@Qualifier
-@Deprecated
-public @interface CookbookVersionsParser {
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java
deleted file mode 100644
index 53c6ea7..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersion.java
+++ /dev/null
@@ -1,51 +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.functions;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.config.CookbookParser;
-import org.jclouds.http.HttpResponse;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-
-/**
- * Parses a cookbook definition from a Json response, taking care of using the
- * appropriate parser.
- * @deprecated Support for Chef 0.9 and 0.10 will be removed in upcoming verions.
- */
-@Singleton
-@Deprecated
-public class ParseCookbookDefinitionCheckingChefVersion implements Function<HttpResponse, Set<String>> {
-
- @VisibleForTesting
- final Function<HttpResponse, Set<String>> parser;
-
- @Inject
- ParseCookbookDefinitionCheckingChefVersion(@CookbookParser Function<HttpResponse, Set<String>> parser) {
- this.parser = parser;
- }
-
- @Override
- public Set<String> apply(HttpResponse response) {
- return parser.apply(response);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java
index 3e172e4..6848bc0 100644
--- a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java
+++ b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJson.java
@@ -16,24 +16,20 @@
*/
package org.jclouds.chef.functions;
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
+import com.google.common.base.Function;
import org.jclouds.chef.domain.CookbookDefinition;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseJson;
-import com.google.common.base.Function;
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.util.Map;
/**
- * Parses a cookbook definition from a Json response, assuming a Chef Server >=
- * 0.10.8.
+ * Parses the cookbook versions in a Chef Server >= 0.10.8.
*/
@Singleton
-public class ParseCookbookDefinitionFromJson implements Function<HttpResponse, Set<String>> {
+public class ParseCookbookDefinitionFromJson implements Function<HttpResponse, CookbookDefinition> {
/** Parser for responses from chef server >= 0.10.8 */
private final ParseJson<Map<String, CookbookDefinition>> parser;
@@ -44,7 +40,13 @@ public class ParseCookbookDefinitionFromJson implements Function<HttpResponse, S
}
@Override
- public Set<String> apply(HttpResponse response) {
- return parser.apply(response).keySet();
+ public CookbookDefinition apply(HttpResponse response) {
+ Map<String, CookbookDefinition> result = parser.apply(response);
+ String cookbookName = result.keySet().iterator().next();
+ CookbookDefinition def = result.values().iterator().next();
+ return CookbookDefinition.builder() //
+ .from(def) //
+ .name(cookbookName) //
+ .build();
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java
deleted file mode 100644
index 692d969..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10.java
+++ /dev/null
@@ -1,52 +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.functions;
-
-import com.google.common.base.Function;
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import java.util.Map;
-
-/**
- * Parses the cookbook versions in a Chef Server >= 0.10.8.
- */
-@Singleton
-public class ParseCookbookDefinitionFromJsonv10 implements Function<HttpResponse, CookbookDefinition> {
-
- /** Parser for responses from chef server >= 0.10.8 */
- private final ParseJson<Map<String, CookbookDefinition>> parser;
-
- @Inject
- ParseCookbookDefinitionFromJsonv10(ParseJson<Map<String, CookbookDefinition>> parser) {
- this.parser = parser;
- }
-
- @Override
- public CookbookDefinition apply(HttpResponse response) {
- Map<String, CookbookDefinition> result = parser.apply(response);
- String cookbookName = result.keySet().iterator().next();
- CookbookDefinition def = result.values().iterator().next();
- return CookbookDefinition.builder() //
- .from(def) //
- .name(cookbookName) //
- .build();
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJson.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJson.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJson.java
new file mode 100644
index 0000000..1d91039
--- /dev/null
+++ b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJson.java
@@ -0,0 +1,63 @@
+/*
+ * 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.functions;
+
+import com.google.common.base.Function;
+import org.jclouds.chef.domain.CookbookDefinition;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+import java.util.Map;
+import java.util.Set;
+
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Sets.newLinkedHashSet;
+
+/**
+ * Parses the cookbook versions in a Chef Server >= 0.10.8.
+ */
+@Singleton
+public class ParseCookbookDefinitionListFromJson implements Function<HttpResponse, Set<CookbookDefinition>> {
+
+ /**
+ * Parser for responses from chef server >= 0.10.8
+ */
+ private final ParseJson<Map<String, CookbookDefinition>> parser;
+
+ @Inject
+ ParseCookbookDefinitionListFromJson(ParseJson<Map<String, CookbookDefinition>> parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public Set<CookbookDefinition> apply(HttpResponse response) {
+ Set<Map.Entry<String, CookbookDefinition>> result = parser.apply(response).entrySet();
+ return newLinkedHashSet(transform(result, new Function<Map.Entry<String, CookbookDefinition>, CookbookDefinition>() {
+ @Override
+ public CookbookDefinition apply(Map.Entry<String, CookbookDefinition> input) {
+ String cookbookName = input.getKey();
+ CookbookDefinition def = input.getValue();
+ return CookbookDefinition.builder() //
+ .from(def) //
+ .name(cookbookName) //
+ .build();
+ }
+ }));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java
deleted file mode 100644
index 5da0797..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10.java
+++ /dev/null
@@ -1,63 +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.functions;
-
-import com.google.common.base.Function;
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.collect.Iterables.transform;
-import static com.google.common.collect.Sets.newLinkedHashSet;
-
-/**
- * Parses the cookbook versions in a Chef Server >= 0.10.8.
- */
-@Singleton
-public class ParseCookbookDefinitionListFromJsonv10 implements Function<HttpResponse, Set<CookbookDefinition>> {
-
- /**
- * Parser for responses from chef server >= 0.10.8
- */
- private final ParseJson<Map<String, CookbookDefinition>> parser;
-
- @Inject
- ParseCookbookDefinitionListFromJsonv10(ParseJson<Map<String, CookbookDefinition>> parser) {
- this.parser = parser;
- }
-
- @Override
- public Set<CookbookDefinition> apply(HttpResponse response) {
- Set<Map.Entry<String, CookbookDefinition>> result = parser.apply(response).entrySet();
- return newLinkedHashSet(transform(result, new Function<Map.Entry<String, CookbookDefinition>, CookbookDefinition>() {
- @Override
- public CookbookDefinition apply(Map.Entry<String, CookbookDefinition> input) {
- String cookbookName = input.getKey();
- CookbookDefinition def = input.getValue();
- return CookbookDefinition.builder() //
- .from(def) //
- .name(cookbookName) //
- .build();
- }
- }));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookNamesFromJson.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookNamesFromJson.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookNamesFromJson.java
new file mode 100644
index 0000000..ae25036
--- /dev/null
+++ b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookNamesFromJson.java
@@ -0,0 +1,50 @@
+/*
+ * 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.functions;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.chef.domain.CookbookDefinition;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+
+import com.google.common.base.Function;
+
+/**
+ * Parses a cookbook definition from a Json response, assuming a Chef Server >=
+ * 0.10.8.
+ */
+@Singleton
+public class ParseCookbookNamesFromJson implements Function<HttpResponse, Set<String>> {
+
+ /** Parser for responses from chef server >= 0.10.8 */
+ private final ParseJson<Map<String, CookbookDefinition>> parser;
+
+ @Inject
+ ParseCookbookNamesFromJson(ParseJson<Map<String, CookbookDefinition>> parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public Set<String> apply(HttpResponse response) {
+ return parser.apply(response).keySet();
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java
deleted file mode 100644
index e98b27a..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsCheckingChefVersion.java
+++ /dev/null
@@ -1,51 +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.functions;
-
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.config.CookbookVersionsParser;
-import org.jclouds.http.HttpResponse;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Function;
-
-/**
- * Parses a cookbook versions from a Json response, taking care of using the
- * appropriate parser.
- * @deprecated Support for Chef 0.9 and 0.10 will be removed in upcoming verions.
- */
-@Singleton
-@Deprecated
-public class ParseCookbookVersionsCheckingChefVersion implements Function<HttpResponse, Set<String>> {
-
- @VisibleForTesting
- final Function<HttpResponse, Set<String>> parser;
-
- @Inject
- ParseCookbookVersionsCheckingChefVersion(@CookbookVersionsParser Function<HttpResponse, Set<String>> parser) {
- this.parser = parser;
- }
-
- @Override
- public Set<String> apply(HttpResponse response) {
- return parser.apply(response);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJson.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJson.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJson.java
new file mode 100644
index 0000000..ac77dfa
--- /dev/null
+++ b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsFromJson.java
@@ -0,0 +1,59 @@
+/*
+ * 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.functions;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.inject.Inject;
+import javax.inject.Singleton;
+
+import org.jclouds.chef.domain.CookbookDefinition;
+import org.jclouds.chef.domain.CookbookDefinition.Version;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.http.functions.ParseJson;
+
+import com.google.common.base.Function;
+import static com.google.common.collect.Iterables.getFirst;
+import static com.google.common.collect.Iterables.transform;
+import static com.google.common.collect.Sets.newLinkedHashSet;
+
+/**
+ * Parses the cookbook versions in a Chef Server >= 0.10.8.
+ */
+@Singleton
+public class ParseCookbookVersionsFromJson implements Function<HttpResponse, Set<String>> {
+
+ /** Parser for responses from chef server >= 0.10.8 */
+ private final ParseJson<Map<String, CookbookDefinition>> parser;
+
+ @Inject
+ ParseCookbookVersionsFromJson(ParseJson<Map<String, CookbookDefinition>> parser) {
+ this.parser = parser;
+ }
+
+ @Override
+ public Set<String> apply(HttpResponse response) {
+ CookbookDefinition def = getFirst(parser.apply(response).values(), null);
+ return newLinkedHashSet(transform(def.getVersions(), new Function<Version, String>() {
+ @Override
+ public String apply(Version input) {
+ return input.getVersion();
+ }
+ }));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java
deleted file mode 100644
index 4bc76d4..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV09FromJson.java
+++ /dev/null
@@ -1,51 +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.functions;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import com.google.common.base.Function;
-import static com.google.common.collect.Iterables.getFirst;
-
-/**
- * Parses the cookbook versions in a Chef Server <= 0.9.8.
- * @deprecated Support for Chef 0.9 and 0.10 will be removed in upcoming versions.
- */
-@Singleton
-@Deprecated
-public class ParseCookbookVersionsV09FromJson implements Function<HttpResponse, Set<String>> {
-
- private final ParseJson<Map<String, Set<String>>> json;
-
- @Inject
- ParseCookbookVersionsV09FromJson(ParseJson<Map<String, Set<String>>> json) {
- this.json = json;
- }
-
- @Override
- public Set<String> apply(HttpResponse response) {
- return getFirst(json.apply(response).values(), null);
-
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java b/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java
deleted file mode 100644
index 1a25ac0..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/functions/ParseCookbookVersionsV10FromJson.java
+++ /dev/null
@@ -1,59 +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.functions;
-
-import java.util.Map;
-import java.util.Set;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.chef.domain.CookbookDefinition.Version;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.http.functions.ParseJson;
-
-import com.google.common.base.Function;
-import static com.google.common.collect.Iterables.getFirst;
-import static com.google.common.collect.Iterables.transform;
-import static com.google.common.collect.Sets.newLinkedHashSet;
-
-/**
- * Parses the cookbook versions in a Chef Server >= 0.10.8.
- */
-@Singleton
-public class ParseCookbookVersionsV10FromJson implements Function<HttpResponse, Set<String>> {
-
- /** Parser for responses from chef server >= 0.10.8 */
- private final ParseJson<Map<String, CookbookDefinition>> parser;
-
- @Inject
- ParseCookbookVersionsV10FromJson(ParseJson<Map<String, CookbookDefinition>> parser) {
- this.parser = parser;
- }
-
- @Override
- public Set<String> apply(HttpResponse response) {
- CookbookDefinition def = getFirst(parser.apply(response).values(), null);
- return newLinkedHashSet(transform(def.getVersions(), new Function<Version, String>() {
- @Override
- public String apply(Version input) {
- return input.getVersion();
- }
- }));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/internal/BaseChefService.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/internal/BaseChefService.java b/apis/chef/src/main/java/org/jclouds/chef/internal/BaseChefService.java
index ca79b77..f80456e 100644
--- a/apis/chef/src/main/java/org/jclouds/chef/internal/BaseChefService.java
+++ b/apis/chef/src/main/java/org/jclouds/chef/internal/BaseChefService.java
@@ -22,8 +22,6 @@ import static org.jclouds.chef.config.ChefProperties.CHEF_BOOTSTRAP_DATABAG;
import java.io.IOException;
import java.io.InputStream;
import java.security.PrivateKey;
-import java.util.List;
-import java.util.Map;
import java.util.concurrent.ExecutorService;
import javax.annotation.Resource;
@@ -32,7 +30,6 @@ import javax.inject.Named;
import javax.inject.Singleton;
import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
import org.jclouds.chef.ChefService;
import org.jclouds.chef.config.ChefProperties;
import org.jclouds.chef.domain.BootstrapConfig;
@@ -56,6 +53,7 @@ import org.jclouds.chef.strategy.ListNodesInEnvironment;
import org.jclouds.chef.strategy.UpdateAutomaticAttributesOnNode;
import org.jclouds.crypto.Crypto;
import org.jclouds.io.ByteStreams2;
+import org.jclouds.io.Payload;
import org.jclouds.io.Payloads;
import org.jclouds.io.payloads.RSADecryptingPayload;
import org.jclouds.io.payloads.RSAEncryptingPayload;
@@ -65,14 +63,11 @@ import org.jclouds.logging.Logger;
import org.jclouds.scriptbuilder.domain.Statement;
import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
import com.google.common.base.Supplier;
-import com.google.common.io.InputSupplier;
@Singleton
public class BaseChefService implements ChefService {
- private final ChefContext chefContext;
private final ChefApi api;
private final CleanupStaleNodesAndClients cleanupStaleNodesAndClients;
private final CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes;
@@ -97,7 +92,7 @@ public class BaseChefService implements ChefService {
protected Logger logger = Logger.NULL;
@Inject
- BaseChefService(ChefContext chefContext, ChefApi api, CleanupStaleNodesAndClients cleanupStaleNodesAndClients,
+ BaseChefService(ChefApi api, CleanupStaleNodesAndClients cleanupStaleNodesAndClients,
CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes,
DeleteAllNodesInList deleteAllNodesInList, ListNodes listNodes, DeleteAllClientsInList deleteAllClientsInList,
ListClients listClients, ListCookbookVersions listCookbookVersions,
@@ -106,7 +101,6 @@ public class BaseChefService implements ChefService {
BootstrapConfigForGroup bootstrapConfigForGroup, ListEnvironments listEnvironments,
ListNodesInEnvironment listNodesInEnvironment,
ListCookbookVersionsInEnvironment listCookbookVersionsInEnvironment, Json json, Crypto crypto) {
- this.chefContext = chefContext;
this.api = api;
this.cleanupStaleNodesAndClients = cleanupStaleNodesAndClients;
this.createNodeAndPopulateAutomaticAttributes = createNodeAndPopulateAutomaticAttributes;
@@ -128,26 +122,17 @@ public class BaseChefService implements ChefService {
}
@Override
- public ChefContext getContext() {
- return chefContext;
+ public byte[] encrypt(InputStream input) throws IOException {
+ @SuppressWarnings("resource")
+ Payload payload = new RSAEncryptingPayload(crypto, Payloads.newPayload(input), privateKey.get());
+ return ByteStreams2.toByteArrayAndClose(payload.openStream());
}
@Override
- public byte[] encrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
- return ByteStreams2.toByteArrayAndClose(new RSAEncryptingPayload(crypto,
- Payloads.newPayload(supplier.getInput()), privateKey.get()).openStream());
- }
-
- @Override
- public byte[] decrypt(InputSupplier<? extends InputStream> supplier) throws IOException {
- return ByteStreams2.toByteArrayAndClose(new RSADecryptingPayload(crypto,
- Payloads.newPayload(supplier.getInput()), privateKey.get()).openStream());
- }
-
- private static void putIfPresent(Map<String, Object> configMap, Optional<?> configProperty, String name) {
- if (configProperty.isPresent()) {
- configMap.put(name, configProperty.get().toString());
- }
+ public byte[] decrypt(InputStream input) throws IOException {
+ @SuppressWarnings("resource")
+ Payload payload = new RSADecryptingPayload(crypto, Payloads.newPayload(input), privateKey.get());
+ return ByteStreams2.toByteArrayAndClose(payload.openStream());
}
@Override
@@ -184,15 +169,6 @@ public class BaseChefService implements ChefService {
return json.toJson(config);
}
- /**
- * @deprecated Use {{@link #getBootstrapConfigForGroup(String)}.
- */
- @Override
- @Deprecated
- public List<String> getRunListForGroup(String group) {
- return getBootstrapConfigForGroup(group).getRunList();
- }
-
@Override
public BootstrapConfig getBootstrapConfigForGroup(String group) {
return bootstrapConfigForGroup.apply(group);
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java b/apis/chef/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
deleted file mode 100644
index e7d1170..0000000
--- a/apis/chef/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
+++ /dev/null
@@ -1,62 +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.base.Preconditions.checkNotNull;
-
-import java.io.IOException;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.Context;
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
-import org.jclouds.chef.ChefService;
-import org.jclouds.internal.BaseView;
-import org.jclouds.location.Provider;
-
-import com.google.common.reflect.TypeToken;
-
-/**
- * @deprecated Will be removed in next version. Directly create the
- * {@link ChefApi} instead and access the {@link ChefService} from
- * it.
- */
-@Singleton
-@Deprecated
-public class ChefContextImpl extends BaseView implements ChefContext {
- private final ChefService chefService;
-
- @Inject
- protected ChefContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
- ChefService chefService) {
- super(backend, backendType);
- this.chefService = checkNotNull(chefService, "chefService");
- }
-
- @Override
- public ChefService getChefService() {
- return chefService;
- }
-
- @Override
- public void close() throws IOException {
- delegate().close();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/ChefApiTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/ChefApiTest.java b/apis/chef/src/test/java/org/jclouds/chef/ChefApiTest.java
index f998a95..99a2da0 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/ChefApiTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/ChefApiTest.java
@@ -39,7 +39,7 @@ import org.jclouds.chef.domain.Resource;
import org.jclouds.chef.domain.Role;
import org.jclouds.chef.filters.SignedHeaderAuth;
import org.jclouds.chef.filters.SignedHeaderAuthTest;
-import org.jclouds.chef.functions.ParseCookbookVersionsCheckingChefVersion;
+import org.jclouds.chef.functions.ParseCookbookVersionsFromJson;
import org.jclouds.chef.functions.ParseKeySetFromJson;
import org.jclouds.chef.functions.ParseSearchClientsFromJson;
import org.jclouds.chef.functions.ParseSearchDatabagFromJson;
@@ -199,7 +199,7 @@ public class ChefApiTest extends BaseRestAnnotationProcessingTest<ChefApi> {
+ "-test\n");
assertPayloadEquals(httpRequest, null, null, false);
- assertResponseParserClassEquals(method, httpRequest, ParseCookbookVersionsCheckingChefVersion.class);
+ assertResponseParserClassEquals(method, httpRequest, ParseCookbookVersionsFromJson.class);
assertSaxResponseParserClassEquals(method, null);
assertFallbackClassEquals(method, EmptySetOnNotFoundOr404.class);
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/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 1382a6c..e218af5 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
@@ -79,6 +79,7 @@ public class ParseClientFromJsonTest {
privateKey = crypto.rsaKeyFactory().generatePrivate(Pems.privateKeySpec(ByteSource.wrap(PRIVATE_KEY.getBytes(Charsets.UTF_8))));
}
+ @SuppressWarnings("resource")
public void test() 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/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersionTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersionTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersionTest.java
deleted file mode 100644
index 300c8e0..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionCheckingChefVersionTest.java
+++ /dev/null
@@ -1,62 +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.functions;
-
-import static org.testng.Assert.assertTrue;
-
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.testng.annotations.Test;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-/**
- * Tests behavior of {@code ParseCookbookDefinitionCheckingChefVersion}.
- */
-@Test(groups = { "unit" }, singleThreaded = true)
-public class ParseCookbookDefinitionCheckingChefVersionTest {
-
- public void testParserFor09() {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance("0.9.8");
- }
- }, new ChefParserModule(), new GsonModule());
-
- ParseCookbookDefinitionCheckingChefVersion parser = injector
- .getInstance(ParseCookbookDefinitionCheckingChefVersion.class);
- assertTrue(parser.parser instanceof ParseKeySetFromJson);
- }
-
- public void testParserFor010() {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance("0.10.8");
- }
- }, new ChefParserModule(), new GsonModule());
-
- ParseCookbookDefinitionCheckingChefVersion parser = injector
- .getInstance(ParseCookbookDefinitionCheckingChefVersion.class);
- assertTrue(parser.parser instanceof ParseCookbookDefinitionFromJson);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonTest.java
index 736b283..956eb89 100644
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonTest.java
+++ b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonTest.java
@@ -19,25 +19,25 @@ package org.jclouds.chef.functions;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
import org.jclouds.chef.ChefApiMetadata;
import org.jclouds.chef.config.ChefParserModule;
+import org.jclouds.chef.domain.CookbookDefinition;
import org.jclouds.http.HttpResponse;
import org.jclouds.json.config.GsonModule;
import org.jclouds.rest.annotations.ApiVersion;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
-import com.google.common.collect.ImmutableSet;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
-/**
- * Tests behavior of {@code ParseCookbookDefinitionFromJson}.
- */
@Test(groups = { "unit" }, singleThreaded = true)
-public class ParseCookbookDefinitionFromJsonTest {
+public class ParseCookbookDefinitionFromJsonTest
+{
private ParseCookbookDefinitionFromJson handler;
@@ -53,7 +53,14 @@ public class ParseCookbookDefinitionFromJsonTest {
handler = injector.getInstance(ParseCookbookDefinitionFromJson.class);
}
- public void testParse010Response() {
+ public void testCookbokDefinitionParsing() throws URISyntaxException {
+ CookbookDefinition.Version v510 = CookbookDefinition.Version.builder()
+ .url(new URI("http://localhost:4000/cookbooks/apache2/5.1.0")).version("5.1.0").build();
+ CookbookDefinition.Version v420 = CookbookDefinition.Version.builder()
+ .url(new URI("http://localhost:4000/cookbooks/apache2/4.2.0")).version("4.2.0").build();
+ CookbookDefinition definition = CookbookDefinition.builder()
+ .name("apache2").url(new URI("http://localhost:4000/cookbooks/apache2")).version(v510).version(v420).build();
+
assertEquals(handler.apply(HttpResponse
.builder()
.statusCode(200)
@@ -63,10 +70,6 @@ public class ParseCookbookDefinitionFromJsonTest {
+ "\"versions\" => [" + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/5.1.0\","
+ "\"version\" => \"5.1.0\"},"
+ "{\"url\" => \"http://localhost:4000/cookbooks/apache2/4.2.0\","
- + "\"version\" => \"4.2.0\"}" + "]" + "}," + "\"nginx\" => {"
- + "\"url\" => \"http://localhost:4000/cookbooks/nginx\"," + "\"versions\" => ["
- + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/1.0.0\"," + "\"version\" => \"1.0.0\"},"
- + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/0.3.0\"," + "\"version\" => \"0.3.0\"}"
- + "]" + "}" + "}").build()), ImmutableSet.of("apache2", "nginx"));
+ + "\"version\" => \"4.2.0\"}" + "]" + "}" + "}").build()), definition);
}
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10Test.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10Test.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10Test.java
deleted file mode 100644
index b5d8a8b..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionFromJsonv10Test.java
+++ /dev/null
@@ -1,74 +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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.jclouds.chef.ChefApiMetadata;
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-@Test(groups = { "unit" }, singleThreaded = true)
-public class ParseCookbookDefinitionFromJsonv10Test {
-
- private ParseCookbookDefinitionFromJsonv10 handler;
-
- @BeforeTest
- protected void setUpInjector() throws IOException {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_API_VERSION);
- }
- }, new ChefParserModule(), new GsonModule());
-
- handler = injector.getInstance(ParseCookbookDefinitionFromJsonv10.class);
- }
-
- public void testCookbokDefinitionParsing() throws URISyntaxException {
- CookbookDefinition.Version v510 = CookbookDefinition.Version.builder()
- .url(new URI("http://localhost:4000/cookbooks/apache2/5.1.0")).version("5.1.0").build();
- CookbookDefinition.Version v420 = CookbookDefinition.Version.builder()
- .url(new URI("http://localhost:4000/cookbooks/apache2/4.2.0")).version("4.2.0").build();
- CookbookDefinition definition = CookbookDefinition.builder()
- .name("apache2").url(new URI("http://localhost:4000/cookbooks/apache2")).version(v510).version(v420).build();
-
- assertEquals(handler.apply(HttpResponse
- .builder()
- .statusCode(200)
- .message("ok")
- .payload(
- "{" + "\"apache2\" => {" + "\"url\" => \"http://localhost:4000/cookbooks/apache2\","
- + "\"versions\" => [" + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/5.1.0\","
- + "\"version\" => \"5.1.0\"},"
- + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/4.2.0\","
- + "\"version\" => \"4.2.0\"}" + "]" + "}" + "}").build()), definition);
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonTest.java
new file mode 100644
index 0000000..ffac979
--- /dev/null
+++ b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonTest.java
@@ -0,0 +1,92 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jclouds.chef.ChefApiMetadata;
+import org.jclouds.chef.config.ChefParserModule;
+import org.jclouds.chef.domain.CookbookDefinition;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.rest.annotations.ApiVersion;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+@Test(groups = {"unit"}, singleThreaded = true)
+public class ParseCookbookDefinitionListFromJsonTest
+{
+ private ParseCookbookDefinitionListFromJson handler;
+
+ @BeforeTest
+ protected void setUpInjector() throws IOException {
+ Injector injector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_API_VERSION);
+ }
+ }, new ChefParserModule(), new GsonModule());
+
+ handler = injector.getInstance(ParseCookbookDefinitionListFromJson.class);
+ }
+
+ public void testCookbokDefinitionListParsing() throws URISyntaxException {
+ CookbookDefinition.Version v510 = CookbookDefinition.Version.builder()
+ .url(new URI("http://localhost:4000/cookbooks/apache2/5.1.0")).version("5.1.0").build();
+ CookbookDefinition.Version v420 = CookbookDefinition.Version.builder()
+ .url(new URI("http://localhost:4000/cookbooks/apache2/4.2.0")).version("4.2.0").build();
+ CookbookDefinition apache2 = CookbookDefinition.builder()
+ .name("apache2").url(new URI("http://localhost:4000/cookbooks/apache2")).version(v510).version(v420).build();
+
+ CookbookDefinition.Version v100 = CookbookDefinition.Version.builder()
+ .url(new URI("http://localhost:4000/cookbooks/nginx/1.0.0")).version("1.0.0").build();
+ CookbookDefinition.Version v030 = CookbookDefinition.Version.builder()
+ .url(new URI("http://localhost:4000/cookbooks/nginx/0.3.0")).version("0.3.0").build();
+ CookbookDefinition nginx = CookbookDefinition.builder()
+ .name("nginx").url(new URI("http://localhost:4000/cookbooks/nginx")).version(v100).version(v030).build();
+
+ assertEquals(handler.apply(HttpResponse
+ .builder()
+ .statusCode(200)
+ .message("ok")
+ .payload(
+ "{" + "\"apache2\" => {" + "\"url\" => \"http://localhost:4000/cookbooks/apache2\","
+ + "\"versions\" => [" + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/5.1.0\","
+ + "\"version\" => \"5.1.0\"},"
+ + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/4.2.0\","
+ + "\"version\" => \"4.2.0\"}" + "]" + "},"
+ + "\"nginx\" => {"
+ + "\"url\" => \"http://localhost:4000/cookbooks/nginx\","
+ + "\"versions\" => ["
+ + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/1.0.0\","
+ + "\"version\" => \"1.0.0\"},"
+ + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/0.3.0\","
+ + "\"version\" => \"0.3.0\"}"
+ + "]}" +
+ "}").build()),
+ ImmutableSet.of(apache2, nginx));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10Test.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10Test.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10Test.java
deleted file mode 100644
index 04f8e35..0000000
--- a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookDefinitionListFromJsonv10Test.java
+++ /dev/null
@@ -1,92 +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.functions;
-
-import static org.testng.Assert.assertEquals;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.jclouds.chef.ChefApiMetadata;
-import org.jclouds.chef.config.ChefParserModule;
-import org.jclouds.chef.domain.CookbookDefinition;
-import org.jclouds.http.HttpResponse;
-import org.jclouds.json.config.GsonModule;
-import org.jclouds.rest.annotations.ApiVersion;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.AbstractModule;
-import com.google.inject.Guice;
-import com.google.inject.Injector;
-
-@Test(groups = {"unit"}, singleThreaded = true)
-public class ParseCookbookDefinitionListFromJsonv10Test {
-
- private ParseCookbookDefinitionListFromJsonv10 handler;
-
- @BeforeTest
- protected void setUpInjector() throws IOException {
- Injector injector = Guice.createInjector(new AbstractModule() {
- @Override
- protected void configure() {
- bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_API_VERSION);
- }
- }, new ChefParserModule(), new GsonModule());
-
- handler = injector.getInstance(ParseCookbookDefinitionListFromJsonv10.class);
- }
-
- public void testCookbokDefinitionListParsing() throws URISyntaxException {
- CookbookDefinition.Version v510 = CookbookDefinition.Version.builder()
- .url(new URI("http://localhost:4000/cookbooks/apache2/5.1.0")).version("5.1.0").build();
- CookbookDefinition.Version v420 = CookbookDefinition.Version.builder()
- .url(new URI("http://localhost:4000/cookbooks/apache2/4.2.0")).version("4.2.0").build();
- CookbookDefinition apache2 = CookbookDefinition.builder()
- .name("apache2").url(new URI("http://localhost:4000/cookbooks/apache2")).version(v510).version(v420).build();
-
- CookbookDefinition.Version v100 = CookbookDefinition.Version.builder()
- .url(new URI("http://localhost:4000/cookbooks/nginx/1.0.0")).version("1.0.0").build();
- CookbookDefinition.Version v030 = CookbookDefinition.Version.builder()
- .url(new URI("http://localhost:4000/cookbooks/nginx/0.3.0")).version("0.3.0").build();
- CookbookDefinition nginx = CookbookDefinition.builder()
- .name("nginx").url(new URI("http://localhost:4000/cookbooks/nginx")).version(v100).version(v030).build();
-
- assertEquals(handler.apply(HttpResponse
- .builder()
- .statusCode(200)
- .message("ok")
- .payload(
- "{" + "\"apache2\" => {" + "\"url\" => \"http://localhost:4000/cookbooks/apache2\","
- + "\"versions\" => [" + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/5.1.0\","
- + "\"version\" => \"5.1.0\"},"
- + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/4.2.0\","
- + "\"version\" => \"4.2.0\"}" + "]" + "},"
- + "\"nginx\" => {"
- + "\"url\" => \"http://localhost:4000/cookbooks/nginx\","
- + "\"versions\" => ["
- + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/1.0.0\","
- + "\"version\" => \"1.0.0\"},"
- + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/0.3.0\","
- + "\"version\" => \"0.3.0\"}"
- + "]}" +
- "}").build()),
- ImmutableSet.of(apache2, nginx));
- }
-}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/4863bb83/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookNamesFromJsonTest.java
----------------------------------------------------------------------
diff --git a/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookNamesFromJsonTest.java b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookNamesFromJsonTest.java
new file mode 100644
index 0000000..39102ee
--- /dev/null
+++ b/apis/chef/src/test/java/org/jclouds/chef/functions/ParseCookbookNamesFromJsonTest.java
@@ -0,0 +1,72 @@
+/*
+ * 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.functions;
+
+import static org.testng.Assert.assertEquals;
+
+import java.io.IOException;
+
+import org.jclouds.chef.ChefApiMetadata;
+import org.jclouds.chef.config.ChefParserModule;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.json.config.GsonModule;
+import org.jclouds.rest.annotations.ApiVersion;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableSet;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * Tests behavior of {@code ParseCookbookNamesFromJson}.
+ */
+@Test(groups = { "unit" }, singleThreaded = true)
+public class ParseCookbookNamesFromJsonTest
+{
+ private ParseCookbookNamesFromJson handler;
+
+ @BeforeTest
+ protected void setUpInjector() throws IOException {
+ Injector injector = Guice.createInjector(new AbstractModule() {
+ @Override
+ protected void configure() {
+ bind(String.class).annotatedWith(ApiVersion.class).toInstance(ChefApiMetadata.DEFAULT_API_VERSION);
+ }
+ }, new ChefParserModule(), new GsonModule());
+
+ handler = injector.getInstance(ParseCookbookNamesFromJson.class);
+ }
+
+ public void testParse010Response() {
+ assertEquals(handler.apply(HttpResponse
+ .builder()
+ .statusCode(200)
+ .message("ok")
+ .payload(
+ "{" + "\"apache2\" => {" + "\"url\" => \"http://localhost:4000/cookbooks/apache2\","
+ + "\"versions\" => [" + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/5.1.0\","
+ + "\"version\" => \"5.1.0\"},"
+ + "{\"url\" => \"http://localhost:4000/cookbooks/apache2/4.2.0\","
+ + "\"version\" => \"4.2.0\"}" + "]" + "}," + "\"nginx\" => {"
+ + "\"url\" => \"http://localhost:4000/cookbooks/nginx\"," + "\"versions\" => ["
+ + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/1.0.0\"," + "\"version\" => \"1.0.0\"},"
+ + "{\"url\" => \"http://localhost:4000/cookbooks/nginx/0.3.0\"," + "\"version\" => \"0.3.0\"}"
+ + "]" + "}" + "}").build()), ImmutableSet.of("apache2", "nginx"));
+ }
+}