Added integration test to filesystem provider

This commit is contained in:
rainbowbreeze 2010-09-01 11:35:40 +02:00
parent 8ca932cb26
commit ddd1e76832
9 changed files with 280 additions and 14 deletions

View File

@ -52,6 +52,24 @@
<artifactId>commons-io</artifactId> <artifactId>commons-io</artifactId>
<version>1.4</version> <version>1.4</version>
</dependency> </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-blobstore</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jclouds-log4j</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<properties>
<jclouds.test.initializer>org.jclouds.filesystem.integration.FilesystemTestInitializer</jclouds.test.initializer>
</properties>
</project> </project>

View File

@ -56,7 +56,6 @@ import java.util.concurrent.ExecutorService;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named; import javax.inject.Named;
import javax.ws.rs.core.HttpHeaders;
import org.jclouds.Constants; import org.jclouds.Constants;
import org.jclouds.blobstore.domain.Blob; import org.jclouds.blobstore.domain.Blob;
@ -85,16 +84,12 @@ import org.jclouds.http.HttpResponse;
import org.jclouds.http.HttpResponseException; import org.jclouds.http.HttpResponseException;
import org.jclouds.http.options.HttpRequestOptions; import org.jclouds.http.options.HttpRequestOptions;
import org.jclouds.io.Payloads; import org.jclouds.io.Payloads;
import org.jclouds.io.payloads.ByteArrayPayload;
import org.jclouds.io.payloads.DelegatingPayload;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.google.common.base.Throwables; import com.google.common.base.Throwables;
import com.google.common.collect.Iterables; import com.google.common.collect.Iterables;
import com.google.common.collect.Multimaps;
import com.google.common.io.Closeables;
import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.internal.Nullable; import com.google.inject.internal.Nullable;

View File

