// Path: src/main/java/de/jeha/s3srv/common/errors/BadDigestException.java
// public class BadDigestException extends Exception {
// 
//     public BadDigestException(String message) {
//         super(message);
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/common/security/Credentials.java
// public class Credentials {
// 
//     private final static String ACCESS_KEY_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//     private final static int ACCESS_KEY_LENGTH = 20;
// 
//     private final static String SECRET_KEY_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
//     private final static String SECRET_KEY_CHARS_WITH_SPECIAL_CHARS = SECRET_KEY_CHARS + "/+";
//     private final static int SECRET_KEY_LENGTH = 40;
// 
//     private final String accessKey;
//     private final String secretKey;
// 
//     public Credentials(String accessKey, String secretKey) {
//         this.accessKey = accessKey;
//         this.secretKey = secretKey;
//     }
// 
//     public String getAccessKey() {
//         return accessKey;
//     }
// 
//     public String getSecretKey() {
//         return secretKey;
//     }
// 
//     /**
//      * Generates a random pair of access key and secret key in a pretty naive way.
//      *
//      * @return randomly generated credentials
//      */
//     public static Credentials generateRandom() {
//         return generateRandom(true);
//     }
// 
//     /**
//      * Generates a random pair of access key and secret key in a pretty naive way.
//      *
//      * @param includeSpecialChars include special chars ('/' and '+') for secret keys
//      * @return randomly generated credentials
//      */
//     public static Credentials generateRandom(boolean includeSpecialChars) {
//         String accessKey = RandomStringUtils.random(ACCESS_KEY_LENGTH, ACCESS_KEY_CHARS);
//         String secretKey = RandomStringUtils.random(
//                 SECRET_KEY_LENGTH,
//                 includeSpecialChars ? SECRET_KEY_CHARS_WITH_SPECIAL_CHARS : SECRET_KEY_CHARS
//         );
// 
//         return new Credentials(accessKey, secretKey);
//     }
// 
//     public void print() {
//         System.out.println();
//         System.out.println("accessKey: " + accessKey);
//         System.out.println("secretKey: " + secretKey);
//         System.out.println();
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/model/S3Object.java
// public class S3Object {
// 
//     private final S3Bucket bucket;
//     private final String key;
//     private final String md5;
//     private final String eTag;
//     private final Integer size;
//     private final Instant lastModified;
//     private final InputStreamCallback inputStreamCallback;
//     private final String contentType;
// 
//     public S3Object(S3Bucket bucket, String key, String md5, String eTag, Integer size, Instant lastModified,
//                     InputStreamCallback inputStreamCallback, String contentType) {
//         this.bucket = bucket;
//         this.key = key;
//         this.md5 = md5;
//         this.eTag = eTag;
//         this.size = size;
//         this.lastModified = lastModified;
//         this.inputStreamCallback = inputStreamCallback;
//         this.contentType = contentType;
//     }
// 
//     public S3Bucket getBucket() {
//         return bucket;
//     }
// 
//     public String getKey() {
//         return key;
//     }
// 
//     public String getMD5() {
//         return md5;
//     }
// 
//     public String getETag() {
//         return eTag;
//     }
// 
//     public Integer getSize() {
//         return size;
//     }
// 
//     public Instant getLastModified() {
//         return lastModified;
//     }
// 
//     public InputStream getInputStream() {
//         return inputStreamCallback.getInputStream();
//     }
// 
//     public String getContentType() {
//         return contentType;
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/storage/StorageBackend.java
// public interface StorageBackend extends HealthAware {
// 
//     List<S3Bucket> listBuckets();
// 
//     void createBucket(S3User user, String bucket);
// 
//     boolean doesBucketExist(String bucket);
// 
//     S3Bucket getBucket(String bucket);
// 
//     void deleteBucket(String bucket);
// 
//     S3Object createObject(String bucket, String key, InputStream contentStream, int contentLength,
//                           String expectedMD5, String contentType)
//             throws IOException, BadDigestException;
// 
//     boolean doesObjectExist(String bucket, String key);
// 
//     List<S3Object> listObjects(String bucket, int max);
// 
//     S3Object getObject(String bucket, String key);
// 
//     void deleteObject(String bucket, String key);
// 
//     /**
//      * @todo maybe separate storage backends for data and account data
//      */
//     S3User getUserByAccessId(String accessKey);
// 
// }


import de.jeha.s3srv.common.errors.BadDigestException;
import de.jeha.s3srv.common.security.Credentials;
import de.jeha.s3srv.model.S3Object;
import de.jeha.s3srv.storage.StorageBackend;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
package de.jeha.s3srv.storage.backends;




/**
 * @author jenshadlich@googlemail.com
 */
public class InMemoryStorageBackendTest {

