Deprecate async apis. Fixes #70

* Deprecated all async apis.
* Refactored tests to extend BaseApiLiveTest.
* ChefContext now extends View.
* HostedChefApi now extends ChefApi.
* PatchedChefApi has been removed.
* Removed HostedChefContext and PrivateChefContext because they are now
  redundant. The concrete apis can be unwrapped from teh ChefContext
  view.
diff --git a/compute/src/test/java/org/jclouds/chef/compute/ChefComputeServiceLiveTest.java b/compute/src/test/java/org/jclouds/chef/compute/ChefComputeServiceLiveTest.java
index 5095c70..42cc63e 100644
--- a/compute/src/test/java/org/jclouds/chef/compute/ChefComputeServiceLiveTest.java
+++ b/compute/src/test/java/org/jclouds/chef/compute/ChefComputeServiceLiveTest.java
@@ -33,6 +33,7 @@
 import java.util.List;
 
 import org.jclouds.chef.ChefApi;
+import org.jclouds.chef.ChefAsyncApi;
 import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.compute.internal.BaseComputeServiceIntegratedChefClientLiveTest;
 import org.jclouds.chef.domain.CookbookVersion;
@@ -54,7 +55,7 @@
 @Test(groups = "live", testName = "ChefComputeServiceLiveTest")
 public class ChefComputeServiceLiveTest
 		extends
