Skip to content

Commit

Permalink
SAK-29519 - Fix Swift tests
Browse files Browse the repository at this point in the history
 * Fix package name
 * Disable tests by default
 * Add swift-tests profile to enable tests
 * Add a properties file to configure Swift account
 * Update README
  • Loading branch information
botimer committed Jul 2, 2015
1 parent 8b4af01 commit 453c281
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 7 deletions.
11 changes: 11 additions & 0 deletions cloud-content/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,14 @@ bodyPathDeleted@org.sakaiproject.content.api.ContentHostingService=/content/dele
If you are not familiar with `sakai-configuration.xml`, it is placed in the same location
as the properties files. See Confluence for an overview:
[https://confluence.sakaiproject.org/display/REL/More+Flexible+Sakai+Configuration](More Flexible Sakai Configuration)


## Testing

Because the tests work against a real backend, they are disabled by default. To
run them, you must activate the `swift-tests` profile (e.g.,
`mvn -Pswift-tests install`) and set your configuration. The settings for the
Swift tests is in `impl/src/test/resources/swift.properties`. These are
straightforward and align with the names/values needed for real usage. The
tests will clean up after themselves unless `deleteEmptyContainers` is set to
false, which can be used to validate content in a container afterward.
29 changes: 29 additions & 0 deletions cloud-content/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,34 @@
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>swift-tests</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<skipTests>false</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package coza.opencollab.sakai.swift;
package coza.opencollab.sakai.cloudcontent;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Method;
import java.util.Properties;
import java.util.Random;
import org.junit.AfterClass;
import org.junit.BeforeClass;
Expand Down Expand Up @@ -41,13 +42,23 @@ public SwiftFileHandlerTest() {
}

@BeforeClass
public static void setUpClass() {
swift.setEndpoint("http://196.252.231.49:35357/v2.0/");
swift.setRegion("regionOne");
swift.setIdentity("OC:ocsakai");
swift.setCredential("00sakai99");
swift.setDeleteEmptyContainers(true);
public static void setUpClass() throws IOException {
Properties props = new Properties();
try {
props.load(SwiftFileHandlerTest.class.getResourceAsStream("/swift.properties"));
} catch(IOException e) {
System.out.println("Cannot read Swift configuration (src/test/resources/swift.properties)... Bailing out.");
throw e;
}

swift.setEndpoint(props.getProperty("endpoint"));
swift.setRegion(props.getProperty("region"));
swift.setIdentity(props.getProperty("identity"));
swift.setCredential(props.getProperty("credential"));
swift.setDeleteEmptyContainers(Boolean.valueOf(props.getProperty("deleteEmptyContainers")));

swift.init();

Random r = new Random(System.currentTimeMillis());
r.nextBytes(BINARY);
}
Expand Down
5 changes: 5 additions & 0 deletions cloud-content/impl/src/test/resources/swift.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
endpoint=http://127.0.0.1:35357/v2.0/
region=RegionOne
identity=tenant:user
credential=password
deleteEmptyContainers=true

0 comments on commit 453c281

Please sign in to comment.