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


Java Validators类代码示例

本文整理汇总了Java中io.dropwizard.jersey.validation.Validators的典型用法代码示例。如果您正苦于以下问题:Java Validators类的具体用法?Java Validators怎么用?Java Validators使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testGetAuthFilters

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testGetAuthFilters() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    final Optional<List<AuthFilter>> filters = TrellisUtils.getAuthFilters(config);
    assertTrue(filters.isPresent());
    filters.ifPresent(f -> assertEquals(3L, f.size()));

    config.getAuth().getAnon().setEnabled(false);
    config.getAuth().getBasic().setEnabled(false);
    config.getAuth().getJwt().setEnabled(false);

    assertFalse(TrellisUtils.getAuthFilters(config).isPresent());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:17,代码来源:TrellisUtilsTest.java

示例2: testConfigurationAuth1

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationAuth1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertTrue(config.getAuth().getWebac().getEnabled());
    assertEquals((Long) 100L, config.getAuth().getWebac().getCacheSize());
    assertEquals((Long) 10L, config.getAuth().getWebac().getCacheExpireSeconds());
    assertTrue(config.getAuth().getAnon().getEnabled());
    assertTrue(config.getAuth().getBasic().getEnabled());
    assertEquals("users.auth", config.getAuth().getBasic().getUsersFile());
    assertTrue(config.getAuth().getJwt().getEnabled());
    assertEquals("secret", config.getAuth().getJwt().getKey());
    assertFalse(config.getAuth().getJwt().getBase64Encoded());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:17,代码来源:TrellisConfigurationTest.java

示例3: setUp

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    environment = new Environment("test", new ObjectMapper(), Validators.newValidator(),
            metricRegistry, ClassLoader.getSystemClassLoader());

    DataSourceFactory dataSourceFactory = new DataSourceFactory();
    dataSourceFactory.setUrl("jdbc:h2:mem:jdbi3-test");
    dataSourceFactory.setUser("sa");
    dataSourceFactory.setDriverClass("org.h2.Driver");
    dataSourceFactory.asSingleConnectionPool();

    dbi = new JdbiFactory(new TimedAnnotationNameStrategy()).build(environment, dataSourceFactory, "h2");
    dbi.useTransaction(h -> {
        h.createScript(Resources.toString(Resources.getResource("schema.sql"), Charsets.UTF_8)).execute();
        h.createScript(Resources.toString(Resources.getResource("data.sql"), Charsets.UTF_8)).execute();
    });
    dao = dbi.onDemand(GameDao.class);
    for (LifeCycle lc : environment.lifecycle().getManagedObjects()) {
        lc.start();
    }
}
 
开发者ID:arteam,项目名称:dropwizard-jdbi3,代码行数:22,代码来源:JdbiTest.java

示例4: testGetAssetConfigurations

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testGetAssetConfigurations() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    final Map<String, String> assets = TrellisUtils.getAssetConfiguration(config);
    assertEquals(3L, assets.size());
    assertEquals("http://example.org/image.icon", assets.get("icon"));
    assertEquals("http://example.org/styles1.css,http://example.org/styles2.css",
            assets.get("css"));
    assertEquals("http://example.org/scripts1.js,http://example.org/scripts2.js",
            assets.get("js"));
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:15,代码来源:TrellisUtilsTest.java

示例5: testGetKafkaProperties

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testGetKafkaProperties() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    final Properties props = TrellisUtils.getKafkaProperties(config);

    assertEquals("org.apache.kafka.common.serialization.StringSerializer", props.getProperty("key.serializer"));
    assertEquals("org.apache.kafka.common.serialization.StringSerializer", props.getProperty("value.serializer"));
    assertEquals("localhost:9092", props.getProperty("bootstrap.servers"));
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:13,代码来源:TrellisUtilsTest.java

