Issue 1022:Move naming convention to Api from Client or Services:: cdmi

This commit is contained in:
Adrian Cole 2012-07-15 15:47:44 -07:00
parent 929a9ce044
commit 647317b9b4
23 changed files with 185 additions and 185 deletions

View File

@ -22,36 +22,36 @@ import java.util.concurrent.TimeUnit;
import org.jclouds.concurrent.Timeout;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.snia.cdmi.v1.features.ContainerClient;
import org.jclouds.snia.cdmi.v1.features.DataClient;
import org.jclouds.snia.cdmi.v1.features.DomainClient;
import org.jclouds.snia.cdmi.v1.features.ContainerApi;
import org.jclouds.snia.cdmi.v1.features.DataApi;
import org.jclouds.snia.cdmi.v1.features.DomainApi;
/**
* Provides synchronous access to CDMI.
* <p/>
*
* @see CDMIAsyncClient
* @see CDMIAsyncApi
* @see <a href="http://www.snia.org/cdmi">api doc</a>
* @author Adrian Cole
*/
@Timeout(duration = 60, timeUnit = TimeUnit.SECONDS)
public interface CDMIClient {
public interface CDMIApi {
/**
* Provides synchronous access to Domain Object Resource Operations.
*/
@Delegate
DomainClient getDomainClient();
DomainApi getDomainApi();
/**
* Provides synchronous access to Container Object Resource Operations.
*/
@Delegate
ContainerClient getContainerClient();
ContainerApi getContainerApi();
/**
* Provides synchronous access to Data Object Resource Operations.
*/
@Delegate
DataClient getDataClient();
DataApi getDataApi();
}

View File

@ -40,7 +40,7 @@ public class CDMIApiMetadata extends BaseRestApiMetadata {
/** The serialVersionUID */
private static final long serialVersionUID = 6725672099385580694L;
public static final TypeToken<RestContext<CDMIClient, CDMIAsyncClient>> CONTEXT_TOKEN = new TypeToken<RestContext<CDMIClient, CDMIAsyncClient>>() {
public static final TypeToken<RestContext<CDMIApi, CDMIAsyncApi>> CONTEXT_TOKEN = new TypeToken<RestContext<CDMIApi, CDMIAsyncApi>>() {
private static final long serialVersionUID = -5070937833892503232L;
};
@ -65,7 +65,7 @@ public class CDMIApiMetadata extends BaseRestApiMetadata {
public static class Builder extends BaseRestApiMetadata.Builder {
protected Builder() {
super(CDMIClient.class, CDMIAsyncClient.class);
super(CDMIApi.class, CDMIAsyncApi.class);
id("cdmi")
.name("SNIA CDMI API")
.identityName("tenantId:user")

View File

@ -19,35 +19,35 @@
package org.jclouds.snia.cdmi.v1;
import org.jclouds.rest.annotations.Delegate;
import org.jclouds.snia.cdmi.v1.features.ContainerAsyncClient;
import org.jclouds.snia.cdmi.v1.features.DataAsyncClient;
import org.jclouds.snia.cdmi.v1.features.DomainAsyncClient;
import org.jclouds.snia.cdmi.v1.features.ContainerAsyncApi;
import org.jclouds.snia.cdmi.v1.features.DataAsyncApi;
import org.jclouds.snia.cdmi.v1.features.DomainAsyncApi;
/**
* Provides asynchronous access to CDMI via their REST API.
* <p/>
*
* @see CDMIClient
* @see CDMIApi
* @see <a href="http://www.snia.org/cdmi">api doc</a>
* @author Adrian Cole
*/
public interface CDMIAsyncClient {
public interface CDMIAsyncApi {
/**
* Provides asynchronous access to Domain Object Resource Operations.
*/
@Delegate
DomainAsyncClient getDomainClient();
DomainAsyncApi getDomainApi();
/**
* Provides asynchronous access to Container Object Resource Operations.
*/
@Delegate
ContainerAsyncClient getContainerClient();
ContainerAsyncApi getContainerApi();
/**
* Provides asynchronous access to Data Object Resource Operations.
*/
@Delegate
DataAsyncClient getDataClient();
DataAsyncApi getDataApi();
}

View File

@ -28,4 +28,4 @@ public interface ObjectTypes {
public static final String CONTAINER = "application/cdmi-container";
public static final String DATAOBJECT = "application/cdmi-object";
public static final String CDMIOBJECT = "application/cdmi-object";
}
}

View File

@ -26,14 +26,14 @@ import org.jclouds.http.annotation.Redirection;
import org.jclouds.http.annotation.ServerError;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.config.RestClientModule;
import org.jclouds.snia.cdmi.v1.CDMIAsyncClient;
import org.jclouds.snia.cdmi.v1.CDMIClient;
import org.jclouds.snia.cdmi.v1.features.ContainerAsyncClient;
import org.jclouds.snia.cdmi.v1.features.ContainerClient;
import org.jclouds.snia.cdmi.v1.features.DataAsyncClient;
import org.jclouds.snia.cdmi.v1.features.DataClient;
import org.jclouds.snia.cdmi.v1.features.DomainAsyncClient;
import org.jclouds.snia.cdmi.v1.features.DomainClient;
import org.jclouds.snia.cdmi.v1.CDMIAsyncApi;
import org.jclouds.snia.cdmi.v1.CDMIApi;
import org.jclouds.snia.cdmi.v1.features.ContainerAsyncApi;
import org.jclouds.snia.cdmi.v1.features.ContainerApi;
import org.jclouds.snia.cdmi.v1.features.DataAsyncApi;
import org.jclouds.snia.cdmi.v1.features.DataApi;
import org.jclouds.snia.cdmi.v1.features.DomainAsyncApi;
import org.jclouds.snia.cdmi.v1.features.DomainApi;
import org.jclouds.snia.cdmi.v1.handlers.CDMIErrorHandler;
import com.google.common.collect.ImmutableMap;
@ -44,11 +44,11 @@ import com.google.common.collect.ImmutableMap;
* @author Adrian Cole
*/
@ConfiguresRestClient
public class CDMIRestClientModule extends RestClientModule<CDMIClient, CDMIAsyncClient> {
public class CDMIRestClientModule extends RestClientModule<CDMIApi, CDMIAsyncApi> {
public static final Map<Class<?>, Class<?>> DELEGATE_MAP = ImmutableMap.<Class<?>, Class<?>> builder().put(
DomainClient.class, DomainAsyncClient.class).put(ContainerClient.class, ContainerAsyncClient.class).put(
DataClient.class, DataAsyncClient.class).build();
DomainApi.class, DomainAsyncApi.class).put(ContainerApi.class, ContainerAsyncApi.class).put(
DataApi.class, DataAsyncApi.class).build();
public CDMIRestClientModule() {
super(DELEGATE_MAP);

View File

@ -27,12 +27,12 @@ import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions;
/**
* Container Object Resource Operations
*
* @see ContainerAsyncClient
* @see ContainerAsyncApi
* @author Kenneth Nagin
* @see <a href="http://www.snia.org/cdmi">api doc</a>
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface ContainerClient {
public interface ContainerApi {
Container createContainer(String containerName,
CreateContainerOptions... options);

View File

@ -45,17 +45,17 @@ import com.google.common.util.concurrent.ListenableFuture;
/**
* Container Object Resource Operations
*
* @see ContainerClient
* @see ContainerApi
* @author Kenneth Nagin
* @see <a href="http://www.snia.org/cdmi">api doc</a>
*/
@SkipEncoding( { '/', '=' })
@RequestFilters( { BasicAuthenticationAndTenantId.class, StripExtraAcceptHeader.class })
@Headers(keys="X-CDMI-Specification-Version", values = "{jclouds.api-version}")
public interface ContainerAsyncClient {
public interface ContainerAsyncApi {
/**
* @see ContainerClient#listContainers()
* @see ContainerApi#listContainers()
*/
@GET
@Consumes( { ObjectTypes.CONTAINER, MediaType.APPLICATION_JSON })
@ -64,7 +64,7 @@ public interface ContainerAsyncClient {
ListenableFuture<Container> getContainer(@PathParam("containerName") String containerName);
/**
* @see ContainerClient#createContainer
* @see ContainerApi#createContainer
*/
@PUT
@Consumes( { ObjectTypes.CONTAINER, MediaType.APPLICATION_JSON })
@ -75,7 +75,7 @@ public interface ContainerAsyncClient {
CreateContainerOptions... options);
/**
* @see ContainerClient#createContainer()
* @see ContainerApi#createContainer()
*/
@DELETE
@Consumes( MediaType.APPLICATION_JSON )

View File

@ -27,12 +27,12 @@ import org.jclouds.snia.cdmi.v1.options.CreateDataObjectOptions;
/**
* Data Object Resource Operations
*
* @see DataAsyncClient
* @see DataAsyncApi
* @author Kenneth Nagin
* @see <a href="http://www.snia.org/cdmi">api doc</a>
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface DataClient {
public interface DataApi {
DataObject createDataObject(String containerName, String dataObjectName,
CreateDataObjectOptions... options);

View File

@ -44,16 +44,16 @@ import com.google.common.util.concurrent.ListenableFuture;
/**
* Data Object Resource Operations
*
* @see DataClient
* @see DataApi
* @author Kenneth Nagin
* @see <a href="http://www.snia.org/cdmi">api doc</a>
*/
@SkipEncoding({ '/', '=' })
@RequestFilters({ BasicAuthenticationAndTenantId.class,
StripExtraAcceptHeader.class })
public interface DataAsyncClient {
public interface DataAsyncApi {
/**
* @see DataClient#getDataObject()
* @see DataApi#getDataObject()
*/
@Headers(keys = "X-CDMI-Specification-Version", values = "{jclouds.api-version}")
@GET
@ -65,7 +65,7 @@ public interface DataAsyncClient {
@PathParam("dataObjectName") String dataObjectName);
/**
* @see DataClient#createDataObject
* @see DataApi#createDataObject
*/
@Headers(keys = "X-CDMI-Specification-Version", values = "{jclouds.api-version}")
@PUT
@ -79,7 +79,7 @@ public interface DataAsyncClient {
CreateDataObjectOptions... options);
/**
* @see DataClient#createDataObjectNonCDMI
* @see DataApi#createDataObjectNonCDMI
*/
@PUT
@Consumes({ "text/plain" })
@ -92,7 +92,7 @@ public interface DataAsyncClient {
CreateDataObjectNonCDMIOptions... options);
/**
* @see DataClient#deleteDataObject()
* @see DataApi#deleteDataObject()
*/
@Headers(keys = "X-CDMI-Specification-Version", values = "{jclouds.api-version}")
@DELETE

View File

@ -25,12 +25,12 @@ import org.jclouds.concurrent.Timeout;
/**
* Domain Object Resource Operations
*
* @see DomainAsyncClient
* @see DomainAsyncApi
* @author Adrian Cole
* @see <a href="http://www.snia.org/cdmi">api doc</a>
*/
@Timeout(duration = 180, timeUnit = TimeUnit.SECONDS)
public interface DomainClient {
public interface DomainApi {
}

View File

@ -27,14 +27,14 @@ import org.jclouds.snia.cdmi.v1.filters.StripExtraAcceptHeader;
/**
* Domain Object Resource Operations
*
* @see DomainClient
* @see DomainApi
* @author Adrian Cole
* @see <a href="http://www.snia.org/cdmi">api doc</a>
*/
@SkipEncoding( { '/', '=' })
@RequestFilters( { BasicAuthenticationAndTenantId.class, StripExtraAcceptHeader.class })
@Headers(keys="X-CDMI-Specification-Version", values = "{jclouds.api-version}")
public interface DomainAsyncClient {
public interface DomainAsyncApi {
}

View File

@ -58,4 +58,4 @@ public class BasicAuthenticationAndTenantId implements HttpRequestFilter {
public HttpRequest filter(HttpRequest request) throws HttpException {
return basicAuthentication.filter(request.toBuilder().replaceHeader("TID", tenantId).build());
}
}
}

View File

@ -39,4 +39,4 @@ public class StripExtraAcceptHeader implements HttpRequestFilter {
public HttpRequest filter(HttpRequest request) throws HttpException {
return request.toBuilder().replaceHeader("Accept", request.getFirstHeaderOrNull("Accept")).build();
}
}
}

View File

@ -23,8 +23,8 @@ import static org.testng.Assert.assertEquals;
import org.jclouds.crypto.CryptoStreams;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.snia.cdmi.v1.CDMIClient;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIClientExpectTest;
import org.jclouds.snia.cdmi.v1.CDMIApi;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiExpectTest;
import org.jclouds.snia.cdmi.v1.parse.ParseContainerTest;
import org.testng.annotations.Test;
@ -34,8 +34,8 @@ import com.google.common.collect.ImmutableMultimap;
*
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "ContainerAsyncClientTest")
public class ContainerClientExpectTest extends BaseCDMIClientExpectTest {
@Test(groups = "unit", testName = "ContainerAsyncApiTest")
public class ContainerApiExpectTest extends BaseCDMIApiExpectTest {
public void testGetContainerWhenResponseIs2xx() throws Exception {
@ -55,10 +55,10 @@ public class ContainerClientExpectTest extends BaseCDMIClientExpectTest {
.payload(payloadFromResource("/container.json"))
.build();
CDMIClient clientWhenContainersExist = requestSendsResponse(getContainer, getContainerResponse);
CDMIApi apiWhenContainersExist = requestSendsResponse(getContainer, getContainerResponse);
assertEquals(
clientWhenContainersExist.getContainerClient().getContainer("MyContainer"),
apiWhenContainersExist.getContainerApi().getContainer("MyContainer"),
new ParseContainerTest().expected());
}

View File

@ -30,7 +30,7 @@ import java.util.logging.Logger;
import org.jclouds.domain.JsonBall;
import org.jclouds.snia.cdmi.v1.ObjectTypes;
import org.jclouds.snia.cdmi.v1.domain.Container;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIClientLiveTest;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest;
import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions;
import org.testng.annotations.Test;
@ -39,8 +39,8 @@ import org.testng.annotations.Test;
* @author Kenneth Nagin
*/
@Test(groups = "live", testName = "ContainerClientLiveTest")
public class ContainerClientLiveTest extends BaseCDMIClientLiveTest {
@Test(groups = "live", testName = "ContainerApiLiveTest")
public class ContainerApiLiveTest extends BaseCDMIApiLiveTest {
@Test
public void testCreateContainer() throws Exception {
@ -52,14 +52,14 @@ public class ContainerClientLiveTest extends BaseCDMIClientLiveTest {
pContainerMetaDataIn.put("containerkey3", "value3");
CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder
.withMetadata(pContainerMetaDataIn);
ContainerClient client = cdmiContext.getApi().getContainerClient();
ContainerApi api = cdmiContext.getApi().getContainerApi();
Logger.getAnonymousLogger().info("createContainer: " + pContainerName);
Container container = client.createContainer(pContainerName,
Container container = api.createContainer(pContainerName,
pCreateContainerOptions);
assertNotNull(container);
System.out.println(container);
Logger.getAnonymousLogger().info("getContainer: " + pContainerName);
container = client.getContainer(pContainerName);
container = api.getContainer(pContainerName);
assertNotNull(container);
System.out.println(container);
assertEquals(container.getObjectType(), ObjectTypes.CONTAINER);
@ -96,13 +96,13 @@ public class ContainerClientLiveTest extends BaseCDMIClientLiveTest {
for (Map<String, String> aclMap : aclMetadataOut) {
System.out.println(aclMap);
}
container = client.getContainer("/");
container = api.getContainer("/");
System.out.println("root container: " + container);
assertEquals(container.getChildren().contains(pContainerName + "/"),
true);
Logger.getAnonymousLogger().info("deleteContainer: " + pContainerName);
client.deleteContainer(pContainerName);
container = client.getContainer("/");
api.deleteContainer(pContainerName);
container = api.getContainer("/");
System.out.println("root container: " + container);
assertEquals(container.getChildren().contains(pContainerName + "/"),
false);

View File

@ -18,13 +18,13 @@
*/
package org.jclouds.snia.cdmi.v1.features;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIClientExpectTest;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiExpectTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "DataAsyncClientTest")
public class DataClientExpectTest extends BaseCDMIClientExpectTest {
@Test(groups = "unit", testName = "DataAsyncApiTest")
public class DataApiExpectTest extends BaseCDMIApiExpectTest {
}

View File

@ -35,7 +35,7 @@ import java.util.logging.Logger;
import org.jclouds.snia.cdmi.v1.domain.Container;
import org.jclouds.snia.cdmi.v1.domain.DataObject;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIClientLiveTest;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest;
import org.jclouds.snia.cdmi.v1.options.CreateContainerOptions;
import org.jclouds.snia.cdmi.v1.options.CreateDataObjectNonCDMIOptions;
import org.jclouds.snia.cdmi.v1.options.CreateDataObjectOptions;
@ -48,8 +48,8 @@ import com.google.common.io.Files;
/**
* @author Kenneth Nagin
*/
@Test(groups = "live", testName = "DataClientLiveTest")
public class DataClientLiveTest extends BaseCDMIClientLiveTest {
@Test(groups = "live", testName = "DataApiLiveTest")
public class DataApiLiveTest extends BaseCDMIApiLiveTest {
@Test
public void testCreateDataObjects() throws Exception {
@ -72,16 +72,16 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
CreateContainerOptions pCreateContainerOptions = CreateContainerOptions.Builder
.withMetadata(pContainerMetaDataIn);
ContainerClient containerClient = cdmiContext.getApi()
.getContainerClient();
DataClient dataClient = cdmiContext.getApi().getDataClient();
ContainerApi containerApi = cdmiContext.getApi()
.getContainerApi();
DataApi dataApi = cdmiContext.getApi().getDataApi();
Logger.getAnonymousLogger().info("createContainer: " + containerName);
Container container = containerClient.createContainer(containerName,
Container container = containerApi.createContainer(containerName,
pCreateContainerOptions);
try {
assertNotNull(container);
System.out.println(container);
container = containerClient.getContainer(containerName);
container = containerApi.getContainer(containerName);
assertNotNull(container);
assertNotNull(container.getChildren());
assertEquals(container.getChildren().isEmpty(), true);
@ -90,10 +90,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
value = "Hello CDMI World1";
CreateDataObjectNonCDMIOptions pCreateDataObjectNoneCDMIOptions = CreateDataObjectNonCDMIOptions.Builder
.withStringPayload(value);
dataClient.createDataObjectNonCDMI(containerName, dataObjectNameIn,
dataApi.createDataObjectNonCDMI(containerName, dataObjectNameIn,
pCreateDataObjectNoneCDMIOptions);
System.out.println(containerClient.getContainer(containerName));
dataObject = dataClient.getDataObject(containerName,
System.out.println(containerApi.getContainer(containerName));
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -106,10 +106,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with value mimetype and metadata
@ -117,10 +117,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(value).mimetype("text/plain")
.metadata(pDataObjectMetaDataIn);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -142,10 +142,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// verify that options order does not matter
@ -153,10 +153,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.metadata(pDataObjectMetaDataIn).mimetype("text/plain")
.value(value);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -178,10 +178,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with empty metadata
@ -190,10 +190,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(value).mimetype("text/plain")
.metadata(pDataObjectMetaDataIn);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -209,20 +209,20 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with null metadata
value = "Hello CDMI World5";
pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(
value).mimetype("text/plain");
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -238,20 +238,20 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with only value
value = "Hello CDMI World6";
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(value);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -266,20 +266,20 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with empty mimetype only
value = "";
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.mimetype(new String());
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -290,15 +290,15 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertNotNull(dataObjectMetaDataOut);
assertEquals(true, dataObjectMetaDataOut.isEmpty());
dataClient.deleteDataObject(containerName, dataObjectNameIn);
dataApi.deleteDataObject(containerName, dataObjectNameIn);
// exercise create data object with no value
value = "";
pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value();
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -313,10 +313,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with byte array
@ -328,10 +328,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
byte[] bytes = bos.toByteArray();
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(bytes);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -344,10 +344,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with an existing file
@ -356,10 +356,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(true, inFile.isFile());
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(inFile);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -374,10 +374,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with a temporary file that we create
@ -387,10 +387,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
Files.write(value, tmpFileIn, Charsets.UTF_8);
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(tmpFileIn);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -405,10 +405,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with a temporary file that we create
@ -417,10 +417,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
Files.write(value, tmpFileIn, Charsets.UTF_8);
pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(
tmpFileIn, Charsets.UTF_8);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -435,10 +435,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with a temporary file that we create
@ -447,10 +447,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
Files.write(value, tmpFileIn, Charsets.US_ASCII);
pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(
tmpFileIn, Charsets.US_ASCII);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -465,10 +465,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with a temporary file with multiple
@ -479,10 +479,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
Files.append("\nline3", tmpFileIn, Charsets.UTF_8);
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(tmpFileIn);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -498,10 +498,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with a temporary file with multiple
@ -512,10 +512,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
Files.append("\nline3", tmpFileIn, Charsets.UTF_8);
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(new FileInputStream(tmpFileIn));
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -531,10 +531,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with a temporary file with multiple
@ -545,10 +545,10 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
Files.append("\nline3", tmpFileIn, Charsets.ISO_8859_1);
pCreateDataObjectOptions = CreateDataObjectOptions.Builder.value(
new FileInputStream(tmpFileIn), Charsets.ISO_8859_1);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -564,20 +564,20 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
// exercise create data object with an inputstream
is = new ByteArrayInputStream(value.getBytes());
pCreateDataObjectOptions = CreateDataObjectOptions.Builder
.value(is);
dataObject = dataClient.createDataObject(containerName,
dataObject = dataApi.createDataObject(containerName,
dataObjectNameIn, pCreateDataObjectOptions);
assertNotNull(dataObject);
dataObject = dataClient.getDataObject(containerName,
dataObject = dataApi.getDataObject(containerName,
dataObjectNameIn);
assertNotNull(dataObject);
System.out.println(dataObject);
@ -592,15 +592,15 @@ public class DataClientLiveTest extends BaseCDMIClientLiveTest {
assertEquals(dataObject.getObjectName(), dataObjectNameIn);
assertEquals(dataObject.getObjectType(), "application/cdmi-object");
assertEquals(dataObject.getParentURI(), "/" + containerName + "/");
assertEquals(containerClient.getContainer(containerName)
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), true);
dataClient.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerClient.getContainer(containerName)
dataApi.deleteDataObject(containerName, dataObjectNameIn);
assertEquals(containerApi.getContainer(containerName)
.getChildren().contains(dataObjectNameIn), false);
} finally {
tmpFileIn.delete();
containerClient.deleteContainer(containerName);
containerApi.deleteContainer(containerName);
}

View File

@ -18,13 +18,13 @@
*/
package org.jclouds.snia.cdmi.v1.features;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIClientExpectTest;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiExpectTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "unit", testName = "DomainClientExpectTest")
public class DomainClientExpectTest extends BaseCDMIClientExpectTest {
@Test(groups = "unit", testName = "DomainApiExpectTest")
public class DomainApiExpectTest extends BaseCDMIApiExpectTest {
}

View File

@ -18,13 +18,13 @@
*/
package org.jclouds.snia.cdmi.v1.features;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIClientLiveTest;
import org.jclouds.snia.cdmi.v1.internal.BaseCDMIApiLiveTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = "live", testName = "ContainerClientLiveTest")
public class DomainClientLiveTest extends BaseCDMIClientLiveTest {
@Test(groups = "live", testName = "ContainerApiLiveTest")
public class DomainApiLiveTest extends BaseCDMIApiLiveTest {
}

View File

@ -18,13 +18,13 @@
*/
package org.jclouds.snia.cdmi.v1.internal;
import org.jclouds.snia.cdmi.v1.CDMIClient;
import org.jclouds.snia.cdmi.v1.CDMIApi;
/**
* Base class for writing KeyStone Rest Client Expect tests
* Base class for writing KeyStone Rest Api Expect tests
*
* @author Adrian Cole
*/
public class BaseCDMIClientExpectTest extends BaseCDMIExpectTest<CDMIClient> {
public class BaseCDMIApiExpectTest extends BaseCDMIExpectTest<CDMIApi> {
}

View File

@ -21,8 +21,8 @@ package org.jclouds.snia.cdmi.v1.internal;
import org.jclouds.apis.BaseContextLiveTest;
import org.jclouds.rest.RestContext;
import org.jclouds.snia.cdmi.v1.CDMIApiMetadata;
import org.jclouds.snia.cdmi.v1.CDMIAsyncClient;
import org.jclouds.snia.cdmi.v1.CDMIClient;
import org.jclouds.snia.cdmi.v1.CDMIAsyncApi;
import org.jclouds.snia.cdmi.v1.CDMIApi;
import org.testng.annotations.AfterGroups;
import org.testng.annotations.BeforeGroups;
import org.testng.annotations.Test;
@ -30,18 +30,18 @@ import org.testng.annotations.Test;
import com.google.common.reflect.TypeToken;
/**
* Tests behavior of {@code CDMIClient}
* Tests behavior of {@code CDMIApi}
*
* @author Adrian Cole
*/
@Test(groups = "live")
public class BaseCDMIClientLiveTest extends BaseContextLiveTest<RestContext<CDMIClient, CDMIAsyncClient>> {
public class BaseCDMIApiLiveTest extends BaseContextLiveTest<RestContext<CDMIApi, CDMIAsyncApi>> {
public BaseCDMIClientLiveTest() {
public BaseCDMIApiLiveTest() {
provider = "cdmi";
}
protected RestContext<CDMIClient, CDMIAsyncClient> cdmiContext;
protected RestContext<CDMIApi, CDMIAsyncApi> cdmiContext;
@BeforeGroups(groups = { "integration", "live" })
@Override
@ -57,7 +57,7 @@ public class BaseCDMIClientLiveTest extends BaseContextLiveTest<RestContext<CDMI
}
@Override
protected TypeToken<RestContext<CDMIClient, CDMIAsyncClient>> contextType() {
protected TypeToken<RestContext<CDMIApi, CDMIAsyncApi>> contextType() {
return CDMIApiMetadata.CONTEXT_TOKEN;
}

View File

@ -22,18 +22,18 @@ import java.util.Properties;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.snia.cdmi.v1.CDMIAsyncClient;
import org.jclouds.snia.cdmi.v1.CDMIAsyncApi;
import com.google.common.base.Function;
import com.google.inject.Module;
/**
* Base class for writing KeyStone Rest Client Expect tests
* Base class for writing KeyStone Rest Api Expect tests
*
* @author Adrian Cole
*/
public class BaseCDMIAsyncClientExpectTest extends BaseCDMIExpectTest<CDMIAsyncClient> {
public CDMIAsyncClient createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props).getInstance(CDMIAsyncClient.class);
public class BaseCDMIAsyncApiExpectTest extends BaseCDMIExpectTest<CDMIAsyncApi> {
public CDMIAsyncApi createClient(Function<HttpRequest, HttpResponse> fn, Module module, Properties props) {
return createInjector(fn, module, props).getInstance(CDMIAsyncApi.class);
}
}

View File

@ -18,14 +18,14 @@
*/
package org.jclouds.snia.cdmi.v1.internal;
import org.jclouds.rest.internal.BaseRestClientExpectTest;
import org.jclouds.rest.internal.BaseRestApiExpectTest;
/**
* Base class for writing CDMI Expect tests
*
* @author Adrian Cole
*/
public class BaseCDMIExpectTest<T> extends BaseRestClientExpectTest<T> {
public class BaseCDMIExpectTest<T> extends BaseRestApiExpectTest<T> {
public BaseCDMIExpectTest() {
provider = "cdmi";