@ -55,9 +55,8 @@ import static org.testng.Assert.*;
@Test(groups = "unit", testName = "filesystem.FilesystemAsyncBlobStoreTest", sequential = true) @Test(groups = "unit", testName = "filesystem.FilesystemAsyncBlobStoreTest", sequential = true)
public class FilesystemAsyncBlobStoreTest { public class FilesystemAsyncBlobStoreTest {
private static final String CONTAINER_NAME = "funambol-test"; private static final String CONTAINER_NAME = "fun-blobstore-test";
private static final String TARGET_BASE_DIR = "./target/basedir/"; private static final String TARGET_CONTAINER_NAME = TestUtils.TARGET_BASE_DIR + CONTAINER_NAME;
private static final String TARGET_CONTAINER_NAME = TARGET_BASE_DIR + CONTAINER_NAME;
private static final String LOGGING_CONFIG_KEY private static final String LOGGING_CONFIG_KEY
= "java.util.logging.config.file"; = "java.util.logging.config.file";
private static final String LOGGING_CONFIG_VALUE private static final String LOGGING_CONFIG_VALUE
@ -88,15 +87,15 @@ public class FilesystemAsyncBlobStoreTest {
}*/ }*/
//create context per filesystem container //create context for filesystem container
Properties prop = new Properties(); Properties prop = new Properties();
prop.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TARGET_BASE_DIR); prop.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR);
context = (BlobStoreContext) new BlobStoreContextFactory().createContext( context = (BlobStoreContext) new BlobStoreContextFactory().createContext(
PROVIDER, prop); PROVIDER, prop);
//create a container in the default location //create a container in the default location
blobStore = context.getBlobStore(); blobStore = context.getBlobStore();
resourcesToBeDeleted.add(new File(TARGET_BASE_DIR)); resourcesToBeDeleted.add(new File(TestUtils.TARGET_BASE_DIR));
} }
@ -529,7 +528,7 @@ public class FilesystemAsyncBlobStoreTest {
*/ */
public void testCreateContainerInLocation() throws IOException { public void testCreateContainerInLocation() throws IOException {
final String CONTAINER_NAME2 = "funambol-test-2"; final String CONTAINER_NAME2 = "funambol-test-2";
final String TARGET_CONTAINER_NAME2 = TARGET_BASE_DIR + CONTAINER_NAME2; final String TARGET_CONTAINER_NAME2 = TestUtils.TARGET_BASE_DIR + CONTAINER_NAME2;
boolean result; boolean result;
@ -547,7 +546,7 @@ public class FilesystemAsyncBlobStoreTest {
assertTrue(result, "Container not created"); assertTrue(result, "Container not created");
result = blobStore.containerExists(CONTAINER_NAME2); result = blobStore.containerExists(CONTAINER_NAME2);
assertTrue(result, "Container doesn't exist"); assertTrue(result, "Container doesn't exist");
TestUtils.directoryExists(TARGET_BASE_DIR + CONTAINER_NAME2, true); TestUtils.directoryExists(TestUtils.TARGET_BASE_DIR + CONTAINER_NAME2, true);
//clean the environment //clean the environment
FileUtils.forceDelete(new File(TARGET_CONTAINER_NAME2)); FileUtils.forceDelete(new File(TARGET_CONTAINER_NAME2));
@ -718,7 +717,7 @@ public class FilesystemAsyncBlobStoreTest {
public void testDeleteContainer() throws IOException{ public void testDeleteContainer() throws IOException{
boolean result; boolean result;
String CONTAINER_NAME2 = "container-to-delete"; String CONTAINER_NAME2 = "container-to-delete";
String TARGET_CONTAINER_NAME2 = TARGET_BASE_DIR + CONTAINER_NAME2; String TARGET_CONTAINER_NAME2 = TestUtils.TARGET_BASE_DIR + CONTAINER_NAME2;
blobStore.createContainerInLocation(null, CONTAINER_NAME); blobStore.createContainerInLocation(null, CONTAINER_NAME);
blobStore.createContainerInLocation(null, CONTAINER_NAME2); blobStore.createContainerInLocation(null, CONTAINER_NAME2);

View File

@ -0,0 +1,33 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.filesystem.integration;
import org.jclouds.blobstore.integration.internal.BaseBlobIntegrationTest;
import org.testng.annotations.Test;
/**
*
* @author James Murty
* @author Adrian Cole
*/
@Test(groups = { "integration" }, testName = "blobstore.FilesystemBlobIntegrationTest")
public class FilesystemBlobIntegrationTest extends BaseBlobIntegrationTest {
}

View File

@ -0,0 +1,32 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.filesystem.integration;
import org.jclouds.blobstore.integration.internal.BaseBlobMapIntegrationTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemBlobMapIntegrationTest")
public class FilesystemBlobMapIntegrationTest extends BaseBlobMapIntegrationTest {
}

View File

@ -0,0 +1,72 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.filesystem.integration;
import static org.jclouds.blobstore.options.ListContainerOptions.Builder.maxResults;
import static org.testng.Assert.assertEquals;
import javax.ws.rs.core.MediaType;
import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.BlobMetadata;
import org.jclouds.blobstore.domain.PageSet;
import org.jclouds.blobstore.domain.StorageMetadata;
import org.jclouds.blobstore.integration.internal.BaseContainerIntegrationTest;
import org.testng.annotations.Test;
import com.google.common.collect.Iterables;
/**
* @author James Murty
* @author Adrian Cole
*/
@Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemContainerIntegrationTest")
public class FilesystemContainerIntegrationTest extends BaseContainerIntegrationTest {
@Test(groups = { "integration", "live" })
public void testNotWithDetails() throws InterruptedException {
String key = "hello";
Blob object = context.getBlobStore().newBlob(key);
object.setPayload(TEST_STRING);
object.getMetadata().setContentType(MediaType.TEXT_PLAIN);
object.getMetadata().setSize(new Long(TEST_STRING.length()));
// NOTE all metadata in jclouds comes out as lowercase, in an effort to normalize the
// providers.
object.getMetadata().getUserMetadata().put("Adrian", "powderpuff");
String containerName = getContainerName();
try {
addBlobToContainer(containerName, object);
validateContent(containerName, key);
PageSet<? extends StorageMetadata> container = context.getBlobStore().list(containerName,
maxResults(1));
BlobMetadata metadata = (BlobMetadata) Iterables.getOnlyElement(container);
// transient container should be lenient and not return metadata on undetailed listing.
assertEquals(metadata.getUserMetadata().size(), 0);
} finally {
returnContainer(containerName);
}
}
}

View File

@ -0,0 +1,31 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.filesystem.integration;
import org.jclouds.blobstore.integration.internal.BaseInputStreamMapIntegrationTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemInputStreamMapIntegrationTest")
public class FilesystemInputStreamMapIntegrationTest extends BaseInputStreamMapIntegrationTest {
}

View File

@ -0,0 +1,31 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.filesystem.integration;
import org.jclouds.blobstore.integration.internal.BaseServiceIntegrationTest;
import org.testng.annotations.Test;
/**
* @author Adrian Cole
*/
@Test(groups = { "integration", "live" }, testName = "blobstore.FilesystemServiceIntegrationTest")
public class FilesystemServiceIntegrationTest extends BaseServiceIntegrationTest {
}

View File

@ -0,0 +1,55 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* Licensed 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.filesystem.integration;
import java.io.IOException;
import java.util.Properties;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.BlobStoreContextFactory;
import org.jclouds.blobstore.integration.TransientBlobStoreTestInitializer;
import org.jclouds.blobstore.integration.internal.BaseBlobStoreIntegrationTest;
import org.jclouds.logging.log4j.config.Log4JLoggingModule;
import com.google.common.collect.ImmutableSet;
import com.google.inject.Module;
import org.jclouds.filesystem.config.FilesystemConstants;
import org.jclouds.filesystem.utils.TestUtils;
/**
*
* @author Adrian Cole
*/
public class FilesystemTestInitializer extends TransientBlobStoreTestInitializer {
@Override
protected BlobStoreContext createLiveContext(Module configurationModule, String url, String app,
String identity, String key) throws IOException {
BaseBlobStoreIntegrationTest.SANITY_CHECK_RETURNED_BUCKET_NAME = true;
Properties prop = new Properties();
prop.setProperty(FilesystemConstants.PROPERTY_BASEDIR, TestUtils.TARGET_BASE_DIR);
return new BlobStoreContextFactory().createContext(
"filesystem",
ImmutableSet.of(configurationModule, new Log4JLoggingModule()),
prop);
}
}