List of usage examples for java.util EnumSet of
public static <E extends Enum<E>> EnumSet<E> of(E e)
From source file:com.microsoft.windowsazure.mobileservices.sdk.testapp.test.MobileServiceFeaturesTests.java
public void testFeaturesToStringConversion() { Hashtable<EnumSet<MobileServiceFeatures>, String> cases; cases = new Hashtable<EnumSet<MobileServiceFeatures>, String>(); for (MobileServiceFeatures feature : MobileServiceFeatures.class.getEnumConstants()) { cases.put(EnumSet.of(feature), feature.getValue()); }/* w ww . j a va 2 s . c o m*/ cases.put(EnumSet.of(MobileServiceFeatures.TypedTable, MobileServiceFeatures.AdditionalQueryParameters), "QS,TT"); cases.put(EnumSet.of(MobileServiceFeatures.UntypedTable, MobileServiceFeatures.AdditionalQueryParameters), "QS,TU"); cases.put(EnumSet.of(MobileServiceFeatures.TypedTable, MobileServiceFeatures.Offline), "OL,TT"); cases.put(EnumSet.of(MobileServiceFeatures.UntypedTable, MobileServiceFeatures.Offline), "OL,TU"); cases.put(EnumSet.of(MobileServiceFeatures.TypedApiCall, MobileServiceFeatures.AdditionalQueryParameters), "AT,QS"); cases.put(EnumSet.of(MobileServiceFeatures.JsonApiCall, MobileServiceFeatures.AdditionalQueryParameters), "AJ,QS"); cases.put(EnumSet.of(MobileServiceFeatures.OpportunisticConcurrency, MobileServiceFeatures.Offline, MobileServiceFeatures.UntypedTable), "OC,OL,TU"); for (EnumSet<MobileServiceFeatures> features : cases.keySet()) { String expected = cases.get(features); String actual = MobileServiceFeatures.featuresToString(features); assertEquals(expected, actual); } }
From source file:ch.cyberduck.core.SingleTransferWorkerTest.java
@Test public void testTransferredSizeRepeat() throws Exception { final Local local = new Local(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); final byte[] content = new byte[62768]; new Random().nextBytes(content); final OutputStream out = local.getOutputStream(false); IOUtils.write(content, out);// ww w . j av a 2 s. c o m out.close(); final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch", new Credentials(System.getProperties().getProperty("webdav.user"), System.getProperties().getProperty("webdav.password"))); host.setDefaultPath("/dav/basic"); final AtomicBoolean failed = new AtomicBoolean(); final DAVSession session = new DAVSession(host) { final DAVUploadFeature upload = new DAVUploadFeature(this) { @Override protected InputStream decorate(final InputStream in, final MessageDigest digest) throws IOException { if (failed.get()) { // Second attempt successful return in; } return new CountingInputStream(in) { @Override protected void beforeRead(final int n) throws IOException { super.beforeRead(n); if (this.getByteCount() >= 32768L) { failed.set(true); throw new SocketTimeoutException(); } } }; } }; @Override @SuppressWarnings("unchecked") public <T> T getFeature(final Class<T> type) { if (type == Upload.class) { return (T) upload; } return super.getFeature(type); } }; session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); final Transfer t = new UploadTransfer(new Host(new TestProtocol()), test, local); final BytecountStreamListener counter = new BytecountStreamListener(new DisabledStreamListener()); assertTrue(new SingleTransferWorker(session, t, new TransferOptions(), new TransferSpeedometer(t), new DisabledTransferPrompt() { @Override public TransferAction prompt(final TransferItem file) { return TransferAction.overwrite; } }, new DisabledTransferErrorCallback(), new DisabledTransferItemCallback(), new DisabledProgressListener(), counter, new DisabledLoginCallback(), TransferItemCache.empty()) { }.run(session)); local.delete(); assertEquals(62768L, counter.getSent(), 0L); assertEquals(62768L, new DAVAttributesFeature(session).find(test).getSize()); assertTrue(failed.get()); new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); }
From source file:ch.cyberduck.core.cryptomator.FTPTouchFeatureTest.java
@Test public void testTouchLongFilenameEncryptedDefaultFeature() throws Exception { final Host host = new Host(new FTPTLSProtocol(), "test.cyberduck.ch", new Credentials(System.getProperties().getProperty("ftp.user"), System.getProperties().getProperty("ftp.password"))); final FTPSession session = new FTPSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); 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(/*from w w w. j av a 2 s. c o m*/ new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoTouchFeature<Integer>(session, new DefaultTouchFeature<Integer>(new DefaultUploadFeature<Integer>(new FTPWriteFeature(session))), new FTPWriteFeature(session), cryptomator).touch(test, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new FTPDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:ch.cyberduck.core.cryptomator.SFTPDirectoryFeatureTest.java
@Test public void testMakeDirectoryLongFilenameEncrypted() 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 Path home = new SFTPHomeDirectoryService(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.directory)); final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore()); cryptomator.create(session, null, new VaultCredentials("test")); session.withRegistry(/*from w w w. j av a2 s.c om*/ new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoDirectoryFeature<Void>(session, new SFTPDirectoryFeature(session), new SFTPWriteFeature(session), cryptomator).mkdir(test, null, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(test)); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new SFTPDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:com.netflix.simianarmy.aws.janitor.crawler.edda.EddaImageJanitorCrawler.java
@Override public EnumSet<? extends ResourceType> resourceTypes() { return EnumSet.of(AWSResourceType.IMAGE); }
From source file:ch.cyberduck.core.cryptomator.SFTPFindFeatureTest.java
@Test public void testFindLongFilenameCryptomator() 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 Path home = new SFTPHomeDirectoryService(session).find(); final Path vault = new Path(home, UUID.randomUUID().toString(), 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 a2 s . c o m*/ new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoTouchFeature<Void>(session, new DefaultTouchFeature<Void>(new DefaultUploadFeature<Void>(new SFTPWriteFeature(session))), new SFTPWriteFeature(session), cryptomator).touch(test, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new SFTPDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:ch.cyberduck.core.nio.LocalReadFeatureTest.java
@Test public void testReadRange() 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 Path workdir = new LocalHomeFinderFeature(session).find(); final Path test = new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)); new LocalTouchFeature(session).touch(test, new TransferStatus()); final int length = 1048576; final byte[] content = RandomUtils.nextBytes(length); {/*from w w w.j a v a 2 s .c o m*/ final TransferStatus status = new TransferStatus().length(content.length).exists(true); final OutputStream out = new LocalWriteFeature(session).write(test, status, new DisabledConnectionCallback()); assertNotNull(out); new StreamCopier(status, status).withLimit(new Long(content.length)) .transfer(new ByteArrayInputStream(content), out); out.close(); } { final TransferStatus status = new TransferStatus(); status.setLength(content.length); status.setAppend(true); status.setOffset(100L); final InputStream in = new LocalReadFeature(session).read(test, status, new DisabledConnectionCallback()); assertNotNull(in); final ByteArrayOutputStream buffer = new ByteArrayOutputStream(content.length - 100); new StreamCopier(status, status).withLimit(new Long(content.length - 100)).transfer(in, buffer); in.close(); final byte[] reference = new byte[content.length - 100]; System.arraycopy(content, 100, reference, 0, content.length - 100); assertArrayEquals(reference, buffer.toByteArray()); } new LocalDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:ch.cyberduck.core.cryptomator.DAVTouchFeatureTest.java
@Test public void testTouchLongFilenameEncryptedDefaultFeature() throws Exception { final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch", new Credentials(System.getProperties().getProperty("webdav.user"), System.getProperties().getProperty("webdav.password"))); host.setDefaultPath("/dav/basic"); final DAVSession session = new DAVSession(host); session.open(new DisabledHostKeyCallback()); session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback()); 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(//from w w w .j a v a2 s . co m new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator)); new CryptoTouchFeature<String>(session, new DefaultTouchFeature<String>(new DAVUploadFeature(new DAVWriteFeature(session))), new DAVWriteFeature(session), cryptomator).touch(test, new TransferStatus()); assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(test)); new CryptoDeleteFeature(session, new DAVDeleteFeature(session), cryptomator) .delete(Arrays.asList(test, vault), new DisabledLoginCallback(), new Delete.DisabledCallback()); session.close(); }
From source file:org.hdiv.spring.boot.autoconfigure.HdivAutoConfiguration.java
@Bean public ServletContextInitializer validatorFilter() { ServletContextInitializer initializer = new ServletContextInitializer() { public void onStartup(ServletContext servletContext) throws ServletException { // Register HDIV InitListener and ValidatorFilter // InitListener servletContext.addListener(new InitListener()); // ValidatorFilter FilterRegistration.Dynamic registration = servletContext.addFilter("validatorFilter", new ValidatorFilter()); EnumSet<DispatcherType> dispatcherTypes = EnumSet.of(DispatcherType.REQUEST); // isMatchAfter false to put it before existing filters registration.addMappingForUrlPatterns(dispatcherTypes, false, "/*"); }//from ww w .ja va 2s . c o m }; return initializer; }