2016-05-31 5 views

답변

5

당분간 Google에서 제공하는 공식 에뮬레이터가 없습니다.

Google 스토리지의 동작을 조롱하는 데 Minio (https://www.minio.io/) 프로젝트를 사용 중입니다. Minio는 파일 시스템을 저장소 백엔드로 사용하고 Google 스토리지와 호환되는 S3 apiV2와의 호환성을 제공합니다.

7

Google은 in-memory emulator을 사용할 수 있습니다 (대부분의 핵심 기능이 구현됩니다).

테스트 클래스 경로 (현재 :0.25.0-alpha)에 com.google.cloud:google-cloud-nio이 필요합니다. 그런 다음 메모리 내 LocalStorageHelper 테스트 도우미 서비스에 의해 구현 된 Storage 인터페이스를 사용/삽입 할 수 있습니다.

사용 예제 :

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) 
    ); 
    } 
관련 문제