SwiftStorageProvider extends S3StorageProvider { @Override protected Map<String, String> getAllSpaceProperties(String spaceId) { log.debug("getAllSpaceProperties(" + spaceId + ")"); String propsBucketName = getBucketName(PROPERTIES_BUCKET); Map<String, String> spaceProperties = new HashMap<>(); String spacePropertiesString; try { spacePropertiesString = s3Client.getObjectAsString(propsBucketName, spaceId); spacePropertiesString = spacePropertiesString.substring(1, spacePropertiesString.length() - 1); String[] spacePropertiesList = spacePropertiesString.split(", "); for (String property : spacePropertiesList) { String[] props = property.split("="); spaceProperties.put(props[0], props[1]); } } catch (AmazonS3Exception e) { log.debug( "Metadata object for space " + spaceId + " was not found in container " + propsBucketName + ", probably because this is a new space." ); } spaceProperties = replaceInMapValues(spaceProperties, "+", "@"); spaceProperties.put(PROPERTIES_SPACE_COUNT, getSpaceCount(spaceId, MAX_ITEM_COUNT)); return spaceProperties; } SwiftStorageProvider(String accessKey, String secretKey, Map<String, String> options);  SwiftStorageProvider(AmazonS3 s3Client, String accessKey); @Override StorageProviderType getStorageProviderType(); @Override void removeSpace(String spaceId); @Override String createHiddenSpace(String spaceId, int expirationInDays); ObjectMetadata expireObject(String bucketName, String contentId, Integer seconds);  }
@Test public void testGetAllSpaceProperties() { setupS3Client(); String bucketName = truncateKey() + "." + spaceId; String propsBucketName = getPropsBucketName(); String properties = "{key1=value1, key2=value2, key3=value+3}"; Bucket bucket = createMock(Bucket.class); Bucket propsBucket = createMock(Bucket.class); expect(bucket.getName()).andReturn(bucketName).anyTimes(); expect(propsBucket.getName()).andReturn(propsBucketName); expect(s3Client.listBuckets()).andReturn(Arrays.asList(bucket, propsBucket)).anyTimes(); expect(s3Client.getObjectAsString(propsBucketName, spaceId)).andReturn(properties); ObjectListing objectListing = createMock("ObjectListing", ObjectListing.class); setUpListObjects(objectListing, 1); setUpListObjects(objectListing, 0); SwiftStorageProvider provider = getProvider(); replay(s3Client, bucket, propsBucket, objectListing); Map<String, String> spaceProps = provider.getAllSpaceProperties(spaceId); assertNotNull(spaceProps); assertEquals("value1", spaceProps.get("key1")); assertEquals("value2", spaceProps.get("key2")); assertEquals("value@3", spaceProps.get("key3")); assertEquals(String.valueOf(1), spaceProps.get(StorageProvider.PROPERTIES_SPACE_COUNT)); verify(s3Client, bucket, propsBucket, objectListing); }