adjusted example for box.net to use rest.properties

This commit is contained in:
Adrian Cole 2010-12-21 21:13:35 +01:00
parent 946311f812
commit 28fd8b8d4f
2 changed files with 16 additions and 5 deletions

View File

@ -23,10 +23,12 @@ import org.jclouds.boxdotnet.BoxDotNetAsyncClient;
import org.jclouds.boxdotnet.BoxDotNetClient; import org.jclouds.boxdotnet.BoxDotNetClient;
import org.jclouds.boxdotnet.handlers.BoxDotNetErrorHandler; import org.jclouds.boxdotnet.handlers.BoxDotNetErrorHandler;
import org.jclouds.http.HttpErrorHandler; import org.jclouds.http.HttpErrorHandler;
import org.jclouds.http.HttpRetryHandler;
import org.jclouds.http.RequiresHttp; import org.jclouds.http.RequiresHttp;
import org.jclouds.http.annotation.ClientError; import org.jclouds.http.annotation.ClientError;
import org.jclouds.http.annotation.Redirection; import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError; import org.jclouds.http.annotation.ServerError;
import org.jclouds.http.handlers.BackoffLimitedRetryHandler;
import org.jclouds.rest.ConfiguresRestClient; import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule; import org.jclouds.rest.config.RestClientModule;
@ -53,7 +55,7 @@ public class BoxDotNetRestClientModule extends
@Override @Override
protected void bindRetryHandlers() { protected void bindRetryHandlers() {
// TODO bind(HttpRetryHandler.class).annotatedWith(ClientError.class).to(BackoffLimitedRetryHandler.class);
} }
} }

View File

@ -20,15 +20,20 @@
package org.jclouds.boxdotnet; package org.jclouds.boxdotnet;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
import static org.jclouds.rest.RestContextFactory.contextSpec;
import static org.jclouds.rest.RestContextFactory.createContext;
import static org.testng.Assert.assertNotNull; import static org.testng.Assert.assertNotNull;
import java.util.Properties;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import org.jclouds.rest.RestContext; import org.jclouds.rest.RestContext;
import org.jclouds.rest.RestContextFactory;
import org.testng.annotations.AfterGroups; import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups; import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
/** /**
* Tests behavior of {@code BoxDotNetClient} * Tests behavior of {@code BoxDotNetClient}
* *
@ -45,8 +50,12 @@ public class BoxDotNetClientLiveTest {
String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity"); String identity = checkNotNull(System.getProperty("jclouds.test.identity"), "jclouds.test.identity");
String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential"); String credential = checkNotNull(System.getProperty("jclouds.test.credential"), "jclouds.test.credential");
context = createContext(contextSpec("boxdotnet", "https://www.box.net/api/1.0/rest", "1.0", Properties restProperties = new Properties();
identity, credential, BoxDotNetClient.class, BoxDotNetAsyncClient.class)); restProperties.setProperty("boxdotnet.contextbuilder", "org.jclouds.boxdotnet.BoxDotNetContextBuilder");
restProperties.setProperty("boxdotnet.propertiesbuilder", "org.jclouds.boxdotnet.BoxDotNetPropertiesBuilder");
context = new RestContextFactory(restProperties).createContext("boxdotnet", identity, credential,
ImmutableSet.<Module> of(new Log4JLoggingModule()));
connection = context.getApi(); connection = context.getApi();
} }