Java Code Examples for java.util.EnumSet.of()

The following are Jave code examples for showing how to use of() of the java.util.EnumSet class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cyberduck   File: CopyWorkerTest.java   View Source Code Vote up 6 votes
@Test
public void testCopyToDifferentFolderLongFilenameCryptomator() throws Exception {
    final Path home = DriveHomeFinderService.MYDRIVE_FOLDER;
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path source = new Path(vault, new RandomStringGenerator.Builder().build().generate(130), EnumSet.of(Path.Type.file));
    final Path targetFolder = new Path(vault, new RandomStringGenerator.Builder().build().generate(130), EnumSet.of(Path.Type.directory));
    final Path target = new Path(targetFolder, 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"));
    final DefaultVaultRegistry registry = new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator);
    session.withRegistry(registry);
    new CryptoTouchFeature<Void>(session, new DefaultTouchFeature<Void>(new DefaultUploadFeature<Void>(new DriveWriteFeature(session))), new DriveWriteFeature(session), cryptomator).touch(source, new TransferStatus());
    Assert.assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    new CryptoDirectoryFeature<Void>(session, new DriveDirectoryFeature(session), new DriveWriteFeature(session), cryptomator).mkdir(targetFolder, null, new TransferStatus());
    Assert.assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(targetFolder));
    final CopyWorker worker = new CopyWorker(Collections.singletonMap(source, target), new TestSessionPool(session, registry), PathCache.empty(), new DisabledProgressListener(), new DisabledConnectionCallback());
    worker.run(session);
    Assert.assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    Assert.assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(target));
    registry.clear();
    new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(vault), PathCache.empty(), new DisabledProgressListener()).run(session);
}
 
Example 2
Project: cyberduck   File: B2LargeUploadPartServiceTest.java   View Source Code Vote up 6 votes
@Test
public void testFindAllPendingInBucket() throws Exception {
    final B2Session session = new B2Session(
            new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")
                    )));
    final Path bucket = new Path("test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path file = new Path(bucket, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final B2StartLargeFileResponse start1Response = session.getClient().startLargeFileUpload(
            new B2FileidProvider(session).getFileid(bucket, new DisabledListProgressListener()),
            file.getName(), null, Collections.emptyMap());
    final B2StartLargeFileResponse start2Response = session.getClient().startLargeFileUpload(
            new B2FileidProvider(session).getFileid(bucket, new DisabledListProgressListener()),
            file.getName(), null, Collections.emptyMap());
    final List<B2FileInfoResponse> list = new B2LargeUploadPartService(session).find(file);
    assertFalse(list.isEmpty());
    assertEquals(start2Response.getFileId(), list.get(0).getFileId());
    assertEquals(start1Response.getFileId(), list.get(1).getFileId());
    session.getClient().cancelLargeFileUpload(start1Response.getFileId());
    session.getClient().cancelLargeFileUpload(start2Response.getFileId());
    session.close();
}
 
Example 3
Project: QuantTester   File: CheckDuplicatedDays.java   View Source Code Vote up 6 votes
/**
 * ���ÿ���·ݵĺ�Լ�ĸ������֮���Ƿ��н������ظ�
 * ��֪AU, A�д�����
 * @param args
 */
public static void main(String[] args) {
	for (int j = 1; j <= 12; j++) {
		final int fj = j;
		IDataSource kt_data = new SinYeeDataSource("y", EnumSet.of(TIME_FRAME.DAY), str -> str.endsWith(mon[fj]));

		BarSeries t= kt_data.getBarSeries(j, TIME_FRAME.DAY);
		if (t == null || t.times == null) {
			continue;
		}
		int[] time = t.times;
		Arrays.sort(time);
		for (int i = 1; i < time.length; i++) {
			if (time[i] == time[i - 1]) {
				System.out.println(i);
			}
		}
	}
}
 
