Class LocalStorageHelper

java.lang.Object
com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper

public final class LocalStorageHelper extends Object
Utility to create an in-memory storage configuration for testing. Storage options can be obtained via the getOptions() method. Returned options will point to FakeStorageRpc.

Note, the created in-memory storage configuration supports limited set of operations and is not thread-safe:

  • Supported operations
    • object create
    • object get
    • object delete
    • list the contents of a bucket
  • Unsupported operations
    • bucket create
    • bucket get
    • bucket delete
    • list all buckets
    • generations
    • file attributes
    • patch
    • continueRewrite
    • createBatch
    • checksums, etags
    • IAM operations
StorageRpcTestBase.list(String, java.util.Map) lists all the objects that have been created rather than the objects in the provided bucket. Since this class does not support creating, listing and deleting buckets, the parameter bucket here is not actually used and on serves as a placeholder.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.google.cloud.storage.StorageOptions
    customOptions(boolean throwIfOptions)
    Returns a StorageOptions that creates a new FakeStorageRpc instance with the given option.
    static com.google.cloud.storage.StorageOptions
    Returns a StorageOptions that use the static FakeStorageRpc instance, and resets it first so you start from a clean slate.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getOptions

      public static com.google.cloud.storage.StorageOptions getOptions()
      Returns a StorageOptions that use the static FakeStorageRpc instance, and resets it first so you start from a clean slate. That instance will throw if you pass it any option.
    • customOptions

      public static com.google.cloud.storage.StorageOptions customOptions(boolean throwIfOptions)
      Returns a StorageOptions that creates a new FakeStorageRpc instance with the given option.