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
;
29 public class GoogleStorageBucketCreateServiceTest
extends AbstractTestCase
{
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
36 final GoogleStorageSession session
= new GoogleStorageSession(host
);
37 session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
38 session
.login(new DisabledPasswordStore() {
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");
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() {
55 public void delete(final Path file
) {
58 assertFalse(session
.getFeature(Find
.class).find(bucket
));