gpt4 book ai didi

io.dropwizard.configuration.YamlConfigurationFactory.build()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-15 15:18:40 28 4
gpt4 key购买 nike

本文整理了Java中io.dropwizard.configuration.YamlConfigurationFactory.build()方法的一些代码示例,展示了YamlConfigurationFactory.build()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlConfigurationFactory.build()方法的具体详情如下:
包路径:io.dropwizard.configuration.YamlConfigurationFactory
类名称:YamlConfigurationFactory
方法名:build

YamlConfigurationFactory.build介绍

暂无

代码示例

代码示例来源:origin: performancecopilot/parfait

@Before
public void setUp() throws Exception {
  objectMapper.getSubtypeResolver().registerSubtypes(
      ConsoleReporterFactory.class,
      CsvReporterFactory.class,
      Slf4jReporterFactory.class,
      ParfaitReporterFactory.class);
  this.config = factory.build(new File(getClass().getResource("metric-app.yml").toURI()));
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationNamespaces1() throws Exception {
  final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("/tmp/trellisData/namespaces.json", config.getNamespaces(), "Incorrect namespace location!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetCORSConfig() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertTrue(TrellisUtils.getCorsConfiguration(config).isPresent(), "CORS configuration is missing!");
  config.getCors().setEnabled(false);
  assertFalse(TrellisUtils.getCorsConfiguration(config).isPresent(), "CORS config persists after disabling it!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationLocations() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("http://localhost:8080/", config.getBaseUrl(), "Incorrect baseUrl!");
  assertEquals("http://hub.example.com/", config.getHubUrl(), "Incorrect hubUrl!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwksAuthenticator() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwksAuthenticator,
      "JWT auth not enabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetWebacCache() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertTrue(TrellisUtils.getWebacCache(config).isPresent(), "WebAC configuration not present!");
  config.getAuth().getWebac().setEnabled(false);
  assertFalse(TrellisUtils.getWebacCache(config).isPresent(), "WebAC config persists after disabling it!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorNoKeystore() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  final String nonexistent = resourceFilePath("config1.yml").replaceAll("config1.yml", "nonexistent.yml");
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(nonexistent);
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not disabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationAssets1() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("org/trellisldp/rdfa/resource.mustache", config.getAssets().getTemplate(), "Bad assets/template");
  assertEquals("http://example.com/image.icon", config.getAssets().getIcon(), "Bad assets/icon value!");
  assertTrue(config.getAssets().getJs().contains("http://example.com/scripts1.js"), "Missing assets/js value!");
  assertTrue(config.getAssets().getCss().contains("http://example.com/styles1.css"), "Missing assets/css value!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationAssets1() throws Exception {
  final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("org/trellisldp/rdfa/resource.mustache", config.getAssets().getTemplate(), "Incorrect asset tpl!");
  assertEquals("http://example.org/image.icon", config.getAssets().getIcon(), "Incorrect asset icon!");
  assertTrue(config.getAssets().getJs().contains("http://example.org/scripts1.js"), "Incorrect asset js!");
  assertTrue(config.getAssets().getCss().contains("http://example.org/styles1.css"), "Incorrect asset css!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetAuthFilters() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setKeyStore(null);
  final List<ContainerRequestFilter> filters = TrellisUtils.getAuthFilters(config);
  assertFalse(filters.isEmpty(), "Auth filters are missing!");
  assertEquals(2L, filters.size(), "Incorrect auth filter count!");
  config.getAuth().getBasic().setEnabled(false);
  config.getAuth().getJwt().setEnabled(false);
  assertTrue(TrellisUtils.getAuthFilters(config).isEmpty(), "Auth filters should have been disabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorNoKeyIds() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("keystore.jks"));
  config.getAuth().getJwt().setKeyIds(asList("foo", "bar"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not disabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationLocations() throws Exception {
  final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertEquals("/tmp/trellisData/binaries", config.getBinaries(), "Incorrect binary location!");
  assertEquals("/tmp/trellisData/mementos", config.getMementos(), "Incorrect memento location!");
  assertEquals("http://localhost:8080/", config.getBaseUrl(), "Incorrect base URL!");
  assertEquals("http://hub.example.com/", config.getHubUrl(), "Incorrect hub URL!");
  final String resources = "http://triplestore.example.com/";
  config.setResources(resources);
  assertEquals(resources, config.getResources(), "Incorrect resource location!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorBadKeystore() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("config1.yml"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not disabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticatorFederated() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("keystore.jks"));
  config.getAuth().getJwt().setKeyIds(asList("trellis", "trellis-ec", "trellis-public"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof FederatedJwtAuthenticator,
      "JWT auth not enabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testGetJwtAuthenticator() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  config.getAuth().getJwt().setJwks(null);
  config.getAuth().getJwt().setKeyStore(resourceFilePath("keystore.jks"));
  assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof JwtAuthenticator,
      "JWT auth not enabled!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
  public void testConfigurationCORS1() throws Exception {
    final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
        Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
      .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertTrue(config.getCors().getEnabled(), "CORS isn't enabled!");
    assertTrue(config.getCors().getAllowOrigin().contains("*"), "CORS origin not '*'");
    assertTrue(config.getCors().getAllowHeaders().contains("Link"), "Link not in CORS allow-headers!");
    assertTrue(config.getCors().getAllowMethods().contains("PATCH"), "PATCH not in CORS allow-methods!");
    assertTrue(config.getCors().getExposeHeaders().contains("Location"), "Location not in CORS expose-headers!");
    assertEquals(180, config.getCors().getMaxAge(), "incorrect max-age in CORS headers!");
    assertTrue(config.getCors().getAllowCredentials(), "CORS allow-credentials not set!");
  }
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationNotifications() throws Exception {
  final AppConfiguration config = new YamlConfigurationFactory<>(AppConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertFalse(config.getNotifications().getEnabled(), "Notifications aren't enabled!");
  assertEquals(NotificationsConfiguration.Type.NONE, config.getNotifications().getType(),
      "Incorrect notification type!");
  assertEquals("example.com:1234", config.getNotifications().getConnectionString(), "Incorrect connect string!");
  assertEquals("foo", config.getNotifications().any().get("some.other.value"), "Incorrect custom value!");
  assertEquals("test", config.getNotifications().getTopicName(), "Incorrect topic name!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
public void testConfigurationNotifications() throws Exception {
  final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
      Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
    .build(new File(getClass().getResource("/config1.yml").toURI()));
  assertFalse(config.getNotifications().getEnabled(), "Notifications unexpectedly enabled!");
  assertEquals(NotificationsConfiguration.Type.NONE, config.getNotifications().getType(),
      "Incorrect notification type!");
  assertEquals("example.com:12345", config.getNotifications().getConnectionString(), "Incorrect connection URL!");
  assertEquals("foo", config.getNotifications().any().get("some.other.value"), "Incorrect custom property!");
  assertEquals("test-topic", config.getNotifications().getTopicName(), "Incorrect topic name!");
}

代码示例来源:origin: trellis-ldp/trellis

@Test
  public void testGetNoJwtAuthenticator() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
        Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
      .build(new File(getClass().getResource("/config1.yml").toURI()));
    config.getAuth().getJwt().setKeyStore(null);
    config.getAuth().getJwt().setKey("");
    config.getAuth().getJwt().setJwks(null);
    assertTrue(TrellisUtils.getJwtAuthenticator(config.getAuth().getJwt()) instanceof NullAuthenticator,
        "JWT auth not disabled!");
  }
}

代码示例来源:origin: trellis-ldp/trellis

@Test
  public void testConfigurationCORS1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
        Validators.newValidator(), Jackson.newMinimalObjectMapper(), "")
      .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertTrue(config.getCors().getEnabled(), "CORS not enabled!");
    assertTrue(config.getCors().getAllowOrigin().contains("*"), "'*' not in CORS allow-origin!");
    assertTrue(config.getCors().getAllowHeaders().contains("Want-Digest"), "want-digest not in CORS allow-headers");
    assertTrue(config.getCors().getAllowMethods().contains("PUT"), "PUT not in CORS allow-methods!");
    assertTrue(config.getCors().getExposeHeaders().contains("Memento-Datetime"),
        "memento-datetime missing from CORS expose-headers!");
    assertEquals(180, config.getCors().getMaxAge(), "Incorrect max-age value in CORS headers!");
    assertTrue(config.getCors().getAllowCredentials(), "Incorrect allow-credentials setting in CORS headers!");
  }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com