Example 4
Project: JavaGraph   File: TypeCheckTest.java   View Source Code Vote up 6 votes
/** Tests all rules in a named grammar (to be loaded from {@link #INPUT_DIR}). */
private void test(String grammarName) {
    try {
        GrammarModel grammarView = Groove.loadGrammar(INPUT_DIR + "/" + grammarName);
        for (ResourceKind kind : EnumSet.of(ResourceKind.RULE,
            ResourceKind.HOST,
            ResourceKind.TYPE)) {
            for (Map.Entry<QualName,? extends NamedResourceModel<?>> entry : grammarView
                .getResourceMap(kind)
                .entrySet()) {
                String name = entry.getKey()
                    .last();
                NamedResourceModel<?> model = entry.getValue();
                if (name.startsWith(OK_PREFIX)) {
                    testCorrect(model);
                } else if (name.startsWith(ERR_PREFIX)) {
                    testErroneous(model);
                }
            }
        }
    } catch (IOException e) {
        Assert.fail(e.getMessage());
    }
}
 
Example 5
Project: incubator-netbeans   File: FileObjectCrawlerTest.java   View Source Code Vote up 6 votes
public void testSymLinksFromRoot() throws Exception {
    final File workDir = getWorkDir();
    final FileObject wd = FileUtil.toFileObject(workDir);
    final FileObject cycleTarget= wd.createFolder("cycleTarget");
    final FileObject rootWithCycle = cycleTarget.createFolder("rootWithExtLink");
    final FileObject folder1 = rootWithCycle.createFolder("folder1");
    final FileObject folder2 = rootWithCycle.createFolder("folder2");
    final FileObject inFolder1 = folder1.createFolder("infolder1");
    final FileObject inFolder2 = folder2.createFolder("cycleTarget");
    folder1.createData("data1.txt");
    inFolder1.createData("data2.txt");
    folder2.createData("data3.txt");
    inFolder2.createData("data4.txt");
    final Map<Pair<FileObject,FileObject>,Boolean> linkMap = new HashMap<>();
    linkMap.put(
        Pair.<FileObject,FileObject>of(cycleTarget, inFolder2), Boolean.TRUE
    );
    FileObjectCrawler.mockLinkTypes = linkMap;
    final FileObjectCrawler c = new FileObjectCrawler(rootWithCycle, EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE), null, CR, SuspendSupport.NOP);
    final Collection<Indexable> indexables = c.getAllResources();
    assertCollectedFiles("Wring collected files", indexables,
            "folder1/data1.txt",
            "folder1/infolder1/data2.txt",
            "folder2/data3.txt");
}
 
Example 6
Project: cyberduck   File: S3ObjectListServiceTest.java   View Source Code Vote up 6 votes
@Test
public void testListAWS2AutoSwitchAWS4SignatureFrankfurt() throws Exception {
    final S3Session session = new S3Session(
            new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
                    ))) {
        @Override
        public S3Protocol.AuthenticationHeaderSignatureVersion getSignatureVersion() {
            return S3Protocol.AuthenticationHeaderSignatureVersion.AWS2;
        }
    };
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("test-eu-central-1-cyberduck", EnumSet.of(Path.Type.volume));
    final AttributedList<Path> list = new S3ObjectListService(session).list(container, new DisabledListProgressListener());
    session.close();
}
 
