2016-05-31 23 views

cevap

5

Şu an için Google tarafından sağlanan resmi bir emülatör yok.

Şu anda Google Storage'ın geliştirilme davranışını bozmak için Minio (https://www.minio.io/) projesini kullanıyorum (Minio dosya sistemini depolama arka planı olarak kullanıyor ve Google Storage ile uyumlu S3 apiV2 ile uyumluluk sağlıyor).

7

Google'ın kullanabileceği bir in-memory emulator vardır (çekirdek işlevlerin çoğu uygulanmaktadır).

Test sınıf yolunuzda com.google.cloud:google-cloud-nio gerekir (şu anda :0.25.0-alpha). Ardından, bellek içi LocalStorageHelper test-helper hizmeti tarafından uygulanan Storage arabirimini kullanabilir/kullanabilirsiniz.

Örnek kullanım:

import com.google.cloud.storage.Storage; 
    import com.google.cloud.storage.contrib.nio.testing.LocalStorageHelper; 

    @Test 
    public void exampleInMemoryGoogleStorageTest() { 
    Storage storage = LocalStorageHelper.getOptions().getService(); 

    final String blobPath = "test/path/foo.txt"; 
    final String testBucketName = "test-bucket"; 
    BlobInfo blobInfo = BlobInfo.newBuilder(
     BlobId.of(testBucketName, blobPath) 
    ).build(); 

    storage.create(blobInfo, "randomContent".getBytes(StandardCharsets.UTF_8)); 
    Iterable<Blob> allBlobsIter = storage.list(testBucketName).getValues(); 
    // expect to find the blob we saved when iterating over bucket blobs 
    assertTrue(
     StreamSupport.stream(allBlobsIter.spliterator(), false) 
      .map(BlobInfo::getName) 
      .anyMatch(blobPath::equals) 
    ); 
    } 
İlgili konular