当前位置: 首页>>代码示例>>Java>>正文


Java Collections.singletonMap方法代码示例

本文整理汇总了Java中java.util.Collections.singletonMap方法的典型用法代码示例。如果您正苦于以下问题:Java Collections.singletonMap方法的具体用法?Java Collections.singletonMap怎么用?Java Collections.singletonMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Collections的用法示例。


在下文中一共展示了Collections.singletonMap方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUpdateYamlScript

import java.util.Collections; //导入方法依赖的package包/类
/**
 * Parse file to updater node
 *
 * @param scriptClass class to use for source
 * @return Node object representing the groovy updater to marshall to xml
 */
public static Map<String, Map<String, Object>> getUpdateYamlScript(final ScriptClass scriptClass) {
    final Updater updater = scriptClass.getUpdater();

    Map<String, Object> properties = new LinkedHashMap<>();
    addNotEmptyProperty(JCR_PRIMARY_TYPE, HIPPOSYS_UPDATERINFO, properties);

    addNotEmptyProperty(HIPPOSYS_BATCHSIZE, updater.batchSize(), properties);
    addNotEmptyProperty(HIPPOSYS_DESCRIPTION, updater.description(), properties);
    addNotEmptyProperty(HIPPOSYS_DRYRUN, updater.dryRun(), properties);
    addNotEmptyProperty(HIPPOSYS_PARAMETERS, updater.parameters(), properties);
    if (StringUtils.isBlank(updater.xpath())) {
        addNotEmptyProperty(HIPPOSYS_PATH, updater.path(), properties);
    }
    addNotEmptyProperty(HIPPOSYS_QUERY, updater.xpath(), properties);
    addNotEmptyProperty(HIPPOSYS_SCRIPT, removeEmptyIndents(scriptClass.getContent()), properties);
    addNotEmptyProperty(HIPPOSYS_THROTTLE, updater.throttle(), properties);
    return Collections.singletonMap(getBootstrapPath(scriptClass), properties);
}
 
开发者ID:openweb-nl,项目名称:hippo-groovy-updater,代码行数:25,代码来源:YamlGenerator.java

示例2: testReferencedInNoNPEForMissingTrees