Example 7
Project: cyberduck   File: LocalMoveFeatureTest.java   View Source Code Vote up 5 votes
@Test(expected = NotfoundException.class)
public void testMoveNotFound() throws Exception {
    final LocalSession session = new LocalSession(new Host(new LocalProtocol(), new LocalProtocol().getDefaultHostname()));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    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 LocalMoveFeature(session).move(test, new Path(workdir, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback());
}
 
Example 8
Project: cyberduck   File: DriveSearchFeatureTest.java   View Source Code Vote up 5 votes
@Test
public void testSearchRoot() throws Exception {
    final String name = new AlphanumericRandomStringService().random();
    final Path workdir = DriveHomeFinderService.MYDRIVE_FOLDER;
    final Path file = new DriveTouchFeature(session).touch(new Path(workdir, name, EnumSet.of(Path.Type.file)), new TransferStatus());
    final DriveSearchFeature feature = new DriveSearchFeature(session);
    assertTrue(feature.search(workdir, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
    // Supports prefix matching only
    assertFalse(feature.search(workdir, new SearchFilter(StringUtils.substring(name, 2)), new DisabledListProgressListener()).contains(file));
    assertTrue(feature.search(workdir, new SearchFilter(StringUtils.substring(name, 0, name.length() - 2)), new DisabledListProgressListener()).contains(file));
    final Path subdir = new Path(workdir, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    assertFalse(feature.search(subdir, new SearchFilter(name), new DisabledListProgressListener()).contains(file));
    new DriveDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
}
 
Example 9
Project: cyberduck   File: MoveWorkerTest.java   View Source Code Vote up 5 votes
@Test
public void testMoveFileOutsideVault() 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(), new DisabledLoginCallback());
    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 clearFolder = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    new SFTPDirectoryFeature(session).mkdir(clearFolder, null, new TransferStatus());
    final Path encryptedFolder = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path encryptedFile = new Path(encryptedFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    final DefaultVaultRegistry registry = new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator);
    session.withRegistry(registry);
    new CryptoDirectoryFeature<Void>(session, new SFTPDirectoryFeature(session), new SFTPWriteFeature(session), cryptomator).mkdir(encryptedFolder, null, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(encryptedFolder));
    new CryptoTouchFeature<Void>(session, new DefaultTouchFeature<Void>(new DefaultUploadFeature<Void>(new SFTPWriteFeature(session))), new SFTPWriteFeature(session), cryptomator).touch(encryptedFile, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(encryptedFile));
    // move file outside vault
    final Path fileRenamed = new Path(clearFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final MoveWorker worker = new MoveWorker(Collections.singletonMap(encryptedFile, fileRenamed), PathCache.empty(), PasswordStoreFactory.get(), new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledProgressListener(), new DisabledTranscriptListener());
    worker.run(session);
    assertFalse(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(encryptedFile));
    assertTrue(new SFTPFindFeature(session).find(fileRenamed));
    new CryptoDeleteFeature(session, new SFTPDeleteFeature(session), cryptomator).delete(Arrays.asList(encryptedFolder, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    new SFTPDeleteFeature(session).delete(Arrays.asList(fileRenamed, clearFolder), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
    registry.clear();
}
 
Example 10
Project: incubator-netbeans   File: FileObjectCrawlerTest.java   View Source Code Vote up 5 votes
public void testDuplicateResults6() throws IOException {
    FileObject root = FileUtil.createFolder(new File(getWorkDir(), "src"));
    String [] paths = new String [] {
            "org/me/prj/foo/file2.txt",
            "org/me/prj/bar/file3.txt",
    };

    populateFolderStructure(root, paths);

    FileObjectCrawler crawler = new FileObjectCrawler(root, new FileObject[] {root.getFileObject("org/me/prj/bar/file3.txt"), root.getFileObject("org/me/prj/foo"), root.getFileObject("org/me/prj/bar")}, EnumSet.<Crawler.TimeStampAction>of(Crawler.TimeStampAction.UPDATE), null, CR, SuspendSupport.NOP);
    assertCollectedFiles("Wrong files collected", crawler.getResources(), new String[] {"org/me/prj/foo/file2.txt","org/me/prj/bar/file3.txt"});
}
 
Example 11
Project: cyberduck   File: S3AccessControlListFeatureTest.java   View Source Code Vote up 5 votes
@Test(expected = NotfoundException.class)
public void testReadNotFound() throws Exception {
    final S3Session session = new S3Session(
            new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(),
                    new Credentials(
                            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
                    )));
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path container = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path test = new Path(container, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final S3AccessControlListFeature f = new S3AccessControlListFeature(session);
    f.getPermission(test);
}
 
Example 12
Project: cyberduck   File: CopyWorkerTest.java   View Source Code Vote up 5 votes
@Test
public void testCopyFile() throws Exception {
    final Host host = new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(),
            new Credentials(
                    System.getProperties().getProperty("b2.user"), System.getProperties().getProperty("b2.key")
            ));
    final B2Session session = new B2Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("/test-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path source = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Path target = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    final DefaultVaultRegistry registry = new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator);
    session.withRegistry(registry);
    final byte[] content = RandomUtils.nextBytes(40500);
    final TransferStatus status = new TransferStatus();
    new CryptoBulkFeature<>(session, new DisabledBulkFeature(), new B2DeleteFeature(session), cryptomator).pre(Transfer.Type.upload, Collections.singletonMap(source, status), new DisabledConnectionCallback());
    new StreamCopier(new TransferStatus(), new TransferStatus()).transfer(new ByteArrayInputStream(content), new CryptoWriteFeature<>(session, new B2WriteFeature(session), cryptomator).write(source, status.length(content.length), new DisabledConnectionCallback()));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    final CopyWorker worker = new CopyWorker(Collections.singletonMap(source, target), new TestSessionPool(session, registry), PathCache.empty(), new DisabledProgressListener(), new DisabledConnectionCallback());
    worker.run(session);
    assertTrue(new CryptoFindFeature(session, new B2FindFeature(session), cryptomator).find(source));
    assertTrue(new CryptoFindFeature(session, new B2FindFeature(session), cryptomator).find(target));
    final ByteArrayOutputStream out = new ByteArrayOutputStream(content.length);
    assertEquals(content.length, IOUtils.copy(new CryptoReadFeature(session, new B2ReadFeature(session), cryptomator).read(target, new TransferStatus().length(content.length), new DisabledConnectionCallback()), out));
    assertArrayEquals(content, out.toByteArray());
    new DeleteWorker(new DisabledLoginCallback(), Collections.singletonList(vault), PathCache.empty(), new DisabledProgressListener()).run(session);
    session.close();
}
 
Example 13
Project: fresco_floodlight   File: ForwardingBase.java   View Source Code Vote up 4 votes
protected void init() {
	messageDamper = new OFMessageDamper(OFMESSAGE_DAMPER_CAPACITY,
			EnumSet.of(OFType.FLOW_MOD),
			OFMESSAGE_DAMPER_TIMEOUT);
}
 
Example 14
Project: elasticsearch_my   File: ClusterChangedEventTests.java   View Source Code Vote up 4 votes
@Override
public EnumSet<MetaData.XContentContext> context() {
    return EnumSet.of(MetaData.XContentContext.GATEWAY);
}
 
Example 15
Project: elasticsearch_my   File: GatewayMetaStateTests.java   View Source Code Vote up 4 votes
@Override
public EnumSet<MetaData.XContentContext> context() {
    return EnumSet.of(MetaData.XContentContext.GATEWAY);
}
 
Example 16
Project: hadoop   File: WebAppProxyServlet.java   View Source Code Vote up 4 votes
public HTML<WebAppProxyServlet._> html() {
  return new HTML<>("html", null, EnumSet.of(EOpt.ENDTAG));
}
 
Example 17
Project: cyberduck   File: AbstractMantaTest.java   View Source Code Vote up 4 votes
protected Path randomFile() {
    return new Path(
        testPathPrefix,
        UUID.randomUUID().toString(),
        EnumSet.of(Type.file));
}
 
Example 18
Project: openjdk-jdk10   File: LegalNoticeFilePlugin.java   View Source Code Vote up 4 votes
@Override
public Set<State> getState() {
    return EnumSet.of(State.AUTO_ENABLED, State.FUNCTIONAL);
}
 
Example 19
Project: incubator-netbeans   File: FXMLHyperlinkProvider.java   View Source Code Vote up 4 votes
@Override
public Set<HyperlinkType> getSupportedHyperlinkTypes() {
    return EnumSet.of(HyperlinkType.GO_TO_DECLARATION);
}
 
Example 20
Project: oscm   File: ValidateSubscriptionStateBean.java   View Source Code Vote up 4 votes
void checkUnsubscribingAllowed(Subscription dbSubscription)
        throws SubscriptionStateException {
    EnumSet<SubscriptionStatus> forbiddenStates = EnumSet.of(
            SubscriptionStatus.INVALID, SubscriptionStatus.DEACTIVATED);
    checkOperationAllowed(dbSubscription, forbiddenStates);
}