@@ -0,0 +1,2919 @@
+package com.google.appengine.tools.cloudstorage;%0A%0Aimport static org.junit.Assert.assertArrayEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport com.google.appengine.api.blobstore.BlobKey;%0Aimport com.google.appengine.api.blobstore.BlobstoreService;%0Aimport com.google.appengine.api.blobstore.BlobstoreServiceFactory;%0Aimport com.google.appengine.api.images.ImagesService;%0Aimport com.google.appengine.api.images.ImagesServiceFactory;%0Aimport com.google.appengine.api.images.ServingUrlOptions;%0Aimport com.google.appengine.tools.development.testing.LocalBlobstoreServiceTestConfig;%0Aimport com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;%0Aimport com.google.appengine.tools.development.testing.LocalImagesServiceTestConfig;%0Aimport com.google.appengine.tools.development.testing.LocalServiceTestHelper;%0Aimport com.google.common.io.BaseEncoding;%0A%0Aimport org.junit.After;%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0Aimport org.junit.runner.RunWith;%0Aimport org.junit.runners.JUnit4;%0A%0Aimport java.io.IOException;%0Aimport java.nio.ByteBuffer;%0A%0A/**%0A */%0A@RunWith(JUnit4.class)%0Apublic class TestServingViaBlobstoreApi %7B%0A%0A  private static final GcsService GCS_SERVICE = GcsServiceFactory.createGcsService();%0A  private static final BlobstoreService BLOB_STORE = BlobstoreServiceFactory.getBlobstoreService();%0A  private static final ImagesService IMAGES_SERVICE = ImagesServiceFactory.getImagesService();%0A%0A  private static final String PNG =%0A      %22iVBORw0KGgoAAAANSUhEUgAAAsAAAAGMAQMAAADuk4YmAAAAA1BMVEX///+nxBvIAAAAAXRSTlMA%22%0A      + %22QObYZgAAADlJREFUeF7twDEBAAAAwiD7p7bGDlgYAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA%22%0A      + %22AAAAAAAAwAGJrAABgPqdWQAAAABJRU5ErkJggg==%22;%0A%0A  LocalServiceTestHelper helper = new LocalServiceTestHelper(%0A      new LocalBlobstoreServiceTestConfig(), new LocalDatastoreServiceTestConfig(),%0A      new LocalImagesServiceTestConfig());%0A%0A  @Before%0A  public void setUp() throws Exception %7B%0A    helper.setUp();%0A  %7D%0A%0A  @After%0A  public void tearDown() throws Exception %7B%0A    helper.tearDown();%0A  %7D%0A%0A  @Test%0A  public void testFoundUrl() throws IOException %7B%0A    GcsFilename gcsFilename =%0A        new GcsFilename(TestServingViaBlobstoreApi.class.getName(), %22testFoundUrl%22);%0A    GcsOutputChannel channel = GCS_SERVICE.createOrReplace(%0A        gcsFilename, new GcsFileOptions.Builder().mimeType(%22image/png%22).build());%0A    byte%5B%5D bytes = BaseEncoding.base64().decode(PNG);%0A    channel.write(ByteBuffer.wrap(bytes));%0A    channel.close();%0A%0A    BlobKey blobKey = BLOB_STORE.createGsBlobKey(%0A        %22/gs/%22 + gcsFilename.getBucketName() + %22/%22 + gcsFilename.getObjectName());%0A%0A    byte%5B%5D imageData = BLOB_STORE.fetchData(blobKey, 0, bytes.length);%0A    assertArrayEquals(bytes, imageData);%0A%0A    ServingUrlOptions opts = ServingUrlOptions.Builder.withBlobKey(blobKey);%0A    opts.imageSize(bytes.length);%0A    String url = IMAGES_SERVICE.getServingUrl(opts);%0A    assertTrue(url.length() %3E 0);%0A  %7D%0A%7D%0A

Add unit test to show how blobstore image serving works.