-			BaseComputeServiceIntegratedChefClientLiveTest<ChefContext> {
+			BaseComputeServiceIntegratedChefClientLiveTest {
 
 	private String group;
 	private String clientName;
@@ -64,14 +65,14 @@
 	public void testCanUpdateRunList() throws IOException {
 		String recipe = "apache2";
 
-		Iterable<? extends CookbookVersion> cookbookVersions = context
+		Iterable<? extends CookbookVersion> cookbookVersions = view
 				.getChefService().listCookbookVersions();
 
 		if (any(cookbookVersions, containsRecipe(recipe))) {
 			List<String> runList = new RunListBuilder().addRecipe(recipe)
 					.build();
-			context.getChefService().updateRunListForGroup(runList, group);
-			assertEquals(context.getChefService().getRunListForGroup(group),
+			view.getChefService().updateRunListForGroup(runList, group);
+			assertEquals(view.getChefService().getRunListForGroup(group),
 					runList);
 		} else {
 			assert false : String.format("recipe %s not in %s", recipe,
@@ -91,7 +92,7 @@
 	@Test(dependsOnMethods = "testCanUpdateRunList")
 	public void testRunNodesWithBootstrap() throws IOException {
 
-		Statement bootstrap = context.getChefService()
+		Statement bootstrap = view.getChefService()
 				.createBootstrapScriptForGroup(group);
 
 		try {
@@ -118,22 +119,20 @@
 			computeContext.getComputeService().destroyNodesMatching(
 					NodePredicates.inGroup(group));
 		if (context != null) {
-			context.getChefService()
+		   view.getChefService()
 					.cleanupStaleNodesAndClients(group + "-", 1);
-			if (clientName != null && context.getApi().clientExists(clientName))
-				context.getApi().deleteClient(clientName);
+		   ChefApi api = view.unwrap(new TypeToken<org.jclouds.rest.RestContext<ChefApi, ChefAsyncApi>>() {
+         }).getApi();
+			if (clientName != null && api.clientExists(clientName))
+				api.deleteClient(clientName);
 			context.close();
 		}
 		super.tearDownContext();
 	}
 
-	@Override
-	protected ChefApi getChefApi(ChefContext context) {
-		return context.getApi();
-	}
+   @Override
+   protected TypeToken<ChefContext> viewType() {
+      return typeToken(ChefContext.class);
+   }
 
-	@Override
-	protected TypeToken<ChefContext> contextType() {
-		return typeToken(ChefContext.class);
-	}
 }
diff --git a/compute/src/test/java/org/jclouds/chef/compute/internal/BaseComputeServiceIntegratedChefClientLiveTest.java b/compute/src/test/java/org/jclouds/chef/compute/internal/BaseComputeServiceIntegratedChefClientLiveTest.java
index 31c7970..a4024a4 100644
--- a/compute/src/test/java/org/jclouds/chef/compute/internal/BaseComputeServiceIntegratedChefClientLiveTest.java
+++ b/compute/src/test/java/org/jclouds/chef/compute/internal/BaseComputeServiceIntegratedChefClientLiveTest.java
@@ -23,9 +23,9 @@
 import java.util.concurrent.ConcurrentHashMap;
 
 import org.jclouds.Constants;
-import org.jclouds.Context;
 import org.jclouds.ContextBuilder;
-import org.jclouds.chef.internal.BaseChefContextLiveTest;
+import org.jclouds.apis.BaseViewLiveTest;
+import org.jclouds.chef.ChefContext;
 import org.jclouds.compute.ComputeServiceContext;
 import org.jclouds.compute.domain.TemplateBuilderSpec;
 import org.jclouds.domain.LoginCredentials;
@@ -45,9 +45,9 @@
 /**
  * @author Adrian Cole
  */
-public abstract class BaseComputeServiceIntegratedChefClientLiveTest<C extends Context>
+public abstract class BaseComputeServiceIntegratedChefClientLiveTest
 		extends
-			BaseChefContextLiveTest<C> {
+			BaseViewLiveTest<ChefContext> {
 
 	protected TemplateBuilderSpec template;
 	protected LoginCredentials loginCredentials = LoginCredentials.builder()
diff --git a/core/pom.xml b/core/pom.xml
index d0f4576..6504b32 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -39,8 +39,6 @@
         <test.chef.build-version />
         <test.chef.identity>chef-webui</test.chef.identity>
         <test.chef.credential>${user.home}/.chef/webui.pem</test.chef.credential>
-        <test.chef.validator.identity>chef-validator</test.chef.validator.identity>
-        <test.chef.validator.credential>${user.home}/.chef/validation.pem</test.chef.validator.credential>
         <jclouds.osgi.import>
           org.jclouds;version=${project.version},
           org.jclouds*;version=${project.version},
@@ -119,8 +117,7 @@
                                         <test.chef.api-version>${test.chef.api-version}</test.chef.api-version>
                                         <test.chef.build-version>${test.chef.build-version}</test.chef.build-version>
                                         <test.chef.identity>${test.chef.identity}</test.chef.identity>
-                                        <test.chef.validator.identity>${test.chef.validator.identity}</test.chef.validator.identity>
-                                        <test.chef.validator.credential>${test.chef.validator.credential}</test.chef.validator.credential>
+                                        <test.chef.credential>${test.chef.credential}</test.chef.credential>
                                     </systemPropertyVariables>
                                 </configuration>
                             </execution>
diff --git a/core/src/main/java/org/jclouds/chef/ChefApiMetadata.java b/core/src/main/java/org/jclouds/chef/ChefApiMetadata.java
index 28c038e..3a1c276 100644
--- a/core/src/main/java/org/jclouds/chef/ChefApiMetadata.java
+++ b/core/src/main/java/org/jclouds/chef/ChefApiMetadata.java
@@ -25,7 +25,6 @@
 import static org.jclouds.chef.config.ChefProperties.CHEF_BOOTSTRAP_DATABAG;
 import static org.jclouds.chef.config.ChefProperties.CHEF_UPDATE_GEMS;
 import static org.jclouds.chef.config.ChefProperties.CHEF_UPDATE_GEM_SYSTEM;
-import static org.jclouds.reflect.Reflection2.typeToken;
 
 import java.net.URI;
 import java.util.Properties;
@@ -93,7 +92,7 @@
                .documentation(URI.create("http://wiki.opscode.com/display/chef/Server+API"))
                .defaultEndpoint("http://localhost:4000")
                .defaultProperties(ChefApiMetadata.defaultProperties())
-               .context(typeToken(ChefContext.class))
+               .view(ChefContext.class)
                .defaultModules(
                      ImmutableSet.<Class<? extends Module>> of(ChefRestClientModule.class, ChefParserModule.class,
                            ChefBootstrapModule.class, JMXOhaiModule.class));
diff --git a/core/src/main/java/org/jclouds/chef/ChefAsyncApi.java b/core/src/main/java/org/jclouds/chef/ChefAsyncApi.java
index 92b7546..46d6730 100644
--- a/core/src/main/java/org/jclouds/chef/ChefAsyncApi.java
+++ b/core/src/main/java/org/jclouds/chef/ChefAsyncApi.java
@@ -95,7 +95,10 @@
  * 
  * @see ChefApi
  * @author Adrian Cole
+ * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(ChefApi.class)} as
+ *             {@link ChefAsyncApi} interface will be removed in jclouds 1.7.
  */
+@Deprecated
 @RequestFilters(SignedHeaderAuth.class)
 @Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
 @Consumes(MediaType.APPLICATION_JSON)
diff --git a/core/src/main/java/org/jclouds/chef/ChefContext.java b/core/src/main/java/org/jclouds/chef/ChefContext.java
index 08d0889..04cecd3 100644
--- a/core/src/main/java/org/jclouds/chef/ChefContext.java
+++ b/core/src/main/java/org/jclouds/chef/ChefContext.java
@@ -18,8 +18,10 @@
  */
 package org.jclouds.chef;
 
+import java.io.Closeable;
+
+import org.jclouds.View;
 import org.jclouds.chef.internal.ChefContextImpl;
-import org.jclouds.rest.RestContext;
 
 import com.google.inject.ImplementedBy;
 
@@ -30,7 +32,7 @@
  * 
  */
 @ImplementedBy(ChefContextImpl.class)
-public interface ChefContext extends RestContext<ChefApi, ChefAsyncApi> {
+public interface ChefContext extends View, Closeable {
 
    ChefService getChefService();
 
diff --git a/core/src/main/java/org/jclouds/chef/ChefContextFactory.java b/core/src/main/java/org/jclouds/chef/ChefContextFactory.java
deleted file mode 100644
index 25e4acd..0000000
--- a/core/src/main/java/org/jclouds/chef/ChefContextFactory.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds 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 static org.jclouds.reflect.Reflection2.typeToken;
-
-import java.util.NoSuchElementException;
-import java.util.Properties;
-
-import org.jclouds.ContextBuilder;
-import org.jclouds.View;
-import org.jclouds.apis.Apis;
-import org.jclouds.javax.annotation.Nullable;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.providers.Providers;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.inject.Module;
-
-/**
- * 
- * @see ContextBuilder
- * @author Adrian Cole
- */
-@Deprecated
-public class ChefContextFactory {
-
-   /**
-    * for porting old code to {@link ContextBuilder}
-    */
-   public ChefContextFactory() {
-   }
-
-   /**
-    * for porting old code to {@link ContextBuilder}
-    */
-   public ChefContextFactory(Properties properties) {
-   }
-
-   /**
-    * @see #createContext(String, String,String, Iterable, Properties)
-    */
-   public ChefContext createContext(String providerOrApi, String identity, String credential) {
-      return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), new Properties());
-   }
-
-   /**
-    * @see #createContext(String, String, String, Iterable, Properties)
-    */
-   public ChefContext createContext(String providerOrApi, Properties overrides) {
-      return createContext(providerOrApi, null, null, ImmutableSet.<Module> of(), overrides);
-   }
-
-   /**
-    * @see #createContext(String, String,String, Iterable, Properties)
-    */
-   public ChefContext createContext(String providerOrApi, Iterable<? extends Module> wiring, Properties overrides) {
-      return createContext(providerOrApi, null, null, wiring, overrides);
-   }
-
-   /**
-    * @see #createContext(String, String,String, Iterable, Properties)
-    */
-   public ChefContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential,
-         Properties overrides) {
-      return createContext(providerOrApi, identity, credential, ImmutableSet.<Module> of(), overrides);
-   }
-
-   /**
-    * @see createContext(String, String,String, Iterable, Properties)
-    */
-   public ChefContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential,
-         Iterable<? extends Module> wiring) {
-      return createContext(providerOrApi, identity, credential, wiring, new Properties());
-   }
-
-   /**
-    * for porting old code to {@link ContextBuilder}
-    * 
-    * @param providerOrApi
-    * @param identity
-    *           nullable, if credentials are present in the overrides
-    * @param credential
-    *           nullable, if credentials are present in the overrides
-    * @param wiring
-    *           Configuration you'd like to pass to the context. Ex.
-    *           ImmutableSet.<Module>of(new ExecutorServiceModule(myexecutor))
-    * @param overrides
-    *           properties to override defaults with.
-    * @return initialized context ready for use
-    */
-   @SuppressWarnings("unchecked")
-   public ChefContext createContext(String providerOrApi, @Nullable String identity, @Nullable String credential,
-         Iterable<? extends Module> wiring, Properties overrides) {
-      ContextBuilder builder = null;
-      try {
-         ProviderMetadata pm = Providers.withId(providerOrApi);
-         builder = ContextBuilder.newBuilder(pm);
-      } catch (NoSuchElementException e) {
-         builder = ContextBuilder.newBuilder(Apis.withId(providerOrApi));
-      }
-      builder.modules(Iterable.class.cast(wiring));
-      builder.overrides(overrides);
-      if (identity != null)
-         builder.credentials(identity, credential);
-      Object context = builder.build();
-      if (context instanceof ChefContext) {
-         return ChefContext.class.cast(context);
-      } else if (context instanceof View) {
-         View tctx = View.class.cast(context);
-         return tctx.unwrap(typeToken(ChefContext.class));
-      } else {
-         throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: "
-               + context.getClass().getSimpleName());
-      }
-
-   }
-
-}
diff --git a/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java b/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java
index 3cc971a..b1532a4 100644
--- a/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java
+++ b/core/src/main/java/org/jclouds/chef/internal/BaseChefService.java
@@ -18,14 +18,21 @@
  */
 package org.jclouds.chef.internal;
 
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Optional;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.ByteStreams;
-import com.google.common.io.InputSupplier;
+import static com.google.common.base.Preconditions.checkNotNull;
+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 javax.annotation.Resource;
+import javax.inject.Inject;
+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;
@@ -55,18 +62,14 @@
 import org.jclouds.logging.Logger;
 import org.jclouds.scriptbuilder.domain.Statement;
 
-import javax.annotation.Resource;
-import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.PrivateKey;
-import java.util.List;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.jclouds.chef.config.ChefProperties.CHEF_BOOTSTRAP_DATABAG;
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.base.Optional;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.io.ByteStreams;
+import com.google.common.io.InputSupplier;
 
 /**
  * @author Adrian Cole
@@ -75,6 +78,7 @@
 public class BaseChefService implements ChefService {
 
    private final ChefContext chefContext;
+   private final ChefApi api;
    private final CleanupStaleNodesAndClients cleanupStaleNodesAndClients;
    private final CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes;
    private final DeleteAllNodesInList deleteAllNodesInList;
@@ -89,20 +93,23 @@
    private final RunListForGroup runListForGroup;
    private final ListCookbookVersions listCookbookVersions;
    private final ListEnvironments listEnvironments;
+   private final Json json;
    @Resource
    @Named(ChefProperties.CHEF_LOGGER)
    protected Logger logger = Logger.NULL;
 
    @Inject
-   protected BaseChefService(ChefContext chefContext, CleanupStaleNodesAndClients cleanupStaleNodesAndClients,
-                             CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes,
-                             DeleteAllNodesInList deleteAllNodesInList, ListNodes listNodes, DeleteAllClientsInList deleteAllClientsInList,
-                             ListClients listClients, ListCookbookVersions listCookbookVersions,
-                             UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode, Supplier<PrivateKey> privateKey,
-                             @Named(CHEF_BOOTSTRAP_DATABAG) String databag, GroupToBootScript groupToBootScript,
-                             BootstrapConfigForGroup bootstrapConfigForGroup, RunListForGroup runListForGroup,
-                             ListEnvironments listEnvironments) {
+   protected BaseChefService(ChefContext chefContext, ChefApi api,
+         CleanupStaleNodesAndClients cleanupStaleNodesAndClients,
+         CreateNodeAndPopulateAutomaticAttributes createNodeAndPopulateAutomaticAttributes,
+         DeleteAllNodesInList deleteAllNodesInList, ListNodes listNodes, DeleteAllClientsInList deleteAllClientsInList,
+         ListClients listClients, ListCookbookVersions listCookbookVersions,
+         UpdateAutomaticAttributesOnNode updateAutomaticAttributesOnNode, Supplier<PrivateKey> privateKey,
+         @Named(CHEF_BOOTSTRAP_DATABAG) String databag, GroupToBootScript groupToBootScript,
+         BootstrapConfigForGroup bootstrapConfigForGroup, RunListForGroup runListForGroup,
+         ListEnvironments listEnvironments, Json json) {
       this.chefContext = checkNotNull(chefContext, "chefContext");
+      this.api = checkNotNull(api, "api");
       this.cleanupStaleNodesAndClients = checkNotNull(cleanupStaleNodesAndClients, "cleanupStaleNodesAndClients");
       this.createNodeAndPopulateAutomaticAttributes = checkNotNull(createNodeAndPopulateAutomaticAttributes,
             "createNodeAndPopulateAutomaticAttributes");
@@ -119,6 +126,7 @@
       this.bootstrapConfigForGroup = checkNotNull(bootstrapConfigForGroup, "bootstrapConfigForGroup");
       this.runListForGroup = checkNotNull(runListForGroup, "runListForGroup");
       this.listEnvironments = checkNotNull(listEnvironments, "listEnvironments");
+      this.json = checkNotNull(json, "json");
    }
 
    @Override
@@ -215,7 +223,7 @@
    @Override
    public void updateBootstrapConfigForGroup(Iterable<String> runList, @Nullable JsonBall jsonAttributes, String group) {
       try {
-         chefContext.getApi().createDatabag(databag);
+         api.createDatabag(databag);
       } catch (IllegalStateException e) {
 
       }
@@ -223,10 +231,10 @@
       String bootstrapConfig = buildBootstrapConfiguration(runList, Optional.fromNullable(jsonAttributes));
       DatabagItem runlist = new DatabagItem(group, bootstrapConfig);
 
-      if (chefContext.getApi().getDatabagItem(databag, group) == null) {
-         chefContext.getApi().createDatabagItem(databag, runlist);
+      if (api.getDatabagItem(databag, group) == null) {
+         api.createDatabagItem(databag, runlist);
       } else {
-         chefContext.getApi().updateDatabagItem(databag, runlist);
+         api.updateDatabagItem(databag, runlist);
       }
    }
 
@@ -257,7 +265,6 @@
       checkNotNull(runList, "runList must not be null");
       checkNotNull(jsonAttributes, "jsonAttributes must not be null");
 
-      Json json = chefContext.utils().json();
       Map<String, Object> bootstrapConfig = Maps.newHashMap();
       bootstrapConfig.put("run_list", Lists.newArrayList(runList));
       if (jsonAttributes.isPresent()) {
diff --git a/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java b/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
index 565b14f..aa74075 100644
--- a/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
+++ b/core/src/main/java/org/jclouds/chef/internal/ChefContextImpl.java
@@ -18,38 +18,33 @@
  */
 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.annotations.Name;
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefAsyncApi;
+import org.jclouds.Context;
 import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.ChefService;
-import org.jclouds.domain.Credentials;
-import org.jclouds.lifecycle.Closer;
+import org.jclouds.internal.BaseView;
 import org.jclouds.location.Provider;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.Utils;
-import org.jclouds.rest.internal.RestContextImpl;
 
-import com.google.common.base.Supplier;
-import com.google.inject.Injector;
-import com.google.inject.TypeLiteral;
+import com.google.common.reflect.TypeToken;
 
 /**
  * @author Adrian Cole
  */
 @Singleton
-public class ChefContextImpl extends RestContextImpl<ChefApi, ChefAsyncApi> implements ChefContext {
+public class ChefContextImpl extends BaseView implements ChefContext {
    private final ChefService chefService;
 
    @Inject
-   protected ChefContextImpl(@Name String name, ProviderMetadata providerMetadata,
-         @Provider Supplier<Credentials> creds, Utils utils, Closer closer, Injector injector, ChefService chefService) {
-      super(name, providerMetadata, creds, utils, closer, injector, TypeLiteral.get(ChefApi.class), TypeLiteral
-            .get(ChefAsyncApi.class));
-      this.chefService = chefService;
+   protected ChefContextImpl(@Provider Context backend, @Provider TypeToken<? extends Context> backendType,
+         ChefService chefService) {
+      super(backend, backendType);
+      this.chefService = checkNotNull(chefService, "checkNotNull");
    }
 
    @Override
@@ -57,4 +52,9 @@
       return chefService;
    }
 
+   @Override
+   public void close() throws IOException {
+      delegate().close();
+   }
+
 }
diff --git a/core/src/main/java/org/jclouds/chef/test/TransientChefAsyncApi.java b/core/src/main/java/org/jclouds/chef/test/TransientChefAsyncApi.java
index 2ccb619..9b7a7c8 100644
--- a/core/src/main/java/org/jclouds/chef/test/TransientChefAsyncApi.java
+++ b/core/src/main/java/org/jclouds/chef/test/TransientChefAsyncApi.java
@@ -66,8 +66,9 @@
  * In-memory chef simulator.
  * 
  * @author Adrian Cole
+ * @deprecated {@link TransientChefAsyncApi} interface will be removed in jclouds 1.7.
  */
-
+@Deprecated
 public class TransientChefAsyncApi implements ChefAsyncApi {
    @Singleton
    private static class StorageMetadataToName implements Function<PageSet<? extends StorageMetadata>, Set<String>> {
diff --git a/core/src/test/java/org/jclouds/chef/ChefApiLiveTest.java b/core/src/test/java/org/jclouds/chef/ChefApiLiveTest.java
index 069f011..5a0b1f1 100644
--- a/core/src/test/java/org/jclouds/chef/ChefApiLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/ChefApiLiveTest.java
@@ -18,37 +18,19 @@
  */
 package org.jclouds.chef;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
-import static org.testng.Assert.assertNotNull;
-
-import org.jclouds.chef.domain.CookbookVersion;
 import org.jclouds.chef.internal.BaseChefApiLiveTest;
 import org.testng.annotations.Test;
 
-import com.google.common.reflect.TypeToken;
-
 /**
  * Tests behavior of {@code ChefApi} against a Chef Server <= 0.9.8.
  * 
  * @author Adrian Cole
  */
 @Test(groups = { "live" })
-public class ChefApiLiveTest extends BaseChefApiLiveTest<ChefContext> {
+public class ChefApiLiveTest extends BaseChefApiLiveTest<ChefApi> {
 
-   @Test
-   public void testListCookbookVersionsWithChefService() throws Exception {
-      Iterable<? extends CookbookVersion> cookbooks = context.getChefService().listCookbookVersions();
-      assertNotNull(cookbooks);
-   }
-
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
+   protected ChefApiLiveTest() {
+      provider = "chef";
    }
 
 }
diff --git a/core/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java b/core/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
index c294645..fc510d5 100644
--- a/core/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/internal/BaseChefApiLiveTest.java
@@ -36,7 +36,6 @@
 import java.util.Properties;
 import java.util.Set;
 
-import org.jclouds.Context;
 import org.jclouds.chef.ChefApi;
 import org.jclouds.chef.domain.ChecksumStatus;
 import org.jclouds.chef.domain.Client;
@@ -53,10 +52,8 @@
 import org.jclouds.crypto.Pems;
 import org.jclouds.io.Payloads;
 import org.jclouds.io.payloads.FilePayload;
-import org.jclouds.rest.AuthorizationException;
 import org.jclouds.rest.ResourceNotFoundException;
 import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Predicate;
@@ -71,39 +68,13 @@
  * @author Adrian Cole
  */
 @Test(groups = { "live", "integration" })
-public abstract class BaseChefApiLiveTest<C extends Context> extends BaseChefContextLiveTest<C> {
-   public static final String PREFIX = System.getProperty("user.name") + "-jcloudstest";
-   public static final String ADMIN_PREFIX = System.getProperty("user.name") + "-jcloudstest-adm";
-   public static final String VALIDATOR_PREFIX = System.getProperty("user.name") + "-jcloudstest-val";
-
-   protected String validatorIdentity;
-   protected String validatorCredential;
-   protected C validatorContext;
-   protected ChefApi validatorClient;
+public abstract class BaseChefApiLiveTest<A extends ChefApi> extends BaseChefLiveTest<A> {
+   public static final String PREFIX = "jcloudstest-" + System.getProperty("user.name");
+   public static final String ADMIN_PREFIX = "jcloudstest-adm-" + System.getProperty("user.name");
 
    // It may take a bit until the search index is populated
    protected int maxWaitForIndexInMs = 60000;
 
-   protected ChefApi chefApi;
-
-   protected Properties setupValidatorProperties() {
-      Properties overrides = setupProperties();
-      validatorIdentity = setIfTestSystemPropertyPresent(overrides, provider + ".validator.identity");
-      validatorCredential = setCredentialFromPemFile(overrides, validatorIdentity, provider + ".validator.credential");
-      overrides.setProperty(provider + ".identity", validatorIdentity);
-      overrides.setProperty(provider + ".credential", validatorCredential);
-      return overrides;
-   }
-
-   @BeforeClass(groups = { "integration", "live" })
-   @Override
-   public void setupContext() {
-      super.setupContext();
-      validatorContext = createContext(setupValidatorProperties(), setupModules());
-      chefApi = getChefApi(context);
-      validatorClient = getChefApi(validatorContext);
-   }
-
    private Node node;
    private Role role;
    protected DatabagItem databagItem;
@@ -123,7 +94,7 @@
       List<Byte> md5 = Bytes.asList(content.getContentMetadata().getContentMD5());
 
       // request an upload site for this file
-      UploadSandbox site = chefApi.getUploadSandboxForChecksums(ImmutableSet.of(md5));
+      UploadSandbox site = api.getUploadSandboxForChecksums(ImmutableSet.of(md5));
 
       try {
          assert site.getChecksums().containsKey(md5) : md5 + " not in " + site.getChecksums();
@@ -131,13 +102,13 @@
          ChecksumStatus status = site.getChecksums().get(md5);
          if (status.needsUpload()) {
             // context.utils().http().put(status.getUrl(), content);
-            chefApi.uploadContent(status.getUrl(), content);
+            api.uploadContent(status.getUrl(), content);
          }
 
-         chefApi.commitSandbox(site.getSandboxId(), true);
+         api.commitSandbox(site.getSandboxId(), true);
 
       } catch (RuntimeException e) {
-         chefApi.commitSandbox(site.getSandboxId(), false);
+         api.commitSandbox(site.getSandboxId(), false);
       }
 
       // create a new cookbook
@@ -145,29 +116,29 @@
       cookbook.getRootFiles().add(new Resource(content));
 
       // upload the cookbook to the remote server
-      chefApi.updateCookbook(PREFIX, "0.0.0", cookbook);
+      api.updateCookbook(PREFIX, "0.0.0", cookbook);
    }
 
    @Test(dependsOnMethods = "testCreateClient")
    public void testGenerateKeyForClient() throws Exception {
-      String credential = Pems.pem(chefApi.generateKeyForClient(PREFIX).getPrivateKey());
+      String credential = Pems.pem(api.generateKeyForClient(PREFIX).getPrivateKey());
       assertClientCreated(PREFIX, credential);
    }
 
    @Test
    public void testListCookbooks() throws Exception {
-      Set<String> cookbookNames = chefApi.listCookbooks();
+      Set<String> cookbookNames = api.listCookbooks();
       assertFalse(cookbookNames.isEmpty());
 
       for (String cookbook : cookbookNames) {
-         for (String version : chefApi.getVersionsOfCookbook(cookbook)) {
-            CookbookVersion cookbookO = chefApi.getCookbook(cookbook, version);
+         for (String version : api.getVersionsOfCookbook(cookbook)) {
+            CookbookVersion cookbookO = api.getCookbook(cookbook, version);
             for (Resource resource : ImmutableList.<Resource> builder().addAll(cookbookO.getDefinitions())
                   .addAll(cookbookO.getFiles()).addAll(cookbookO.getLibraries()).addAll(cookbookO.getSuppliers())
                   .addAll(cookbookO.getRecipes()).addAll(cookbookO.getResources()).addAll(cookbookO.getRootFiles())
                   .addAll(cookbookO.getTemplates()).build()) {
                try {
-                  InputStream stream = chefApi.getResourceContents(resource);
+                  InputStream stream = api.getResourceContents(resource);
                   byte[] md5 = asByteSource(stream).hash(md5()).asBytes();
                   assertEquals(md5, resource.getChecksum());
                } catch (NullPointerException e) {
@@ -180,95 +151,75 @@
 
    @Test(dependsOnMethods = "testCreateNewCookbook")
    public void testUpdateCookbook() throws Exception {
-      CookbookVersion cookbook = chefApi.getCookbook(PREFIX, "0.0.0");
-      assertNotNull(chefApi.updateCookbook(PREFIX, "0.0.0", cookbook));
+      CookbookVersion cookbook = api.getCookbook(PREFIX, "0.0.0");
+      assertNotNull(api.updateCookbook(PREFIX, "0.0.0", cookbook));
    }
 
    @Test(dependsOnMethods = { "testCreateNewCookbook", "testUpdateCookbook" })
    public void testDeleteCookbook() throws Exception {
-      assertNotNull(chefApi.deleteCookbook(PREFIX, "0.0.0"));
-   }
-
-   @Test(expectedExceptions = AuthorizationException.class)
-   public void testValidatorCannotListClients() throws Exception {
-      for (String client : validatorClient.listClients()) {
-         assertNotNull(validatorClient.getClient(client));
-      }
-   }
-
-   @Test(expectedExceptions = AuthorizationException.class)
-   public void testValidatorCannotDeleteClient() throws Exception {
-      validatorClient.deleteClient(PREFIX);
-   }
-
-   @Test
-   public void testValidatorCreateClient() throws Exception {
-      chefApi.deleteClient(VALIDATOR_PREFIX);
-      String credential = Pems.pem(validatorClient.createClient(VALIDATOR_PREFIX).getPrivateKey());
-      assertClientCreated(VALIDATOR_PREFIX, credential);
+      assertNotNull(api.deleteCookbook(PREFIX, "0.0.0"));
    }
 
    @Test
    public void testCreateClient() throws Exception {
-      chefApi.deleteClient(PREFIX);
-      String credential = Pems.pem(chefApi.createClient(PREFIX).getPrivateKey());
+      api.deleteClient(PREFIX);
+      String credential = Pems.pem(api.createClient(PREFIX).getPrivateKey());
       assertClientCreated(PREFIX, credential);
    }
 
    @Test
    public void testCreateAdminClient() throws Exception {
-      chefApi.deleteClient(ADMIN_PREFIX);
-      String credential = Pems.pem(chefApi.createClient(ADMIN_PREFIX, CreateClientOptions.Builder.admin())
-            .getPrivateKey());
+      api.deleteClient(ADMIN_PREFIX);
+      String credential = Pems.pem(api.createClient(ADMIN_PREFIX, CreateClientOptions.Builder.admin()).getPrivateKey());
       assertClientCreated(ADMIN_PREFIX, credential);
    }
 
    @Test
    public void testClientExists() throws Exception {
-      assertNotNull(chefApi.clientExists(validatorIdentity));
+      assertNotNull(api.clientExists(identity));
    }
 
    @Test
    public void testListNodes() throws Exception {
-      Set<String> nodes = chefApi.listNodes();
+      Set<String> nodes = api.listNodes();
       assertNotNull(nodes);
    }
 
    @Test(dependsOnMethods = "testCreateRole")
    public void testCreateNode() throws Exception {
-      chefApi.deleteNode(PREFIX);
-      chefApi.createNode(new Node(PREFIX, Collections.singleton("role[" + PREFIX + "]"), "_default"));
-      node = chefApi.getNode(PREFIX);
+      api.deleteNode(PREFIX);
+      api.createNode(new Node(PREFIX, Collections.singleton("role[" + PREFIX + "]"), "_default"));
+      node = api.getNode(PREFIX);
       // TODO check recipes
       assertNotNull(node);
-      Set<String> nodes = chefApi.listNodes();
+      Set<String> nodes = api.listNodes();
       assert nodes.contains(PREFIX) : String.format("node %s not in %s", PREFIX, nodes);
    }
 
    @Test(dependsOnMethods = "testCreateNode")
    public void testNodeExists() throws Exception {
-      assertNotNull(chefApi.nodeExists(PREFIX));
+      assertNotNull(api.nodeExists(PREFIX));
    }
 
    @Test(dependsOnMethods = "testNodeExists")
    public void testUpdateNode() throws Exception {
-      for (String nodename : chefApi.listNodes()) {
-         Node node = chefApi.getNode(nodename);
-         chefApi.updateNode(node);
+      for (String nodename : api.listNodes()) {
+         Node node = api.getNode(nodename);
+         api.updateNode(node);
       }
    }
 
    @Test
    public void testListRoles() throws Exception {
-      Set<String> roles = chefApi.listRoles();
+      Set<String> roles = api.listRoles();
       assertNotNull(roles);
    }
 
    @Test
    public void testCreateRole() throws Exception {
-      chefApi.deleteRole(PREFIX);
-      chefApi.createRole(new Role(PREFIX, Collections.singleton("recipe[java]")));
-      role = chefApi.getRole(PREFIX);
+      api.deleteRole(PREFIX);
+      api.createRole(new Role(PREFIX, Collections.singleton("recipe[java]")));
+      role = api.getRole(PREFIX);
       assertNotNull(role);
       assertEquals(role.getName(), PREFIX);
       assertEquals(role.getRunList(), Collections.singleton("recipe[java]"));
@@ -276,37 +227,37 @@
 
    @Test(dependsOnMethods = "testCreateRole")
    public void testRoleExists() throws Exception {
-      assertNotNull(chefApi.roleExists(PREFIX));
+      assertNotNull(api.roleExists(PREFIX));
    }
 
    @Test(dependsOnMethods = "testRoleExists")
    public void testUpdateRole() throws Exception {
-      for (String rolename : chefApi.listRoles()) {
-         Role role = chefApi.getRole(rolename);
-         chefApi.updateRole(role);
+      for (String rolename : api.listRoles()) {
+         Role role = api.getRole(rolename);
+         api.updateRole(role);
       }
    }
 
    @Test
    public void testListDatabags() throws Exception {
-      Set<String> databags = chefApi.listDatabags();
+      Set<String> databags = api.listDatabags();
       assertNotNull(databags);
    }
 
    @Test
    public void testCreateDatabag() throws Exception {
-      chefApi.deleteDatabag(PREFIX);
-      chefApi.createDatabag(PREFIX);
+      api.deleteDatabag(PREFIX);
+      api.createDatabag(PREFIX);
    }
 
    @Test(dependsOnMethods = "testCreateDatabag")
    public void testDatabagExists() throws Exception {
-      assertNotNull(chefApi.databagExists(PREFIX));
+      assertNotNull(api.databagExists(PREFIX));
    }
 
    @Test(dependsOnMethods = "testCreateDatabagItem")
    public void testListDatabagItems() throws Exception {
-      Set<String> databagItems = chefApi.listDatabagItems(PREFIX);
+      Set<String> databagItems = api.listDatabagItems(PREFIX);
       assertNotNull(databagItems);
    }
 
@@ -314,14 +265,14 @@
    public void testCreateDatabagItem() throws Exception {
       Properties config = new Properties();
       config.setProperty("foo", "bar");
-      chefApi.deleteDatabagItem(PREFIX, PREFIX);
-      databagItem = chefApi.createDatabagItem(PREFIX, new DatabagItem("config", context.utils().json().toJson(config)));
+      api.deleteDatabagItem(PREFIX, PREFIX);
+      databagItem = api.createDatabagItem(PREFIX, new DatabagItem("config", json.toJson(config)));
       assertNotNull(databagItem);
       assertEquals(databagItem.getId(), "config");
 
       // The databagItem json contains extra keys: (the name and the type if the
       // item)
-      Properties props = context.utils().json().fromJson(databagItem.toString(), Properties.class);
+      Properties props = json.fromJson(databagItem.toString(), Properties.class);
       for (Object key : config.keySet()) {
          assertTrue(props.containsKey(key));
          assertEquals(config.get(key), props.get(key));
@@ -330,20 +281,20 @@
 
    @Test(dependsOnMethods = "testCreateDatabagItem")
    public void testDatabagItemExists() throws Exception {
-      assertNotNull(chefApi.databagItemExists(PREFIX, PREFIX));
+      assertNotNull(api.databagItemExists(PREFIX, PREFIX));
    }
 
    @Test(dependsOnMethods = "testDatabagItemExists")
    public void testUpdateDatabagItem() throws Exception {
-      for (String databagItemId : chefApi.listDatabagItems(PREFIX)) {
-         DatabagItem databagItem = chefApi.getDatabagItem(PREFIX, databagItemId);
-         chefApi.updateDatabagItem(PREFIX, databagItem);
+      for (String databagItemId : api.listDatabagItems(PREFIX)) {
+         DatabagItem databagItem = api.getDatabagItem(PREFIX, databagItemId);
+         api.updateDatabagItem(PREFIX, databagItem);
       }
    }
 
    @Test
    public void testListSearchIndexes() throws Exception {
-      Set<String> indexes = chefApi.listSearchIndexes();
+      Set<String> indexes = api.listSearchIndexes();
       assertNotNull(indexes);
       assert indexes.contains("node") : indexes;
       assert indexes.contains("client") : indexes;
@@ -352,7 +303,7 @@
 
    @Test
    public void testSearchNodes() throws Exception {
-      SearchResult<? extends Node> results = chefApi.searchNodes();
+      SearchResult<? extends Node> results = api.searchNodes();
       assertNotNull(results);
    }
 
@@ -361,7 +312,7 @@
       Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
          @Override
          public boolean apply(SearchOptions input) {
-            SearchResult<? extends Node> results = chefApi.searchNodes(input);
+            SearchResult<? extends Node> results = api.searchNodes(input);
             assertNotNull(results);
             if (results.size() > 0) {
                assertEquals(results.size(), 1);
@@ -380,7 +331,7 @@
 
    @Test
    public void testSearchClients() throws Exception {
-      SearchResult<? extends Client> results = chefApi.searchClients();
+      SearchResult<? extends Client> results = api.searchClients();
       assertNotNull(results);
    }
 
@@ -389,7 +340,7 @@
       Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
          @Override
          public boolean apply(SearchOptions input) {
-            SearchResult<? extends Client> results = chefApi.searchClients(input);
+            SearchResult<? extends Client> results = api.searchClients(input);
             assertNotNull(results);
             if (results.size() > 0) {
                assertEquals(results.size(), 1);
@@ -408,7 +359,7 @@
 
    @Test
    public void testSearchRoles() throws Exception {
-      SearchResult<? extends Role> results = chefApi.searchRoles();
+      SearchResult<? extends Role> results = api.searchRoles();
       assertNotNull(results);
    }
 
@@ -417,7 +368,7 @@
       Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
          @Override
          public boolean apply(SearchOptions input) {
-            SearchResult<? extends Role> results = chefApi.searchRoles(input);
+            SearchResult<? extends Role> results = api.searchRoles(input);
             assertNotNull(results);
             if (results.size() > 0) {
                assertEquals(results.size(), 1);
@@ -436,7 +387,7 @@
 
    @Test(dependsOnMethods = { "testListSearchIndexes", "testDatabagItemExists" })
    public void testSearchDatabag() throws Exception {
-      SearchResult<? extends DatabagItem> results = chefApi.searchDatabag(PREFIX);
+      SearchResult<? extends DatabagItem> results = api.searchDatabag(PREFIX);
       assertNotNull(results);
    }
 
@@ -445,7 +396,7 @@
       Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
          @Override
          public boolean apply(SearchOptions input) {
-            SearchResult<? extends DatabagItem> results = chefApi.searchDatabag(PREFIX, input);
+            SearchResult<? extends DatabagItem> results = api.searchDatabag(PREFIX, input);
             assertNotNull(results);
             if (results.size() > 0) {
                assertEquals(results.size(), 1);
@@ -464,15 +415,15 @@
 
    @Test(expectedExceptions = ResourceNotFoundException.class, dependsOnMethods = "testListSearchIndexes")
    public void testSearchDatabagNotFound() throws Exception {
-      SearchResult<? extends DatabagItem> results = chefApi.searchDatabag("whoopie");
+      SearchResult<? extends DatabagItem> results = api.searchDatabag("whoopie");
       assertNotNull(results);
    }
 
    @Test
    public void testCreateEnvironment() {
-      chefApi.deleteEnvironment(PREFIX);
-      chefApi.createEnvironment(new Environment(PREFIX, PREFIX));
-      Environment env = chefApi.getEnvironment(PREFIX);
+      api.deleteEnvironment(PREFIX);
+      api.createEnvironment(new Environment(PREFIX, PREFIX));
+      Environment env = api.getEnvironment(PREFIX);
       assertNotNull(env);
       assertEquals(env.getName(), PREFIX);
       assertEquals(env.getDescription(), PREFIX);
@@ -480,23 +431,23 @@
 
    @Test(dependsOnMethods = "testCreateEnvironment")
    public void testListEnvironment() {
-      Set<String> envList = chefApi.listEnvironments();
+      Set<String> envList = api.listEnvironments();
       assertNotNull(envList);
       assertTrue(envList.contains(PREFIX));
    }
 
    @Test(dependsOnMethods = "testCreateEnvironment")
    public void testSearchEnvironments() throws Exception {
-      SearchResult<? extends Environment> results = chefApi.searchEnvironments();
+      SearchResult<? extends Environment> results = api.searchEnvironments();
       assertNotNull(results);
    }
 
-   @Test(dependsOnMethods = {"testListSearchIndexes", "testCreateEnvironment"})
+   @Test(dependsOnMethods = { "testListSearchIndexes", "testCreateEnvironment" })
    public void testSearchEnvironmentsWithOptions() throws Exception {
       Predicate<SearchOptions> waitForIndex = retry(new Predicate<SearchOptions>() {
          @Override
          public boolean apply(SearchOptions input) {
-            SearchResult<? extends Environment> results = chefApi.searchEnvironments(input);
+            SearchResult<? extends Environment> results = api.searchEnvironments(input);
             assertNotNull(results);
             if (results.size() > 0) {
                assertEquals(results.size(), 1);
@@ -513,22 +464,22 @@
       assertTrue(waitForIndex.apply(options));
    }
 
+   @Test
+   public void testListCookbookVersionsWithChefService() throws Exception {
+      Iterable<? extends CookbookVersion> cookbooks = chefService.listCookbookVersions();
+      assertNotNull(cookbooks);
+   }
+
    @AfterClass(groups = { "live", "integration" })
    @Override
-   public void tearDownContext() {
-      chefApi.deleteClient(PREFIX);
-      chefApi.deleteClient(ADMIN_PREFIX);
-      chefApi.deleteClient(VALIDATOR_PREFIX);
-      chefApi.deleteNode(PREFIX);
-      chefApi.deleteRole(PREFIX);
-      chefApi.deleteDatabag(PREFIX);
-      chefApi.deleteEnvironment(PREFIX);
-      try {
-         Closeables.close(validatorContext, true);
-      } catch (IOException e) {
-         throw propagate(e);
-      }
-      super.tearDownContext();
+   public void tearDown() {
+      api.deleteClient(PREFIX);
+      api.deleteClient(ADMIN_PREFIX);
+      api.deleteNode(PREFIX);
+      api.deleteRole(PREFIX);
+      api.deleteDatabag(PREFIX);
+      api.deleteEnvironment(PREFIX);
+      super.tearDown();
    }
 
    private void assertClientCreated(String identity, String credential) {
@@ -536,14 +487,14 @@
       overrides.setProperty(provider + ".identity", identity);
       overrides.setProperty(provider + ".credential", credential);
 
-      C clientContext = createContext(overrides, setupModules());
+      A clientApi = create(overrides, setupModules());
 
       try {
-         Client client = getChefApi(clientContext).getClient(identity);
+         Client client = clientApi.getClient(identity);
          assertNotNull(client);
       } finally {
          try {
-            Closeables.close(clientContext, true);
+            Closeables.close(clientApi, true);
          } catch (IOException e) {
             throw propagate(e);
          }
diff --git a/core/src/test/java/org/jclouds/chef/internal/BaseChefContextLiveTest.java b/core/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java
similarity index 65%
rename from core/src/test/java/org/jclouds/chef/internal/BaseChefContextLiveTest.java
rename to core/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java
index 9d800df..0503b86 100644
--- a/core/src/test/java/org/jclouds/chef/internal/BaseChefContextLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/internal/BaseChefLiveTest.java
@@ -18,31 +18,35 @@
  */
 package org.jclouds.chef.internal;
 
+import static org.jclouds.reflect.Types2.checkBound;
+
 import java.io.File;
 import java.io.IOException;
 import java.util.Properties;
 
-import org.jclouds.Context;
-import org.jclouds.apis.BaseContextLiveTest;
+import org.jclouds.apis.BaseApiLiveTest;
 import org.jclouds.chef.ChefApi;
+import org.jclouds.chef.ChefService;
+import org.jclouds.json.Json;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Charsets;
 import com.google.common.base.Throwables;
 import com.google.common.io.Files;
+import com.google.common.reflect.TypeToken;
+import com.google.inject.Injector;
+import com.google.inject.Module;
 
 /**
  * 
  * @author Adrian Cole
  */
 @Test(groups = "live")
-public abstract class BaseChefContextLiveTest<C extends Context> extends BaseContextLiveTest<C> {
+public abstract class BaseChefLiveTest<A extends ChefApi> extends BaseApiLiveTest<A> {
 
-   public BaseChefContextLiveTest() {
-      provider = "chef";
-   }
-
-   protected abstract ChefApi getChefApi(C context);
+   protected Injector injector;
+   protected ChefService chefService;
+   protected Json json;
 
    /**
     * the credential is a path to the pem file.
@@ -54,6 +58,19 @@
       return overrides;
    }
 
+   @Override
+   protected void initialize() {
+      super.initialize();
+      chefService = injector.getInstance(ChefService.class);
+      json = injector.getInstance(Json.class);
+   }
+
+   @Override
+   protected A create(Properties props, Iterable<Module> modules) {
+      injector = newBuilder().modules(modules).overrides(props).buildInjector();
+      return injector.getInstance(resolveApiClass());
+   }
+
    protected String setCredentialFromPemFile(Properties overrides, String identity, String key) {
       String val = null;
       String credentialFromFile = null;
@@ -71,4 +88,11 @@
       return credentialFromFile;
    }
 
+   @SuppressWarnings("unchecked")
+   private Class<A> resolveApiClass() {
+      return Class.class.cast(checkBound(new TypeToken<A>(getClass()) {
+         private static final long serialVersionUID = 1L;
+      }).getRawType());
+   }
+
 }
diff --git a/core/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java b/core/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java
index 7d6bcc8..d0804a4 100644
--- a/core/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/internal/BaseStubbedOhaiLiveTest.java
@@ -18,14 +18,11 @@
  */
 package org.jclouds.chef.internal;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
-
 import java.util.Map;
 
 import org.jclouds.apis.ApiMetadata;
 import org.jclouds.chef.ChefApi;
 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.chef.config.ChefRestClientModule;
@@ -39,7 +36,6 @@
 import com.google.common.base.Suppliers;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
 import com.google.inject.Module;
 
 /**
@@ -48,7 +44,7 @@
  */
 @Test(groups = "live")
 @Deprecated
-public class BaseStubbedOhaiLiveTest extends BaseChefContextLiveTest<ChefContext> {
+public class BaseStubbedOhaiLiveTest extends BaseChefLiveTest<ChefApi> {
 
    @ConfiguresOhai
    static class TestOhaiModule extends OhaiModule {
@@ -67,14 +63,4 @@
                   ImmutableSet.<Class<? extends Module>> of(ChefRestClientModule.class, ChefParserModule.class,
                         ChefBootstrapModule.class, TestOhaiModule.class)).build();
    }
-
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
-   }
 }
diff --git a/core/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java b/core/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java
index 6590abb..0ba2381 100644
--- a/core/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/strategy/internal/CleanupStaleNodesAndClientsImplLiveTest.java
@@ -18,16 +18,14 @@
  */
 package org.jclouds.chef.strategy.internal;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
 
 import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
-import org.jclouds.chef.internal.BaseChefContextLiveTest;
-import org.testng.annotations.BeforeClass;
+import org.jclouds.chef.internal.BaseChefLiveTest;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
 
 /**
  * Tests behavior of {@code CleanupStaleNodesAndClientsImpl} strategies
@@ -35,17 +33,16 @@
  * @author Adrian Cole
  */
 @Test(groups = "live", testName = "CleanupStaleNodesAndClientsImplLiveTest")
-public class CleanupStaleNodesAndClientsImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
+public class CleanupStaleNodesAndClientsImplLiveTest extends BaseChefLiveTest<ChefApi> {
 
    private CreateNodeAndPopulateAutomaticAttributesImpl creater;
    private CleanupStaleNodesAndClientsImpl strategy;
 
-   @BeforeClass(groups = { "integration", "live" })
    @Override
-   public void setupContext() {
-      super.setupContext();
-      this.creater = context.utils().injector().getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
-      this.strategy = context.utils().injector().getInstance(CleanupStaleNodesAndClientsImpl.class);
+   public void initialize() {
+      super.initialize();
+      this.creater = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
+      this.strategy = injector.getInstance(CleanupStaleNodesAndClientsImpl.class);
    }
 
    @Test
@@ -54,25 +51,15 @@
          creater.execute(prefix, ImmutableSet.<String> of());
          // http://tickets.corp.opscode.com/browse/PL-522
          // assert chef.nodeExists(prefix);
-         assert context.getApi().getNode(prefix) != null;
+         assertNotNull(api.getNode(prefix));
          strategy.execute(prefix, 10);
-         assert context.getApi().getNode(prefix) != null;
+         assertNotNull(api.getNode(prefix));
          Thread.sleep(1000);
          strategy.execute(prefix, 1);
-         assert context.getApi().getNode(prefix) == null;
+         assertNull(api.getNode(prefix));
       } finally {
-         context.getApi().deleteNode(prefix);
+         api.deleteNode(prefix);
       }
    }
 
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
-   }
-
 }
diff --git a/core/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java b/core/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java
index 1adafe0..a0cd655 100644
--- a/core/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/strategy/internal/CreateNodeAndPopulateAutomaticAttributesImplLiveTest.java
@@ -18,21 +18,17 @@
  */
 package org.jclouds.chef.strategy.internal;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
 import static org.testng.Assert.assertEquals;
 
 import java.util.Set;
 
 import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.domain.Node;
-import org.jclouds.chef.internal.BaseChefContextLiveTest;
+import org.jclouds.chef.internal.BaseChefLiveTest;
 import org.jclouds.ohai.config.OhaiModule.CurrentUserProvider;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
 
 /**
  * Tests behavior of {@code CreateNodeAndPopulateAutomaticAttributesImpl}
@@ -41,40 +37,30 @@
  * @author Adrian Cole
  */
 @Test(groups = "live", testName = "CreateNodeAndPopulateAutomaticAttributesImplLiveTest")
-public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
+public class CreateNodeAndPopulateAutomaticAttributesImplLiveTest extends BaseChefLiveTest<ChefApi> {
 
    private CurrentUserProvider currentUserProvider;
+   private CreateNodeAndPopulateAutomaticAttributesImpl strategy;
 
-   @BeforeClass(groups = { "integration", "live" })
    @Override
-   public void setupContext() {
-      super.setupContext();
-      this.currentUserProvider = context.utils().injector().getInstance(CurrentUserProvider.class);
+   public void initialize() {
+      super.initialize();
+      this.currentUserProvider = injector.getInstance(CurrentUserProvider.class);
+      this.strategy = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
    }
 
    @Test
    public void testExecute() {
       Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
       try {
-         context.utils().injector().getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class)
-               .execute(prefix, runList);
-         Node node = context.getApi().getNode(prefix);
+         strategy.execute(prefix, runList);
+         Node node = api.getNode(prefix);
          assertEquals(node.getName(), prefix);
          assertEquals(node.getRunList(), runList);
          assertEquals(node.getAutomatic().get("current_user").toString(), currentUserProvider.get().toString());
       } finally {
-         context.getApi().deleteNode(prefix);
+         api.deleteNode(prefix);
       }
    }
 
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
-   }
-
 }
diff --git a/core/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java b/core/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java
index f4ef90d..615342b 100644
--- a/core/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/strategy/internal/DeleteAllApisAndNodesInListImplLiveTest.java
@@ -18,16 +18,14 @@
  */
 package org.jclouds.chef.strategy.internal;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
 
 import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
-import org.jclouds.chef.internal.BaseChefContextLiveTest;
-import org.testng.annotations.BeforeClass;
+import org.jclouds.chef.internal.BaseChefLiveTest;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
 
 /**
  * Tests behavior of {@code DeleteAllApisAndNodesInListImpl} strategies
@@ -35,19 +33,16 @@
  * @author Adrian Cole
  */
 @Test(groups = "live", testName = "DeleteAllApisAndNodesInListImplLiveTest")
-public class DeleteAllApisAndNodesInListImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
+public class DeleteAllApisAndNodesInListImplLiveTest extends BaseChefLiveTest<ChefApi> {
 
    private DeleteAllNodesInListImpl strategy;
    private CreateNodeAndPopulateAutomaticAttributesImpl creater;
-   private ChefApi chef;
 
-   @BeforeClass(groups = { "integration", "live" })
    @Override
-   public void setupContext() {
-      super.setupContext();
-      this.creater = context.utils().injector().getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
-      this.strategy = context.utils().injector().getInstance(DeleteAllNodesInListImpl.class);
-      this.chef = context.getApi();
+   public void initialize() {
+      super.initialize();
+      this.creater = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
+      this.strategy = injector.getInstance(DeleteAllNodesInListImpl.class);
    }
 
    @Test
@@ -57,26 +52,17 @@
          creater.execute(prefix + 1, ImmutableSet.<String> of());
 
          // http://tickets.corp.opscode.com/browse/PL-522
-         // assert chef.nodeExists(prefix);
-         assert chef.getNode(prefix) != null;
-         assert chef.getNode(prefix + 1) != null;
+         // assert api.nodeExists(prefix);
+         assertNotNull(api.getNode(prefix));
+         assertNotNull(api.getNode(prefix + 1));
 
          strategy.execute(ImmutableSet.of(prefix, prefix + 1));
-         assert chef.getNode(prefix) == null;
-         assert chef.getNode(prefix + 1) == null;
+         assertNull(api.getNode(prefix));
+         assertNull(api.getNode(prefix + 1));
       } finally {
-         chef.deleteNode(prefix);
-         chef.deleteNode(prefix + 1);
+         api.deleteNode(prefix);
+         api.deleteNode(prefix + 1);
       }
    }
 
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
-   }
 }
diff --git a/core/src/test/java/org/jclouds/chef/strategy/internal/GetNodesImplLiveTest.java b/core/src/test/java/org/jclouds/chef/strategy/internal/GetNodesImplLiveTest.java
index 543208d..10dd287 100644
--- a/core/src/test/java/org/jclouds/chef/strategy/internal/GetNodesImplLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/strategy/internal/GetNodesImplLiveTest.java
@@ -19,19 +19,15 @@
 package org.jclouds.chef.strategy.internal;
 
 import static com.google.common.collect.Iterables.size;
-import static org.jclouds.reflect.Reflection2.typeToken;
 import static org.testng.Assert.assertEquals;
 
 import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
-import org.jclouds.chef.internal.BaseChefContextLiveTest;
+import org.jclouds.chef.internal.BaseChefLiveTest;
 import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import com.google.common.base.Predicate;
 import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
 
 /**
  * Tests behavior of {@code GetNodesImpl} strategies
@@ -39,29 +35,26 @@
  * @author Adrian Cole
  */
 @Test(groups = "live", testName = "GetNodesImplLiveTest")
-public class GetNodesImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
+public class GetNodesImplLiveTest extends BaseChefLiveTest<ChefApi> {
 
    private ListNodesImpl strategy;
    private CreateNodeAndPopulateAutomaticAttributesImpl creater;
-   private ChefApi chef;
 
-   @BeforeClass(groups = { "integration", "live" })
    @Override
-   public void setupContext() {
-      super.setupContext();
-      this.creater = context.utils().injector().getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
-      this.strategy = context.utils().injector().getInstance(ListNodesImpl.class);
-      this.chef = context.getApi();
+   public void initialize() {
+      super.initialize();
+      this.creater = injector.getInstance(CreateNodeAndPopulateAutomaticAttributesImpl.class);
+      this.strategy = injector.getInstance(ListNodesImpl.class);
       creater.execute(prefix, ImmutableSet.<String> of());
       creater.execute(prefix + 1, ImmutableSet.<String> of());
    }
 
    @AfterClass(groups = { "integration", "live" })
    @Override
-   protected void tearDownContext() {
-      chef.deleteNode(prefix);
-      chef.deleteNode(prefix + 1);
-      super.tearDownContext();
+   protected void tearDown() {
+      api.deleteNode(prefix);
+      api.deleteNode(prefix + 1);
+      super.tearDown();
    }
 
    @Test
@@ -86,14 +79,4 @@
       assertEquals(size(strategy.execute(ImmutableSet.of(prefix, prefix + 1))), 2);
    }
 
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
-   }
-
 }
diff --git a/core/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java b/core/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java
index cb8a78a..e3268f2 100644
--- a/core/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java
+++ b/core/src/test/java/org/jclouds/chef/strategy/internal/UpdateAutomaticAttributesOnNodeImplLiveTest.java
@@ -18,21 +18,17 @@
  */
 package org.jclouds.chef.strategy.internal;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
 import static org.testng.Assert.assertEquals;
 
 import java.util.Set;
 
 import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.domain.Node;
-import org.jclouds.chef.internal.BaseChefContextLiveTest;
+import org.jclouds.chef.internal.BaseChefLiveTest;
 import org.jclouds.ohai.config.OhaiModule.CurrentUserProvider;
-import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
 
 /**
  * Tests behavior of {@code UpdateAutomaticAttributesOnNodeImpl} strategies
@@ -40,39 +36,30 @@
  * @author Adrian Cole
  */
 @Test(groups = "live", testName = "UpdateAutomaticAttributesOnNodeImplLiveTest")
-public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefContextLiveTest<ChefContext> {
+public class UpdateAutomaticAttributesOnNodeImplLiveTest extends BaseChefLiveTest<ChefApi> {
 
    private CurrentUserProvider currentUserProvider;
+   private UpdateAutomaticAttributesOnNodeImpl strategy;
 
-   @BeforeClass(groups = { "integration", "live" })
    @Override
-   public void setupContext() {
-      super.setupContext();
-      this.currentUserProvider = context.utils().injector().getInstance(CurrentUserProvider.class);
+   public void initialize() {
+      super.initialize();
+      this.currentUserProvider = injector.getInstance(CurrentUserProvider.class);
+      this.strategy = injector.getInstance(UpdateAutomaticAttributesOnNodeImpl.class);
    }
 
    @Test
    public void testExecute() {
       Set<String> runList = ImmutableSet.of("role[" + prefix + "]");
       try {
-         context.getApi().createNode(new Node(prefix, runList, "_default"));
-         context.utils().injector().getInstance(UpdateAutomaticAttributesOnNodeImpl.class).execute(prefix);
-         Node node = context.getApi().getNode(prefix);
+         api.createNode(new Node(prefix, runList, "_default"));
+         strategy.execute(prefix);
+         Node node = api.getNode(prefix);
          assertEquals(node.getName(), prefix);
          assertEquals(node.getRunList(), runList);
          assertEquals(node.getAutomatic().get("current_user").toString(), currentUserProvider.get().toString());
       } finally {
-         context.getApi().deleteNode(prefix);
+         api.deleteNode(prefix);
       }
    }
-
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
-   }
 }
diff --git a/core/src/test/java/org/jclouds/chef/test/TransientChefApiIntegrationTest.java b/core/src/test/java/org/jclouds/chef/test/TransientChefApiIntegrationTest.java
index 5a3c6ed..5df97fa 100644
--- a/core/src/test/java/org/jclouds/chef/test/TransientChefApiIntegrationTest.java
+++ b/core/src/test/java/org/jclouds/chef/test/TransientChefApiIntegrationTest.java
@@ -18,31 +18,23 @@
  */
 package org.jclouds.chef.test;
 
-import static com.google.common.base.Throwables.propagate;
-import static org.jclouds.reflect.Reflection2.typeToken;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertNotNull;
 
-import java.io.IOException;
 import java.util.Properties;
 
 import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.domain.DatabagItem;
-import org.jclouds.chef.internal.BaseChefContextLiveTest;
-import org.testng.annotations.AfterClass;
+import org.jclouds.chef.internal.BaseChefLiveTest;
 import org.testng.annotations.Test;
 
-import com.google.common.io.Closeables;
-import com.google.common.reflect.TypeToken;
-
 /**
  * Tests behavior of {@code TransientChefApi}
  * 
  * @author Adrian Cole
  */
 @Test(groups = { "integration" })
-public class TransientChefApiIntegrationTest extends BaseChefContextLiveTest<ChefContext> {
+public class TransientChefApiIntegrationTest extends BaseChefLiveTest<ChefApi> {
    public static final String PREFIX = System.getProperty("user.name") + "-jcloudstest";
    private DatabagItem databagItem;
 
@@ -55,57 +47,37 @@
       return new Properties();
    }
 
-   @AfterClass(groups = { "integration", "live" })
-   @Override
-   public void tearDownContext() {
-      try {
-         Closeables.close(context, true);
-      } catch (IOException e) {
-         throw propagate(e);
-      }
-   }
-
    public void testCreateDatabag() {
-      context.getApi().deleteDatabag(PREFIX);
-      context.getApi().createDatabag(PREFIX);
+      api.deleteDatabag(PREFIX);
+      api.createDatabag(PREFIX);
    }
 
    @Test(dependsOnMethods = "testCreateDatabag")
    public void testDatabagExists() {
-      assertNotNull(context.getApi().databagExists(PREFIX));
+      assertNotNull(api.databagExists(PREFIX));
    }
 
    @Test(dependsOnMethods = { "testDatabagExists" })
    public void testCreateDatabagItem() {
       Properties config = new Properties();
       config.setProperty("foo", "bar");
-      databagItem = context.getApi().createDatabagItem(PREFIX,
-            new DatabagItem("config", context.utils().json().toJson(config)));
+      databagItem = api.createDatabagItem(PREFIX, new DatabagItem("config", json.toJson(config)));
       assertNotNull(databagItem);
       assertEquals(databagItem.getId(), "config");
-      assertEquals(config, context.utils().json().fromJson(databagItem.toString(), Properties.class));
+      assertEquals(config, json.fromJson(databagItem.toString(), Properties.class));
    }
 
    @Test(dependsOnMethods = "testCreateDatabagItem")
    public void testDatabagItemExists() {
-      assertNotNull(context.getApi().databagItemExists(PREFIX, PREFIX));
+      assertNotNull(api.databagItemExists(PREFIX, PREFIX));
    }
 
    @Test(dependsOnMethods = "testDatabagItemExists")
    public void testUpdateDatabagItem() {
-      for (String databagItemId : context.getApi().listDatabagItems(PREFIX)) {
-         DatabagItem databagItem = context.getApi().getDatabagItem(PREFIX, databagItemId);
-         context.getApi().updateDatabagItem(PREFIX, databagItem);
+      for (String databagItemId : api.listDatabagItems(PREFIX)) {
+         DatabagItem databagItem = api.getDatabagItem(PREFIX, databagItemId);
+         api.updateDatabagItem(PREFIX, databagItem);
       }
    }
 
-   @Override
-   protected ChefApi getChefApi(ChefContext context) {
-      return context.getApi();
-   }
-
-   @Override
-   protected TypeToken<ChefContext> contextType() {
-      return typeToken(ChefContext.class);
-   }
 }
diff --git a/labs/hostedchef/pom.xml b/labs/hostedchef/pom.xml
index 4575776..36be52e 100644
--- a/labs/hostedchef/pom.xml
+++ b/labs/hostedchef/pom.xml
@@ -33,14 +33,12 @@
     <description>jclouds components to access Hosted Chef</description>
 
     <properties>
-        <test.jclouds.hostedchef.org>YOUR_ORG</test.jclouds.hostedchef.org>
-        <test.hostedchef.endpoint>https://api.opscode.com/organizations/${test.jclouds.hostedchef.org}</test.hostedchef.endpoint>
+        <test.hostedchef.org>YOUR_ORG</test.hostedchef.org>
+        <test.hostedchef.endpoint>https://api.opscode.com/organizations/${test.hostedchef.org}</test.hostedchef.endpoint>
         <test.hostedchef.api-version />
         <test.hostedchef.build-version />
         <test.hostedchef.identity>YOUR_USER</test.hostedchef.identity>
-        <test.hostedchef.credential>${user.home}/.chef/${test.jclouds.hostedchef.org}/${test.hostedchef.identity}.pem</test.hostedchef.credential>
-        <test.hostedchef.validator.identity>${test.jclouds.hostedchef.org}-validator</test.hostedchef.validator.identity>
-        <test.hostedchef.validator.credential>${user.home}/.chef/${test.jclouds.hostedchef.org}/${test.hostedchef.validator.identity}.pem</test.hostedchef.validator.credential>
+        <test.hostedchef.credential>${user.home}/.chef/${test.hostedchef.org}/${test.hostedchef.identity}.pem</test.hostedchef.credential>
         <jclouds.osgi.export>org.jclouds.hostedchef*;version="${project.version}"</jclouds.osgi.export>
         <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
     </properties>
@@ -96,7 +94,7 @@
                                 </goals>
                                 <configuration>
                                     <systemPropertyVariables>
-                                        <test.jclouds.hostedchef.org>${test.jclouds.hostedchef.org}</test.jclouds.hostedchef.org>
+                                        <test.hostedchef.org>${test.hostedchef.org}</test.hostedchef.org>
                                         <test.hostedchef.endpoint>${test.hostedchef.endpoint}</test.hostedchef.endpoint>
                                         <test.hostedchef.api-version>${test.hostedchef.api-version}</test.hostedchef.api-version>
                                         <test.hostedchef.build-version>${test.hostedchef.build-version}</test.hostedchef.build-version>
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApi.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApi.java
index e01ca64..aac9f04 100644
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApi.java
+++ b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApi.java
@@ -18,24 +18,26 @@
  */
 package org.jclouds.hostedchef;
 
-import java.io.Closeable;
 import java.util.Set;
+
+import org.jclouds.chef.ChefApi;
 import org.jclouds.hostedchef.domain.Group;
 import org.jclouds.hostedchef.domain.User;
-import org.jclouds.rest.annotations.Delegate;
 
 /**
  * Provides synchronous access to the Hosted Chef Api.
  * 
  * @author Ignasi Barrera
  */
-public interface HostedChefApi extends Closeable {
+public interface HostedChefApi extends ChefApi {
 
    /**
-    * Gets the core Chef Api.
+    * Check if there exists a node with the given name.
+    * 
+    * @return <code>true</code> if the specified node name exists.
     */
-   @Delegate
-   PatchedChefApi getChefApi();
+   @Override
+   boolean nodeExists(String name);
 
    /**
     * Retrieves an existing user.
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApiMetadata.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApiMetadata.java
index 5c42abc..0c451dd 100644
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApiMetadata.java
+++ b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefApiMetadata.java
@@ -18,14 +18,13 @@
  */
 package org.jclouds.hostedchef;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
-
 import java.net.URI;
 import java.util.Properties;
 
 import org.jclouds.apis.ApiMetadata;
 import org.jclouds.chef.ChefApiMetadata;
 import org.jclouds.chef.ChefAsyncApi;
+import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.config.ChefBootstrapModule;
 import org.jclouds.chef.config.ChefParserModule;
 import org.jclouds.hostedchef.config.HostedChefRestClientModule;
@@ -70,7 +69,7 @@
                .version(ChefAsyncApi.VERSION)
                .documentation(URI.create("http://www.opscode.com/support"))
                .defaultEndpoint("https://api.opscode.com")
-               .context(typeToken(HostedChefContext.class))
+               .view(ChefContext.class)
                .defaultProperties(HostedChefApiMetadata.defaultProperties())
                .defaultModules(
                      ImmutableSet.<Class<? extends Module>> of(HostedChefRestClientModule.class,
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefAsyncApi.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefAsyncApi.java
index da0d1d8..46f5d49 100644
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefAsyncApi.java
+++ b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefAsyncApi.java
@@ -18,7 +18,6 @@
  */
 package org.jclouds.hostedchef;
 
-import java.io.Closeable;
 import java.util.Set;
 
 import javax.inject.Named;
@@ -32,7 +31,10 @@
 import javax.ws.rs.core.MediaType;
 
 import org.jclouds.Constants;
+import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
 import org.jclouds.Fallbacks.NullOnNotFoundOr404;
+import org.jclouds.chef.ChefApi;
+import org.jclouds.chef.ChefAsyncApi;
 import org.jclouds.chef.filters.SignedHeaderAuth;
 import org.jclouds.chef.functions.ParseKeySetFromJson;
 import org.jclouds.hostedchef.binders.BindGroupNameToJsonPayload;
@@ -41,7 +43,6 @@
 import org.jclouds.hostedchef.domain.Group;
 import org.jclouds.hostedchef.domain.User;
 import org.jclouds.rest.annotations.BinderParam;
-import org.jclouds.rest.annotations.Delegate;
 import org.jclouds.rest.annotations.Fallback;
 import org.jclouds.rest.annotations.Headers;
 import org.jclouds.rest.annotations.ParamParser;
@@ -55,17 +56,27 @@
  * 
  * @see HostedChefApi
  * @author Ignasi Barrera
+ * @deprecated please use
+ *             {@code org.jclouds.ContextBuilder#buildApi(HostedChefApi.class)}
+ *             as {@link HostedChefAsyncApi} interface will be removed in
+ *             jclouds 1.7.
  */
+@Deprecated
 @RequestFilters(SignedHeaderAuth.class)
 @Consumes(MediaType.APPLICATION_JSON)
 @Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
-public interface HostedChefAsyncApi extends Closeable {
+public interface HostedChefAsyncApi extends ChefAsyncApi {
 
    /**
-    * @see HostedChefApi#getChefApi()
+    * @see ChefApi#nodeExists(String)
     */
-   @Delegate
-   PatchedChefAsyncApi getChefApi();
+   @Override
+   // Use get instead of HEAD
+   @Named("node:exists")
+   @GET
+   @Path("/nodes/{nodename}")
+   @Fallback(FalseOnNotFoundOr404.class)
+   ListenableFuture<Boolean> nodeExists(@PathParam("nodename") String nodename);
 
    /**
     * @see HostedChefApi#getUser(String)
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefContext.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefContext.java
deleted file mode 100644
index 989bf22..0000000
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/HostedChefContext.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds 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.hostedchef;
-
-import org.jclouds.hostedchef.internal.HostedChefContextImpl;
-import org.jclouds.rest.RestContext;
-
-import com.google.inject.ImplementedBy;
-
-@ImplementedBy(HostedChefContextImpl.class)
-public interface HostedChefContext extends RestContext<HostedChefApi, HostedChefAsyncApi> {
-
-}
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/PatchedChefApi.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/PatchedChefApi.java
deleted file mode 100644
index 3405676..0000000
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/PatchedChefApi.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds 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.hostedchef;
-
-import org.jclouds.chef.ChefApi;
-
-/**
- * Private chef api seems to miss support for HEAD method in the node resource.
- * This class overrides the {@link ChefApi#nodeExists(String)} method to use GET
- * instead of HEAD.
- * 
- * @author Ignasi Barrera
- */
-public interface PatchedChefApi extends ChefApi {
-   /**
-    * Check if there exists a node with the given name.
-    * 
-    * @return <code>true</code> if the specified node name exists.
-    */
-   @Override
-   boolean nodeExists(String name);
-}
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/PatchedChefAsyncApi.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/PatchedChefAsyncApi.java
deleted file mode 100644
index 7cc747d..0000000
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/PatchedChefAsyncApi.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds 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.hostedchef;
-
-import javax.inject.Named;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-
-import org.jclouds.Constants;
-import org.jclouds.Fallbacks.FalseOnNotFoundOr404;
-import org.jclouds.chef.ChefApi;
-import org.jclouds.chef.ChefAsyncApi;
-import org.jclouds.chef.filters.SignedHeaderAuth;
-import org.jclouds.rest.annotations.Fallback;
-import org.jclouds.rest.annotations.Headers;
-import org.jclouds.rest.annotations.RequestFilters;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-/**
- * Private chef api seems to miss support for HEAD method in the node resource.
- * This class overrides the {@link ChefAsyncApi#nodeExists(String)} method to
- * use GET instead of HEAD.
- * 
- * @author Ignasi Barrera
- */
-@RequestFilters(SignedHeaderAuth.class)
-@Consumes(MediaType.APPLICATION_JSON)
-@Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
-public interface PatchedChefAsyncApi extends ChefAsyncApi {
-   /**
-    * @see ChefApi#nodeExists(String)
-    */
-   @Override
-   // Use get instead of HEAD
-   @Named("node:exists")
-   @GET
-   @Path("/nodes/{nodename}")
-   @Fallback(FalseOnNotFoundOr404.class)
-   ListenableFuture<Boolean> nodeExists(@PathParam("nodename") String nodename);
-}
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/config/HostedChefRestClientModule.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/config/HostedChefRestClientModule.java
index 3f5c491..5f0534e 100644
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/config/HostedChefRestClientModule.java
+++ b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/config/HostedChefRestClientModule.java
@@ -20,20 +20,13 @@
 
 import static org.jclouds.reflect.Reflection2.typeToken;
 
-import java.util.Map;
-
 import org.jclouds.chef.ChefApi;
 import org.jclouds.chef.ChefAsyncApi;
 import org.jclouds.chef.config.BaseChefRestClientModule;
 import org.jclouds.hostedchef.HostedChefApi;
 import org.jclouds.hostedchef.HostedChefAsyncApi;
-import org.jclouds.hostedchef.PatchedChefApi;
-import org.jclouds.hostedchef.PatchedChefAsyncApi;
 import org.jclouds.rest.ConfiguresRestClient;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Provides;
-
 /**
  * Configures the Hosted Chef connection.
  * 
@@ -41,21 +34,16 @@
  */
 @ConfiguresRestClient
 public class HostedChefRestClientModule extends BaseChefRestClientModule<HostedChefApi, HostedChefAsyncApi> {
-   public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
-         .put(PatchedChefApi.class, PatchedChefAsyncApi.class)//
-         .build();
 
    public HostedChefRestClientModule() {
-      super(typeToken(HostedChefApi.class), typeToken(HostedChefAsyncApi.class), DELEGATE_MAP);
+      super(typeToken(HostedChefApi.class), typeToken(HostedChefAsyncApi.class));
    }
 
-   @Provides
-   private ChefApi provideChefApi(HostedChefApi in){
-      return in.getChefApi();
+   @Override
+   protected void configure() {
+      super.configure();
+      bind(ChefApi.class).to(HostedChefApi.class);
+      bind(ChefAsyncApi.class).to(HostedChefAsyncApi.class);
    }
 
-   @Provides
-   private ChefAsyncApi provideChefApi(HostedChefAsyncApi in){
-      return in.getChefApi();
-   }
 }
diff --git a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/internal/HostedChefContextImpl.java b/labs/hostedchef/src/main/java/org/jclouds/hostedchef/internal/HostedChefContextImpl.java
deleted file mode 100644
index 662554b..0000000
--- a/labs/hostedchef/src/main/java/org/jclouds/hostedchef/internal/HostedChefContextImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds 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.hostedchef.internal;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.annotations.Name;
-import org.jclouds.domain.Credentials;
-import org.jclouds.hostedchef.HostedChefApi;
-import org.jclouds.hostedchef.HostedChefAsyncApi;
-import org.jclouds.hostedchef.HostedChefContext;
-import org.jclouds.lifecycle.Closer;
-import org.jclouds.location.Provider;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.Utils;
-import org.jclouds.rest.internal.RestContextImpl;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Injector;
-import com.google.inject.TypeLiteral;
-
-/**
- * @author Ignasi Barrera
- */
-@Singleton
-public class HostedChefContextImpl extends RestContextImpl<HostedChefApi, HostedChefAsyncApi> implements
-      HostedChefContext {
-
-   @Inject
-   protected HostedChefContextImpl(@Name String name, ProviderMetadata providerMetadata,
-         @Provider Supplier<Credentials> creds, Utils utils, Closer closer, Injector injector) {
-      super(name, providerMetadata, creds, utils, closer, injector, TypeLiteral.get(HostedChefApi.class), TypeLiteral
-            .get(HostedChefAsyncApi.class));
-   }
-
-}
diff --git a/labs/hostedchef/src/test/java/org/jclouds/hostedchef/HostedChefApiLiveTest.java b/labs/hostedchef/src/test/java/org/jclouds/hostedchef/HostedChefApiLiveTest.java
index 77cff3e..adcb8be 100644
--- a/labs/hostedchef/src/test/java/org/jclouds/hostedchef/HostedChefApiLiveTest.java
+++ b/labs/hostedchef/src/test/java/org/jclouds/hostedchef/HostedChefApiLiveTest.java
@@ -18,7 +18,6 @@
  */
 package org.jclouds.hostedchef;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
 import static org.testng.Assert.assertNotNull;
@@ -28,16 +27,13 @@
 import java.util.Set;
 import java.util.UUID;
 
-import org.jclouds.chef.ChefApi;
 import org.jclouds.chef.internal.BaseChefApiLiveTest;
 import org.jclouds.hostedchef.domain.Group;
 import org.jclouds.hostedchef.domain.User;
-import org.jclouds.rest.AuthorizationException;
 import org.jclouds.rest.ResourceNotFoundException;
 import org.testng.annotations.Test;
 
 import com.google.common.collect.ImmutableSet;
-import com.google.common.reflect.TypeToken;
 
 /**
  * Tests behavior of the HostedChefApi.
@@ -45,7 +41,7 @@
  * @author Adrian Cole
  */
 @Test(groups = "live", singleThreaded = true, testName = "HostedChefApiLiveTest")
-public class HostedChefApiLiveTest extends BaseChefApiLiveTest<HostedChefContext> {
+public class HostedChefApiLiveTest extends BaseChefApiLiveTest<HostedChefApi> {
 
    private static final String GROUP_NAME = System.getProperty("user.name") + "-jcloudstest";
 
@@ -54,12 +50,6 @@
    }
 
    @Override
-   @Test(expectedExceptions = AuthorizationException.class)
-   public void testValidatorCreateClient() throws Exception {
-      validatorClient.createClient(VALIDATOR_PREFIX);
-   }
-
-   @Override
    @Test
    public void testSearchClientsWithOptions() throws Exception {
       // This test will fail because Hosted Chef does not index client name.
@@ -69,73 +59,63 @@
    }
 
    public void testGetUser() {
-      User user = context.getApi().getUser(identity);
+      User user = api.getUser(identity);
       assertEquals(user.getUsername(), identity);
       assertNotNull(user.getPublicKey());
    }
 
    public void testGetUnexistingUser() {
-      User user = context.getApi().getUser(UUID.randomUUID().toString());
+      User user = api.getUser(UUID.randomUUID().toString());
       assertNull(user);
    }
 
    public void testListGroups() {
-      Set<String> groups = context.getApi().listGroups();
+      Set<String> groups = api.listGroups();
       assertNotNull(groups);
       assertFalse(groups.isEmpty());
    }
 
    public void testGetUnexistingGroup() {
-      Group group = context.getApi().getGroup(UUID.randomUUID().toString());
+      Group group = api.getGroup(UUID.randomUUID().toString());
       assertNull(group);
    }
 
    public void testCreateGroup() {
-      context.getApi().createGroup(GROUP_NAME);
-      Group group = context.getApi().getGroup(GROUP_NAME);
+      api.createGroup(GROUP_NAME);
+      Group group = api.getGroup(GROUP_NAME);
       assertNotNull(group);
       assertEquals(group.getGroupname(), GROUP_NAME);
    }
 
    @Test(dependsOnMethods = "testCreateGroup")
    public void testUpdateGroup() {
-      Group group = context.getApi().getGroup(GROUP_NAME);
+      Group group = api.getGroup(GROUP_NAME);
       group.setUsers(ImmutableSet.of(identity));
-      group.setClients(ImmutableSet.of(validatorIdentity));
+      group.setClients(ImmutableSet.of(identity));
 
-      context.getApi().updateGroup(group);
-      group = context.getApi().getGroup(GROUP_NAME);
+      api.updateGroup(group);
+      group = api.getGroup(GROUP_NAME);
 
       assertNotNull(group);
       assertTrue(group.getUsers().contains(identity));
-      assertTrue(group.getClients().contains(validatorIdentity));
+      assertTrue(group.getClients().contains(identity));
    }
 
    @Test(expectedExceptions = ResourceNotFoundException.class)
    public void testUpdateUnexistingGroup() {
-      context.getApi().updateGroup(new Group(UUID.randomUUID().toString()));
+      api.updateGroup(new Group(UUID.randomUUID().toString()));
    }
 
    @Test(dependsOnMethods = "testUpdateGroup")
    public void testDeleteGroup() {
-      context.getApi().deleteGroup(GROUP_NAME);
-      Group group = context.getApi().getGroup(GROUP_NAME);
+      api.deleteGroup(GROUP_NAME);
+      Group group = api.getGroup(GROUP_NAME);
       assertNull(group);
    }
 
    @Test(expectedExceptions = ResourceNotFoundException.class)
    public void testDeleteUnexistingGroup() {
-      context.getApi().deleteGroup(UUID.randomUUID().toString());
-   }
-
-   @Override
-   protected ChefApi getChefApi(HostedChefContext context) {
-      return context.getApi().getChefApi();
-   }
-
-   @Override
-   protected TypeToken<HostedChefContext> contextType() {
-      return typeToken(HostedChefContext.class);
+      api.deleteGroup(UUID.randomUUID().toString());
    }
 
 }
diff --git a/labs/privatechef/pom.xml b/labs/privatechef/pom.xml
index bb41693..b77e608 100644
--- a/labs/privatechef/pom.xml
+++ b/labs/privatechef/pom.xml
@@ -33,15 +33,12 @@
     <description>jclouds components to access Private Chef</description>
 
     <properties>
-        <test.jclouds.privatechef.org>YOUR_ORG</test.jclouds.privatechef.org>
-        <test.privatechef.endpoint>https://api.opscode.com/organizations/${test.jclouds.privatechef.org}</test.privatechef.endpoint>
+        <test.privatechef.org>YOUR_ORG</test.privatechef.org>
+        <test.privatechef.endpoint>https://api.opscode.com/organizations/${test.privatechef.org}</test.privatechef.endpoint>
         <test.privatechef.api-version />
         <test.privatechef.build-version />
         <test.privatechef.identity>YOUR_USER</test.privatechef.identity>
-        <test.privatechef.credential>${user.home}/.chef/${test.jclouds.privatechef.org}/${jclouds.privatechef.identity}.pem</test.privatechef.credential>
-        <test.privatechef.validator.identity>${test.jclouds.privatechef.org}-validator</test.privatechef.validator.identity>
-        <test.privatechef.validator.credential>${user.home}/.chef/${test.jclouds.privatechef.org}/${test.privatechef.validator.identity}.pem</test.privatechef.validator.credential>
-
+        <test.privatechef.credential>${user.home}/.chef/${test.privatechef.org}/${jclouds.privatechef.identity}.pem</test.privatechef.credential>
         <jclouds.osgi.export>org.jclouds.privatechef*;version="${project.version}"</jclouds.osgi.export>
         <jclouds.osgi.import>org.jclouds*;version="${project.version}",*</jclouds.osgi.import>
     </properties>
@@ -109,7 +106,7 @@
                                 </goals>
                                 <configuration>
                                     <systemPropertyVariables>
-                                        <test.jclouds.privatechef.org>${test.jclouds.privatechef.org}</test.jclouds.privatechef.org>
+                                        <test.privatechef.org>${test.privatechef.org}</test.privatechef.org>
                                         <test.privatechef.endpoint>${test.privatechef.endpoint}</test.privatechef.endpoint>
                                         <test.privatechef.api-version>${test.privatechef.api-version}</test.privatechef.api-version>
                                         <test.privatechef.build-version>${test.privatechef.build-version}</test.privatechef.build-version>
diff --git a/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefApiMetadata.java b/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefApiMetadata.java
index 3585058..66d1447 100644
--- a/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefApiMetadata.java
+++ b/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefApiMetadata.java
@@ -18,14 +18,13 @@
  */
 package org.jclouds.privatechef;
 
-import static org.jclouds.reflect.Reflection2.typeToken;
-
 import java.net.URI;
 import java.util.Properties;
 
 import org.jclouds.apis.ApiMetadata;
 import org.jclouds.chef.ChefApiMetadata;
 import org.jclouds.chef.ChefAsyncApi;
+import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.config.ChefBootstrapModule;
 import org.jclouds.chef.config.ChefParserModule;
 import org.jclouds.ohai.config.JMXOhaiModule;
@@ -71,7 +70,7 @@
                .documentation(URI.create("http://www.opscode.com/support/"))
                .defaultEndpoint("https://api.opscode.com")
                .defaultProperties(PrivateChefApiMetadata.defaultProperties())
-               .context(typeToken(PrivateChefContext.class))
+               .view(ChefContext.class)
                .defaultModules(
                      ImmutableSet.<Class<? extends Module>> of(PrivateChefRestClientModule.class,
                            ChefParserModule.class, ChefBootstrapModule.class, JMXOhaiModule.class));
diff --git a/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefAsyncApi.java b/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefAsyncApi.java
index aa86f0c..61da123 100644
--- a/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefAsyncApi.java
+++ b/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefAsyncApi.java
@@ -32,7 +32,11 @@
  * 
  * @see HostedChefAsyncApi
  * @author Ignasi Barrera
+ * @deprecated please use {@code org.jclouds.ContextBuilder#buildApi(PrivateChefApi.class)}
+ *             as {@link PrivateChefAsyncApi} interface will be removed in
+ *             jclouds 1.7.
  */
+@Deprecated
 @RequestFilters(SignedHeaderAuth.class)
 @Consumes(MediaType.APPLICATION_JSON)
 @Headers(keys = "X-Chef-Version", values = "{" + Constants.PROPERTY_API_VERSION + "}")
diff --git a/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefContext.java b/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefContext.java
deleted file mode 100644
index f145509..0000000
--- a/labs/privatechef/src/main/java/org/jclouds/privatechef/PrivateChefContext.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds 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.privatechef;
-
-import org.jclouds.privatechef.internal.PrivateChefContextImpl;
-import org.jclouds.rest.RestContext;
-
-import com.google.inject.ImplementedBy;
-
-@ImplementedBy(PrivateChefContextImpl.class)
-public interface PrivateChefContext extends RestContext<PrivateChefApi, PrivateChefAsyncApi> {
-
-}
diff --git a/labs/privatechef/src/main/java/org/jclouds/privatechef/config/PrivateChefRestClientModule.java b/labs/privatechef/src/main/java/org/jclouds/privatechef/config/PrivateChefRestClientModule.java
index 2a211b0..63d9755 100644
--- a/labs/privatechef/src/main/java/org/jclouds/privatechef/config/PrivateChefRestClientModule.java
+++ b/labs/privatechef/src/main/java/org/jclouds/privatechef/config/PrivateChefRestClientModule.java
@@ -20,20 +20,13 @@
 
 import static org.jclouds.reflect.Reflection2.typeToken;
 
-import java.util.Map;
-
 import org.jclouds.chef.ChefApi;
 import org.jclouds.chef.ChefAsyncApi;
 import org.jclouds.chef.config.BaseChefRestClientModule;
-import org.jclouds.hostedchef.PatchedChefApi;
-import org.jclouds.hostedchef.PatchedChefAsyncApi;
 import org.jclouds.privatechef.PrivateChefApi;
 import org.jclouds.privatechef.PrivateChefAsyncApi;
 import org.jclouds.rest.ConfiguresRestClient;
 
-import com.google.common.collect.ImmutableMap;
-import com.google.inject.Provides;
-
 /**
  * Configures the Hosted Chef connection.
  * 
@@ -41,21 +34,16 @@
  */
 @ConfiguresRestClient
 public class PrivateChefRestClientModule extends BaseChefRestClientModule<PrivateChefApi, PrivateChefAsyncApi> {
-   public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder()//
-         .put(PatchedChefApi.class, PatchedChefAsyncApi.class)//
-         .build();
 
    public PrivateChefRestClientModule() {
-      super(typeToken(PrivateChefApi.class), typeToken(PrivateChefAsyncApi.class), DELEGATE_MAP);
+      super(typeToken(PrivateChefApi.class), typeToken(PrivateChefAsyncApi.class));
    }
 
-   @Provides
-   private ChefApi provideChefApi(PrivateChefApi in){
-      return in.getChefApi();
+   @Override
+   protected void configure() {
+      super.configure();
+      bind(ChefApi.class).to(PrivateChefApi.class);
+      bind(ChefAsyncApi.class).to(PrivateChefAsyncApi.class);
    }
 
-   @Provides
-   private ChefAsyncApi provideChefApi(PrivateChefAsyncApi in){
-      return in.getChefApi();
-   }
 }
diff --git a/labs/privatechef/src/main/java/org/jclouds/privatechef/internal/PrivateChefContextImpl.java b/labs/privatechef/src/main/java/org/jclouds/privatechef/internal/PrivateChefContextImpl.java
deleted file mode 100644
index 7ba8d80..0000000
--- a/labs/privatechef/src/main/java/org/jclouds/privatechef/internal/PrivateChefContextImpl.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * Licensed to jclouds, Inc. (jclouds) under one or more
- * contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  jclouds 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.privatechef.internal;
-
-import javax.inject.Inject;
-import javax.inject.Singleton;
-
-import org.jclouds.annotations.Name;
-import org.jclouds.domain.Credentials;
-import org.jclouds.lifecycle.Closer;
-import org.jclouds.location.Provider;
-import org.jclouds.privatechef.PrivateChefApi;
-import org.jclouds.privatechef.PrivateChefAsyncApi;
-import org.jclouds.privatechef.PrivateChefContext;
-import org.jclouds.providers.ProviderMetadata;
-import org.jclouds.rest.Utils;
-import org.jclouds.rest.internal.RestContextImpl;
-
-import com.google.common.base.Supplier;
-import com.google.inject.Injector;
-import com.google.inject.TypeLiteral;
-
-/**
- * @author Adrian Cole
- */
-@Singleton
-public class PrivateChefContextImpl extends RestContextImpl<PrivateChefApi, PrivateChefAsyncApi> implements
-      PrivateChefContext {
-
-   @Inject
-   protected PrivateChefContextImpl(@Name String name, ProviderMetadata providerMetadata,
-         @Provider Supplier<Credentials> creds, Utils utils, Closer closer, Injector injector) {
-      super(name, providerMetadata, creds, utils, closer, injector, TypeLiteral.get(PrivateChefApi.class), TypeLiteral
-            .get(PrivateChefAsyncApi.class));
-   }
-
-}
diff --git a/servlet/src/main/java/org/jclouds/chef/servlet/ChefRegistrationListener.java b/servlet/src/main/java/org/jclouds/chef/servlet/ChefRegistrationListener.java
index 228afc8..cff935b 100644
--- a/servlet/src/main/java/org/jclouds/chef/servlet/ChefRegistrationListener.java
+++ b/servlet/src/main/java/org/jclouds/chef/servlet/ChefRegistrationListener.java
@@ -35,7 +35,9 @@
 import javax.servlet.ServletContextListener;
 
 import org.jclouds.ContextBuilder;
+import org.jclouds.chef.ChefApi;
 import org.jclouds.chef.ChefApiMetadata;
+import org.jclouds.chef.ChefAsyncApi;
 import org.jclouds.chef.ChefContext;
 import org.jclouds.chef.ChefService;
 import org.jclouds.chef.domain.Node;
@@ -45,6 +47,8 @@
 
 import com.google.common.base.Splitter;
 import com.google.common.collect.ImmutableSet;
+import com.google.common.io.Closeables;
+import com.google.common.reflect.TypeToken;
 import com.google.inject.AbstractModule;
 
 /**
@@ -103,7 +107,9 @@
 	}
 
 	private String findNextNodeName(ChefService client, String pattern) {
-		Set<String> nodes = client.getContext().getApi().listNodes();
+	    ChefApi api = client.getContext().unwrap(new TypeToken<org.jclouds.rest.RestContext<ChefApi, ChefAsyncApi>>() {
+        }).getApi();
+		Set<String> nodes = api.listNodes();
 		String nodeName;
 		Set<String> names = newHashSet(nodes);
 		int index = 0;
@@ -127,7 +133,7 @@
 								servletContextEvent.getServletContext());
 					}
 
-				})).overrides(props).build(typeToken(ChefContext.class))
+				})).overrides(props).buildView(ChefContext.class)
 				.getChefService();
 	}
 
@@ -155,7 +161,7 @@
 			client.deleteAllNodesInList(singleton(node.getName()));
 		}
 		if (client != null) {
-			client.getContext().close();
+			Closeables.closeQuietly(client.getContext());
 		}
 	}
 }
\ No newline at end of file