Search in sources :

Example 1 with TranscriptListener

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();
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledX509TrustManager(ch.cyberduck.core.ssl.DisabledX509TrustManager) Scheme(ch.cyberduck.core.Scheme) Host(ch.cyberduck.core.Host) TranscriptListener(ch.cyberduck.core.TranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DisabledCancelCallback(ch.cyberduck.core.DisabledCancelCallback) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledHostKeyCallback(ch.cyberduck.core.DisabledHostKeyCallback) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) DefaultX509KeyManager(ch.cyberduck.core.ssl.DefaultX509KeyManager) Credentials(ch.cyberduck.core.Credentials) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with TranscriptListener

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());
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) AsciiRandomStringService(ch.cyberduck.core.AsciiRandomStringService) TranscriptListener(ch.cyberduck.core.TranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with TranscriptListener

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"));
}
Also used : ProgressListener(ch.cyberduck.core.ProgressListener) TranscriptListener(ch.cyberduck.core.TranscriptListener) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with TranscriptListener

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));
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) TranscriptListener(ch.cyberduck.core.TranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with TranscriptListener

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));
}
Also used : Path(ch.cyberduck.core.Path) Delete(ch.cyberduck.core.features.Delete) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) TranscriptListener(ch.cyberduck.core.TranscriptListener) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) DefaultFindFeature(ch.cyberduck.core.shared.DefaultFindFeature) DisabledLoginCallback(ch.cyberduck.core.DisabledLoginCallback) TransferStatus(ch.cyberduck.core.transfer.TransferStatus) AlphanumericRandomStringService(ch.cyberduck.core.AlphanumericRandomStringService) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

TranscriptListener (ch.cyberduck.core.TranscriptListener)6 IntegrationTest (ch.cyberduck.test.IntegrationTest)6 Test (org.junit.Test)6 DisabledLoginCallback (ch.cyberduck.core.DisabledLoginCallback)4 Path (ch.cyberduck.core.Path)4 Delete (ch.cyberduck.core.features.Delete)4 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)4 TransferStatus (ch.cyberduck.core.transfer.TransferStatus)3 ProgressListener (ch.cyberduck.core.ProgressListener)2 DefaultFindFeature (ch.cyberduck.core.shared.DefaultFindFeature)2 AlphanumericRandomStringService (ch.cyberduck.core.AlphanumericRandomStringService)1 AsciiRandomStringService (ch.cyberduck.core.AsciiRandomStringService)1 Credentials (ch.cyberduck.core.Credentials)1 DisabledCancelCallback (ch.cyberduck.core.DisabledCancelCallback)1 DisabledHostKeyCallback (ch.cyberduck.core.DisabledHostKeyCallback)1 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)1 Host (ch.cyberduck.core.Host)1 Scheme (ch.cyberduck.core.Scheme)1 DefaultX509KeyManager (ch.cyberduck.core.ssl.DefaultX509KeyManager)1 DisabledX509TrustManager (ch.cyberduck.core.ssl.DisabledX509TrustManager)1