import java.util.Collections; //导入方法依赖的package包/类
public void testReferencedInNoNPEForMissingTrees() throws Exception {
    String code = "package test; public class Test { private void test() { | if (true) System.err.println(); } private int a^aa;}";
    int pos = code.indexOf("|");
    
    code = code.replaceAll(Pattern.quote("|"), "");

    int varpos = code.indexOf("^");
    
    code = code.replaceAll(Pattern.quote("^"), "");

    prepareTest("test/Test.java", code);

    TreePath tp = info.getTreeUtilities().pathFor(pos);
    TreePath var = info.getTreeUtilities().pathFor(varpos);
    Map<String, TreePath> variables = Collections.singletonMap("$1", var);
    Map<String, Collection<? extends TreePath>> multiVariables = Collections.<String, Collection<? extends TreePath>>singletonMap("$2$", Arrays.asList(tp));
    Map<String, String> variables2Names = Collections.emptyMap();
    Context ctx = new Context(SPIAccessor.getINSTANCE().createHintContext(info, HintsSettings.getGlobalSettings(), null, null, variables, multiVariables, variables2Names));

    new Matcher(ctx).referencedIn(new Variable("$1"), new Variable("$2$"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:MatcherTest.java

示例3: testMoveSameFolderCryptomator

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testMoveSameFolderCryptomator() 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(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new DefaultHomeFinderService(session).find();
    final Path vault = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
    final Path source = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final Path target = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(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(source, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    final MoveWorker worker = new MoveWorker(Collections.singletonMap(source, target), PathCache.empty(), PasswordStoreFactory.get(), new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledProgressListener(), new DisabledTranscriptListener());
    worker.run(session);
    assertFalse(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(target));
    new CryptoDeleteFeature(session, new FTPDeleteFeature(session), cryptomator).delete(Arrays.asList(target, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:25,代码来源:MoveWorkerTest.java

示例4: queryParamMapsConvertedToNullShouldError

import java.util.Collections; //导入方法依赖的package包/类
@Test public void queryParamMapsConvertedToNullShouldError() throws Exception {
  class Example {
    @GET("/query") Call<ResponseBody> queryPath(@QueryMap Map<String, String> a) {
      return null;
    }
  }

  Retrofit.Builder retrofitBuilder = new Retrofit.Builder()
      .baseUrl("http://example.com")
      .addConverterFactory(new NullObjectConverterFactory());

  Map<String, String> queryMap = Collections.singletonMap("kit", "kat");

  try {
    buildRequest(Example.class, retrofitBuilder, queryMap);
    fail();
  } catch (IllegalArgumentException e) {
    assertThat(e).hasMessageContaining(
        "Query map value 'kat' converted to null by retrofit2.helpers.NullObjectConverterFactory$1 for key 'kit'.");
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:RequestBuilderTest.java

示例5: deleteNode

import java.util.Collections; //导入方法依赖的package包/类
protected void deleteNode(String nodeId, boolean permanent, int expectedStatus) throws Exception
{
    Map params = null;
    if (permanent == true)
    {
        params = Collections.singletonMap("permanent", "true");
    }
    
    delete(URL_NODES, nodeId, params, expectedStatus);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:11,代码来源:AbstractBaseApiTest.java

示例6: testMoveSameFolderCryptomator

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testMoveSameFolderCryptomator() throws Exception {
    final Host host = new Host(new S3Protocol(), new S3Protocol().getDefaultHostname(), new Credentials(
            System.getProperties().getProperty("s3.key"), System.getProperties().getProperty("s3.secret")
    ));
    final S3Session session = new S3Session(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("test-us-east-1-cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    final Path vault = new Path(home, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
    final Path source = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final Path target = new Path(vault, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
    final CryptoVault cryptomator = new CryptoVault(vault, new DisabledPasswordStore());
    cryptomator.create(session, null, new VaultCredentials("test"));
    session.withRegistry(new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator));
    final byte[] content = RandomUtils.nextBytes(40500);
    final TransferStatus status = new TransferStatus();
    new CryptoBulkFeature<>(session, new DisabledBulkFeature(), new S3DefaultDeleteFeature(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 S3MultipartWriteFeature(session), cryptomator).write(source, status.length(content.length), new DisabledConnectionCallback()));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    final MoveWorker worker = new MoveWorker(Collections.singletonMap(source, target), PathCache.empty(), PasswordStoreFactory.get(), new DisabledLoginCallback(), new DisabledHostKeyCallback(), new DisabledProgressListener(), new DisabledTranscriptListener());
    worker.run(session);
    assertFalse(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(target));
    final ByteArrayOutputStream out = new ByteArrayOutputStream(content.length);
    assertEquals(content.length, IOUtils.copy(new CryptoReadFeature(session, new S3ReadFeature(session), cryptomator).read(target, new TransferStatus().length(content.length), new DisabledConnectionCallback()), out));
    assertArrayEquals(content, out.toByteArray());
    new CryptoDeleteFeature(session, new S3DefaultDeleteFeature(session), cryptomator).delete(Arrays.asList(target, vault), new DisabledLoginCallback(), new Delete.DisabledCallback());
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:31,代码来源:MoveWorkerTest.java

示例7: testCopyFileOutsideVault

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testCopyFileOutsideVault() throws Exception {
    final Host host = new Host(new AzureProtocol(), "kahy9boj3eib.blob.core.windows.net", new Credentials(
            System.getProperties().getProperty("azure.account"), System.getProperties().getProperty("azure.key")
    ));
    final AzureSession session = new AzureSession(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("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 clearFolder = new Path(home, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    new AzureDirectoryFeature(session, null).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 AzureDirectoryFeature(session, null), new AzureWriteFeature(session, null), 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 AzureWriteFeature(session, null))), new AzureWriteFeature(session, null), cryptomator).touch(encryptedFile, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(encryptedFile));
    // move file outside vault
    final Path cleartextFile = new Path(clearFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final CopyWorker worker = new CopyWorker(Collections.singletonMap(encryptedFile, cleartextFile), new TestSessionPool(session, registry), PathCache.empty(), new DisabledProgressListener(), new DisabledConnectionCallback());
    worker.run(session);
    assertTrue(new CryptoFindFeature(session, new AzureFindFeature(session, null), cryptomator).find(encryptedFile));
    assertTrue(new AzureFindFeature(session, null).find(cleartextFile));
    registry.clear();
    new DeleteWorker(new DisabledLoginCallback(), Arrays.asList(vault, clearFolder), PathCache.empty(), new DisabledProgressListener()).run(session);
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:33,代码来源:CopyWorkerTest.java

示例8: testCopyFile

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testCopyFile() 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 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 SFTPDeleteFeature(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 SFTPWriteFeature(session), cryptomator).write(source, status.length(content.length), new DisabledConnectionCallback()));
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    assertEquals(content.length, new CryptoAttributesFeature(session, new SFTPAttributesFinderFeature(session), cryptomator).find(source).getSize());
    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 SFTPFindFeature(session), cryptomator).find(source));
    assertTrue(new CryptoFindFeature(session, new SFTPFindFeature(session), cryptomator).find(target));
    final ByteArrayOutputStream out = new ByteArrayOutputStream(content.length);
    assertEquals(content.length, IOUtils.copy(new CryptoReadFeature(session, new SFTPReadFeature(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();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:33,代码来源:CopyWorkerTest.java

示例9: testCopyToDifferentFolderLongFilenameCryptomator

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testCopyToDifferentFolderLongFilenameCryptomator() throws Exception {
    final Host host = new Host(new AzureProtocol(), "kahy9boj3eib.blob.core.windows.net", new Credentials(
            System.getProperties().getProperty("azure.account"), System.getProperties().getProperty("azure.key")
    ));
    final AzureSession session = new AzureSession(host);
    session.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final Path home = new Path("cyberduck", EnumSet.of(Path.Type.directory, Path.Type.volume));
    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"));
    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 DefaultVaultRegistry registry = new DefaultVaultRegistry(new DisabledPasswordStore(), new DisabledPasswordCallback(), cryptomator);
    session.withRegistry(registry);
    new CryptoTouchFeature<Void>(session, new DefaultTouchFeature<Void>(new DefaultUploadFeature<Void>(new AzureWriteFeature(session, null))), new AzureWriteFeature(session, null), cryptomator).touch(source, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    new CryptoDirectoryFeature<Void>(session, new AzureDirectoryFeature(session, null), new AzureWriteFeature(session, null), cryptomator).mkdir(targetFolder, null, new TransferStatus());
    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);
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    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);
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:29,代码来源:CopyWorkerTest.java

示例10: testEvaluate

import java.util.Collections; //导入方法依赖的package包/类
public void testEvaluate() throws Exception {
    // XXX check override order, property name evaluation, $$ escaping, bare or final $,
    // cyclic errors, undef'd property substitution, no substs in predefs, etc.
    Map<String,String> m1 = Collections.singletonMap("y", "val");
    Map<String,String> m2 = new HashMap<String,String>();
    m2.put("x", "${y}");
    m2.put("y", "y-${x}");
    List<Map<String,String>> m1m2 = new ArrayList<Map<String,String>>();
    m1m2.add(m1);
    m1m2.add(m2);
    assertEquals("x evaluates to former y", "val", evaluate("x", Collections.<String,String>emptyMap(), m1m2));
    assertEquals("first y defines it", "val", evaluate("y", Collections.<String,String>emptyMap(), m1m2));
    assertEquals("circularity error", null, evaluate("x", Collections.<String,String>emptyMap(), Collections.singletonList(m2)));
    assertEquals("circularity error", null, evaluate("y", Collections.<String,String>emptyMap(), Collections.singletonList(m2)));
    m2.clear();
    m2.put("y", "yval_${z}");
    m2.put("x", "xval_${y}");
    m2.put("z", "zval");
    Map<String,String> all = evaluateAll(Collections.<String,String>emptyMap(), Collections.singletonList(m2));
    assertNotNull("no circularity error", all);
    assertEquals("have three properties", 3, all.size());
    assertEquals("double substitution", "xval_yval_zval", all.get("x"));
    assertEquals("single substitution", "yval_zval", all.get("y"));
    assertEquals("no substitution", "zval", all.get("z"));
    // Yuck. But it failed once, so check it now.
    Properties p = new Properties();
    p.load(new ByteArrayInputStream("project.mylib=../mylib\njavac.classpath=${project.mylib}/build/mylib.jar\nrun.classpath=${javac.classpath}:build/classes".getBytes("US-ASCII")));
    all = evaluateAll(Collections.<String,String>emptyMap(), Collections.singletonList(NbCollections.checkedMapByFilter(p, String.class, String.class, true)));
    assertNotNull("no circularity error", all);
    assertEquals("javac.classpath correctly substituted", "../mylib/build/mylib.jar", all.get("javac.classpath"));
    assertEquals("run.classpath correctly substituted", "../mylib/build/mylib.jar:build/classes", all.get("run.classpath"));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:33,代码来源:SequentialPropertyEvaluatorTest.java

示例11: analyzePosition

import java.util.Collections; //导入方法依赖的package包/类
@Override
protected Map<Event, Position> analyzePosition(Position position) {
    Device device = Context.getIdentityManager().getById(position.getDeviceId());
    if (device == null || !Context.getIdentityManager().isLatestPosition(position)) {
        return null;
    }

    double maintenanceInterval = Context.getDeviceManager()
            .lookupAttributeDouble(device.getId(), ATTRIBUTE_MAINTENANCE_INTERVAL, 0, false);
    if (maintenanceInterval == 0) {
        return null;
    }
    double maintenanceStart = Context.getDeviceManager()
            .lookupAttributeDouble(device.getId(), ATTRIBUTE_MAINTENANCE_START, 0, false);

    double oldTotalDistance = 0.0;
    double newTotalDistance = 0.0;

    Position lastPosition = Context.getIdentityManager().getLastPosition(position.getDeviceId());
    if (lastPosition != null) {
        oldTotalDistance = lastPosition.getDouble(Position.KEY_TOTAL_DISTANCE);
    }
    newTotalDistance = position.getDouble(Position.KEY_TOTAL_DISTANCE);

    oldTotalDistance -= maintenanceStart;
    newTotalDistance -= maintenanceStart;

    if ((long) (oldTotalDistance / maintenanceInterval) < (long) (newTotalDistance / maintenanceInterval)) {
        Event event = new Event(Event.TYPE_MAINTENANCE, position.getDeviceId(), position.getId());
        event.set(Position.KEY_TOTAL_DISTANCE, newTotalDistance);
        return Collections.singletonMap(event, position);
    }

    return null;
}
 
开发者ID:bamartinezd,项目名称:traccar-service,代码行数:36,代码来源:MaintenanceEventHandler.java

示例12: testCopyToDifferentFolderCryptomator

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testCopyToDifferentFolderCryptomator() 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(), new DisabledLoginCallback());
    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 source = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
    final Path targetFolder = new Path(vault, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
    final Path target = new Path(targetFolder, 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 CryptoTouchFeature<Integer>(session, new DefaultTouchFeature<Integer>(new DefaultUploadFeature<Integer>(new FTPWriteFeature(session))), new FTPWriteFeature(session), cryptomator).touch(source, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    new CryptoDirectoryFeature<Integer>(session, new FTPDirectoryFeature(session), new FTPWriteFeature(session), cryptomator).mkdir(targetFolder, null, new TransferStatus());
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(targetFolder));
    final FTPSession copySession = new FTPSession(host);
    copySession.open(new DisabledHostKeyCallback(), new DisabledLoginCallback());
    copySession.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
    final CopyWorker worker = new CopyWorker(Collections.singletonMap(source, target), new TestSessionPool(copySession, registry), PathCache.empty(), new DisabledProgressListener(), new DisabledConnectionCallback());
    worker.run(session);
    assertTrue(new CryptoFindFeature(session, new DefaultFindFeature(session), cryptomator).find(source));
    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);
    session.close();
}
 
开发者ID:iterate-ch,项目名称:cyberduck,代码行数:33,代码来源:CopyWorkerTest.java

示例13: testAspectWithChildAssociationsCreationAndRetrieval

import java.util.Collections; //导入方法依赖的package包/类
public void testAspectWithChildAssociationsCreationAndRetrieval() throws Exception
{
    // Create a folder.  This is like the user's home folder, say.
    NodeRef folderNodeRef = nodeService.createNode(
            rootNodeRef,
            ContentModel.ASSOC_CHILDREN,
            QName.createQName(BaseNodeServiceTest.NAMESPACE, "UserX-" + GUID.generate()),
            ContentModel.TYPE_FOLDER).getChildRef();
    // Create a document.  This is the actual document uploaded by the user.
    NodeRef fileNodeRef = nodeService.createNode(
            folderNodeRef,
            ContentModel.ASSOC_CONTAINS,
            QName.createQName(BaseNodeServiceTest.NAMESPACE, "Uploaded.pdf"),
            ContentModel.TYPE_FOLDER).getChildRef();
    // So, thus far, this is exactly what you have.  Now for the bit to add some renditions.
    // First, we can make some content data pages - spoofed, of course
    List<ContentData> renditionContentPages = new ArrayList<ContentData>(20);
    // This loop is where you will, outside of the transaction, push the page content into the repo
    for(int i = 0; i < 100; i++)
    {
        ContentData contentData = new ContentData(null, MimetypeMap.MIMETYPE_PDF, 10245, "UTF-8");
        renditionContentPages.add(contentData);
    }
    
    nodeService.addAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED, null);
    int pageNumber = 0;
    for (ContentData renditionContentPage : renditionContentPages)
    {
        pageNumber++;
        QName renditionQName = makePageAssocName(pageNumber);
        Map<QName, Serializable> properties = Collections.singletonMap(
                PROP_QNAME_TEST_RENDITION_PAGE_CONTENT,
                (Serializable) renditionContentPage);
        nodeService.createNode(
                fileNodeRef,
                ASSOC_TYPE_QNAME_TEST_RENDITION,
                renditionQName,
                TYPE_QNAME_TEST_RENDITION_PAGE,
                properties);
    }
    
    // That's it for uploading.  Now we retrieve them.
    if (!nodeService.hasAspect(fileNodeRef, ASPECT_QNAME_TEST_RENDERED))
    {
        // Jump to the original rendition retrieval code
        return;
    }
    // It has the aspect, so it's the new model
    List<ChildAssociationRef> fetchedRenditionChildAssocs = nodeService.getChildAssocs(
            fileNodeRef,
            ASSOC_TYPE_QNAME_TEST_RENDITION,
            RegexQNamePattern.MATCH_ALL);
    assertEquals(
            "We didn't get the correct number of pages back",
            renditionContentPages.size(),
            fetchedRenditionChildAssocs.size());
    // Get page ... 5.  This is to prove that they are ordered.
    ChildAssociationRef fetchedRenditionChildAssoc5 = fetchedRenditionChildAssocs.get(4);
    QName page5QName = makePageAssocName(5);
    assertEquals(
            "Local name of page 5 assoc is not correct",
            page5QName,
            fetchedRenditionChildAssoc5.getQName());
    // Now retrieve page 5 using the NodeService
    List<ChildAssociationRef> fetchedRenditionChildAssocsPage5 = nodeService.getChildAssocs(
            fileNodeRef,
            ASSOC_TYPE_QNAME_TEST_RENDITION,
            page5QName);
    assertEquals("Expected exactly one result", 1, fetchedRenditionChildAssocsPage5.size());
    assertEquals("Targeted page retrieval was not correct",
            page5QName,
            fetchedRenditionChildAssocsPage5.get(0).getQName());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:74,代码来源:BaseNodeServiceTest.java

示例14: testPatternJoinGroupLeader

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testPatternJoinGroupLeader() {
    final String consumerId = "leader";

    subscriptions.subscribe(Pattern.compile("test.*"), rebalanceListener);

    // partially update the metadata with one topic first,
    // let the leader to refresh metadata during assignment
    metadata.setTopics(singletonList(topic1));
    metadata.update(TestUtils.singletonCluster(topic1, 1), Collections.<String>emptySet(), time.milliseconds());

    client.prepareResponse(groupCoordinatorResponse(node, Errors.NONE));
    coordinator.ensureCoordinatorReady();

    // normal join group
    Map<String, List<String>> memberSubscriptions = Collections.singletonMap(consumerId, singletonList(topic1));
    partitionAssignor.prepare(Collections.singletonMap(consumerId, Arrays.asList(t1p, t2p)));

    client.prepareResponse(joinGroupLeaderResponse(1, consumerId, memberSubscriptions, Errors.NONE));
    client.prepareResponse(new MockClient.RequestMatcher() {
        @Override
        public boolean matches(AbstractRequest body) {
            SyncGroupRequest sync = (SyncGroupRequest) body;
            return sync.memberId().equals(consumerId) &&
                    sync.generationId() == 1 &&
                    sync.groupAssignment().containsKey(consumerId);
        }
    }, syncGroupResponse(Arrays.asList(t1p, t2p), Errors.NONE));
    // expect client to force updating the metadata, if yes gives it both topics
    client.prepareMetadataUpdate(cluster, Collections.<String>emptySet());

    coordinator.poll(time.milliseconds(), Long.MAX_VALUE);

    assertFalse(coordinator.needRejoin());
    assertEquals(2, subscriptions.assignedPartitions().size());
    assertEquals(2, subscriptions.groupSubscription().size());
    assertEquals(2, subscriptions.subscription().size());
    assertEquals(1, rebalanceListener.revokedCount);
    assertEquals(Collections.emptySet(), rebalanceListener.revoked);
    assertEquals(1, rebalanceListener.assignedCount);
    assertEquals(2, rebalanceListener.assigned.size());
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:43,代码来源:ConsumerCoordinatorTest.java

示例15: testConstruction

import java.util.Collections; //导入方法依赖的package包/类
@Test
public void testConstruction() {
    final Set<RuleChange> ruleChanges = new HashSet<>(1);

    final Instant start = NOW.minus(Period.ofWeeks(-1));
    final Instant end = start.plus(Period.ofWeeks(5));
    final DateRange range = new DateRange(start, end);
    final InputDriver[] drivers = getInputDriverArray("Test1", "Test2", "Test3");
    final Map<String, String> outputs = Collections.singletonMap("outputDriver", "result");
    final DecisionTreeRule rule =
            new DecisionTreeRule(new UUID(0, 1), new UUID(0, 2), drivers, outputs, start, end);
    final RuleChange ruleChange = new RuleChange(Type.NEW, rule);

    ruleChanges.add(ruleChange);

    final Set<ValueGroupChange> valueGroupChanges = new HashSet<>(1);
    final List<String> valueGroupDrivers = getValueGroupsDrivers("Test1", "Test2", "Test3");
    final ValueGroup valueGroup = new ValueGroup(new UUID(0, 1), "TestValueGroup", valueGroupDrivers,
            range);
    final ValueGroupChange valueGroupChange =
            new ValueGroupChange(Type.NEW, valueGroup);

    valueGroupChanges.add(valueGroupChange);

    final Instant initiatorTime = NOW;
    final Instant authoriserTime = initiatorTime.plus(Period.ofWeeks(1));

    final Audit audit = new Audit("User1", initiatorTime, "User2", authoriserTime);
    final Change change = new Change(INITIAL_CHANGE_ID, "TEST-RULESET", NOW, CHANGE_RANGE, audit, ruleChanges,
            valueGroupChanges);

    final Set<Change> changes = new HashSet<>(1);
    changes.add(change);

    final UUID uuid = new UUID(0, 3);
    final ChangeSet changeSet = new ChangeSet(uuid, "changeset-name", changes);
    setBean(changeSet);

    this.injectedValues.put("id", uuid);
    this.injectedValues.put("name", "changeset-name");
    this.injectedValues.put("changes", changes);

    JblTestClassUtils.assertGetterCorrectForConstructorInjection(this.injectedValues, getBean());
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:45,代码来源:ChangeSetTest.java


注:本文中的java.util.Collections.singletonMap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。