1 package ch
.cyberduck
.core
.azure
;
3 import ch
.cyberduck
.core
.AbstractTestCase
;
4 import ch
.cyberduck
.core
.Credentials
;
5 import ch
.cyberduck
.core
.DisabledHostKeyCallback
;
6 import ch
.cyberduck
.core
.DisabledLoginCallback
;
7 import ch
.cyberduck
.core
.DisabledPasswordStore
;
8 import ch
.cyberduck
.core
.DisabledProgressListener
;
9 import ch
.cyberduck
.core
.DisabledTranscriptListener
;
10 import ch
.cyberduck
.core
.Host
;
11 import ch
.cyberduck
.core
.LoginConnectionService
;
12 import ch
.cyberduck
.core
.Path
;
13 import ch
.cyberduck
.core
.PathCache
;
14 import ch
.cyberduck
.core
.features
.Delete
;
16 import org
.junit
.Test
;
18 import java
.util
.Collections
;
19 import java
.util
.EnumSet
;
21 import java
.util
.UUID
;
23 import static org
.junit
.Assert
.*;
28 public class AzureMetadataFeatureTest
extends AbstractTestCase
{
31 public void testSetMetadata() throws Exception
{
32 final Host host
= new Host(new AzureProtocol(), "cyberduck.blob.core.windows.net", new Credentials(
33 properties
.getProperty("azure.account"), properties
.getProperty("azure.key")
35 final AzureSession session
= new AzureSession(host
);
36 new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(),
37 new DisabledPasswordStore(), new DisabledProgressListener(), new DisabledTranscriptListener()).connect(session
, PathCache
.empty());
38 final Path container
= new Path("cyberduck", EnumSet
.of(Path
.Type
.directory
, Path
.Type
.volume
));
39 final Path test
= new Path(container
, UUID
.randomUUID().toString() + ".txt", EnumSet
.of(Path
.Type
.file
));
40 new AzureTouchFeature(session
, null).touch(test
);
41 final String v
= UUID
.randomUUID().toString();
42 new AzureMetadataFeature(session
, null).setMetadata(test
, Collections
.<String
, String
>singletonMap("Test", v
));
43 final Map
<String
, String
> metadata
= new AzureMetadataFeature(session
, null).getMetadata(test
);
44 assertFalse(metadata
.isEmpty());
45 assertTrue(metadata
.containsKey("Test"));
46 assertEquals(v
, metadata
.get("Test"));
47 new AzureDeleteFeature(session
, null).delete(Collections
.singletonList(test
), new DisabledLoginCallback(), new Delete
.Callback() {
49 public void delete(final Path file
) {
56 public void testSetCacheControl() throws Exception
{
57 final Host host
= new Host(new AzureProtocol(), "cyberduck.blob.core.windows.net", new Credentials(
58 properties
.getProperty("azure.account"), properties
.getProperty("azure.key")
60 final AzureSession session
= new AzureSession(host
);
61 new LoginConnectionService(new DisabledLoginCallback(), new DisabledHostKeyCallback(),
62 new DisabledPasswordStore(), new DisabledProgressListener(), new DisabledTranscriptListener()).connect(session
, PathCache
.empty());
63 final Path container
= new Path("cyberduck", EnumSet
.of(Path
.Type
.directory
, Path
.Type
.volume
));
64 final Path test
= new Path(container
, UUID
.randomUUID().toString() + ".txt", EnumSet
.of(Path
.Type
.file
));
65 new AzureTouchFeature(session
, null).touch(test
);
66 final AzureMetadataFeature service
= new AzureMetadataFeature(session
, null);
67 service
.setMetadata(test
, Collections
.<String
, String
>singletonMap("Cache-Control",
68 "public, max-age=0"));
69 final Map
<String
, String
> metadata
= service
.getMetadata(test
);
70 assertFalse(metadata
.isEmpty());
71 assertTrue(metadata
.containsKey("Cache-Control"));
72 assertEquals("public, max-age=0", metadata
.get("Cache-Control"));
73 // Make sure content type is not deleted
74 assertTrue(metadata
.containsKey("Content-Type"));
75 assertEquals("application/octet-stream", metadata
.get("Content-Type"));
76 new AzureDeleteFeature(session
, null).delete(Collections
.singletonList(test
), new DisabledLoginCallback(), new Delete
.Callback() {
78 public void delete(final Path file
) {