Java 类io.vertx.core.file.FileSystemException 实例源码

项目:vertx-configuration-service    文件:HoconProcessorTest.java   
@Test
public void testWithMissingFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigurationRetriever.create(vertx,
      new ConfigurationRetrieverOptions().addStore(
          new ConfigurationStoreOptions()
              .setType("file")
              .setFormat("hocon")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-missing-file.conf"))));

  retriever.getConfiguration(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(FileSystemException.class);
    async.complete();
  });
}
项目:vertx-configuration-service    文件:YamlProcessorTest.java   
@Test
public void testWithMissingFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigurationRetriever.create(vertx,
      new ConfigurationRetrieverOptions().addStore(
          new ConfigurationStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-missing-file.yaml"))));

  retriever.getConfiguration(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(FileSystemException.class);
    async.complete();
  });
}
项目:vertx-utils    文件:ConfigLoaderTest.java   
@Test
public void testStringValuesAsBadFiles() throws Exception {
    loader.load(TEST_PATH, new Handler<AsyncResult<JsonObject>>() {
        @Override
        public void handle(AsyncResult<JsonObject> result) {
            try {
                assertTrue(result.failed());
                assertTrue(result.cause() instanceof FileSystemException);
            } finally {
                latch.countDown();
            }
        }
    });

    verify(fileSystem).readFile(eq(TEST_PATH), handlerCaptor.capture());
    handlerCaptor.getValue().handle(Future.<Buffer>failedFuture(new FileSystemException("bad file")));
}
项目:vertx-config    文件:YamlProcessorTest.java   
@Test
public void testWithMissingFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("yaml")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-missing-file.yaml"))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(FileSystemException.class);
    async.complete();
  });
}
项目:vertx-config    文件:HoconProcessorTest.java   
@Test
public void testWithMissingFile(TestContext tc) {
  Async async = tc.async();
  retriever = ConfigRetriever.create(vertx,
      new ConfigRetrieverOptions().addStore(
          new ConfigStoreOptions()
              .setType("file")
              .setFormat("hocon")
              .setConfig(new JsonObject().put("path", "src/test/resources/some-missing-file.conf"))));

  retriever.getConfig(ar -> {
    assertThat(ar.failed()).isTrue();
    assertThat(ar.cause()).isNotNull().isInstanceOf(FileSystemException.class);
    async.complete();
  });
}
项目:vertx-auth    文件:JWTAuthProviderImpl.java   
public JWTAuthProviderImpl(Vertx vertx, JWTAuthOptions config) {
  this.permissionsClaimKey = config.getPermissionsClaimKey();
  this.jwtOptions = config.getJWTOptions();

  final KeyStoreOptions keyStore = config.getKeyStore();

  // attempt to load a Key file
  try {
    if (keyStore != null) {
      KeyStore ks = KeyStore.getInstance(keyStore.getType());

      // synchronize on the class to avoid the case where multiple file accesses will overlap
      synchronized (JWTAuthProviderImpl.class) {
        final Buffer keystore = vertx.fileSystem().readFileBlocking(keyStore.getPath());

        try (InputStream in = new ByteArrayInputStream(keystore.getBytes())) {
          ks.load(in, keyStore.getPassword().toCharArray());
        }
      }

      this.jwt = new JWT(ks, keyStore.getPassword().toCharArray());
    } else {
      // no key file attempt to load pem keys
      this.jwt = new JWT();

      final List<PubSecKeyOptions> keys = config.getPubSecKeys();

      if (keys != null) {
        for (PubSecKeyOptions pubSecKey : config.getPubSecKeys()) {
          if (pubSecKey.isSymmetric()) {
            jwt.addJWK(new JWK(pubSecKey.getAlgorithm(), pubSecKey.getPublicKey()));
          } else {
            jwt.addJWK(new JWK(pubSecKey.getAlgorithm(), pubSecKey.isCertificate(), pubSecKey.getPublicKey(), pubSecKey.getSecretKey()));
          }
        }
      }

      // TODO: remove once the deprecation ends!
      final List<SecretOptions> secrets = config.getSecrets();

      if (secrets != null) {
        for (SecretOptions secret: secrets) {
          this.jwt.addSecret(secret.getType(), secret.getSecret());
        }
      }
    }

  } catch (KeyStoreException | IOException | FileSystemException | CertificateException | NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
  }
}