Example usage for java.util EnumSet of

List of usage examples for java.util EnumSet of

Introduction

In this page you can find the example usage for java.util EnumSet of.

Prototype

public static <E extends Enum<E>> EnumSet<E> of(E e) 

Source Link

Document

Creates an enum set initially containing the specified element.

Usage

From source file:ch.cyberduck.core.manta.MantaWriteFeatureTest.java

@Test
public void testWrite() throws Exception {
    final MantaWriteFeature feature = new MantaWriteFeature(session);
    final Path container = new MantaDirectoryFeature(session).mkdir(randomDirectory(), "",
            new TransferStatus());
    final byte[] content = RandomUtils.nextBytes(5 * 1024 * 1024);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);/*from  w w w .j a  v a  2 s.co  m*/
    final Path file = new Path(container, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    final HttpResponseOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    final byte[] buffer = new byte[32 * 1024];
    assertEquals(content.length, IOUtils.copyLarge(in, out, buffer));
    in.close();
    out.close();
    assertNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new MantaReadFeature(session).read(file,
            new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new MantaDeleteFeature(session).delete(Collections.singletonList(container), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
}

From source file:microsoft.exchange.webservices.data.property.definition.ByteArrayPropertyDefinitionTest.java

/**
 * setup//w  ww  . ja  v  a  2 s .  co  m
 */
@Before
public void init() {
    this.testObject = new ByteArrayPropertyDefinition("myTestObject", "myTestUri",
            EnumSet.of(PropertyDefinitionFlags.None), ExchangeVersion.Exchange2010_SP2);
}

From source file:com.netflix.simianarmy.client.aws.chaos.TagsChaosCrawler.java

/**
 * {@inheritDoc}
 */
@Override
public EnumSet groupTypes() {
    return EnumSet.of(Type.TAGGED_EC2);
}

From source file:ch.cyberduck.core.manta.MantaReadFeatureTest.java

@Test(expected = NotfoundException.class)
public void testReadNotFound() throws Exception {
    final TransferStatus status = new TransferStatus();
    try {//  w w  w.j a  va  2 s  . c  o m
        final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), "",
                new TransferStatus());
        new MantaReadFeature(session).read(new Path(drive, "nosuchname", EnumSet.of(Path.Type.file)), status,
                new DisabledConnectionCallback());
    } catch (NotfoundException e) {
        assertEquals("Not Found. Please contact your web hosting service provider for assistance.",
                e.getDetail());
        throw e;
    }
}

From source file:ch.cyberduck.core.onedrive.OneDriveBufferWriteFeatureTest.java

@Test
public void testWrite() throws Exception {
    final OneDriveBufferWriteFeature feature = new OneDriveBufferWriteFeature(session);
    final Path container = new OneDriveHomeFinderFeature(session).find();
    final byte[] content = RandomUtils.nextBytes(5 * 1024);
    final TransferStatus status = new TransferStatus();
    status.setLength(content.length);//from  www  .  java 2s.co  m
    final Path file = new Path(container, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.file));
    final HttpResponseOutputStream<Void> out = feature.write(file, status, new DisabledConnectionCallback());
    final ByteArrayInputStream in = new ByteArrayInputStream(content);
    new StreamCopier(status, status).transfer(in, out);
    in.close();
    out.flush();
    assertEquals(content.length, status.getOffset());
    assertEquals(content.length, status.getLength());
    out.close();
    assertEquals(content.length, status.getOffset());
    assertEquals(content.length, status.getLength());
    assertNull(out.getStatus());
    assertTrue(new DefaultFindFeature(session).find(file));
    final byte[] compare = new byte[content.length];
    final InputStream stream = new OneDriveReadFeature(session).read(file,
            new TransferStatus().length(content.length), new DisabledConnectionCallback());
    IOUtils.readFully(stream, compare);
    stream.close();
    assertArrayEquals(content, compare);
    new OneDriveDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
}

From source file:ch.cyberduck.cli.CommandLinePathParser.java

