Add callback for delete operation.
[cyberduck.git] / test / ch / cyberduck / core / gstorage / GoogleStorageBucketCreateServiceTest.java
bloba58f9f90b3561d45a877b47c174aa300f51b84e5
1 package ch.cyberduck.core.gstorage;
3 import ch.cyberduck.core.AbstractTestCase;
4 import ch.cyberduck.core.Credentials;
5 import ch.cyberduck.core.DisabledCancelCallback;
6 import ch.cyberduck.core.DisabledHostKeyCallback;
7 import ch.cyberduck.core.DisabledLoginCallback;
8 import ch.cyberduck.core.DisabledPasswordStore;
9 import ch.cyberduck.core.DisabledTranscriptListener;
10 import ch.cyberduck.core.Host;
11 import ch.cyberduck.core.Path;
12 import ch.cyberduck.core.Scheme;
13 import ch.cyberduck.core.features.Delete;
14 import ch.cyberduck.core.features.Find;
15 import ch.cyberduck.core.s3.S3DefaultDeleteFeature;
17 import org.junit.Test;
19 import java.util.Collections;
20 import java.util.EnumSet;
21 import java.util.UUID;
23 import static org.junit.Assert.assertFalse;
24 import static org.junit.Assert.assertTrue;
26 /**
27 * @version $Id$
29 public class GoogleStorageBucketCreateServiceTest extends AbstractTestCase {
31 @Test
32 public void testCreate() throws Exception {
33 final Host host = new Host(new GoogleStorageProtocol(), new GoogleStorageProtocol().getDefaultHostname(), new Credentials(
34 properties.getProperty("google.projectid"), null
35 ));
36 final GoogleStorageSession session = new GoogleStorageSession(host);
37 session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
38 session.login(new DisabledPasswordStore() {
39 @Override
40 public String getPassword(final Scheme scheme, final int port, final String hostname, final String user) {
41 if(user.equals("Google OAuth2 Access Token")) {
42 return properties.getProperty("google.accesstoken");
44 if(user.equals("Google OAuth2 Refresh Token")) {
45 return properties.getProperty("google.refreshtoken");
47 return null;
49 }, new DisabledLoginCallback(), new DisabledCancelCallback());
50 final Path bucket = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory, Path.Type.volume));
51 new GoogleStorageBucketCreateService(session).create(bucket, "US");
52 assertTrue(session.getFeature(Find.class).find(bucket));
53 new S3DefaultDeleteFeature(session).delete(Collections.<Path>singletonList(bucket), new DisabledLoginCallback(), new Delete.Callback() {
54 @Override
55 public void delete(final Path file) {
57 });
58 assertFalse(session.getFeature(Find.class).find(bucket));
59 session.close();