Author: [email protected] Date: Mon Oct 10 16:41:01 2011 New Revision: 1483
Log: initial commit of amdatu storage Added: trunk/amdatu-storage/blobstore/ trunk/amdatu-storage/blobstore/pom.xml trunk/amdatu-storage/blobstore/src/ trunk/amdatu-storage/blobstore/src/main/ trunk/amdatu-storage/blobstore/src/main/java/ trunk/amdatu-storage/blobstore/src/main/java/org/ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/BlobStoreService.java trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/impl/ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/impl/BlobStoreServiceImpl.java trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/osgi/ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/osgi/Activator.java trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/osgi/BlobStoreServiceFactory.java trunk/amdatu-storage/blobstore/src/main/resources/ trunk/amdatu-storage/blobstore/src/test/ trunk/amdatu-storage/blobstore/src/test/java/ trunk/amdatu-storage/blobstore/src/test/resources/ trunk/amdatu-storage/pom.xml trunk/amdatu-storage/test-integration/ trunk/amdatu-storage/test-integration/base/ trunk/amdatu-storage/test-integration/base/pom.xml trunk/amdatu-storage/test-integration/base/src/ trunk/amdatu-storage/test-integration/base/src/main/ trunk/amdatu-storage/test-integration/base/src/main/java/ trunk/amdatu-storage/test-integration/base/src/main/java/org/ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/blobstore/ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/blobstore/test/ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/blobstore/test/integration/ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/blobstore/test/integration/base/ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/blobstore/test/integration/base/BlobStoreFixture.java trunk/amdatu-storage/test-integration/base/src/main/resources/ trunk/amdatu-storage/test-integration/base/src/main/resources/META-INF/ trunk/amdatu-storage/test-integration/base/src/test/ trunk/amdatu-storage/test-integration/base/src/test/java/ trunk/amdatu-storage/test-integration/base/src/test/resources/ trunk/amdatu-storage/test-integration/pom.xml trunk/amdatu-storage/test-integration/tests/ trunk/amdatu-storage/test-integration/tests/pom.xml trunk/amdatu-storage/test-integration/tests/src/ trunk/amdatu-storage/test-integration/tests/src/main/ trunk/amdatu-storage/test-integration/tests/src/main/java/ trunk/amdatu-storage/test-integration/tests/src/main/resources/ trunk/amdatu-storage/test-integration/tests/src/main/resources/META-INF/ trunk/amdatu-storage/test-integration/tests/src/test/ trunk/amdatu-storage/test-integration/tests/src/test/java/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/blobstore/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/blobstore/test/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/blobstore/test/integration/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/blobstore/test/integration/tests/ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/blobstore/test/integration/tests/BlobStoreTest.java trunk/amdatu-storage/test-integration/tests/src/test/resources/ Modified: trunk/pom.xml Added: trunk/amdatu-storage/blobstore/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-storage/blobstore/pom.xml Mon Oct 10 16:41:01 2011 @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <artifactId>blobstore</artifactId> + <packaging>bundle</packaging> + <name>Amdatu Blob Store</name> + <description>Support for Blob Stores such as Amazon S3 using the jclouds API</description> + + <parent> + <groupId>org.amdatu.storage</groupId> + <artifactId>org.amdatu.storage</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <properties> + <jclouds.version>1.1.1</jclouds.version> + </properties> + + <dependencies> + <dependency> + <groupId>org.jclouds</groupId> + <artifactId>jclouds-allblobstore</artifactId> + <version>${jclouds.version}</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <configuration> + <instructions> + <Bundle-Activator>org.amdatu.storage.blobstore.osgi.Activator</Bundle-Activator> + <Bundle-SymbolicName>org.amdatu.storage.blobstore.jclouds</Bundle-SymbolicName> + <Export-Package>org.amdatu.storage.blobstore,org.jclouds.blobstore,org.jclouds.blobstore.domain + </Export-Package> + <Embed-Dependency>*;type=!bundle;scope=compile;inline=true</Embed-Dependency> + <Embed-Transitive>true</Embed-Transitive> + <Import-Package> + !org.jclouds.blobstore,!org.jclouds.blobstore.domain,!com.google.inject.internal.asm.util,!javax.mail.*,!org.bouncycastle.asn1.*,!sun.misc.*,* + </Import-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/BlobStoreService.java ============================================================================== --- (empty file) +++ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/BlobStoreService.java Mon Oct 10 16:41:01 2011 @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.storage.blobstore; + +import java.util.Properties; + +import org.jclouds.blobstore.BlobStoreContext; + +/** + * + * The BlobStoreService has the sole purpose of exposing the jclouds BlobStoreContext API. + * Using this service is more flexible than direct usage however because it can be configured using Configuration Admin. + */ +public interface BlobStoreService { + /** + * Retrieves the jclouds BlobStoreContext API. THe caller is responsible for closing the context. + */ + BlobStoreContext getContext(); + + enum Providers{ + TRANSIENT("transient"), + FILESYSTEM("filesystem"), + EUCALYPTUS_PARTNERCLOUD_S3("eucalyptus-partnercloud-s3"), + SYNAPTIC_STORAGE("synaptic-storage"), + AZUREBLOB("azureblob"), + CLOUDONESTORAGE("cloudonestorage"), + CLOUDFILES_US("cloudfiles-us"), + CLOUDFILES_UK("cloudfiles-uk"), + NINEFOLD_STORAGE("ninefold-storage"), + AWS_S3("aws-s3"), + GOOGLESTORAGE("googlestorage"), + SCALEUP_STORAGE("scaleup-storage"), + HOSTEUROPE_STORAGE("hosteurope-storage"), + TISCALI_STORAGE("tiscali-storage"); + + private String id; + + Providers(String id) { + this.id = id; + } + + @Override + public String toString() { + return id; + } + + public Properties getAsServiceProperties() { + Properties props = new Properties(); + props.put("provider", id); + return props; + } + + public String getAsServiceFilter() { + StringBuilder sb = new StringBuilder("(&(provider="); + sb.append(id).append("))"); + return sb.toString(); + } + } +} Added: trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/impl/BlobStoreServiceImpl.java ============================================================================== --- (empty file) +++ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/impl/BlobStoreServiceImpl.java Mon Oct 10 16:41:01 2011 @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.storage.blobstore.impl; + +import java.util.Dictionary; + +import org.amdatu.storage.blobstore.BlobStoreService; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.BlobStoreContextFactory; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.osgi.service.log.LogService; + +/** + * Creates a BlobStoreContext for the provider, identity and secret configured by Configuration Admin. + * Multiple instance of this service can coexist for using multiple blob store providers. + * Each service instance has a property "provider" that is one of {@link BlobStoreService#Providers}. + * + */ +public class BlobStoreServiceImpl implements BlobStoreService, ManagedService { + private volatile LogService m_log; + public static final String PID = "org.amdatu.storage"; + private String provider; + private String identity; + private String secretkey; + + public synchronized BlobStoreContext getContext() { + m_log.log(LogService.LOG_DEBUG, "Creating context for provider '" + provider + "'" + " with identity '" + identity + "'"); + return new BlobStoreContextFactory().createContext(provider, identity, secretkey); + } + + public synchronized void updated(Dictionary properties) throws ConfigurationException { + if (properties != null) { + provider = (String) properties.get("provider"); + if (provider == null) { + throw new ConfigurationException("provider", + "Missing mandatory provider configuration"); + } + + identity = (String) properties.get("identity"); + if (identity == null) { + throw new ConfigurationException("identity", + "Missing mandatory identity configuration"); + } + + secretkey = (String) properties.get("secret"); + if (secretkey == null) { + throw new ConfigurationException("secret", + "Missing mandatory secret key configuration"); + } + } + } +} Added: trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/osgi/Activator.java ============================================================================== --- (empty file) +++ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/osgi/Activator.java Mon Oct 10 16:41:01 2011 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.storage.blobstore.osgi; + +import java.util.Properties; + +import org.apache.felix.dm.DependencyActivatorBase; +import org.apache.felix.dm.DependencyManager; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.service.cm.ManagedServiceFactory; +import org.osgi.service.log.LogService; + +/** + * Registers a ManagedServiceFactory that can be configured for different storage providers. + */ +public class Activator extends DependencyActivatorBase{ + @Override + public void init(BundleContext bundleContext, DependencyManager dependencyManager) throws Exception { + Properties props = new Properties(); + props.put(Constants.SERVICE_PID, BlobStoreServiceFactory.PID); + + dependencyManager.add(createComponent() + .setInterface(ManagedServiceFactory.class.getName(), props) + .setImplementation(BlobStoreServiceFactory.class) + .add(dependencyManager.createServiceDependency().setService(LogService.class).setRequired(true))); + } + + @Override + public void destroy(BundleContext bundleContext, DependencyManager dependencyManager) throws Exception { + } +} Added: trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/osgi/BlobStoreServiceFactory.java ============================================================================== --- (empty file) +++ trunk/amdatu-storage/blobstore/src/main/java/org/amdatu/storage/blobstore/osgi/BlobStoreServiceFactory.java Mon Oct 10 16:41:01 2011 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.storage.blobstore.osgi; + +import org.amdatu.storage.blobstore.BlobStoreService; +import org.amdatu.storage.blobstore.impl.BlobStoreServiceImpl; +import org.apache.felix.dm.Component; +import org.apache.felix.dm.DependencyManager; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedServiceFactory; +import org.osgi.service.log.LogService; + +import java.util.Dictionary; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +/** + * Service factory that configures BlobStoreService instances. A new instance is created for each provider. + */ +public class BlobStoreServiceFactory implements ManagedServiceFactory { + + private static final String PROVIDER_KEY = "provider"; + public final static String PID = "org.amdatu.storage.servicefactory"; + private volatile DependencyManager m_dependencyManager; + private volatile LogService m_log; + private final Map<String, Component> m_components = new HashMap<String, Component>(); + + + public String getName() { + return "org.amdatu.storage.blobstorefactory"; + } + + public synchronized void updated(String pid, Dictionary properties) + throws ConfigurationException { + + if (m_components.containsKey(pid)) { + m_log.log(LogService.LOG_DEBUG, "pid already registered for provider '" + properties.get(PROVIDER_KEY) + "', skipping registration"); + return; + } + + Properties serviceProperties = new Properties(); + String provider = (String)properties.get(PROVIDER_KEY); + if(provider == null) { + m_log.log(LogService.LOG_ERROR, "Error while registering new BlobStoreService: provider property not set"); + return; + } + + serviceProperties.setProperty(PROVIDER_KEY, provider); + + m_log.log(LogService.LOG_INFO, "Registering BlobStoreService for provider + '" + serviceProperties.getProperty(PROVIDER_KEY) + "'"); + + Component component = m_dependencyManager + .createComponent() + .setInterface(BlobStoreService.class.getName(), serviceProperties) + .setImplementation(BlobStoreServiceImpl.class) + .add(m_dependencyManager.createConfigurationDependency().setPid(pid)) + .add(m_dependencyManager.createServiceDependency().setService(LogService.class).setRequired(true)); + + m_dependencyManager.add(component); + m_components.put(pid, component); + } + + public synchronized void deleted(String pid) { + m_log.log(LogService.LOG_INFO, "Unregistering service with pid: '" + pid + "'"); + m_dependencyManager.remove(m_components.remove(pid)); + } + +} Added: trunk/amdatu-storage/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-storage/pom.xml Mon Oct 10 16:41:01 2011 @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.amdatu.storage</groupId> + <artifactId>org.amdatu.storage</artifactId> + <version>1.0.0-SNAPSHOT</version> + <packaging>pom</packaging> + + <name>Amdatu Storage</name> + <description>Storage related APIs such as Blob stores and Table stores</description> + + <parent> + <groupId>org.amdatu</groupId> + <artifactId>amdatu</artifactId> + <version>4-SNAPSHOT</version> + <relativePath>../amdatu-parent/pom.xml</relativePath> + </parent> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-SymbolicName>org.amdatu.storage.blobstore</Bundle-SymbolicName> + </instructions> + </configuration> + </plugin> + </plugins> + </build> + + <modules> + <module>blobstore</module> + <module>test-integration</module> + </modules> +</project> Added: trunk/amdatu-storage/test-integration/base/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-storage/test-integration/base/pom.xml Mon Oct 10 16:41:01 2011 @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <artifactId>testintegration.base</artifactId> + <packaging>bundle</packaging> + <name>Amdatu Storage - Integration tests base</name> + + <parent> + <groupId>org.amdatu.storage</groupId> + <artifactId>testintegration</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName> + <Export-Package>org.amdatu.storage.blobstore.test.integration.base</Export-Package> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> Added: trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/blobstore/test/integration/base/BlobStoreFixture.java ============================================================================== --- (empty file) +++ trunk/amdatu-storage/test-integration/base/src/main/java/org/amdatu/storage/blobstore/test/integration/base/BlobStoreFixture.java Mon Oct 10 16:41:01 2011 @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.storage.blobstore.test.integration.base; + +import static org.ops4j.pax.exam.CoreOptions.composite; +import static org.ops4j.pax.exam.CoreOptions.mavenBundle; + +import org.ops4j.pax.exam.Option; + + +public class BlobStoreFixture { + + public Option provision() { + return composite( + org.ops4j.pax.exam.CoreOptions.provision( + mavenBundle().groupId("org.amdatu.storage").artifactId("blobstore").versionAsInProject(), + mavenBundle().groupId("org.amdatu.storage").artifactId("testintegration.base").versionAsInProject(), + mavenBundle().groupId("org.ops4j.pax.swissbox").artifactId("pax-swissbox-core").versionAsInProject(), + mavenBundle().groupId("org.ops4j.base").artifactId("ops4j-base-lang").versionAsInProject())); + } +} Added: trunk/amdatu-storage/test-integration/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-storage/test-integration/pom.xml Mon Oct 10 16:41:01 2011 @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <artifactId>testintegration</artifactId> + <packaging>pom</packaging> + <name>Amdatu Storage - Integration tests parent</name> + <parent> + <groupId>org.amdatu.storage</groupId> + <artifactId>org.amdatu.storage</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + <properties> + <org.amdatu.core.version>0.2.1-SNAPSHOT</org.amdatu.core.version> + </properties> + + <modules> + <module>base</module> + <module>tests</module> + </modules> + + <dependencies> + <dependency> + <groupId>org.amdatu.core</groupId> + <artifactId>org.amdatu.core.itest.base</artifactId> + <version>${org.amdatu.core.version}</version> + <scope>compile</scope> + <type>bundle</type> + </dependency> + </dependencies> + +</project> Added: trunk/amdatu-storage/test-integration/tests/pom.xml ============================================================================== --- (empty file) +++ trunk/amdatu-storage/test-integration/tests/pom.xml Mon Oct 10 16:41:01 2011 @@ -0,0 +1,100 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" + xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <artifactId>testintegration.tests</artifactId> + <name>Amdatu Storage - Integration tests</name> + + <parent> + <groupId>org.amdatu.storage</groupId> + <artifactId>testintegration</artifactId> + <version>1.0.0-SNAPSHOT</version> + <relativePath>../pom.xml</relativePath> + </parent> + + <dependencies> + <dependency> + <groupId>org.amdatu.storage</groupId> + <artifactId>testintegration.base</artifactId> + <version>1.0.0-SNAPSHOT</version> + <type>bundle</type> + </dependency> + + <dependency> + <groupId>org.amdatu.storage</groupId> + <artifactId>blobstore</artifactId> + <version>1.0.0-SNAPSHOT</version> + <type>bundle</type> + </dependency> + + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.8.1</version> + <scope>test</scope> + </dependency> + + </dependencies> + + <build> + <plugins> + <!-- Outside the itest profile just skip surefire. --> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + <profiles> + <profile> + <id>itest</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.ops4j.pax.exam</groupId> + <artifactId>maven-paxexam-plugin</artifactId> + <executions> + <execution> + <phase>integration-test</phase> + <id>generate-depends-file</id> + <goals> + <goal>generate-depends-file</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>run-integration-test</id> + <phase>integration-test</phase> + <goals> + <goal>test</goal> + </goals> + <configuration> + <systemPropertyVariables> + <org.osgi.framework.system.packages.extra>sun.misc,com.sun.management + </org.osgi.framework.system.packages.extra> + </systemPropertyVariables> + <skip>false</skip> + </configuration> + </execution> + </executions> + <configuration> + <skip>true</skip> + </configuration> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> Added: trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/blobstore/test/integration/tests/BlobStoreTest.java ============================================================================== --- (empty file) +++ trunk/amdatu-storage/test-integration/tests/src/test/java/org/amdatu/storage/blobstore/test/integration/tests/BlobStoreTest.java Mon Oct 10 16:41:01 2011 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2010, 2011 The Amdatu Foundation + * + * 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.amdatu.storage.blobstore.test.integration.tests; + + +import org.amdatu.core.itest.base.CoreFixture; +import org.amdatu.core.itest.base.TestContext; +import org.amdatu.storage.blobstore.test.integration.base.*; +import org.jclouds.blobstore.BlobStoreContext; +import org.jclouds.blobstore.domain.PageSet; +import org.jclouds.blobstore.domain.StorageMetadata; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.Option; +import org.ops4j.pax.exam.junit.Configuration; +import org.ops4j.pax.exam.junit.ExamReactorStrategy; +import org.ops4j.pax.exam.junit.JUnit4TestRunner; +import org.ops4j.pax.exam.spi.reactors.AllConfinedStagedReactorFactory; +import org.osgi.framework.BundleContext; +import org.amdatu.storage.blobstore.*; +import org.amdatu.storage.blobstore.osgi.*; + + +import java.util.Properties; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; +import static org.junit.Assert.assertThat; +import static org.ops4j.pax.exam.CoreOptions.options; +import static org.ops4j.pax.exam.LibraryOptions.junitBundles; + +@RunWith(JUnit4TestRunner.class) +@ExamReactorStrategy(AllConfinedStagedReactorFactory.class) +public class BlobStoreTest { + private BlobStoreFixture blobstorageFixture = new BlobStoreFixture(); + private CoreFixture m_coreFixture = new CoreFixture(); + + @Configuration + public Option[] config() { + return options(junitBundles(), m_coreFixture.provisionWithFsStorage(), + blobstorageFixture.provision()); + } + + /** + * Test with the in memory provider. + * This is the only provider that can be used in a portable way without provindg a username and password in the test. + * Tests if the service instance can be found and used after adding the provider configuration to Configuration Admin. + * @param bundleContext + * @throws Exception + */ + @Test + public void testCreateBlobStoreService(BundleContext bundleContext) + throws Exception { + TestContext testContext = testContextSetUp(bundleContext); + + BlobStoreService service = testContext.getService( + BlobStoreService.class, BlobStoreService.Providers.TRANSIENT.getAsServiceFilter()); + BlobStoreContext context = service.getContext(); + PageSet<? extends StorageMetadata> list = context.getBlobStore().list(); + + //There is one stub file + assertThat(list.size(), is(1)); + + context.close(); + } + + private TestContext testContextSetUp(BundleContext bundleContext) + throws Exception { + assertThat(bundleContext, is(notNullValue())); + TestContext testContext = new TestContext(bundleContext); + Thread.sleep(1000); + Properties props = new Properties(); + props.setProperty("provider", BlobStoreService.Providers.TRANSIENT.toString()); + props.setProperty("identity", "user"); + props.setProperty("secret", "password"); + + testContext.updateFactoryConfig(BlobStoreServiceFactory.PID, props); + Thread.sleep(1000); + + return testContext; + } + +} Modified: trunk/pom.xml ============================================================================== --- trunk/pom.xml (original) +++ trunk/pom.xml Mon Oct 10 16:41:01 2011 @@ -45,6 +45,7 @@ <module>amdatu-cassandra</module> <module>amdatu-opensocial</module> <module>amdatu-semanticweb</module> + <module>amdatu-storage</module> </modules> </profile> <profile> _______________________________________________ Amdatu-commits mailing list [email protected] http://lists.amdatu.org/mailman/listinfo/amdatu-commits
