use of ch.cyberduck.core.TranscriptListener in project cyberduck by iterate-ch.
the class SpectraDirectoryFeatureTest method testCreatePlaceholder.
@Test
public void testCreatePlaceholder() throws Exception {
final Host host = new Host(new SpectraProtocol() {
@Override
public Scheme getScheme() {
return Scheme.http;
}
}, System.getProperties().getProperty("spectra.hostname"), Integer.valueOf(System.getProperties().getProperty("spectra.port")), new Credentials(System.getProperties().getProperty("spectra.user"), System.getProperties().getProperty("spectra.key")));
final SpectraSession session = new SpectraSession(host, new DisabledX509TrustManager(), new DefaultX509KeyManager());
final AtomicBoolean b = new AtomicBoolean();
final Path container = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
final String name = UUID.randomUUID().toString();
session.withListener(new TranscriptListener() {
@Override
public void log(final Type request, final String message) {
switch(request) {
case request:
if ((String.format("PUT /%s/%s/ HTTP/1.1", container.getName(), name)).equals(message)) {
b.set(true);
}
}
}
});
session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback(), new DisabledCancelCallback());
session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback());
final Path test = new SpectraDirectoryFeature(session, new SpectraWriteFeature(session)).mkdir(new Path(container, name, EnumSet.of(Path.Type.directory)), new TransferStatus());
assertTrue(b.get());
assertTrue(new SpectraFindFeature(session).find(test));
assertTrue(new DefaultFindFeature(session).find(test));
new SpectraDeleteFeature(session).delete(Collections.<Path>singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback());
session.close();
}
use of ch.cyberduck.core.TranscriptListener in project cyberduck by iterate-ch.
the class S3BucketCreateServiceTest method testCreateBucket.
@Test
public void testCreateBucket() throws Exception {
final AtomicBoolean header = new AtomicBoolean();
final AtomicBoolean signature = new AtomicBoolean();
session.withListener(new TranscriptListener() {
@Override
public void log(final Type request, final String message) {
if (StringUtils.contains(message, "Expect: 100-continue")) {
header.set(true);
}
if (StringUtils.contains(message, "SignedHeaders=content-type;date;expect;host;x-amz-acl;x-amz-content-sha256;x-amz-date")) {
signature.set(true);
}
}
});
final S3BucketCreateService create = new S3BucketCreateService(session);
final Path bucket = new Path(new AsciiRandomStringService().random(), EnumSet.of(Path.Type.directory, Path.Type.volume));
create.create(bucket, "eu-central-1");
assertTrue(header.get());
bucket.attributes().setRegion("eu-central-1");
assertTrue(new S3FindFeature(session).find(bucket));
new S3DefaultDeleteFeature(session).delete(Collections.<Path>singletonList(bucket), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
use of ch.cyberduck.core.TranscriptListener in project cyberduck by iterate-ch.
the class SFTPCommandFeatureTest method testSend.
@Test
@Ignore
public void testSend() throws Exception {
final StringBuilder t = new StringBuilder();
new SFTPCommandFeature(session).send("ps", new ProgressListener() {
@Override
public void message(final String message) {
assertEquals("ps", message);
}
}, new TranscriptListener() {
@Override
public void log(final Type request, final String message) {
switch(request) {
case response:
t.append(message);
}
}
});
assertTrue("PID TTY TIME CMD22417 ? 00:00:00 sshd22418 ? 00:00:00 sftp-server22427 ? 00:00:00 ps", t.toString().startsWith(" PID TTY TIME"));
}
use of ch.cyberduck.core.TranscriptListener in project cyberduck by iterate-ch.
the class SwiftDeleteFeatureTest method testDeletePlaceholder.
@Test
public void testDeletePlaceholder() throws Exception {
final AtomicBoolean delete = new AtomicBoolean();
final String name = "placeholder-" + UUID.randomUUID().toString();
session.withListener(new TranscriptListener() {
@Override
public void log(final Type request, final String message) {
switch(request) {
case request:
if (("DELETE /v1/MossoCloudFS_59113590-c679-46c3-bf62-9d7c3d5176ee/test.cyberduck.ch/" + name + " HTTP/1.1").equals(message)) {
delete.set(true);
}
}
}
});
final Path container = new Path("test.cyberduck.ch", EnumSet.of(Path.Type.directory, Path.Type.volume));
container.attributes().setRegion("IAD");
final Path placeholder = new Path(container, name, EnumSet.of(Path.Type.directory));
new SwiftDirectoryFeature(session).mkdir(placeholder, new TransferStatus());
final SwiftFindFeature find = new SwiftFindFeature(session);
assertTrue(find.find(placeholder));
new SwiftDeleteFeature(session).delete(Collections.singletonList(placeholder), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertTrue(delete.get());
Thread.sleep(1000L);
assertFalse(find.find(placeholder));
}
use of ch.cyberduck.core.TranscriptListener in project cyberduck by iterate-ch.
the class SwiftDirectoryFeatureTest method testCreatePlaceholder.
@Test
public void testCreatePlaceholder() throws Exception {
final AtomicBoolean put = new AtomicBoolean();
final String parentname = new AlphanumericRandomStringService().random();
final String name = new AlphanumericRandomStringService().random();
session.withListener(new TranscriptListener() {
@Override
public void log(final Type request, final String message) {
switch(request) {
case request:
if (("PUT /v1/MossoCloudFS_59113590-c679-46c3-bf62-9d7c3d5176ee/test.cyberduck.ch/" + parentname + "/" + name + " HTTP/1.1").equals(message)) {
put.set(true);
}
}
}
});
final Path container = new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.volume, Path.Type.directory));
container.attributes().setRegion("IAD");
final SwiftDirectoryFeature feature = new SwiftDirectoryFeature(session, new SwiftRegionService(session), new SwiftWriteFeature(session, new SwiftRegionService(session)));
final Path parent = feature.mkdir(new Path(container, parentname, EnumSet.of(Path.Type.directory)), new TransferStatus());
final Path placeholder = feature.mkdir(new Path(parent, name, EnumSet.of(Path.Type.directory)), new TransferStatus());
assertTrue(put.get());
assertTrue(new SwiftFindFeature(session).find(placeholder));
assertTrue(new DefaultFindFeature(session).find(placeholder));
assertEquals(placeholder.attributes().getChecksum(), new SwiftAttributesFinderFeature(session).find(placeholder).getChecksum());
assertTrue(new SwiftObjectListService(session, new SwiftRegionService(session)).list(placeholder, new DisabledListProgressListener()).isEmpty());
assertEquals(1, new SwiftObjectListService(session, new SwiftRegionService(session)).list(parent, new DisabledListProgressListener()).size());
new SwiftDeleteFeature(session).delete(Arrays.asList(placeholder, parent), new DisabledLoginCallback(), new Delete.DisabledCallback());
assertFalse(new SwiftFindFeature(session).find(placeholder));
}
Aggregations