public Path parse(final String uri) {
    final Host host = new HostParser(factory).get(uri);
    switch (host.getProtocol().getType()) {
    case s3://from  ww w. ja va 2  s.c  o m
    case googlestorage:
    case swift:
        final PathAttributes attributes = new PathAttributes();
        if (input.hasOption(TerminalOptionsBuilder.Params.region.name())) {
            attributes.setRegion(input.getOptionValue(TerminalOptionsBuilder.Params.region.name()));
        }
    }
    if (StringUtils.isBlank(host.getDefaultPath())) {
        return new Path(String.valueOf(Path.DELIMITER), EnumSet.of(detector.detect(host.getDefaultPath())));
    }
    return new Path(host.getDefaultPath(), EnumSet.of(detector.detect(host.getDefaultPath())));
}

From source file:ch.cyberduck.core.nio.LocalReadFeatureTest.java

@Test(expected = NotfoundException.class)
public void testReadNotFound() throws Exception {
    final LocalSession session = new LocalSession(
            new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname()));
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    final Path workdir = new LocalHomeFinderFeature(session).find();
    new LocalReadFeature(session).read(new Path(workdir, "nosuchname", EnumSet.of(Path.Type.file)), status,
            new DisabledConnectionCallback());
}

From source file:ch.cyberduck.core.cryptomator.DropboxDirectoryFeatureTest.java

@Test
public void testMakeDirectoryEncrypted() throws Exception {
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    final Path test = new Path(vault, new AlphanumericRandomStringService().random(),
            EnumSet.of(Path.Type.directory));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(//w  w  w  .  j  a va2  s .c o m
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    new CryptoDirectoryFeature<String>(session, new DropboxDirectoryFeature(session),
            new DropboxWriteFeature(session), cryptomator).mkdir(test, null, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new DropboxDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

From source file:ch.cyberduck.core.cryptomator.DriveTouchFeatureTest.java

@Test
public void testTouchLongFilenameEncrypted() throws Exception {
    final Path home = new DriveHomeFinderService(session).find();
    final CryptoVault cryptomator = new CryptoVault(
            new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)),
            new DisabledPasswordStore());
    final Path vault = cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(/*from w w w  .  ja v  a 2  s.co  m*/
            new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final Path test = new CryptoTouchFeature<Void>(session, new DriveTouchFeature(session),
            new DriveWriteFeature(session), cryptomator)
                    .touch(new Path(vault, new RandomStringGenerator.Builder().build().generate(130),
                            EnumSet.of(Path.Type.file)), new TransferStatus());
    Assert.assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test));
    new CryptoDeleteFeature(session, new DriveDeleteFeature(session), cryptomator)
            .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
}

From source file:ch.cyberduck.cli.CommandLinePathParserTest.java

@Test
public void testParse() throws Exception {
    final CommandLineParser parser = new PosixParser();
    final CommandLine input = parser.parse(new Options(), new String[] {});

    final ProtocolFactory factory = new ProtocolFactory(new HashSet<>(Arrays.asList(new FTPTLSProtocol() {
        @Override//from  w  ww  . j a  v a 2s .c o  m
        public boolean isEnabled() {
            return true;
        }
    }, new S3Protocol() {
        @Override
        public boolean isEnabled() {
            return true;
        }
    })));
    assertEquals(new Path("/", EnumSet.of(Path.Type.directory)),
            new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/"));
    assertEquals(new Path("/d", EnumSet.of(Path.Type.directory)),
            new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/d/"));
    assertEquals(new Path("/d", EnumSet.of(Path.Type.file)),
            new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/d"));
    assertEquals(new Path("/", EnumSet.of(Path.Type.directory)),
            new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch/"));
    assertEquals(new Path("/", EnumSet.of(Path.Type.directory)),
            new CommandLinePathParser(input, factory).parse("ftps://u@test.cyberduck.ch"));

    assertEquals(new Path("/test.cyberduck.ch", EnumSet.of(Path.Type.directory)),
            new CommandLinePathParser(input, factory).parse("s3://u@test.cyberduck.ch/"));
    assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.directory)),
            new CommandLinePathParser(input, factory).parse("s3://u@test.cyberduck.ch/d/"));
    assertEquals(new Path("/test.cyberduck.ch/d", EnumSet.of(Path.Type.file)),
            new CommandLinePathParser(input, factory).parse("s3://u@test.cyberduck.ch/d"));
}