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.openstack.SwiftSmallObjectUploadFeatureTest.java

@Test(expected = ChecksumException.class)
public void testPostChecksumFailure() throws Exception {
    final StorageObject o = new StorageObject("f");
    o.setMd5sum("d41d8cd98f00b204e9800998ecf8427f");
    try {/*w  w  w. j a v a  2 s.c om*/
        final SwiftSession session = new SwiftSession(new Host(new SwiftProtocol()));
        new SwiftSmallObjectUploadFeature(new SwiftWriteFeature(session, new SwiftRegionService(session)))
                .post(new Path("/f", EnumSet.of(Path.Type.file)), MessageDigest.getInstance("MD5"), o);
    } catch (ChecksumException e) {
        assertEquals("Upload f failed", e.getMessage());
        assertEquals(
                "Mismatch between MD5 hash d41d8cd98f00b204e9800998ecf8427e of uploaded data and ETag d41d8cd98f00b204e9800998ecf8427f returned by the server.",
                e.getDetail());
        throw e;
    }
}

From source file:ch.cyberduck.core.googledrive.DriveUploadFeatureTest.java

@Test
public void testWrite() throws Exception {
    final TransferStatus status = new TransferStatus();
    final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString());
    final byte[] content = "test".getBytes("UTF-8");
    final OutputStream out = local.getOutputStream(false);
    IOUtils.write(content, out);//  w w  w .  ja  va 2  s .c om
    IOUtils.closeQuietly(out);
    status.setLength(content.length);
    final Path test = new Path(new DriveHomeFinderService(session).find(), UUID.randomUUID().toString(),
            EnumSet.of(Path.Type.file));
    final HttpConnectionPoolBuilder builder = new HttpConnectionPoolBuilder(session.getHost(),
            new ThreadLocalHostnameDelegatingTrustManager(new DisabledX509TrustManager(),
                    session.getHost().getHostname()),
            new DefaultX509KeyManager(), new DisabledProxyFinder());
    final DriveUploadFeature upload = new DriveUploadFeature(new DriveWriteFeature(session));
    upload.upload(test, local, new BandwidthThrottle(BandwidthThrottle.UNLIMITED), new DisabledStreamListener(),
            status, new DisabledConnectionCallback());
    test.attributes()
            .setVersionId(new DriveFileidProvider(session).getFileid(test, new DisabledListProgressListener()));
    assertTrue(session.getFeature(Find.class).find(test));
    assertEquals(content.length,
            session.list(test.getParent(), new DisabledListProgressListener()).get(test).attributes().getSize(),
            0L);
    assertEquals(content.length,
            new DriveWriteFeature(session).append(test, status.getLength(), PathCache.empty()).size, 0L);
    {
        final byte[] buffer = new byte[content.length];
        IOUtils.readFully(new DriveReadFeature(session).read(test, new TransferStatus(),
                new DisabledConnectionCallback()), buffer);
        assertArrayEquals(content, buffer);
    }
    {
        final byte[] buffer = new byte[content.length - 1];
        final InputStream in = new DriveReadFeature(session).read(test,
                new TransferStatus().length(content.length).append(true).skip(1L),
                new DisabledConnectionCallback());
        IOUtils.readFully(in, buffer);
        IOUtils.closeQuietly(in);
        final byte[] reference = new byte[content.length - 1];
        System.arraycopy(content, 1, reference, 0, content.length - 1);
        assertArrayEquals(reference, buffer);
    }
    new DriveDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(),
            new Delete.DisabledCallback());
}

From source file:org.uoiu.platform.web.DefaultWebApplicationInitializer.java

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
    AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
    //    appContext.register(AppConfig.class);
    appContext.getEnvironment().setActiveProfiles("webapp");
    servletContext.addListener(new ContextLoaderListener(appContext));

    AnnotationConfigWebApplicationContext mvcContext = new AnnotationConfigWebApplicationContext();
    mvcContext.register(MvcConfig.class);

    ServletRegistration.Dynamic dispatcher = servletContext.addServlet("dispatcher",
            new DispatcherServlet(mvcContext));
    dispatcher.setLoadOnStartup(1);//from w  w  w  . j ava 2  s  . c  o  m
    dispatcher.addMapping("/");

    FilterRegistration.Dynamic encodingFilter = servletContext.addFilter("encodingFilter",
            characterEncodingFilter());
    encodingFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), true, "/*");
}

From source file:com.flipkart.zjsonpatch.CompatibilityTest.java

@Test
public void withFlagReplaceNodeWithMissingValueShouldValidateCorrectly() {
    JsonPatch.validate(addNodeWithMissingValue, EnumSet.of(MISSING_VALUES_AS_NULLS));
}

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