示例6: testGetCurator

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testGetCurator() throws Exception {
    final TestingServer zk = new TestingServer(true);

    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    config.getZookeeper().setEnsembleServers(zk.getConnectString());

    final CuratorFramework curator = TrellisUtils.getCuratorClient(config);
    assertEquals(CuratorFrameworkState.STARTED, curator.getState());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:14,代码来源:TrellisUtilsTest.java

示例7: testConfigurationGeneral1

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationGeneral1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertTrue(config.getAsync());
    assertEquals("Trellis", config.getDefaultName());
    assertEquals((Integer) 86400, config.getCacheMaxAge());
    assertEquals((Long) 100L, config.getJsonLdCacheSize());
    assertEquals((Long) 24L, config.getJsonLdCacheExpireHours());
    assertTrue(config.getJsonLdDomainWhitelist().isEmpty());
    assertTrue(config.getJsonLdWhitelist().contains("http://example.org/context.json"));
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:15,代码来源:TrellisConfigurationTest.java

示例8: testConfigurationAssets1

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationAssets1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertEquals("http://example.org/image.icon", config.getAssets().getIcon());
    assertTrue(config.getAssets().getJs().contains("http://example.org/scripts1.js"));
    assertTrue(config.getAssets().getCss().contains("http://example.org/styles1.css"));
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:11,代码来源:TrellisConfigurationTest.java

示例9: testConfigurationLocations

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationLocations() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertEquals("/tmp/trellisData/binaries", config.getBinaries().getPath());
    assertEquals("/tmp/trellisData/resources", config.getResources().getPath());
    assertEquals("http://localhost:8080/", config.getBaseUrl());
    assertEquals((Integer) 4, config.getBinaries().getLevels());
    assertEquals((Integer) 2, config.getBinaries().getLength());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:13,代码来源:TrellisConfigurationTest.java

示例10: testConfigurationNamespaces1

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationNamespaces1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertEquals("/tmp/trellisData/namespaces.json", config.getNamespaces().getFile());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:9,代码来源:TrellisConfigurationTest.java

示例11: testConfigurationCORS1

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationCORS1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertTrue(config.getCors().getEnabled());
    assertTrue(config.getCors().getAllowOrigin().contains("*"));
    assertTrue(config.getCors().getAllowHeaders().contains("Link"));
    assertTrue(config.getCors().getAllowMethods().contains("PATCH"));
    assertTrue(config.getCors().getExposeHeaders().contains("Location"));
    assertEquals((Integer) 180, config.getCors().getMaxAge());
    assertTrue(config.getCors().getAllowCredentials());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:15,代码来源:TrellisConfigurationTest.java

示例12: testConfigurationZookeeper1

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationZookeeper1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertEquals("localhost:2181", config.getZookeeper().getEnsembleServers());
    assertEquals((Integer) 100, config.getZookeeper().getTimeout());
    assertEquals((Integer) 1000, config.getZookeeper().getRetryMs());
    assertEquals((Integer) 10, config.getZookeeper().getRetryMax());
    assertEquals((Integer) 50, config.getZookeeper().getRetryMaxMs());
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:13,代码来源:TrellisConfigurationTest.java

示例13: testConfigurationKafka1

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Test
public void testConfigurationKafka1() throws Exception {
    final TrellisConfiguration config = new YamlConfigurationFactory<>(TrellisConfiguration.class,
            Validators.newValidator(), Jackson.newObjectMapper(), "")
        .build(new File(getClass().getResource("/config1.yml").toURI()));

    assertEquals("localhost:9092", config.getKafka().getBootstrapServers());

    final Properties props = config.getKafka().asProperties();
    assertEquals("all", props.getProperty("acks"));
    assertEquals("16384", props.getProperty("batch.size"));
    assertEquals("otherValue", props.getProperty("otherProperty"));
}
 
开发者ID:trellis-ldp,项目名称:trellis-rosid,代码行数:14,代码来源:TrellisConfigurationTest.java

示例14: getPac4jFactory

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
protected Pac4jFactory getPac4jFactory(
        Collection<Pac4jFeatureSupport> featuresSupported,
        String resourceName) throws Exception {
    ObjectMapper om = Jackson.newObjectMapper();
    Bootstrap<?> b = mock(Bootstrap.class);
    when(b.getObjectMapper()).thenReturn(om);

    for (Pac4jFeatureSupport fs : featuresSupported) {
        fs.setup(b);
    }

    return new YamlConfigurationFactory<>(Pac4jFactory.class,
            Validators.newValidator(), om, "dw").build(
                    new File(Resources.getResource(resourceName).toURI()));
}
 
开发者ID:pac4j,项目名称:dropwizard-pac4j,代码行数:16,代码来源:AbstractConfigurationTest.java

示例15: run

import io.dropwizard.jersey.validation.Validators; //导入依赖的package包/类
@Override
public void run(Environment environment) {
    environment.setValidator(Validators
            .newConfiguration()
            .constraintValidatorFactory(new InjectingValidatorFactory())
            .buildValidatorFactory()
            .getValidator());
}
 
开发者ID:alex-shpak,项目名称:dropwizard-hk2bundle,代码行数:9,代码来源:HK2ValidationBundle.java


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