List of usage examples for java.util EnumSet of
public static <E extends Enum<E>> EnumSet<E> of(E e)
From source file:ch.cyberduck.core.cryptomator.OneDriveDirectoryFeatureTest.java
@Test public void testMakeDirectoryEncrypted() throws Exception { final Path home = new OneDriveHomeFinderFeature(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(//from ww w . j av a 2 s . c o m new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoDirectoryFeature<Void>(session, new OneDriveDirectoryFeature(session), new OneDriveWriteFeature(session), cryptomator).mkdir(test, null, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new OneDriveDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:com.quinsoft.zeidon.ActivateOptions.java
public ActivateOptions(TaskQualification task) { super(task.getTask()); activateFlags = EnumSet.of(ActivateFlags.fMULTIPLE); }
From source file:com.flipkart.zjsonpatch.CompatibilityTest.java
@Test public void withFlagReplaceShouldTreatMissingValuesAsNull() throws IOException { JsonNode source = mapper.readTree("{\"a\":\"test\"}"); JsonNode expected = mapper.readTree("{\"a\":null}"); JsonNode result = JsonPatch.apply(replaceNodeWithMissingValue, source, EnumSet.of(MISSING_VALUES_AS_NULLS)); assertThat(result, equalTo(expected)); }
From source file:ch.cyberduck.core.onedrive.OneDriveWriteFeatureTest.java
@Test public void testWrite() throws Exception { final OneDriveWriteFeature feature = new OneDriveWriteFeature(session); final Path container = new OneDriveHomeFinderFeature(session).find(); final byte[] content = RandomUtils.nextBytes(5 * 1024 * 1024); final TransferStatus status = new TransferStatus(); status.setLength(content.length);//ww w .jav a2 s .c o 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 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.core.cryptomator.DriveDirectoryFeatureTest.java
@Test public void testMakeDirectoryEncrypted() 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(// www.j av a 2s . c om new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); final Path test = new CryptoDirectoryFeature<Void>(session, new DriveDirectoryFeature(session), new DriveWriteFeature(session), cryptomator) .mkdir(new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), null, new TransferStatus()); 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.core.dropbox.DropboxReadFeatureTest.java
@Test public void testReadInterrupt() throws Exception { final DropboxWriteFeature write = new DropboxWriteFeature(session); final TransferStatus writeStatus = new TransferStatus(); final byte[] content = RandomUtils.nextBytes(66800); writeStatus.setLength(content.length); final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final OutputStream out = write.write(test, writeStatus, new DisabledConnectionCallback()); assertNotNull(out);/*from w ww .j av a 2s . co m*/ new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); // Unknown length in status final TransferStatus readStatus = new TransferStatus(); // Read a single byte { final InputStream in = new DropboxReadFeature(session).read(test, readStatus, new DisabledConnectionCallback()); assertNotNull(in.read()); in.close(); } { final InputStream in = new DropboxReadFeature(session).read(test, readStatus, new DisabledConnectionCallback()); assertNotNull(in); in.close(); } new DropboxDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:ch.cyberduck.core.dropbox.DropboxWriteFeatureTest.java
@Test public void testReadWrite() throws Exception { final DropboxWriteFeature write = new DropboxWriteFeature(session); final TransferStatus status = new TransferStatus(); final byte[] content = RandomUtils.nextBytes(66800); status.setLength(content.length);// w ww. ja v a2 s . c o m final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final OutputStream out = write.write(test, status, new DisabledConnectionCallback()); assertNotNull(out); new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), out); assertTrue(new DropboxFindFeature(session).find(test)); assertEquals(content.length, session.list(test.getParent(), new DisabledListProgressListener()).get(test) .attributes().getSize()); assertEquals(content.length, write.append(test, status.getLength(), PathCache.empty()).size, 0L); { final InputStream in = new DropboxReadFeature(session).read(test, new TransferStatus().length(content.length), new DisabledConnectionCallback()); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length); new StreamCopier(status, status).transfer(in, buffer); in.close(); assertArrayEquals(content, buffer.toByteArray()); } { final byte[] buffer = new byte[content.length - 1]; final InputStream in = new DropboxReadFeature(session).read(test, new TransferStatus().length(content.length).append(true).skip(1L), new DisabledConnectionCallback()); IOUtils.readFully(in, buffer); in.close(); final byte[] reference = new byte[content.length - 1]; System.arraycopy(content, 1, reference, 0, content.length - 1); assertArrayEquals(reference, buffer); } new DropboxDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:ch.cyberduck.core.shared.DefaultCopyFeatureTest.java
@Test public void testSupported() 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); final Path source = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); assertTrue(new DefaultCopyFeature(session).isSupported(source, target)); session.close();/*from ww w .j a v a 2s. co m*/ }
From source file:ch.cyberduck.core.cryptomator.DropboxTouchFeatureTest.java
@Test public void testTouchLongFilenameEncrypted() 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 RandomStringGenerator.Builder().build().generate(130), EnumSet.of(Path.Type.file)); final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore()); cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(/* w w w . ja v a 2 s. c o m*/ new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoTouchFeature<String>(session, new DefaultTouchFeature<String>(new DropboxUploadFeature(new DropboxWriteFeature(session))), new DropboxWriteFeature(session), cryptomator).touch(test, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DropboxFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new DropboxDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:com.indeed.imhotep.web.config.WebApp.java
@Override public void onStartup(ServletContext servletContext) throws ServletException { if (WebApp.started) { return; // avoid double initialization when a subclass exists }//from w w w. j a v a 2 s. c om WebApp.started = true; initWebapp(servletContext); initCharacterEncodingFilter(servletContext); super.onStartup(servletContext); FilterRegistration.Dynamic noCacheFilter = servletContext.addFilter("nocache", NoCacheFilter.class); noCacheFilter.addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST), false, "/*"); cleanupTempFiles(); }