@Override
public AttributedList<Path> list(final Path directory, final ListProgressListener listener)
        throws BackgroundException {
    final AttributedList<Path> children = new AttributedList<>();
    final Iterator<MantaObject> objectsIter;
    try {/* w ww.java  2s  .c om*/
        objectsIter = session.getClient().listObjects(directory.getAbsolute()).iterator();
    } catch (MantaObjectException e) {
        throw new MantaExceptionMappingService().map("Listing directory {0} failed", e, directory);
    } catch (MantaClientHttpResponseException e) {
        throw new MantaHttpExceptionMappingService().map("Listing directory {0} failed", e, directory);
    } catch (IOException e) {
        throw new DefaultIOExceptionMappingService().map("Listing directory {0} failed", e);
    }
    final MantaObjectAttributeAdapter adapter = new MantaObjectAttributeAdapter(session);
    while (objectsIter.hasNext()) {
        MantaObject o = objectsIter.next();
        final Path file = new Path(directory, FilenameUtils.getName(o.getPath()),
                EnumSet.of(o.isDirectory() ? Path.Type.directory : Path.Type.file), adapter.convert(o));
        children.add(file);
        listener.chunk(directory, children);
    }
    return children;
}

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

@Test
public void testFindWildcard() throws Exception {
    final CommandLineParser parser = new PosixParser();
    final CommandLine input = parser.parse(TerminalOptionsBuilder.options(),
            new String[] { "--delete", "rackspace://cdn.cyberduck.ch/remote/*.txt" });

    assertTrue(new DeletePathFinder()
            .find(input, TerminalAction.delete, new Path("/remote/*.txt", EnumSet.of(Path.Type.file)))
            .contains(new TransferItem(new Path("/remote", EnumSet.of(Path.Type.directory)))));
}

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

private Path buildNormalizedHomePath(final String rawHomePath) {
    final String defaultPath = StringUtils.defaultIfBlank(rawHomePath, Path.HOME);
    final String accountRootRegex = String.format("^/?(%s|~~?)/?", accountRoot.getAbsolute());
    final String subdirectoryRawPath = defaultPath.replaceFirst(accountRootRegex, "");

    if (StringUtils.isEmpty(subdirectoryRawPath)) {
        return accountRoot;
    }// w  ww  .  jav  a2  s .c  o  m

    final String[] subdirectoryPathSegments = StringUtils.split(subdirectoryRawPath, Path.DELIMITER);
    Path homePath = accountRoot;

    for (final String pathSegment : subdirectoryPathSegments) {
        EnumSet<Path.Type> types = EnumSet.of(Path.Type.directory);
        if (homePath.getParent().equals(accountRoot)
                && StringUtils.equalsAny(pathSegment, HOME_PATH_PRIVATE, HOME_PATH_PUBLIC)) {
            types.add(Path.Type.volume);
        }

        homePath = new Path(homePath, pathSegment, types);
    }

    return homePath;
}

From source file:ch.cyberduck.ui.cocoa.controller.FileController.java

@Override
public boolean validate() {
    if (StringUtils.contains(inputField.stringValue(), Path.DELIMITER)) {
        return false;
    }/*from   w  w w  . ja  va  2  s  .c o m*/
    if (StringUtils.isNotBlank(inputField.stringValue())) {
        if (cache.get(workdir)
                .contains(new Path(workdir, inputField.stringValue(), EnumSet.of(Path.Type.file)))) {
            return false;
        }
        if (cache.get(workdir)
                .contains(new Path(workdir, inputField.stringValue(), EnumSet.of(Path.Type.directory)))) {
            return false;
        }
        return true;
    }
    return false;
}

From source file:ch.cyberduck.core.sftp.SFTPReadFeatureTest.java

@Test(expected = NotfoundException.class)
public void testReadNotFound() throws Exception {
    final Host host = new Host(new SFTPProtocol(), "test.cyberduck.ch",
            new Credentials(System.getProperties().getProperty("sftp.user"),
                    System.getProperties().getProperty("sftp.password")));
    final SFTPSession session = new SFTPSession(host);
    session.open(new DisabledHostKeyCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final TransferStatus status = new TransferStatus();
    new SFTPReadFeature(session).read(
            new Path(new SFTPHomeDirectoryService(session).find(), "nosuchname", EnumSet.of(Path.Type.file)),
            status, new DisabledConnectionCallback());
}

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

@Test
public void testLocalInOptionsDownload() throws Exception {
    final CommandLineParser parser = new PosixParser();
    final String temp = System.getProperty("java.io.tmpdir");
    final CommandLine input = parser.parse(TerminalOptionsBuilder.options(),
            new String[] { "--download", "rackspace://cdn.cyberduck.ch/remote", String.format("%s/f", temp) });

    final Set<TransferItem> found = new SingleTransferItemFinder().find(input, TerminalAction.download,
            new Path("/cdn.cyberduck.ch/remote", EnumSet.of(Path.Type.file)));
    assertFalse(found.isEmpty());//ww  w.  j a  v a 2  s. co m
    assertEquals(new TransferItem(new Path("/cdn.cyberduck.ch/remote", EnumSet.of(Path.Type.file)),
            LocalFactory.get(String.format("%s/f", temp))), found.iterator().next());

}