Merge pull request #64 in ITERATE/cyberduck from feature/windows/9074 to master
[cyberduck.git] / test / ch / cyberduck / core / s3 / S3BucketCreateServiceTest.java
blob0ba7e0de06bbfddef093937f4de00fa7c5ab6a37
1 package ch.cyberduck.core.s3;
3 /*
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
5 * http://cyberduck.ch/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
20 import ch.cyberduck.core.AbstractTestCase;
21 import ch.cyberduck.core.Credentials;
22 import ch.cyberduck.core.DisabledHostKeyCallback;
23 import ch.cyberduck.core.DisabledLoginCallback;
24 import ch.cyberduck.core.DisabledTranscriptListener;
25 import ch.cyberduck.core.Host;
26 import ch.cyberduck.core.Path;
27 import ch.cyberduck.core.ProtocolFactory;
28 import ch.cyberduck.core.exception.AccessDeniedException;
29 import ch.cyberduck.core.features.Delete;
30 import ch.cyberduck.core.features.Location;
32 import org.junit.Ignore;
33 import org.junit.Test;
35 import java.util.Collections;
36 import java.util.EnumSet;
37 import java.util.UUID;
39 import static org.junit.Assert.*;
41 /**
42 * @version $Id$
44 public class S3BucketCreateServiceTest extends AbstractTestCase {
46 @Test
47 @Ignore
48 public void testCreate() throws Exception {
49 final S3Session session = new S3Session(
50 new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
51 new Credentials(
52 properties.getProperty("s3.key"), properties.getProperty("s3.secret")
53 )));
54 assertNotNull(session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()));
55 final S3FindFeature find = new S3FindFeature(session);
56 final S3DefaultDeleteFeature delete = new S3DefaultDeleteFeature(session);
57 final S3BucketCreateService create = new S3BucketCreateService(session);
58 for(Location.Name region : ProtocolFactory.S3_SSL.getRegions()) {
59 final Path bucket = new Path(UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory, Path.Type.volume));
60 create.create(bucket, region.getIdentifier());
61 bucket.attributes().setRegion(region.getIdentifier());
62 assertTrue(find.find(bucket));
63 delete.delete(Collections.<Path>singletonList(bucket), new DisabledLoginCallback(), new Delete.Callback() {
64 @Override
65 public void delete(final Path file) {
67 });
68 assertFalse(find.find(bucket));
70 session.close();
73 @Test(expected = AccessDeniedException.class)
74 public void testCreateExistsAlreadyConflict() throws Exception {
75 final S3Session session = new S3Session(
76 new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
77 new Credentials(
78 properties.getProperty("s3.key"), properties.getProperty("s3.secret")
79 )));
80 assertNotNull(session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()));
81 final S3BucketCreateService service = new S3BucketCreateService(session);
82 try {
83 final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume));
84 service.create(container, "us-east-1");
86 finally {
87 session.close();