    @Test
// Path: src/main/java/de/jeha/s3srv/common/errors/BadDigestException.java
// public class BadDigestException extends Exception {
// 
//     public BadDigestException(String message) {
//         super(message);
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/common/security/Credentials.java
// public class Credentials {
// 
//     private final static String ACCESS_KEY_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//     private final static int ACCESS_KEY_LENGTH = 20;
// 
//     private final static String SECRET_KEY_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
//     private final static String SECRET_KEY_CHARS_WITH_SPECIAL_CHARS = SECRET_KEY_CHARS + "/+";
//     private final static int SECRET_KEY_LENGTH = 40;
// 
//     private final String accessKey;
//     private final String secretKey;
// 
//     public Credentials(String accessKey, String secretKey) {
//         this.accessKey = accessKey;
//         this.secretKey = secretKey;
//     }
// 
//     public String getAccessKey() {
//         return accessKey;
//     }
// 
//     public String getSecretKey() {
//         return secretKey;
//     }
// 
//     /**
//      * Generates a random pair of access key and secret key in a pretty naive way.
//      *
//      * @return randomly generated credentials
//      */
//     public static Credentials generateRandom() {
//         return generateRandom(true);
//     }
// 
//     /**
//      * Generates a random pair of access key and secret key in a pretty naive way.
//      *
//      * @param includeSpecialChars include special chars ('/' and '+') for secret keys
//      * @return randomly generated credentials
//      */
//     public static Credentials generateRandom(boolean includeSpecialChars) {
//         String accessKey = RandomStringUtils.random(ACCESS_KEY_LENGTH, ACCESS_KEY_CHARS);
//         String secretKey = RandomStringUtils.random(
//                 SECRET_KEY_LENGTH,
//                 includeSpecialChars ? SECRET_KEY_CHARS_WITH_SPECIAL_CHARS : SECRET_KEY_CHARS
//         );
// 
//         return new Credentials(accessKey, secretKey);
//     }
// 
//     public void print() {
//         System.out.println();
//         System.out.println("accessKey: " + accessKey);
//         System.out.println("secretKey: " + secretKey);
//         System.out.println();
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/model/S3Object.java
// public class S3Object {
// 
//     private final S3Bucket bucket;
//     private final String key;
//     private final String md5;
//     private final String eTag;
//     private final Integer size;
//     private final Instant lastModified;
//     private final InputStreamCallback inputStreamCallback;
//     private final String contentType;
// 
//     public S3Object(S3Bucket bucket, String key, String md5, String eTag, Integer size, Instant lastModified,
//                     InputStreamCallback inputStreamCallback, String contentType) {
//         this.bucket = bucket;
//         this.key = key;
//         this.md5 = md5;
//         this.eTag = eTag;
//         this.size = size;
//         this.lastModified = lastModified;
//         this.inputStreamCallback = inputStreamCallback;
//         this.contentType = contentType;
//     }
// 
//     public S3Bucket getBucket() {
//         return bucket;
//     }
// 
//     public String getKey() {
//         return key;
//     }
// 
//     public String getMD5() {
//         return md5;
//     }
// 
//     public String getETag() {
//         return eTag;
//     }
// 
//     public Integer getSize() {
//         return size;
//     }
// 
//     public Instant getLastModified() {
//         return lastModified;
//     }
// 
//     public InputStream getInputStream() {
//         return inputStreamCallback.getInputStream();
//     }
// 
//     public String getContentType() {
//         return contentType;
//     }
// 
// }
// 
// Path: src/main/java/de/jeha/s3srv/storage/StorageBackend.java
// public interface StorageBackend extends HealthAware {
// 
//     List<S3Bucket> listBuckets();
// 
//     void createBucket(S3User user, String bucket);
// 
//     boolean doesBucketExist(String bucket);
// 
//     S3Bucket getBucket(String bucket);
// 
//     void deleteBucket(String bucket);
// 
//     S3Object createObject(String bucket, String key, InputStream contentStream, int contentLength,
//                           String expectedMD5, String contentType)
//             throws IOException, BadDigestException;
// 
//     boolean doesObjectExist(String bucket, String key);
// 
//     List<S3Object> listObjects(String bucket, int max);
// 
//     S3Object getObject(String bucket, String key);
// 
//     void deleteObject(String bucket, String key);
// 
//     /**
//      * @todo maybe separate storage backends for data and account data
//      */
//     S3User getUserByAccessId(String accessKey);
// 
// }


// Path: src/test/java/de/jeha/s3srv/storage/backends/InMemoryStorageBackendTest.java
import de.jeha.s3srv.common.errors.BadDigestException;
import de.jeha.s3srv.common.security.Credentials;
import de.jeha.s3srv.model.S3Object;
import de.jeha.s3srv.storage.StorageBackend;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.Test;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;

package de.jeha.s3srv.storage.backends;




/**
 * @author jenshadlich@googlemail.com
 */
public class InMemoryStorageBackendTest {

    @Test
    public void test() throws IOException, BadDigestException {